1
0
Fork 0
mirror of synced 2024-05-11 08:12:40 +12:00

Merge branch 'functions' of github.com:appwrite/appwrite into swoole-and-functions

This commit is contained in:
Eldad Fux 2020-07-12 23:43:03 +03:00
commit db0dcf5eaa
144 changed files with 6822 additions and 366 deletions

View file

@ -37,4 +37,4 @@ install:
script:
- docker ps
- docker exec appwrite test
- docker exec appwrite test

View file

@ -107,8 +107,6 @@ Currently, all of the Appwrite microservices are intended to communicate using t
Security and privacy are extremely important to Appwrite, developers, and users alike. Make sure to follow the best industry standards and practices.
<!-- To help you make sure you are doing as best as possible, we have set up our security checklist for pull requests and contributors. Please make sure to follow the list before sending a pull request. -->
## Dependencies
Please avoid introducing new dependencies to Appwrite without consulting the team. New dependencies can be very helpful but also introduce new security and privacy issues, complexity, and impact total docker image size.
@ -148,7 +146,7 @@ After finishing the installation process, you can start writing and editing code
To build a new version of the Appwrite server, all you need to do is run the build.sh file like this:
```bash
bash ./build.sh 1.0.0
bash ./build.sh X.X.X
```
Before running the command, make sure you have proper write permissions to the Appwrite docker hub team.

View file

@ -102,7 +102,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN \
apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests webp certbot htop procps \
apt-get install -y --no-install-recommends --no-install-suggests webp certbot htop procps docker.io \
libonig-dev libcurl4-gnutls-dev libmagickwand-dev libyaml-dev libbrotli-dev libz-dev && \
pecl install imagick yaml && \
docker-php-ext-enable imagick yaml
@ -172,4 +172,4 @@ EXPOSE 80
#, "-dxdebug.profiler_enable=1"
#, "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php"
CMD [ "php", "app/server.php", "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" ]
CMD [ "php", "app/server.php", "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" ]

View file

@ -266,6 +266,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $webhooks, $audi
if($project->getId()
&& $mode !== APP_MODE_ADMIN
&& !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage and admin mode
$usage
->setParam('request', $request->getSize() + $usage->getParam('storage'))
->setParam('response', $response->getSize())

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,29 @@
<?php
return [
[
'name' => 'Node.js 14',
'image' => 'node:14',
'logo' => 'node.png',
],
[
'name' => 'PHP 7.4',
'image' => 'php:7.4-cli',
'logo' => 'php.png',
],
[
'name' => 'Ruby 2.7',
'image' => 'ruby:2.7',
'logo' => 'ruby.png',
],
[
'name' => 'Dart 2.8',
'image' => 'google/dart:2.8',
'logo' => 'dart.png',
],
[
'name' => 'Python 3.8',
'image' => 'python:3.8',
'logo' => 'python.png',
],
];

View file

@ -37,6 +37,8 @@ $admins = [
'users.write',
'collections.read',
'collections.write',
'functions.read',
'functions.write',
'platforms.read',
'platforms.write',
'keys.read',

View file

@ -11,6 +11,9 @@ return [ // List of publicly visible scopes
'documents.write',
'files.read',
'files.write',
'functions.read',
'functions.write',
'health.read',
// 'platforms.read',
// 'platforms.write',
// 'keys.read',

View file

@ -75,6 +75,13 @@ return [
'sdk' => true,
'tests' => false,
],
'v1/functions' => [
'name' => 'Users',
'description' => '/docs/services/functions.md',
'controller' => 'controllers/api/functions.php',
'sdk' => true,
'tests' => false,
],
'v1/mock' => [
'name' => 'Mock',
'description' => '',

View file

@ -0,0 +1,481 @@
<?php
global $utopia, $response, $projectDB;
use Appwrite\Database\Database;
use Appwrite\Database\Validator\UID;
use Appwrite\Task\Validator\Cron;
use Utopia\Response;
use Utopia\Validator\ArrayList;
use Utopia\Validator\Assoc;
use Utopia\Validator\Text;
use Utopia\Validator\Range;
use Utopia\Validator\WhiteList;
use Cron\CronExpression;
include_once __DIR__ . '/../shared/api.php';
$utopia->post('/v1/functions')
->desc('Create Function')
->label('scope', 'functions.write')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'create')
->label('sdk.description', '/docs/references/functions/create-function.md')
->param('name', '', function () { return new Text(128); }, 'Function name.')
->param('vars', [], function () { return new Assoc();}, 'Key-value JSON object.', true)
->param('events', [], function () { return new ArrayList(new Text(256)); }, 'Events list.', true)
->param('schedule', '', function () { return new Cron(); }, 'Schedule CRON syntax.', true)
->param('timeout', 15, function () { return new Range(1, 900); }, 'Function maximum execution time in seconds.', true)
->action(
function ($name, $vars, $events, $schedule, $timeout) use ($response, $projectDB) {
$function = $projectDB->createDocument([
'$collection' => Database::SYSTEM_COLLECTION_FUNCTIONS,
'$permissions' => [
'read' => [],
'write' => [],
],
'dateCreated' => time(),
'dateUpdated' => time(),
'status' => 'paused',
'name' => $name,
'tag' => '',
'vars' => $vars,
'events' => $events,
'schedule' => $schedule,
'previous' => null,
'next' => null,
'timeout' => $timeout,
]);
if (false === $function) {
throw new Exception('Failed saving function to DB', 500);
}
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
->json($function->getArrayCopy())
;
}
);
$utopia->get('/v1/functions')
->desc('List Functions')
->label('scope', 'functions.read')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'list')
->label('sdk.description', '/docs/references/functions/list-functions.md')
->param('search', '', function () { return new Text(256); }, 'Search term to filter your list results.', true)
->param('limit', 25, function () { return new Range(0, 100); }, 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, function () { return new Range(0, 2000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true)
->action(
function ($search, $limit, $offset, $orderType) use ($response, $projectDB) {
$results = $projectDB->getCollection([
'limit' => $limit,
'offset' => $offset,
'orderField' => 'dateCreated',
'orderType' => $orderType,
'orderCast' => 'int',
'search' => $search,
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_FUNCTIONS,
],
]);
$response->json(['sum' => $projectDB->getSum(), 'functions' => $results]);
}
);
$utopia->get('/v1/functions/:functionId')
->desc('Get Function')
->label('scope', 'functions.read')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'get')
->label('sdk.description', '/docs/references/functions/get-function.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->action(
function ($functionId) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('function not found', 404);
}
$response->json($function->getArrayCopy());
}
);
$utopia->put('/v1/functions/:functionId')
->desc('Update Function')
->label('scope', 'functions.write')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'update')
->label('sdk.description', '/docs/references/functions/update-function.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->param('name', '', function () { return new Text(128); }, 'Function name.')
->param('vars', [], function () { return new Assoc();}, 'Key-value JSON object.', true)
->param('events', [], function () { return new ArrayList(new Text(256)); }, 'Events list.', true)
->param('schedule', '', function () { return new Cron(); }, 'Schedule CRON syntax.', true)
->param('timeout', 15, function () { return new Range(1, 900); }, 'Function maximum execution time in seconds.', true)
->action(
function ($functionId, $name, $vars, $events, $schedule, $timeout) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
$cron = (!empty($function->getAttribute('tag', null)) && !empty($schedule)) ? CronExpression::factory($schedule) : null;
$next = (!empty($function->getAttribute('tag', null)) && !empty($schedule)) ? $cron->getNextRunDate()->format('U') : null;
$function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [
'dateUpdated' => time(),
'name' => $name,
'vars' => $vars,
'events' => $events,
'schedule' => $schedule,
'previous' => null,
'next' => $next,
'timeout' => $timeout,
]));
if (false === $function) {
throw new Exception('Failed saving function to DB', 500);
}
$response->json($function->getArrayCopy());
}
);
$utopia->patch('/v1/functions/:functionId/tag')
->desc('Update Function Tag')
->label('scope', 'functions.write')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'updateTag')
->label('sdk.description', '/docs/references/functions/update-tag.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->param('tag', '', function () { return new UID(); }, 'Tag unique ID.')
->action(
function ($functionId, $tag) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
$schedule = $function->getAttribute('schedule', '');
$cron = (!empty($function->getAttribute('tag')&& !empty($schedule))) ? CronExpression::factory($schedule) : null;
$next = (!empty($function->getAttribute('tag')&& !empty($schedule))) ? $cron->getNextRunDate()->format('U') : null;
$function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [
'tag' => $tag,
'next' => $next,
]));
if (false === $function) {
throw new Exception('Failed saving function to DB', 500);
}
$response->json($function->getArrayCopy());
}
);
$utopia->delete('/v1/functions/:functionId')
->desc('Delete Function')
->label('scope', 'functions.write')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'delete')
->label('sdk.description', '/docs/references/functions/delete-function.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->action(
function ($functionId) use ($response, $projectDB, $webhook, $audit, $usage) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
if (!$projectDB->deleteDocument($function->getId())) {
throw new Exception('Failed to remove function from DB', 500);
}
$response->noContent();
}
);
$utopia->post('/v1/functions/:functionId/tags')
->desc('Create Tag')
->label('scope', 'functions.write')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'createTag')
->label('sdk.description', '/docs/references/functions/create-tag.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->param('env', '', function () { return new WhiteList(['node-14', 'node-12', 'php-7.4']); }, 'Execution enviornment.')
->param('command', '', function () { return new Text('1028'); }, 'Code execution command.')
->param('code', '', function () { return new Text(128); }, 'Code package. Use the '.APP_NAME.' code packager to create a deployable package file.')
->action(
function ($functionId, $env, $command, $code) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
$tag = $projectDB->createDocument([
'$collection' => Database::SYSTEM_COLLECTION_TAGS,
'$permissions' => [
'read' => [],
'write' => [],
],
'dateCreated' => time(),
'functionId' => $function->getId(),
'env' => $env,
'command' => $command,
'code' => $code,
]);
if (false === $tag) {
throw new Exception('Failed saving tag to DB', 500);
}
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
->json($tag->getArrayCopy())
;
}
);
$utopia->get('/v1/functions/:functionId/tags')
->desc('List Tags')
->label('scope', 'functions.read')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'listTags')
->label('sdk.description', '/docs/references/functions/list-tags.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->param('search', '', function () { return new Text(256); }, 'Search term to filter your list results.', true)
->param('limit', 25, function () { return new Range(0, 100); }, 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, function () { return new Range(0, 2000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true)
->action(
function ($functionId, $search, $limit, $offset, $orderType) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
$results = $projectDB->getCollection([
'limit' => $limit,
'offset' => $offset,
'orderField' => 'dateCreated',
'orderType' => $orderType,
'orderCast' => 'int',
'search' => $search,
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_TAGS,
'functionId='.$function->getId(),
],
]);
$response->json(['sum' => $projectDB->getSum(), 'tags' => $results]);
}
);
$utopia->get('/v1/functions/:functionId/tags/:tagId')
->desc('Get Tag')
->label('scope', 'functions.read')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'getTag')
->label('sdk.description', '/docs/references/functions/get-tag.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->param('tagId', '', function () { return new UID(); }, 'Tag unique ID.')
->action(
function ($functionId, $tagId) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
$tag = $projectDB->getDocument($tagId);
if($tag->getAttribute('functionId') !== $function->getId()) {
throw new Exception('Tag not found', 404);
}
if (empty($tag->getId()) || Database::SYSTEM_COLLECTION_TAGS != $tag->getCollection()) {
throw new Exception('Tag not found', 404);
}
$response->json($tag->getArrayCopy());
}
);
$utopia->delete('/v1/functions/:functionId/tags/:tagId')
->desc('Delete Tag')
->label('scope', 'functions.write')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'deleteTag')
->label('sdk.description', '/docs/references/functions/delete-tag.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->param('tagId', '', function () { return new UID(); }, 'Tag unique ID.')
->action(
function ($functionId, $tagId) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
$tag = $projectDB->getDocument($tagId);
if($tag->getAttribute('functionId') !== $function->getId()) {
throw new Exception('Tag not found', 404);
}
if (empty($tag->getId()) || Database::SYSTEM_COLLECTION_TAGS != $tag->getCollection()) {
throw new Exception('Tag not found', 404);
}
if (!$projectDB->deleteDocument($tag->getId())) {
throw new Exception('Failed to remove tag from DB', 500);
}
$response->noContent();
}
);
$utopia->post('/v1/functions/:functionId/executions')
->desc('Create Execution')
->label('scope', 'functions.write')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'createExecution')
->label('sdk.description', '/docs/references/functions/create-execution.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->param('async', 1, function () { return new Range(0, 1); }, 'Execute code asynchronously. Pass 1 for true, 0 for false. Default value is 1.', true)
->action(
function ($functionId, $async) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
$execution = $projectDB->createDocument([
'$collection' => Database::SYSTEM_COLLECTION_EXECUTIONS,
'$permissions' => [
'read' => [],
'write' => [],
],
'dateCreated' => time(),
'functionId' => $function->getId(),
'status' => 'waiting', // Proccesing / Completed / Failed
'exitCode' => 0,
'stdout' => '',
'stderr' => '',
'time' => 0,
]);
if (false === $execution) {
throw new Exception('Failed saving execution to DB', 500);
}
$tag = $projectDB->getDocument($function->getAttribute('tag'));
if($tag->getAttribute('functionId') !== $function->getId()) {
throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404);
}
if (empty($tag->getId()) || Database::SYSTEM_COLLECTION_TAGS != $tag->getCollection()) {
throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404);
}
if((bool)$async) {
}
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
->json($execution->getArrayCopy())
;
}
);
$utopia->get('/v1/functions/:functionId/executions')
->desc('List Executions')
->label('scope', 'functions.read')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'listExecutions')
->label('sdk.description', '/docs/references/functions/list-executions.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->param('search', '', function () { return new Text(256); }, 'Search term to filter your list results.', true)
->param('limit', 25, function () { return new Range(0, 100); }, 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, function () { return new Range(0, 2000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true)
->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true)
->action(
function ($functionId, $search, $limit, $offset, $orderType) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
$results = $projectDB->getCollection([
'limit' => $limit,
'offset' => $offset,
'orderField' => 'dateCreated',
'orderType' => $orderType,
'orderCast' => 'int',
'search' => $search,
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_EXECUTIONS,
'functionId='.$function->getId(),
],
]);
$response->json(['sum' => $projectDB->getSum(), 'executions' => $results]);
}
);
$utopia->get('/v1/functions/:functionId/executions/:executionId')
->desc('Get Execution')
->label('scope', 'functions.read')
->label('sdk.platform', [APP_PLATFORM_SERVER])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'getExecution')
->label('sdk.description', '/docs/references/functions/get-execution.md')
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
->param('executionId', '', function () { return new UID(); }, 'Execution unique ID.')
->action(
function ($functionId, $executionId) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);
if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) {
throw new Exception('Function not found', 404);
}
$execution = $projectDB->getDocument($executionId);
if($execution->getAttribute('functionId') !== $function->getId()) {
throw new Exception('Execution not found', 404);
}
if (empty($execution->getId()) || Database::SYSTEM_COLLECTION_EXECUTIONS != $execution->getCollection()) {
throw new Exception('Execution not found', 404);
}
$response->json($execution->getArrayCopy());
}
);

View file

@ -284,7 +284,7 @@ App::get('/v1/projects/:projectId/usage')
}, $requests)),
],
'network' => [
'data' => $network,
'data' => \array_map(function ($value) {return ['value' => \round($value['value'] / 1000000, 2), 'date' => $value['date']];}, $network), // convert bytes to mb
'total' => \array_sum(\array_map(function ($item) {
return $item['value'];
}, $network)),

View file

@ -462,7 +462,6 @@ App::patch('/v1/users/:userId/prefs')
$response->json($prefs);
}, ['response', 'projectDB']);
App::delete('/v1/users/:userId/sessions/:sessionId')
->desc('Delete User Session')
->groups(['api', 'users'])

View file

@ -152,7 +152,7 @@ App::get('/console/webhooks')
/** @var Utopia\View $layout */
$page = new View(__DIR__.'/../../views/console/webhooks/index.phtml');
$page
->setParam('events', Config::getParam('events', []))
;
@ -338,3 +338,31 @@ App::get('/console/users/teams/team')
->setParam('title', APP_NAME.' - Team')
->setParam('body', $page);
}, ['layout']);
App::get('/console/functions')
->desc('Platform console project functions')
->label('permission', 'public')
->label('scope', 'console')
->action(function ($layout) {
$page = new View(__DIR__.'/../../views/console/functions/index.phtml');
$layout
->setParam('title', APP_NAME.' - Functions')
->setParam('body', $page);
}, ['layout']);
App::get('/console/functions/function')
->desc('Platform console project function')
->label('permission', 'public')
->label('scope', 'console')
->action(function ($layout) {
$page = new View(__DIR__.'/../../views/console/functions/function.phtml');
$page
->setParam('events', Config::getParam('events', []))
;
$layout
->setParam('title', APP_NAME.' - Function')
->setParam('body', $page);
}, ['layout']);

View file

@ -19,6 +19,7 @@ use Appwrite\Database\Document;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Event\Event;
use Appwrite\Extend\PDO;
use Appwrite\OpenSSL\OpenSSL;
use Utopia\App;
use Utopia\View;
use Utopia\Config\Config;
@ -80,6 +81,43 @@ Config::load('storage-outputs', __DIR__.'/config/storage/outputs.php');
Resque::setBackend(App::getEnv('_APP_REDIS_HOST', '')
.':'.App::getEnv('_APP_REDIS_PORT', ''));
/**
* DB Filters
*/
Database::addFilter('json',
function($value) {
if(!is_array($value)) {
return $value;
}
return json_encode($value);
},
function($value) {
return json_decode($value, true);
}
);
Database::addFilter('encrypt',
function($value) use ($request) {
$key = $request->getServer('_APP_OPENSSL_KEY_V1');
$iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM));
$tag = null;
return json_encode([
'data' => OpenSSL::encrypt($value, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag),
'method' => OpenSSL::CIPHER_AES_128_GCM,
'iv' => bin2hex($iv),
'tag' => bin2hex($tag),
'version' => '1',
]);
},
function($value) use ($request) {
$value = json_decode($value, true);
$key = $request->getServer('_APP_OPENSSL_KEY_V'.$value['version']);
return OpenSSL::decrypt($value['data'], $value['method'], $key, 0, hex2bin($value['iv']), hex2bin($value['tag']));
}
);
/*
* Registry
*/
@ -172,6 +210,9 @@ $register->set('queue-mails', function () {
$register->set('queue-deletes', function () {
return new Event('v1-deletes', 'DeletesV1');
});
$register->set('queue-functions', function () {
return new Event('v1-functions', 'FunctionsV1');
});
/*
* Localization
@ -271,6 +312,10 @@ App::setResource('deletes', function($register) {
return $register->get('queue-deletes');
}, ['register']);
App::setResource('functions', function($register) {
return $register->get('queue-functions');
}, ['register']);
// Test Mock
App::setResource('clients', function($console, $project) {
/**

View file

@ -7,4 +7,4 @@ sdk
let result = sdk.avatars.getInitials();
console.log(result); // Resource URL
console.log(result); // Resource URL

View file

@ -1208,6 +1208,60 @@
return config.endpoint + path + ((query) ? '?' + query : '');
},
/**
* Get User Initials
*
* Use this endpoint to show your user initials avatar icon on your website or
* app. By default, this route will try to print your logged-in user name or
* email initials. You can also overwrite the user name if you pass the 'name'
* parameter. If no name is given and no user is logged, an empty avatar will
* be returned.
*
* You can use the color and background params to change the avatar colors. By
* default, a random theme will be selected. The random theme will persist for
* the user's initials when reloading the same theme will always return for
* the same initials.
*
* @param {string} name
* @param {number} width
* @param {number} height
* @param {string} color
* @param {string} background
* @throws {Error}
* @return {string}
*/
getInitials: function(name = '', width = 500, height = 500, color = '', background = '') {
let path = '/avatars/initials';
let payload = {};
if(name) {
payload['name'] = name;
}
if(width) {
payload['width'] = width;
}
if(height) {
payload['height'] = height;
}
if(color) {
payload['color'] = color;
}
if(background) {
payload['background'] = background;
}
payload['project'] = config.project;
let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&');
return config.endpoint + path + ((query) ? '?' + query : '');
},
/**
* Get QR Code
*

View file

@ -79,14 +79,12 @@ query=query.join("&");return config.endpoint+path+((query)?'?'+query:'')},getIma
let path='/avatars/image';let payload={};if(url){payload.url=url}
if(width){payload.width=width}
if(height){payload.height=height}
payload.project=config.project;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index<payload[p].length;index++){let param=payload[p][index];query.push(encodeURIComponent(p+'[]')+"="+encodeURIComponent(param))}}else{query.push(encodeURIComponent(p)+"="+encodeURIComponent(payload[p]))}}
query=query.join("&");return config.endpoint+path+((query)?'?'+query:'')},getInitials:function(name='',width=500,height=500,color='',background=''){let path='/avatars/initials';let payload={};if(name){payload.name=name}
payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getInitials:function(name='',width=500,height=500,color='',background=''){let path='/avatars/initials';let payload={};if(name){payload.name=name}
if(width){payload.width=width}
if(height){payload.height=height}
if(color){payload.color=color}
if(background){payload.background=background}
payload.project=config.project;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index<payload[p].length;index++){let param=payload[p][index];query.push(encodeURIComponent(p+'[]')+"="+encodeURIComponent(param))}}else{query.push(encodeURIComponent(p)+"="+encodeURIComponent(payload[p]))}}
query=query.join("&");return config.endpoint+path+((query)?'?'+query:'')},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')}
payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')}
let path='/avatars/qr';let payload={};if(text){payload.text=text}
if(size){payload.size=size}
if(margin){payload.margin=margin}

View file

@ -8,4 +8,4 @@ sdk
let result = sdk.avatars.getInitials();
console.log(result); // Resource URL
console.log(result); // Resource URL

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = sdk.functions.create('[NAME]');
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.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
});

View file

@ -0,0 +1,14 @@
let sdk = new Appwrite();
sdk
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = sdk.functions.updateActive('[FUNCTION_ID]', '[ACTIVE]');
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = sdk.functions.updateTag('[FUNCTION_ID]', '[TAG]');
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});

View file

@ -0,0 +1,15 @@
let sdk = new Appwrite();
sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = sdk.functions.update('[FUNCTION_ID]', '[NAME]');
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});

View file

@ -1258,6 +1258,62 @@
return config.endpoint + path + ((query) ? '?' + query : '');
},
/**
* Get User Initials
*
* Use this endpoint to show your user initials avatar icon on your website or
* app. By default, this route will try to print your logged-in user name or
* email initials. You can also overwrite the user name if you pass the 'name'
* parameter. If no name is given and no user is logged, an empty avatar will
* be returned.
*
* You can use the color and background params to change the avatar colors. By
* default, a random theme will be selected. The random theme will persist for
* the user's initials when reloading the same theme will always return for
* the same initials.
*
* @param {string} name
* @param {number} width
* @param {number} height
* @param {string} color
* @param {string} background
* @throws {Error}
* @return {string}
*/
getInitials: function(name = '', width = 500, height = 500, color = '', background = '') {
let path = '/avatars/initials';
let payload = {};
if(name) {
payload['name'] = name;
}
if(width) {
payload['width'] = width;
}
if(height) {
payload['height'] = height;
}
if(color) {
payload['color'] = color;
}
if(background) {
payload['background'] = background;
}
payload['project'] = config.project;
payload['key'] = config.key;
let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&');
return config.endpoint + path + ((query) ? '?' + query : '');
},
/**
* Get QR Code
*
@ -1807,6 +1863,472 @@
}
};
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[]} events
* @param {string} schedule
* @param {number} timeout
* @throws {Error}
* @return {Promise}
*/
create: function(name, vars = [], events = [], schedule = '', timeout = 15) {
if(name === undefined) {
throw new Error('Missing required parameter: "name"');
}
let path = '/functions';
let payload = {};
if(name) {
payload['name'] = name;
}
if(vars) {
payload['vars'] = vars;
}
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[]} events
* @param {string} schedule
* @param {number} timeout
* @throws {Error}
* @return {Promise}
*/
update: function(functionId, name, vars = [], events = [], schedule = '', timeout = 15) {
if(functionId === undefined) {
throw new Error('Missing required parameter: "functionId"');
}
if(name === undefined) {
throw new Error('Missing required parameter: "name"');
}
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
let payload = {};
if(name) {
payload['name'] = name;
}
if(vars) {
payload['vars'] = vars;
}
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);
},
/**
* 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);
},
/**
* Update Function Tag
*
*
* @param {string} functionId
* @param {string} tag
* @throws {Error}
* @return {Promise}
*/
updateTag: function(functionId, tag) {
if(functionId === undefined) {
throw new Error('Missing required parameter: "functionId"');
}
if(tag === undefined) {
throw new Error('Missing required parameter: "tag"');
}
let path = '/functions/{functionId}/tag'.replace(new RegExp('{functionId}', 'g'), functionId);
let payload = {};
if(tag) {
payload['tag'] = tag;
}
return http
.patch(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 = {
/**
@ -4498,6 +5020,7 @@
account: account,
avatars: avatars,
database: database,
functions: functions,
health: health,
locale: locale,
projects: projects,

View file

@ -79,14 +79,12 @@ query=query.join("&");return config.endpoint+path+((query)?'?'+query:'')},getIma
let path='/avatars/image';let payload={};if(url){payload.url=url}
if(width){payload.width=width}
if(height){payload.height=height}
payload.project=config.project;payload.key=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index<payload[p].length;index++){let param=payload[p][index];query.push(encodeURIComponent(p+'[]')+"="+encodeURIComponent(param))}}else{query.push(encodeURIComponent(p)+"="+encodeURIComponent(payload[p]))}}
query=query.join("&");return config.endpoint+path+((query)?'?'+query:'')},getInitials:function(name='',width=500,height=500,color='',background=''){let path='/avatars/initials';let payload={};if(name){payload.name=name}
payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getInitials:function(name='',width=500,height=500,color='',background=''){let path='/avatars/initials';let payload={};if(name){payload.name=name}
if(width){payload.width=width}
if(height){payload.height=height}
if(color){payload.color=color}
if(background){payload.background=background}
payload.project=config.project;payload.key=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index<payload[p].length;index++){let param=payload[p][index];query.push(encodeURIComponent(p+'[]')+"="+encodeURIComponent(param))}}else{query.push(encodeURIComponent(p)+"="+encodeURIComponent(payload[p]))}}
query=query.join("&");return config.endpoint+path+((query)?'?'+query:'')},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')}
payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')}
let path='/avatars/qr';let payload={};if(text){payload.text=text}
if(size){payload.size=size}
if(margin){payload.margin=margin}
@ -147,7 +145,54 @@ 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)},getAntiVirus:function(){let path='/health/anti-virus';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)},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)},getLanguages:function(){let path='/locale/languages';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=[],events=[],schedule='',timeout=15){if(name===undefined){throw new Error('Missing required parameter: "name"')}
let path='/functions';let payload={};if(name){payload.name=name}
if(vars){payload.vars=vars}
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=[],events=[],schedule='',timeout=15){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
if(name===undefined){throw new Error('Missing required parameter: "name"')}
let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(name){payload.name=name}
if(vars){payload.vars=vars}
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)},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)},updateTag:function(functionId,tag){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
if(tag===undefined){throw new Error('Missing required parameter: "tag"')}
let path='/functions/{functionId}/tag'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(tag){payload.tag=tag}
return http.patch(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)},getAntiVirus:function(){let path='/health/anti-virus';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)},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)},getLanguages:function(){let path='/locale/languages';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}
@ -379,4 +424,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:{})
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:{})

View file

@ -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;
@ -617,6 +618,168 @@ declare namespace Appwrite {
}
export interface Functions {
/**
* List Functions
*
*
* @param {string} search
* @param {number} limit
* @param {number} offset
* @param {string} orderType
* @throws {Error}
* @return {Promise}
*/
list(search: string, limit: number, offset: number, orderType: string): Promise<object>;
/**
* Create Function
*
*
* @param {string} name
* @param {object} vars
* @param {string[]} events
* @param {string} schedule
* @param {number} timeout
* @throws {Error}
* @return {Promise}
*/
create(name: string, vars: object, events: string[], schedule: string, timeout: number): Promise<object>;
/**
* Get Function
*
*
* @param {string} functionId
* @throws {Error}
* @return {Promise}
*/
get(functionId: string): Promise<object>;
/**
* Update Function
*
*
* @param {string} functionId
* @param {string} name
* @param {object} vars
* @param {string[]} events
* @param {string} schedule
* @param {number} timeout
* @throws {Error}
* @return {Promise}
*/
update(functionId: string, name: string, vars: object, events: string[], schedule: string, timeout: number): Promise<object>;
/**
* Delete Function
*
*
* @param {string} functionId
* @throws {Error}
* @return {Promise}
*/
delete(functionId: string): Promise<object>;
/**
* List Executions
*
*
* @param {string} functionId
* @param {string} search
* @param {number} limit
* @param {number} offset
* @param {string} orderType
* @throws {Error}
* @return {Promise}
*/
listExecutions(functionId: string, search: string, limit: number, offset: number, orderType: string): Promise<object>;
/**
* Create Execution
*
*
* @param {string} functionId
* @param {number} async
* @throws {Error}
* @return {Promise}
*/
createExecution(functionId: string, async: number): Promise<object>;
/**
* Get Execution
*
*
* @param {string} functionId
* @param {string} executionId
* @throws {Error}
* @return {Promise}
*/
getExecution(functionId: string, executionId: string): Promise<object>;
/**
* Update Function Tag
*
*
* @param {string} functionId
* @param {string} tag
* @throws {Error}
* @return {Promise}
*/
updateTag(functionId: string, tag: string): Promise<object>;
/**
* List Tags
*
*
* @param {string} functionId
* @param {string} search
* @param {number} limit
* @param {number} offset
* @param {string} orderType
* @throws {Error}
* @return {Promise}
*/
listTags(functionId: string, search: string, limit: number, offset: number, orderType: string): Promise<object>;
/**
* Create Tag
*
*
* @param {string} functionId
* @param {string} env
* @param {string} command
* @param {string} code
* @throws {Error}
* @return {Promise}
*/
createTag(functionId: string, env: string, command: string, code: string): Promise<object>;
/**
* Get Tag
*
*
* @param {string} functionId
* @param {string} tagId
* @throws {Error}
* @return {Promise}
*/
getTag(functionId: string, tagId: string): Promise<object>;
/**
* Delete Tag
*
*
* @param {string} functionId
* @param {string} tagId
* @throws {Error}
* @return {Promise}
*/
deleteTag(functionId: string, tagId: string): Promise<object>;
}
export interface Health {
/**

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.CreateExecution("[FUNCTION_ID]", 0)
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.CreateTag("[FUNCTION_ID]", "node-14", "[COMMAND]", "[CODE]")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.Create("[NAME]", , [], "", 0)
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.DeleteTag("[FUNCTION_ID]", "[TAG_ID]")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.Delete("[FUNCTION_ID]")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.GetExecution("[FUNCTION_ID]", "[EXECUTION_ID]")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.GetTag("[FUNCTION_ID]", "[TAG_ID]")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.Get("[FUNCTION_ID]")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.ListExecutions("[FUNCTION_ID]", "[SEARCH]", 0, 0, "ASC")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.ListTags("[FUNCTION_ID]", "[SEARCH]", 0, 0, "ASC")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.List("[SEARCH]", 0, 0, "ASC")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.UpdateActive("[FUNCTION_ID]", "[ACTIVE]")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.UpdateTag("[FUNCTION_ID]", "[TAG]")
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go"
)
func main() {
var client := appwrite.Client{}
client.SetProject("5df5acd0d48c2") // Your project ID
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
var service := appwrite.Functions{
client: &client
}
var response, error := service.Update("[FUNCTION_ID]", "[NAME]", , [], "", 0)
if error != nil {
panic(error)
}
fmt.Println(response)
}

View file

@ -0,0 +1,186 @@
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, Events []interface{}, Schedule string, Timeout int) (map[string]interface{}, error) {
path := "/functions"
params := map[string]interface{}{
"name": Name,
"vars": Vars,
"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, 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,
"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)
}
// 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)
}
// UpdateTag
func (srv *Functions) UpdateTag(FunctionId string, Tag string) (map[string]interface{}, error) {
r := strings.NewReplacer("{functionId}", FunctionId)
path := r.Replace("/functions/{functionId}/tag")
params := map[string]interface{}{
"tag": Tag,
}
return srv.client.Call("PATCH", 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)
}

View file

@ -0,0 +1,255 @@
package .services;
import okhttp3.Call;
import .Client;
import .enums.OrderType;
import java.io.File;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import static java.util.Map.entry;
public class Functions extends Service {
public Functions(Client client){
super(client);
}
/// List Functions
public Call list(String search, int limit, int offset, OrderType orderType) {
final String path = "/functions";
final Map<String, Object> params = Map.ofEntries(
entry("search", search),
entry("limit", limit),
entry("offset", offset),
entry("orderType", orderType.name())
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("GET", path, headers, params);
}
/// Create Function
public Call create(String name, Object vars, List events, String schedule, int timeout) {
final String path = "/functions";
final Map<String, Object> params = Map.ofEntries(
entry("name", name),
entry("vars", vars),
entry("events", events),
entry("schedule", schedule),
entry("timeout", timeout)
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("POST", path, headers, params);
}
/// Get Function
public Call get(String functionId) {
final String path = "/functions/{functionId}".replace("{functionId}", functionId);
final Map<String, Object> params = Map.ofEntries(
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("GET", path, headers, params);
}
/// Update Function
public Call update(String functionId, String name, Object vars, List events, String schedule, int timeout) {
final String path = "/functions/{functionId}".replace("{functionId}", functionId);
final Map<String, Object> params = Map.ofEntries(
entry("name", name),
entry("vars", vars),
entry("events", events),
entry("schedule", schedule),
entry("timeout", timeout)
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("PUT", path, headers, params);
}
/// Delete Function
public Call delete(String functionId) {
final String path = "/functions/{functionId}".replace("{functionId}", functionId);
final Map<String, Object> params = Map.ofEntries(
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("DELETE", path, headers, params);
}
/// List Executions
public Call listExecutions(String functionId, String search, int limit, int offset, OrderType orderType) {
final String path = "/functions/{functionId}/executions".replace("{functionId}", functionId);
final Map<String, Object> params = Map.ofEntries(
entry("search", search),
entry("limit", limit),
entry("offset", offset),
entry("orderType", orderType.name())
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("GET", path, headers, params);
}
/// Create Execution
public Call createExecution(String functionId, int async) {
final String path = "/functions/{functionId}/executions".replace("{functionId}", functionId);
final Map<String, Object> params = Map.ofEntries(
entry("async", async)
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("POST", path, headers, params);
}
/// Get Execution
public Call getExecution(String functionId, String executionId) {
final String path = "/functions/{functionId}/executions/{executionId}".replace("{functionId}", functionId).replace("{executionId}", executionId);
final Map<String, Object> params = Map.ofEntries(
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("GET", path, headers, params);
}
/// Update Function Tag
public Call updateTag(String functionId, String tag) {
final String path = "/functions/{functionId}/tag".replace("{functionId}", functionId);
final Map<String, Object> params = Map.ofEntries(
entry("tag", tag)
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("PATCH", path, headers, params);
}
/// List Tags
public Call listTags(String functionId, String search, int limit, int offset, OrderType orderType) {
final String path = "/functions/{functionId}/tags".replace("{functionId}", functionId);
final Map<String, Object> params = Map.ofEntries(
entry("search", search),
entry("limit", limit),
entry("offset", offset),
entry("orderType", orderType.name())
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("GET", path, headers, params);
}
/// Create Tag
public Call createTag(String functionId, String env, String command, String code) {
final String path = "/functions/{functionId}/tags".replace("{functionId}", functionId);
final Map<String, Object> params = Map.ofEntries(
entry("env", env),
entry("command", command),
entry("code", code)
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("POST", path, headers, params);
}
/// Get Tag
public Call getTag(String functionId, String tagId) {
final String path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId);
final Map<String, Object> params = Map.ofEntries(
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("GET", path, headers, params);
}
/// Delete Tag
public Call deleteTag(String functionId, String tagId) {
final String path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId);
final Map<String, Object> params = Map.ofEntries(
);
final Map<String, String> headers = Map.ofEntries(
entry("content-type", "application/json")
);
return client.call("DELETE", path, headers, params);
}
}

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.createExecution('[FUNCTION_ID]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.createTag('[FUNCTION_ID]', 'node-14', '[COMMAND]', '[CODE]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.create('[NAME]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.deleteTag('[FUNCTION_ID]', '[TAG_ID]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.delete('[FUNCTION_ID]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.getExecution('[FUNCTION_ID]', '[EXECUTION_ID]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.getTag('[FUNCTION_ID]', '[TAG_ID]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.get('[FUNCTION_ID]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.listExecutions('[FUNCTION_ID]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.listTags('[FUNCTION_ID]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.list();
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.updateActive('[FUNCTION_ID]', '[ACTIVE]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.updateTag('[FUNCTION_ID]', '[TAG]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -0,0 +1,19 @@
const sdk = require('node-appwrite');
// Init SDK
let client = new sdk.Client();
let functions = new sdk.Functions(client);
client
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.update('[FUNCTION_ID]', '[NAME]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

View file

@ -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,

View file

@ -0,0 +1,282 @@
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[] events
* @param string schedule
* @param number timeout
* @throws Exception
* @return {}
*/
async create(name, vars = [], events = [], schedule = '', timeout = 15) {
let path = '/functions';
return await this.client.call('post', path, {
'content-type': 'application/json',
},
{
'name': name,
'vars': vars,
'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[] events
* @param string schedule
* @param number timeout
* @throws Exception
* @return {}
*/
async update(functionId, name, vars = [], events = [], schedule = '', timeout = 15) {
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,
'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',
},
{
});
}
/**
* 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',
},
{
});
}
/**
* Update Function Tag
*
* @param string functionId
* @param string tag
* @throws Exception
* @return {}
*/
async updateTag(functionId, tag) {
let path = '/functions/{functionId}/tag'.replace(new RegExp('{functionId}', 'g'), functionId);
return await this.client.call('patch', path, {
'content-type': 'application/json',
},
{
'tag': tag
});
}
/**
* 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;

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->createExecution('[FUNCTION_ID]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->createTag('[FUNCTION_ID]', 'node-14', '[COMMAND]', '[CODE]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->create('[NAME]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->deleteTag('[FUNCTION_ID]', '[TAG_ID]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->delete('[FUNCTION_ID]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->getExecution('[FUNCTION_ID]', '[EXECUTION_ID]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->getTag('[FUNCTION_ID]', '[TAG_ID]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->get('[FUNCTION_ID]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->listExecutions('[FUNCTION_ID]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->listTags('[FUNCTION_ID]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->list();

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->updateActive('[FUNCTION_ID]', '[ACTIVE]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->updateTag('[FUNCTION_ID]', '[TAG]');

View file

@ -0,0 +1,15 @@
<?php
use Appwrite\Client;
use Appwrite\Services\Functions;
$client = new Client();
$client
->setProject('5df5acd0d48c2') // Your project ID
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
$functions = new Functions($client);
$result = $functions->update('[FUNCTION_ID]', '[NAME]');

View file

@ -0,0 +1,186 @@
# 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. | [] |
| events | array | Events list. | [] |
| schedule | string | Schedule CRON syntax. | |
| timeout | integer | Function maximum execution time in seconds. | 15 |
## 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. | [] |
| events | array | Events list. | [] |
| schedule | string | Schedule CRON syntax. | |
| timeout | integer | Function maximum execution time in seconds. | 15 |
## Delete Function
```http request
DELETE https://appwrite.io/v1/functions/{functionId}
```
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| functionId | string | **Required** Function 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. | |
## Update Function Tag
```http request
PATCH https://appwrite.io/v1/functions/{functionId}/tag
```
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| functionId | string | **Required** Function unique ID. | |
| tag | string | Tag 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. | |

View file

@ -0,0 +1,300 @@
<?php
namespace Appwrite\Services;
use Exception;
use Appwrite\Client;
use Appwrite\Service;
class Functions extends Service
{
/**
* List Functions
*
* @param string $search
* @param int $limit
* @param int $offset
* @param string $orderType
* @throws Exception
* @return array
*/
public function list(string $search = '', int $limit = 25, int $offset = 0, string $orderType = 'ASC'):array
{
$path = str_replace([], [], '/functions');
$params = [];
$params['search'] = $search;
$params['limit'] = $limit;
$params['offset'] = $offset;
$params['orderType'] = $orderType;
return $this->client->call(Client::METHOD_GET, $path, [
'content-type' => 'application/json',
], $params);
}
/**
* Create Function
*
* @param string $name
* @param array $vars
* @param array $events
* @param string $schedule
* @param int $timeout
* @throws Exception
* @return array
*/
public function create(string $name, array $vars = , array $events = [], string $schedule = '', int $timeout = 15):array
{
$path = str_replace([], [], '/functions');
$params = [];
$params['name'] = $name;
$params['vars'] = $vars;
$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 array $events
* @param string $schedule
* @param int $timeout
* @throws Exception
* @return array
*/
public function update(string $functionId, string $name, array $vars = , array $events = [], string $schedule = '', int $timeout = 15):array
{
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}');
$params = [];
$params['name'] = $name;
$params['vars'] = $vars;
$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);
}
/**
* 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);
}
/**
* Update Function Tag
*
* @param string $functionId
* @param string $tag
* @throws Exception
* @return array
*/
public function updateTag(string $functionId, string $tag):array
{
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/tag');
$params = [];
$params['tag'] = $tag;
return $this->client->call(Client::METHOD_PATCH, $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);
}
}

View file

@ -0,0 +1,178 @@
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=[], events=[], schedule='', timeout=15):
"""Create Function"""
params = {}
path = '/functions'
params['name'] = name
params['vars'] = vars
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=[], events=[], schedule='', timeout=15):
"""Update Function"""
params = {}
path = '/functions/{functionId}'
path = path.replace('{functionId}', function_id)
params['name'] = name
params['vars'] = vars
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 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 update_tag(self, function_id, tag):
"""Update Function Tag"""
params = {}
path = '/functions/{functionId}/tag'
path = path.replace('{functionId}', function_id)
params['tag'] = tag
return self.client.call('patch', 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)

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.create_execution('[FUNCTION_ID]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.create_tag('[FUNCTION_ID]', 'node-14', '[COMMAND]', '[CODE]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.create('[NAME]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.delete_tag('[FUNCTION_ID]', '[TAG_ID]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.delete('[FUNCTION_ID]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.get_execution('[FUNCTION_ID]', '[EXECUTION_ID]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.get_tag('[FUNCTION_ID]', '[TAG_ID]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.get('[FUNCTION_ID]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.list_executions('[FUNCTION_ID]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.list_tags('[FUNCTION_ID]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.list()

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.update_active('[FUNCTION_ID]', '[ACTIVE]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.update_tag('[FUNCTION_ID]', '[TAG]')

View file

@ -0,0 +1,13 @@
from appwrite.client import Client
from appwrite.services.functions import Functions
client = Client()
(client
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
)
functions = Functions(client)
result = functions.update('[FUNCTION_ID]', '[NAME]')

View file

@ -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'

View file

@ -0,0 +1,193 @@
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: [], events: [], schedule: '', timeout: 15)
path = '/functions'
params = {
'name': name,
'vars': vars,
'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: [], events: [], schedule: '', timeout: 15)
path = '/functions/{functionId}'
.gsub('{function_id}', function_id)
params = {
'name': name,
'vars': vars,
'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 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 update_tag(function_id:, tag:)
path = '/functions/{functionId}/tag'
.gsub('{function_id}', function_id)
params = {
'tag': tag
}
return @client.call('patch', 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

Some files were not shown because too many files have changed in this diff Show more