diff --git a/.env b/.env deleted file mode 100644 index 5bb845ae57..0000000000 --- a/.env +++ /dev/null @@ -1,4 +0,0 @@ -TESTS_FACEBOOK_APP_ID=dbase -TESTS_FACEBOOK_APP_KEY=SDASDHAJSHDAJSHDJHSD -DB_PW=dbpassword -DB_ROOT_PW=dbrootpw \ No newline at end of file diff --git a/.gitignore b/.gitignore index 16ce41ad7f..fa6a24789b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ /tests/resources/storage/ /.idea/ .DS_Store -.php_cs.cache \ No newline at end of file +.php_cs.cache +.env \ No newline at end of file diff --git a/CHANGES.md b/CHANGES.md index 3d775c73e4..51239015fd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,14 +4,38 @@ * Upgraded core API PHP version to 7.4 * New database rule validation options -* Update docs example with auth info -* Allow non-web platform skip origin header +* Allow non-web platform to skip origin header +* Limited console dashboard to show max 5 alerts at the same time +* Added more webhooks events +* Normailized all webhooks event names +* Added support for SameSite cookie option with fallback cookie for old clients +* Added a new Discord OAuth adapter +* Added a new Twitch OAuth adapter +* Added a new Spotify OAuth adapter +* Added a new Yahoo OAuth adapter +* Added a new Salesforce OAuth adapter +* Added a new Yandex OAuth adapter +* Added a new Paypal OAuth adapter +* Added a new Bitly OAuth adapter +* Upgraded MariaDB image to version 1.0.2 +* Upgraded SMTP image to version 1.0.1 +* File upload route (POST /v1/storage/files) now accept a single file per request * Added ENV vars to change system email sender name and address +* Usage for requests made by project admin in the console are not counted as API usage +* Added ENV var to change default file upload size limit. New default value is 100MB ## Bug Fixes * Fixed bug where user status was saved as a string instead of an integer +* Fixed gravatar icons not showing up correctly on the console +* Fixed code location of project not found error * Fixed bug where tags element would ignore tab key for parsing new tags +* Fixed OAuth login error saying project UID is missing when its not +* Fixed wrong input validation for user preferences + +## Breaking Changes + +* Merged Auth and Account service route to make the API REST compatible # Version 0.4.0 (PRE-RELEASE) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b9dd6fcc6..f5c97fbf85 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -169,5 +169,6 @@ docker exec appwrite /bin/bash -c '/usr/share/nginx/html/vendor/bin/phpunit' From time to time, our team will add tutorials that will help contributors find their way in the Appwrite source code. Below is a list of currently available tutorials: -* [Adding Support for a New OAuth Provider](./docs/tutorials/add-oauth-provider.md) -* [Appwrite Environment Variables](./docs/tutorials/add-oauth-provider.md) +* [Adding Support for a New OAuth2 Provider](./docs/tutorials/add-oauth2-provider.md) +* [Appwrite Environment Variables](./docs/tutorials/environment-variables.md) +* [Running in Production](./docs/tutorials/running-in-production.md) diff --git a/Dockerfile b/Dockerfile index 556d9ace09..47b8bad8af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,7 @@ ENV TZ=Asia/Tel_Aviv \ _APP_EDITION=community \ _APP_OPTIONS_ABUSE=enabled \ _APP_OPENSSL_KEY_V1=your-secret-key \ + _APP_STORAGE_LIMIT=104857600 \ _APP_REDIS_HOST=redis \ _APP_REDIS_PORT=6379 \ _APP_DB_HOST=mariadb \ @@ -63,6 +64,7 @@ ENV TZ=Asia/Tel_Aviv \ _APP_STATSD_PORT=8125 \ _APP_SMTP_HOST=smtp \ _APP_SMTP_PORT=25 \ + _APP_SETUP=self-hosted \ _APP_VERSION=$VERSION #ENV _APP_SMTP_SECURE '' #ENV _APP_SMTP_USERNAME '' @@ -94,8 +96,9 @@ RUN \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Set Upload Limit -RUN echo "upload_max_filesize = 4M" > /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini +# Set Upload Limit (default to 100MB) +RUN echo "upload_max_filesize = ${_APP_STORAGE_LIMIT}" > /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini +RUN echo "post_max_size = ${_APP_STORAGE_LIMIT}" > /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini # Nginx Configuration (with self-signed ssl certificates) COPY ./docker/nginx.conf /etc/nginx/nginx.conf diff --git a/README.md b/README.md index faeeaaf511..45f005fcc5 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ Appwrite API services aim to make developer's life a lot easier by hiding the co Using Appwrite, you can easily manage user authentication with multiple sign-in methods, a database for storing and querying user and team data, storage and file management, image manipulation and cropping, schedule cron tasks and many other features to help you get more results in faster times and with a lot less code. +Appwrite can also integrate really well with your backend. Appwrite can word behind your own proxy facing your internal network, or alongside your own custom backend. You can use Appwrite server SDK to integrate your backend with Appwrite's APIs and webhooks. + [https://appwrite.io](https://appwrite.io) ![Appwrite](public/images/github.png) @@ -51,7 +53,7 @@ docker-compose up -d --remove-orphans ``` -Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please notice that on non-linux native hosts, the server might take a few minutes to start after installation completes. +Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-linux native hosts, the server might take a few minutes to start after installation completes. For advanced production and custom installation, check out our Docker [environment variables](docs/tutorials/environment-variables.md) docs. @@ -71,8 +73,7 @@ Getting started with Appwrite is as easy as creating a new project, choosing you ### Services -* [**Auth**](https://appwrite.io/docs/auth) - Manage user authentication using multiple sign-in methods and account recovery. -* [**Account**](https://appwrite.io/docs/account) - Manage current user account. Track and manage the user sessions, devices, and security audit log. +* [**Account**](https://appwrite.io/docs/account) - Manage current user authentication and account. Track and manage the user sessions, devices, sigin methods, and security logs. * [**Users**](https://appwrite.io/docs/users) - Manage and list all project users when in admin mode. * [**Teams**](https://appwrite.io/docs/teams) - Manage and group users in teams. Manage memberships, invites and user roles within a team. * [**Database**](https://appwrite.io/docs/database) - Manage database collections and documents. Read, create, update and delete documents and filter lists of documents collections using an advanced filter with graph-like capabilities. diff --git a/app/app.php b/app/app.php index 90eb4a8487..7dfadcbad8 100644 --- a/app/app.php +++ b/app/app.php @@ -13,6 +13,7 @@ use Utopia\Validator\Range; use Utopia\View; use Utopia\Exception; use Auth\Auth; +use Database\Database; use Database\Document; use Database\Validator\Authorization; use Event\Event; @@ -22,7 +23,6 @@ use Utopia\Validator\WhiteList; * Configuration files */ $roles = include __DIR__.'/config/roles.php'; // User roles and scopes -$sdks = include __DIR__.'/config/sdks.php'; // List of SDK clients $services = include __DIR__.'/config/services.php'; // List of services $webhook = new Event('v1-webhooks', 'WebhooksV1'); @@ -54,6 +54,7 @@ $clients = array_unique(array_merge($clientsConsole, array_map(function ($node) })))); $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $roles, $webhook, $audit, $usage, $domain, $clients) { + $route = $utopia->match($request); $referrer = $request->getServer('HTTP_REFERER', ''); @@ -119,19 +120,19 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $ $scope = $route->getLabel('scope', 'none'); // Allowed scope for chosen route $scopes = $roles[$role]['scopes']; // Allowed scopes for user role - + // Check if given key match project API keys $key = $project->search('secret', $request->getHeader('X-Appwrite-Key', ''), $project->getAttribute('keys', [])); - + /* * Try app auth when we have project key and no user * Mock user to app and grant API key scopes in addition to default app scopes */ if (null !== $key && $user->isEmpty()) { $user = new Document([ - '$uid' => 0, + '$id' => 0, 'status' => Auth::USER_STATUS_ACTIVATED, - 'email' => 'app.'.$project->getUid().'@service.'.$domain, + 'email' => 'app.'.$project->getId().'@service.'.$domain, 'password' => '', 'name' => $project->getAttribute('name', 'Untitled'), ]); @@ -139,10 +140,10 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $ $role = Auth::USER_ROLE_APP; $scopes = array_merge($roles[$role]['scopes'], $key->getAttribute('scopes', [])); - Authorization::disable(); // Cancel security segmentation for API keys. + Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys. } - Authorization::setRole('user:'.$user->getUid()); + Authorization::setRole('user:'.$user->getId()); Authorization::setRole('role:'.$role); array_map(function ($node) { @@ -158,6 +159,10 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $ // TDOO Check if user is god if (!in_array($scope, $scopes)) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) { // Check if permission is denied because project is missing + throw new Exception('Project not found', 404); + } + throw new Exception($user->getAttribute('email', 'Guest').' (role: '.strtolower($roles[$role]['label']).') missing scope ('.$scope.')', 401); } @@ -173,14 +178,14 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $ * Background Jobs */ $webhook - ->setParam('projectId', $project->getUid()) + ->setParam('projectId', $project->getId()) ->setParam('event', $route->getLabel('webhook', '')) ->setParam('payload', []) ; $audit - ->setParam('projectId', $project->getUid()) - ->setParam('userId', $user->getUid()) + ->setParam('projectId', $project->getId()) + ->setParam('userId', $user->getId()) ->setParam('event', '') ->setParam('resource', '') ->setParam('userAgent', $request->getServer('HTTP_USER_AGENT', '')) @@ -189,7 +194,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $ ; $usage - ->setParam('projectId', $project->getUid()) + ->setParam('projectId', $project->getId()) ->setParam('url', $request->getServer('HTTP_HOST', '').$request->getServer('REQUEST_URI', '')) ->setParam('method', $request->getServer('REQUEST_METHOD', 'UNKNOWN')) ->setParam('request', 0) @@ -198,7 +203,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $ ; }); -$utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage) { +$utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage, $mode, $project, $utopia) { /* * Trigger Events for background jobs @@ -206,16 +211,22 @@ $utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage if (!empty($webhook->getParam('event'))) { $webhook->trigger(); } - + if (!empty($audit->getParam('event'))) { $audit->trigger(); } + + $route = $utopia->match($request); - $usage - ->setParam('request', $request->getSize()) - ->setParam('response', $response->getSize()) - ->trigger() - ; + 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()) + ->setParam('response', $response->getSize()) + ->trigger() + ; + } }); $utopia->options(function () use ($request, $response, $domain, $project) { @@ -236,6 +247,7 @@ $utopia->error(function ($error /* @var $error Exception */) use ($request, $res case 402: // Error allowed publicly case 403: // Error allowed publicly case 404: // Error allowed publicly + case 409: // Error allowed publicly case 412: // Error allowed publicly case 429: // Error allowed publicly $code = $error->getCode(); @@ -330,10 +342,8 @@ $utopia->get('/robots.txt') ->label('docs', false) ->action( function () use ($response) { - $response->text('# robotstxt.org/ - -User-agent: * -'); + $template = new View(__DIR__.'/views/general/robots.phtml'); + $response->text($template->render(false)); } ); @@ -343,33 +353,27 @@ $utopia->get('/humans.txt') ->label('docs', false) ->action( function () use ($response) { - $response->text('# humanstxt.org/ -# The humans responsible & technology colophon - -# TEAM - -- -- - -# THANKS - '); + $template = new View(__DIR__.'/views/general/humans.phtml'); + $response->text($template->render(false)); } ); $utopia->get('/v1/info') // This is only visible to gods -->label('scope', 'god') + ->label('scope', 'god') ->label('docs', false) ->action( - function () use ($response, $user, $project, $version, $env) { //TODO CONSIDER BLOCKING THIS ACTION TO ROLE GOD + function () use ($response, $user, $project, $version, $env) { $response->json([ 'name' => 'API', 'version' => $version, 'environment' => $env, 'time' => date('Y-m-d H:i:s', time()), 'user' => [ - 'id' => $user->getUid(), + 'id' => $user->getId(), 'name' => $user->getAttribute('name', ''), ], 'project' => [ - 'id' => $project->getUid(), + 'id' => $project->getId(), 'name' => $project->getAttribute('name', ''), ], ]); @@ -407,7 +411,7 @@ $utopia->get('/v1/proxy') $utopia->get('/v1/open-api-2.json') ->label('scope', 'public') ->label('docs', false) - ->param('platform', 'client', function () {return new WhiteList(['client', 'server']);}, 'Choose target platform.', true) + ->param('platform', 'client', function () {return new WhiteList([APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER, APP_PLATFORM_CONSOLE]);}, 'Choose target platform.', true) ->param('extensions', 0, function () {return new Range(0, 1);}, 'Show extra data.', true) ->param('tests', 0, function () {return new Range(0, 1);}, 'Include only test services.', true) ->action( @@ -436,14 +440,21 @@ $utopia->get('/v1/open-api-2.json') if (!$tests && !$service['sdk']) { continue; } - + /** @noinspection PhpIncludeInspection */ include_once $service['controller']; } $security = [ - 'client' => ['Project' => []], - 'server' => ['Project' => [], 'Key' => []], + APP_PLATFORM_CLIENT => ['Project' => []], + APP_PLATFORM_SERVER => ['Project' => [], 'Key' => []], + APP_PLATFORM_CONSOLE => ['Project' => [], 'Key' => []], + ]; + + $platforms = [ + 'client' => APP_PLATFORM_CLIENT, + 'server' => APP_PLATFORM_SERVER, + 'all' => APP_PLATFORM_CONSOLE, ]; /* @@ -476,13 +487,13 @@ $utopia->get('/v1/open-api-2.json') 'Project' => [ 'type' => 'apiKey', 'name' => 'X-Appwrite-Project', - 'description' => 'Your Appwrite project ID', + 'description' => 'Your project ID', 'in' => 'header', ], 'Key' => [ 'type' => 'apiKey', 'name' => 'X-Appwrite-Key', - 'description' => 'Your Appwrite project secret key', + 'description' => 'Your secret API key', 'in' => 'header', ], 'Locale' => [ @@ -543,6 +554,13 @@ $utopia->get('/v1/open-api-2.json') ], ]; + if ($extensions) { + $output['securityDefinitions']['Project']['extensions'] = ['demo' => '5df5acd0d48c2']; + $output['securityDefinitions']['Key']['extensions'] = ['demo' => '919c2d18fb5d4...a2ae413da83346ad2']; + $output['securityDefinitions']['Locale']['extensions'] = ['demo' => 'en']; + $output['securityDefinitions']['Mode']['extensions'] = ['demo' => '']; + } + foreach ($utopia->getRoutes() as $key => $method) { foreach ($method as $route) { /* @var $route \Utopia\Route */ if (!$route->getLabel('docs', true)) { @@ -553,6 +571,10 @@ $utopia->get('/v1/open-api-2.json') continue; } + if($platform !== APP_PLATFORM_CONSOLE && !in_array($platforms[$platform], $route->getLabel('sdk.platform', []))) { + continue; + } + $url = str_replace('/v1', '', $route->getURL()); $scope = $route->getLabel('scope', ''); $hide = $route->getLabel('sdk.hide', false); @@ -582,6 +604,17 @@ $utopia->get('/v1/open-api-2.json') ]; if ($extensions) { + $platformList = $route->getLabel('sdk.platform', []); + + if(in_array(APP_PLATFORM_CLIENT, $platformList)) { + $platformList = array_merge($platformList, [ + APP_PLATFORM_WEB, + APP_PLATFORM_IOS, + APP_PLATFORM_ANDROID, + APP_PLATFORM_FLUTTER, + ]); + } + $temp['extensions'] = [ 'weight' => $route->getOrder(), 'cookies' => $route->getLabel('sdk.cookies', false), @@ -591,10 +624,11 @@ $utopia->get('/v1/open-api-2.json') 'rate-limit' => $route->getLabel('abuse-limit', 0), 'rate-time' => $route->getLabel('abuse-time', 3600), 'scope' => $route->getLabel('scope', ''), + 'platforms' => $platformList, ]; } - if ((!empty($scope) && 'public' != $scope)) { + if ((!empty($scope))) { // && 'public' != $scope $temp['security'][] = $route->getLabel('sdk.security', $security[$platform]); } @@ -640,8 +674,9 @@ $utopia->get('/v1/open-api-2.json') break; case 'Utopia\Validator\JSON': case 'Utopia\Validator\Mock': + case 'Utopia\Validator\Assoc': + $node['type'] = 'object'; $node['type'] = 'object'; - $node['type'] = 'string'; $node['x-example'] = '{}'; //$node['format'] = 'json'; break; @@ -722,7 +757,93 @@ $utopia->get('/v1/open-api-2.json') ksort($output['paths']); - $response->json($output); + $response + ->json($output); + } + ); + + +$utopia->get('/v1/debug') + ->label('scope', 'public') + ->label('docs', false) + ->action( + function () use ($response, $request, $utopia, $domain, $services) { + $output = [ + 'scopes' => [], + 'webhooks' => [], + 'methods' => [], + 'routes' => [], + 'docs' => [], + ]; + + foreach ($services as $service) { /* @noinspection PhpIncludeInspection */ + /** @noinspection PhpIncludeInspection */ + if($service['tests']) { + continue; + } + + include_once $service['controller']; + } + + $i = 0; + + foreach ($utopia->getRoutes() as $key => $method) { + foreach ($method as $route) { /* @var $route \Utopia\Route */ + if (!$route->getLabel('docs', true)) { + continue; + } + + if (empty($route->getLabel('sdk.namespace', null))) { + continue; + } + + if ($route->getLabel('scope', false)) { + $output['scopes'][$route->getLabel('scope', false)] = $route->getMethod().' '.$route->getURL(); + } + + if ($route->getLabel('sdk.description', false)) { + if(!realpath(__DIR__.'/../'.$route->getLabel('sdk.description', false))) { + throw new Exception('Docs file ('.$route->getLabel('sdk.description', false).') is missing', 500); + } + + if(array_key_exists($route->getLabel('sdk.description', false), $output['docs'])) { + throw new Exception('Docs file ('.$route->getLabel('sdk.description', false).') is already in use by another route', 500); + } + + $output['docs'][$route->getLabel('sdk.description', false)] = $route->getMethod().' '.$route->getURL(); + } + + if ($route->getLabel('webhook', false)) { + if(array_key_exists($route->getLabel('webhook', false), $output['webhooks'])) { + //throw new Exception('Webhook ('.$route->getLabel('webhook', false).') is already in use by another route', 500); + } + + $output['webhooks'][$route->getLabel('webhook', false)] = $route->getMethod().' '.$route->getURL(); + } + + if ($route->getLabel('sdk.namespace', false)) { + $method = $route->getLabel('sdk.namespace', false).'->'.$route->getLabel('sdk.method', false).'()'; + if(array_key_exists($method, $output['methods'])) { + throw new Exception('Method ('.$method.') is already in use by another route', 500); + } + + $output['methods'][$method] = $route->getMethod().' '.$route->getURL(); + } + + $output['routes'][$route->getURL().' ('.$route->getMethod().')'] = []; + + $i++; + } + } + + ksort($output['scopes']); + ksort($output['webhooks']); + ksort($output['methods']); + ksort($output['routes']); + ksort($output['docs']); + + $response + ->json($output); } ); diff --git a/app/config/collections.php b/app/config/collections.php index bd97399bb2..45ad9a3a5b 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -6,7 +6,7 @@ use Database\Database; $collections = [ 'console' => [ - '$uid' => 'console', + '$id' => 'console', '$collection' => 'projects', '$permissions' => ['read' => ['*']], 'name' => 'Appwrite', @@ -71,7 +71,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_COLLECTIONS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_COLLECTIONS, '$permissions' => ['read' => ['*']], 'name' => 'Collections', 'structure' => true, @@ -126,7 +126,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_RULES => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_RULES, + '$id' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => ['*']], 'name' => 'Collections Rule', 'structure' => true, @@ -198,7 +198,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_USERS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_USERS, + '$id' => Database::SYSTEM_COLLECTION_USERS, '$permissions' => ['read' => ['*']], 'name' => 'User', 'structure' => true, @@ -268,8 +268,8 @@ $collections = [ ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Confirmation Status', - 'key' => 'confirm', + 'label' => 'Email Verification Status', + 'key' => 'emailVerification', 'type' => 'boolean', 'default' => '', 'required' => true, @@ -308,7 +308,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_TOKENS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_TOKENS, + '$id' => Database::SYSTEM_COLLECTION_TOKENS, '$permissions' => ['read' => ['*']], 'name' => 'Token', 'structure' => true, @@ -362,7 +362,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_MEMBERSHIPS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, + '$id' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, '$permissions' => ['read' => ['*']], 'name' => 'Membership', 'structure' => true, @@ -434,7 +434,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_TEAMS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_TEAMS, + '$id' => Database::SYSTEM_COLLECTION_TEAMS, '$permissions' => ['read' => ['*']], 'name' => 'Team', 'structure' => true, @@ -470,7 +470,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_PROJECTS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_PROJECTS, + '$id' => Database::SYSTEM_COLLECTION_PROJECTS, '$permissions' => ['read' => ['*']], 'name' => 'Project', 'structure' => true, @@ -610,7 +610,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_WEBHOOKS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_WEBHOOKS, + '$id' => Database::SYSTEM_COLLECTION_WEBHOOKS, '$permissions' => ['read' => ['*']], 'name' => 'Webhook', 'structure' => true, @@ -673,7 +673,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_KEYS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_KEYS, + '$id' => Database::SYSTEM_COLLECTION_KEYS, '$permissions' => ['read' => ['*']], 'name' => 'Key', 'structure' => true, @@ -708,7 +708,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_TASKS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_TASKS, + '$id' => Database::SYSTEM_COLLECTION_TASKS, '$permissions' => ['read' => ['*']], 'name' => 'Task', 'structure' => true, @@ -861,7 +861,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_PLATFORMS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_PLATFORMS, + '$id' => Database::SYSTEM_COLLECTION_PLATFORMS, '$permissions' => ['read' => ['*']], 'name' => 'Platform', 'structure' => true, @@ -933,7 +933,7 @@ $collections = [ ], Database::SYSTEM_COLLECTION_FILES => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$uid' => Database::SYSTEM_COLLECTION_FILES, + '$id' => Database::SYSTEM_COLLECTION_FILES, '$permissions' => ['read' => ['*']], 'name' => 'File', 'structure' => true, @@ -1078,7 +1078,7 @@ $collections = [ ]; /* - * Add enabled OAuth providers to default data rules + * Add enabled OAuth2 providers to default data rules */ foreach ($providers as $key => $provider) { if (!$provider['enabled']) { @@ -1087,8 +1087,8 @@ foreach ($providers as $key => $provider) { $collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OAuth '.ucfirst($key).' ID', - 'key' => 'usersOauth'.ucfirst($key).'Appid', + 'label' => 'OAuth2 '.ucfirst($key).' ID', + 'key' => 'usersOauth2'.ucfirst($key).'Appid', 'type' => 'text', 'default' => '', 'required' => false, @@ -1097,8 +1097,8 @@ foreach ($providers as $key => $provider) { $collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OAuth '.ucfirst($key).' Secret', - 'key' => 'usersOauth'.ucfirst($key).'Secret', + 'label' => 'OAuth2 '.ucfirst($key).' Secret', + 'key' => 'usersOauth2'.ucfirst($key).'Secret', 'type' => 'text', 'default' => '', 'required' => false, @@ -1107,8 +1107,8 @@ foreach ($providers as $key => $provider) { $collections[Database::SYSTEM_COLLECTION_USERS]['rules'][] = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OAuth '.ucfirst($key).' ID', - 'key' => 'oauth'.ucfirst($key), + 'label' => 'OAuth2 '.ucfirst($key).' ID', + 'key' => 'oauth2'.ucfirst($key), 'type' => 'text', 'default' => '', 'required' => false, @@ -1117,8 +1117,8 @@ foreach ($providers as $key => $provider) { $collections[Database::SYSTEM_COLLECTION_USERS]['rules'][] = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OAuth '.ucfirst($key).' Access Token', - 'key' => 'oauth'.ucfirst($key).'AccessToken', + 'label' => 'OAuth2 '.ucfirst($key).' Access Token', + 'key' => 'oauth2'.ucfirst($key).'AccessToken', 'type' => 'text', 'default' => '', 'required' => false, diff --git a/app/config/locales/af.php b/app/config/locales/af.php index ae66ae30ea..5d4612f97e 100644 --- a/app/config/locales/af.php +++ b/app/config/locales/af.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s span', - 'auth.emails.confirm.title' => 'Profiel Bevestiging', - 'auth.emails.confirm.body' => 'af.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Verander Wagwoord', - 'auth.emails.recovery.body' => 'af.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Uitnodiging na %s span by %s', - 'auth.emails.invitation.body' => 'af.email.auth.invitation.tpl', + 'account.emails.team' => '%s span', + 'account.emails.verification.title' => 'Profiel Bevestiging', + 'account.emails.verification.body' => 'af.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Verander Wagwoord', + 'account.emails.recovery.body' => 'af.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Uitnodiging na %s span by %s', + 'account.emails.invitation.body' => 'af.email.auth.invitation.tpl', 'locale.country.unknown' => 'Onbekend', diff --git a/app/config/locales/ar.php b/app/config/locales/ar.php index 623df549d3..0674ff378c 100644 --- a/app/config/locales/ar.php +++ b/app/config/locales/ar.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'rtl', // Service - Users - 'auth.emails.team' => 'فريق %s', - 'auth.emails.confirm.title' => 'تأكيد الحساب', - 'auth.emails.confirm.body' => 'ar.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'إعادة تعيين كلمة المرور', - 'auth.emails.recovery.body' => 'ar.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'دعوة لفريق %s في %s', - 'auth.emails.invitation.body' => 'ar.email.auth.invitation.tpl', + 'account.emails.team' => 'فريق %s', + 'account.emails.verification.title' => 'تأكيد الحساب', + 'account.emails.verification.body' => 'ar.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'إعادة تعيين كلمة المرور', + 'account.emails.recovery.body' => 'ar.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'دعوة لفريق %s في %s', + 'account.emails.invitation.body' => 'ar.email.auth.invitation.tpl', 'locale.country.unknown' => 'مجهول', diff --git a/app/config/locales/bn.php b/app/config/locales/bn.php index c592128c12..6ccf2a6ea2 100644 --- a/app/config/locales/bn.php +++ b/app/config/locales/bn.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s টীম', - 'auth.emails.confirm.title' => 'অ্যাকাউন্ট নিশ্চিতকরণ', - 'auth.emails.confirm.body' => 'bn.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'পাসওয়ার্ড রিসেট', - 'auth.emails.recovery.body' => 'bn.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'আমন্ত্রণ %s এই টীম-এ যেটি এখানের %s', - 'auth.emails.invitation.body' => 'bn.email.auth.invitation.tpl', + 'account.emails.team' => '%s টীম', + 'account.emails.verification.title' => 'অ্যাকাউন্ট নিশ্চিতকরণ', + 'account.emails.verification.body' => 'bn.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'পাসওয়ার্ড রিসেট', + 'account.emails.recovery.body' => 'bn.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'আমন্ত্রণ %s এই টীম-এ যেটি এখানের %s', + 'account.emails.invitation.body' => 'bn.email.auth.invitation.tpl', 'locale.country.unknown' => 'অজানা', diff --git a/app/config/locales/cat.php b/app/config/locales/cat.php index 86c9916f98..078a76ab82 100644 --- a/app/config/locales/cat.php +++ b/app/config/locales/cat.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Equip', - 'auth.emails.confirm.title' => 'Confirmació del compte', - 'auth.emails.confirm.body' => 'cat.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Restablir contrasenya', - 'auth.emails.recovery.body' => 'cat.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Invitació a l\'Equip %s a %s', - 'auth.emails.invitation.body' => 'cat.email.auth.invitation.tpl', + 'account.emails.team' => '%s Equip', + 'account.emails.verification.title' => 'Confirmació del compte', + 'account.emails.verification.body' => 'cat.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Restablir contrasenya', + 'account.emails.recovery.body' => 'cat.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Invitació a l\'Equip %s a %s', + 'account.emails.invitation.body' => 'cat.email.auth.invitation.tpl', 'locale.country.unknown' => 'Desconegut', diff --git a/app/config/locales/cz.php b/app/config/locales/cz.php index 4162906ca2..11cbe0c93e 100644 --- a/app/config/locales/cz.php +++ b/app/config/locales/cz.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s tým', - 'auth.emails.confirm.title' => 'Potvrzení účtu', - 'auth.emails.confirm.body' => 'cz.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Resetovat heslo', - 'auth.emails.recovery.body' => 'cz.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Pozvánka do týmu% s na% s', - 'auth.emails.invitation.body' => 'cz.email.auth.invitation.tpl', + 'account.emails.team' => '%s tým', + 'account.emails.verification.title' => 'Potvrzení účtu', + 'account.emails.verification.body' => 'cz.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Resetovat heslo', + 'account.emails.recovery.body' => 'cz.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Pozvánka do týmu% s na% s', + 'account.emails.invitation.body' => 'cz.email.auth.invitation.tpl', 'locale.country.unknown' => 'Neznámý', diff --git a/app/config/locales/de.php b/app/config/locales/de.php index b3b347be05..8e2774db6f 100644 --- a/app/config/locales/de.php +++ b/app/config/locales/de.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Team', - 'auth.emails.confirm.title' => 'Accountbestätigung', - 'auth.emails.confirm.body' => 'de.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Passwort zurücksetzen', - 'auth.emails.recovery.body' => 'de.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Einladung zum %s Team bei %s', - 'auth.emails.invitation.body' => 'de.email.auth.invitation.tpl', + 'account.emails.team' => '%s Team', + 'account.emails.verification.title' => 'Accountbestätigung', + 'account.emails.verification.body' => 'de.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Passwort zurücksetzen', + 'account.emails.recovery.body' => 'de.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Einladung zum %s Team bei %s', + 'account.emails.invitation.body' => 'de.email.auth.invitation.tpl', 'locale.country.unknown' => 'Unbekannt', diff --git a/app/config/locales/en.php b/app/config/locales/en.php index cbd1dd2f51..80e7b5326f 100644 --- a/app/config/locales/en.php +++ b/app/config/locales/en.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Team', - 'auth.emails.confirm.title' => 'Account Confirmation', - 'auth.emails.confirm.body' => 'en.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Password Reset', - 'auth.emails.recovery.body' => 'en.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Invitation to %s Team at %s', - 'auth.emails.invitation.body' => 'en.email.auth.invitation.tpl', + 'account.emails.team' => '%s Team', + 'account.emails.verification.title' => 'Account Verification', + 'account.emails.verification.body' => 'en.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Password Reset', + 'account.emails.recovery.body' => 'en.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Invitation to %s Team at %s', + 'account.emails.invitation.body' => 'en.email.auth.invitation.tpl', 'locale.country.unknown' => 'Unknown', diff --git a/app/config/locales/es.php b/app/config/locales/es.php index cc8e82b7bd..efe6c53fa9 100644 --- a/app/config/locales/es.php +++ b/app/config/locales/es.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Equipo %s', - 'auth.emails.confirm.title' => 'Confirmación de la cuenta', - 'auth.emails.confirm.body' => 'es.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Reestablecer contraseña', - 'auth.emails.recovery.body' => 'es.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Invitación al Equipo %s en %s', - 'auth.emails.invitation.body' => 'es.email.auth.invitation.tpl', + 'account.emails.team' => 'Equipo %s', + 'account.emails.verification.title' => 'Confirmación de la cuenta', + 'account.emails.verification.body' => 'es.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Reestablecer contraseña', + 'account.emails.recovery.body' => 'es.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Invitación al Equipo %s en %s', + 'account.emails.invitation.body' => 'es.email.auth.invitation.tpl', 'locale.country.unknown' => 'Desconocido', diff --git a/app/config/locales/fi.php b/app/config/locales/fi.php index 76d8e66cb3..a39a830e72 100644 --- a/app/config/locales/fi.php +++ b/app/config/locales/fi.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Tiimi', - 'auth.emails.confirm.title' => 'Tilin Vahvistus', - 'auth.emails.confirm.body' => 'en.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Salasanan Nollaus', - 'auth.emails.recovery.body' => 'en.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Kutsu %s Tiimiin %s', - 'auth.emails.invitation.body' => 'en.email.auth.invitation.tpl', + 'account.emails.team' => '%s Tiimi', + 'account.emails.verification.title' => 'Tilin Vahvistus', + 'account.emails.verification.body' => 'en.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Salasanan Nollaus', + 'account.emails.recovery.body' => 'en.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Kutsu %s Tiimiin %s', + 'account.emails.invitation.body' => 'en.email.auth.invitation.tpl', 'locale.country.unknown' => 'Unknown', diff --git a/app/config/locales/fo.php b/app/config/locales/fo.php index 389fc10d12..1537dc339e 100644 --- a/app/config/locales/fo.php +++ b/app/config/locales/fo.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Lið', - 'auth.emails.confirm.title' => 'Vátta brúkari', - 'auth.emails.confirm.body' => 'fo.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Glómt passord', - 'auth.emails.recovery.body' => 'fo.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Innbjóðing til %s Lið hjá %s', - 'auth.emails.invitation.body' => 'fo.email.auth.invitation.tpl', + 'account.emails.team' => '%s Lið', + 'account.emails.verification.title' => 'Vátta brúkari', + 'account.emails.verification.body' => 'fo.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Glómt passord', + 'account.emails.recovery.body' => 'fo.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Innbjóðing til %s Lið hjá %s', + 'account.emails.invitation.body' => 'fo.email.auth.invitation.tpl', 'locale.country.unknown' => 'Ókjent', diff --git a/app/config/locales/fr.php b/app/config/locales/fr.php index f74a2a72db..f3a2cbbab4 100644 --- a/app/config/locales/fr.php +++ b/app/config/locales/fr.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Équipe %s', - 'auth.emails.confirm.title' => 'Confirmation de création de compte', - 'auth.emails.confirm.body' => 'fr.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Réinitialisation de mot de passe', - 'auth.emails.recovery.body' => 'fr.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Invitation pour l\'équipe %s au projet %s', - 'auth.emails.invitation.body' => 'fr.email.auth.invitation.tpl', + 'account.emails.team' => 'Équipe %s', + 'account.emails.verification.title' => 'Confirmation de création de compte', + 'account.emails.verification.body' => 'fr.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Réinitialisation de mot de passe', + 'account.emails.recovery.body' => 'fr.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Invitation pour l\'équipe %s au projet %s', + 'account.emails.invitation.body' => 'fr.email.auth.invitation.tpl', 'locale.country.unknown' => 'Inconnu', diff --git a/app/config/locales/gr.php b/app/config/locales/gr.php index 95f24f938b..ab067b0141 100644 --- a/app/config/locales/gr.php +++ b/app/config/locales/gr.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Ομάδα %s', - 'auth.emails.confirm.title' => 'Επιβεβαίωση Λογαριασμού', - 'auth.emails.confirm.body' => 'gr.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Επαναφορά Κωδικού Πρόσβασης', - 'auth.emails.recovery.body' => 'gr.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Πρόσκληση στην ομάδα %s στο %s', - 'auth.emails.invitation.body' => 'gr.email.auth.invitation.tpl', + 'account.emails.team' => 'Ομάδα %s', + 'account.emails.verification.title' => 'Επιβεβαίωση Λογαριασμού', + 'account.emails.verification.body' => 'gr.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Επαναφορά Κωδικού Πρόσβασης', + 'account.emails.recovery.body' => 'gr.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Πρόσκληση στην ομάδα %s στο %s', + 'account.emails.invitation.body' => 'gr.email.auth.invitation.tpl', 'locale.country.unknown' => 'Άγνωστο', diff --git a/app/config/locales/he.php b/app/config/locales/he.php index 14a3e2cc2a..91e3f5d1f4 100644 --- a/app/config/locales/he.php +++ b/app/config/locales/he.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'rtl', // Service - Users - 'auth.emails.team' => 'צוות %s', - 'auth.emails.confirm.title' => 'אימות חשבון', - 'auth.emails.confirm.body' => 'he.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'איפוס סיסמא', - 'auth.emails.recovery.body' => 'he.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'הזמנה לצוות של %s ב־%s', - 'auth.emails.invitation.body' => 'he.email.auth.invitation.tpl', + 'account.emails.team' => 'צוות %s', + 'account.emails.verification.title' => 'אימות חשבון', + 'account.emails.verification.body' => 'he.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'איפוס סיסמא', + 'account.emails.recovery.body' => 'he.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'הזמנה לצוות של %s ב־%s', + 'account.emails.invitation.body' => 'he.email.auth.invitation.tpl', 'locale.country.unknown' => 'לא ידוע', diff --git a/app/config/locales/hi.php b/app/config/locales/hi.php index fb1979fe5b..17dacc3709 100644 --- a/app/config/locales/hi.php +++ b/app/config/locales/hi.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s टीम', - 'auth.emails.confirm.title' => 'अकाउंट कन्फर्मेशन ', - 'auth.emails.confirm.body' => 'hi.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'पासवर्ड रिसेट ', - 'auth.emails.recovery.body' => 'hi.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'इनविटेशन %s टीम %s', - 'auth.emails.invitation.body' => 'hi.email.auth.invitation.tpl', + 'account.emails.team' => '%s टीम', + 'account.emails.verification.title' => 'अकाउंट कन्फर्मेशन ', + 'account.emails.verification.body' => 'hi.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'पासवर्ड रिसेट ', + 'account.emails.recovery.body' => 'hi.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'इनविटेशन %s टीम %s', + 'account.emails.invitation.body' => 'hi.email.auth.invitation.tpl', 'locale.country.unknown' => 'अज्ञात', diff --git a/app/config/locales/hu.php b/app/config/locales/hu.php index a4ca49b5c2..d5f1b7e684 100644 --- a/app/config/locales/hu.php +++ b/app/config/locales/hu.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Csapat', - 'auth.emails.confirm.title' => 'Fiók megerősítés', - 'auth.emails.confirm.body' => 'hu.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Jelszó Visszaállítás', - 'auth.emails.recovery.body' => 'hu.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Meghívás a %s Csapathoz %s', - 'auth.emails.invitation.body' => 'hu.email.auth.invitation.tpl', + 'account.emails.team' => '%s Csapat', + 'account.emails.verification.title' => 'Fiók megerősítés', + 'account.emails.verification.body' => 'hu.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Jelszó Visszaállítás', + 'account.emails.recovery.body' => 'hu.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Meghívás a %s Csapathoz %s', + 'account.emails.invitation.body' => 'hu.email.auth.invitation.tpl', 'locale.country.unknown' => 'Ismeretlen', diff --git a/app/config/locales/hy.php b/app/config/locales/hy.php index 00ca681096..2b70ba1c60 100644 --- a/app/config/locales/hy.php +++ b/app/config/locales/hy.php @@ -5,13 +5,13 @@ return [ 'settings.locale' => 'ru', 'settings.direction' => 'ltr', - 'auth.emails.team' => 'Թիմ %s', - 'auth.emails.confirm.title' => 'Հաշվեհամարի հաստատում', - 'auth.emails.confirm.body' => 'hy.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Գաղտնաբառի փոփոխում', - 'auth.emails.recovery.body' => 'hy.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Հրավիրում ենք %s թիմ, %s պրոեկտի համար', - 'auth.emails.invitation.body' => 'hy.email.auth.invitation.tpl', + 'account.emails.team' => 'Թիմ %s', + 'account.emails.verification.title' => 'Հաշվեհամարի հաստատում', + 'account.emails.verification.body' => 'hy.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Գաղտնաբառի փոփոխում', + 'account.emails.recovery.body' => 'hy.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Հրավիրում ենք %s թիմ, %s պրոեկտի համար', + 'account.emails.invitation.body' => 'hy.email.auth.invitation.tpl', 'locale.country.unknown' => 'Անհայտ', diff --git a/app/config/locales/id.php b/app/config/locales/id.php index 3997a4c50b..938f059536 100644 --- a/app/config/locales/id.php +++ b/app/config/locales/id.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Tim %s', - 'auth.emails.confirm.title' => 'Konfirmasi Akun', - 'auth.emails.confirm.body' => 'id.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Reset Kata Sandi', - 'auth.emails.recovery.body' => 'id.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Undangan ke Tim %s di %s', - 'auth.emails.invitation.body' => 'id.email.auth.invitation.tpl', + 'account.emails.team' => 'Tim %s', + 'account.emails.verification.title' => 'Konfirmasi Akun', + 'account.emails.verification.body' => 'id.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Reset Kata Sandi', + 'account.emails.recovery.body' => 'id.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Undangan ke Tim %s di %s', + 'account.emails.invitation.body' => 'id.email.auth.invitation.tpl', 'locale.country.unknown' => 'Tidak diketahui', diff --git a/app/config/locales/is.php b/app/config/locales/is.php index acc5ec8329..d1a8c36c77 100644 --- a/app/config/locales/is.php +++ b/app/config/locales/is.php @@ -4,13 +4,13 @@ return [ 'settings.locale' => 'is', 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Teymi', - 'auth.emails.confirm.title' => 'Staðfesting reiknings', - 'auth.emails.confirm.body' => 'is.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Núllstilla lykilorð', - 'auth.emails.recovery.body' => 'is.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Boð í %s lið í %s', - 'auth.emails.invitation.body' => 'is.email.auth.invitation.tpl', + 'account.emails.team' => '%s Teymi', + 'account.emails.verification.title' => 'Staðfesting reiknings', + 'account.emails.verification.body' => 'is.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Núllstilla lykilorð', + 'account.emails.recovery.body' => 'is.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Boð í %s lið í %s', + 'account.emails.invitation.body' => 'is.email.auth.invitation.tpl', 'locale.country.unknown' => 'Óþekktur', 'countries' => include 'is.countries.php', 'continents' => include 'is.continents.php', diff --git a/app/config/locales/it.php b/app/config/locales/it.php index 759381649b..d2241e4ef8 100644 --- a/app/config/locales/it.php +++ b/app/config/locales/it.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Servizio - Utenti - 'auth.emails.team' => 'Team %s', - 'auth.emails.confirm.title' => 'Conferma dell\'account', - 'auth.emails.confirm.body' => 'it.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Recupero password', - 'auth.emails.recovery.body' => 'it.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Invito al team %s di %s', - 'auth.emails.invitation.body' => 'it.email.auth.invitation.tpl', + 'account.emails.team' => 'Team %s', + 'account.emails.verification.title' => 'Conferma dell\'account', + 'account.emails.verification.body' => 'it.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Recupero password', + 'account.emails.recovery.body' => 'it.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Invito al team %s di %s', + 'account.emails.invitation.body' => 'it.email.auth.invitation.tpl', 'locale.country.unknown' => 'Sconosciuto', diff --git a/app/config/locales/ja.php b/app/config/locales/ja.php index 65be7c84bb..a45ef1b9fc 100644 --- a/app/config/locales/ja.php +++ b/app/config/locales/ja.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s チーム', - 'auth.emails.confirm.title' => 'アカウント確認のお願い', - 'auth.emails.confirm.body' => 'ja.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'パスワード再設定のお願い', - 'auth.emails.recovery.body' => 'ja.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => '%s チーム(%s プロジェクト)への招待', - 'auth.emails.invitation.body' => 'ja.email.auth.invitation.tpl', + 'account.emails.team' => '%s チーム', + 'account.emails.verification.title' => 'アカウント確認のお願い', + 'account.emails.verification.body' => 'ja.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'パスワード再設定のお願い', + 'account.emails.recovery.body' => 'ja.email.auth.recovery.tpl', + 'account.emails.invitation.title' => '%s チーム(%s プロジェクト)への招待', + 'account.emails.invitation.body' => 'ja.email.auth.invitation.tpl', 'locale.country.unknown' => '不明', diff --git a/app/config/locales/jv.php b/app/config/locales/jv.php index 2326430e57..dcc26ab54a 100644 --- a/app/config/locales/jv.php +++ b/app/config/locales/jv.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Tim %s', - 'auth.emails.confirm.title' => 'Konfirmasi akun', - 'auth.emails.confirm.body' => 'jv.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Reset Sandi', - 'auth.emails.recovery.body' => 'jv.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Undangan menyang %s Tim ing %s', - 'auth.emails.invitation.body' => 'jv.email.auth.invitation.tpl', + 'account.emails.team' => 'Tim %s', + 'account.emails.verification.title' => 'Konfirmasi akun', + 'account.emails.verification.body' => 'jv.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Reset Sandi', + 'account.emails.recovery.body' => 'jv.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Undangan menyang %s Tim ing %s', + 'account.emails.invitation.body' => 'jv.email.auth.invitation.tpl', 'locale.country.unknown' => 'Ora dingerteni', diff --git a/app/config/locales/ko.php b/app/config/locales/ko.php index 8400c23d43..fefadb5c80 100644 --- a/app/config/locales/ko.php +++ b/app/config/locales/ko.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s 팀', - 'auth.emails.confirm.title' => '계정 확인', - 'auth.emails.confirm.body' => 'ko.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => '비밀번호 재설정', - 'auth.emails.recovery.body' => 'ko.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => '%s 팀(%s 프로젝트)에 합류 초대', - 'auth.emails.invitation.body' => 'ko.email.auth.invitation.tpl', + 'account.emails.team' => '%s 팀', + 'account.emails.verification.title' => '계정 확인', + 'account.emails.verification.body' => 'ko.email.auth.confirm.tpl', + 'account.emails.recovery.title' => '비밀번호 재설정', + 'account.emails.recovery.body' => 'ko.email.auth.recovery.tpl', + 'account.emails.invitation.title' => '%s 팀(%s 프로젝트)에 합류 초대', + 'account.emails.invitation.body' => 'ko.email.auth.invitation.tpl', 'locale.country.unknown' => '알려지지 않은', diff --git a/app/config/locales/lt.php b/app/config/locales/lt.php index 0ff7ab770e..01be0499b5 100644 --- a/app/config/locales/lt.php +++ b/app/config/locales/lt.php @@ -3,13 +3,13 @@ return [ 'settings.inspire' => '"Menas būti išmintingu — tai menas žinoti, ką galima paniekti."', // This is the line printed in the homepage and console 'view-source' 'settings.locale' => 'lt', 'settings.direction' => 'ltr', - 'auth.emails.team' => 'Komanda %s', - 'auth.emails.confirm.title' => 'Paskyros patvirtinimas', - 'auth.emails.confirm.body' => 'lt.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Atnaujinti slaptažodį', - 'auth.emails.recovery.body' => 'lt.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Pakeisti į komandą %s projektui %s', - 'auth.emails.invitation.body' => 'lt.email.auth.invitation.tpl', + 'account.emails.team' => 'Komanda %s', + 'account.emails.verification.title' => 'Paskyros patvirtinimas', + 'account.emails.verification.body' => 'lt.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Atnaujinti slaptažodį', + 'account.emails.recovery.body' => 'lt.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Pakeisti į komandą %s projektui %s', + 'account.emails.invitation.body' => 'lt.email.auth.invitation.tpl', 'locale.country.unknown' => 'Nežinoma', 'countries' => include 'lt.countries.php', 'continents' => include 'lt.continents.php', diff --git a/app/config/locales/ml.php b/app/config/locales/ml.php index 78819283d8..577e11612b 100644 --- a/app/config/locales/ml.php +++ b/app/config/locales/ml.php @@ -4,13 +4,13 @@ return [ 'settings.locale' => 'ml', 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s ടീം', - 'auth.emails.confirm.title' => 'അക്കൗണ്ട് കൺഫർമേഷൻ', - 'auth.emails.confirm.body' => 'ml.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'പാസ്‌വേഡ് റീസെറ്റ്', - 'auth.emails.recovery.body' => 'ml.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'ഇൻവിറ്റേഷൻ- %s ടീം, %s പ്രോജക്ട്', - 'auth.emails.invitation.body' => 'ml.email.auth.invitation.tpl', + 'account.emails.team' => '%s ടീം', + 'account.emails.verification.title' => 'അക്കൗണ്ട് കൺഫർമേഷൻ', + 'account.emails.verification.body' => 'ml.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'പാസ്‌വേഡ് റീസെറ്റ്', + 'account.emails.recovery.body' => 'ml.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'ഇൻവിറ്റേഷൻ- %s ടീം, %s പ്രോജക്ട്', + 'account.emails.invitation.body' => 'ml.email.auth.invitation.tpl', 'locale.country.unknown' => 'Unknown', 'countries' => include 'ml.countries.php', 'continents' => include 'ml.continents.php', diff --git a/app/config/locales/ms.php b/app/config/locales/ms.php index 7854ac30c5..b080dd0838 100644 --- a/app/config/locales/ms.php +++ b/app/config/locales/ms.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Team', - 'auth.emails.confirm.title' => 'Pengesahan akaun', - 'auth.emails.confirm.body' => 'ms.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Tetapkan semula kata laluan', - 'auth.emails.recovery.body' => 'ms.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Undangan ke dalam kumpulan %s di %s', - 'auth.emails.invitation.body' => 'ms.email.auth.invitation.tpl', + 'account.emails.team' => '%s Team', + 'account.emails.verification.title' => 'Pengesahan akaun', + 'account.emails.verification.body' => 'ms.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Tetapkan semula kata laluan', + 'account.emails.recovery.body' => 'ms.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Undangan ke dalam kumpulan %s di %s', + 'account.emails.invitation.body' => 'ms.email.auth.invitation.tpl', 'locale.country.unknown' => 'Tidak Diketahui', diff --git a/app/config/locales/nl.php b/app/config/locales/nl.php index 4832cb623a..4f315cdaf5 100644 --- a/app/config/locales/nl.php +++ b/app/config/locales/nl.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Team', - 'auth.emails.confirm.title' => 'Account Bevestiging', - 'auth.emails.confirm.body' => 'nl.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Wachtwoord herstellen', - 'auth.emails.recovery.body' => 'nl.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Uitnodiging naar %s Team voor %s', - 'auth.emails.invitation.body' => 'nl.email.auth.invitation.tpl', + 'account.emails.team' => '%s Team', + 'account.emails.verification.title' => 'Account Bevestiging', + 'account.emails.verification.body' => 'nl.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Wachtwoord herstellen', + 'account.emails.recovery.body' => 'nl.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Uitnodiging naar %s Team voor %s', + 'account.emails.invitation.body' => 'nl.email.auth.invitation.tpl', 'locale.country.unknown' => 'Onbekend', diff --git a/app/config/locales/no.php b/app/config/locales/no.php index c09fe5d521..f160f1eecf 100644 --- a/app/config/locales/no.php +++ b/app/config/locales/no.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Team', - 'auth.emails.confirm.title' => 'Bekreftelse av konto', - 'auth.emails.confirm.body' => 'no.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Reset passord', - 'auth.emails.recovery.body' => 'no.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Invitasjon til %s Team på %s', - 'auth.emails.invitation.body' => 'no.email.auth.invitation.tpl', + 'account.emails.team' => '%s Team', + 'account.emails.verification.title' => 'Bekreftelse av konto', + 'account.emails.verification.body' => 'no.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Reset passord', + 'account.emails.recovery.body' => 'no.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Invitasjon til %s Team på %s', + 'account.emails.invitation.body' => 'no.email.auth.invitation.tpl', 'locale.country.unknown' => 'Ukjent', diff --git a/app/config/locales/ph.php b/app/config/locales/ph.php index d338f4d094..6cea3203bd 100644 --- a/app/config/locales/ph.php +++ b/app/config/locales/ph.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Pangkat ng %s', - 'auth.emails.confirm.title' => 'Pagkumpirma ng Account', - 'auth.emails.confirm.body' => 'ph.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Pagreset ng Password', - 'auth.emails.recovery.body' => 'ph.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Paanyaya sa Pangkat ng %s sa %s', - 'auth.emails.invitation.body' => 'ph.email.auth.invitation.tpl', + 'account.emails.team' => 'Pangkat ng %s', + 'account.emails.verification.title' => 'Pagkumpirma ng Account', + 'account.emails.verification.body' => 'ph.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Pagreset ng Password', + 'account.emails.recovery.body' => 'ph.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Paanyaya sa Pangkat ng %s sa %s', + 'account.emails.invitation.body' => 'ph.email.auth.invitation.tpl', 'locale.country.unknown' => 'Hindi alam', diff --git a/app/config/locales/pl.php b/app/config/locales/pl.php index 3c6ae708d4..7fc5875bf8 100644 --- a/app/config/locales/pl.php +++ b/app/config/locales/pl.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Zespół %s', - 'auth.emails.confirm.title' => 'Potwierdzenie konta', - 'auth.emails.confirm.body' => 'en.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Zresetowanie hasła', - 'auth.emails.recovery.body' => 'en.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Zaproszenie do zespołu %s - %s', - 'auth.emails.invitation.body' => 'en.email.auth.invitation.tpl', + 'account.emails.team' => 'Zespół %s', + 'account.emails.verification.title' => 'Potwierdzenie konta', + 'account.emails.verification.body' => 'en.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Zresetowanie hasła', + 'account.emails.recovery.body' => 'en.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Zaproszenie do zespołu %s - %s', + 'account.emails.invitation.body' => 'en.email.auth.invitation.tpl', 'locale.country.unknown' => 'Nieznany', diff --git a/app/config/locales/pn.php b/app/config/locales/pn.php index 907926db61..a53f2ef2b1 100644 --- a/app/config/locales/pn.php +++ b/app/config/locales/pn.php @@ -4,13 +4,13 @@ return [ 'settings.locale' => 'pn', 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s ਟੀਮ(Priyanka)', - 'auth.emails.confirm.title' => 'ਖਾਤਾ ਪੁਸ਼ਟੀਕਰਣ', - 'auth.emails.confirm.body' => 'app/config/locales/templates/pn.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'ਪਾਸਵਰਡ ਰੀਸੈੱਟ', - 'auth.emails.recovery.body' => 'app/config/locales/templates/pn.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => '% S ਟੀਮ% s ਤੇ ਸੱਦਾ', - 'auth.emails.invitation.body' => 'app/config/locales/templates/pn.email.auth.invitation.tpl', + 'account.emails.team' => '%s ਟੀਮ(Priyanka)', + 'account.emails.verification.title' => 'ਖਾਤਾ ਪੁਸ਼ਟੀਕਰਣ', + 'account.emails.verification.body' => 'app/config/locales/templates/pn.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'ਪਾਸਵਰਡ ਰੀਸੈੱਟ', + 'account.emails.recovery.body' => 'app/config/locales/templates/pn.email.auth.recovery.tpl', + 'account.emails.invitation.title' => '% S ਟੀਮ% s ਤੇ ਸੱਦਾ', + 'account.emails.invitation.body' => 'app/config/locales/templates/pn.email.auth.invitation.tpl', 'locale.country.unknown' => 'India', 'countries' => include 'pn.countries.php', 'continents' => include 'pn.continents.php', diff --git a/app/config/locales/pt-br.php b/app/config/locales/pt-br.php index 5fcd96fae0..7a97be1454 100644 --- a/app/config/locales/pt-br.php +++ b/app/config/locales/pt-br.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Time %s', - 'auth.emails.confirm.title' => 'Confirmação de Conta', - 'auth.emails.confirm.body' => 'pt-br.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Redefinição de Senha', - 'auth.emails.recovery.body' => 'pt-br.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Convite para a Equipe %s em %s', - 'auth.emails.invitation.body' => 'pt-br.email.auth.invitation.tpl', + 'account.emails.team' => 'Time %s', + 'account.emails.verification.title' => 'Confirmação de Conta', + 'account.emails.verification.body' => 'pt-br.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Redefinição de Senha', + 'account.emails.recovery.body' => 'pt-br.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Convite para a Equipe %s em %s', + 'account.emails.invitation.body' => 'pt-br.email.auth.invitation.tpl', 'locale.country.unknown' => 'Desconhecido', diff --git a/app/config/locales/pt-pt.php b/app/config/locales/pt-pt.php index 4bdfe64af4..59358cd257 100644 --- a/app/config/locales/pt-pt.php +++ b/app/config/locales/pt-pt.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Equipa %s', - 'auth.emails.confirm.title' => 'Confirmação de Conta', - 'auth.emails.confirm.body' => 'pt-pt.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Repor palavra-passe', - 'auth.emails.recovery.body' => 'pt-pt.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Convite para a Equipa %s em %s', - 'auth.emails.invitation.body' => 'pt-pt.email.auth.invitation.tpl', + 'account.emails.team' => 'Equipa %s', + 'account.emails.verification.title' => 'Confirmação de Conta', + 'account.emails.verification.body' => 'pt-pt.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Repor palavra-passe', + 'account.emails.recovery.body' => 'pt-pt.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Convite para a Equipa %s em %s', + 'account.emails.invitation.body' => 'pt-pt.email.auth.invitation.tpl', 'locale.country.unknown' => 'Desconhecido', diff --git a/app/config/locales/ro.php b/app/config/locales/ro.php index c1669e6d27..36bb85fcda 100644 --- a/app/config/locales/ro.php +++ b/app/config/locales/ro.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Echipa', - 'auth.emails.confirm.title' => 'Confirmă Contul', - 'auth.emails.confirm.body' => 'ro.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Resetează Parola', - 'auth.emails.recovery.body' => 'ro.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Invitație în Echipa %s la %s', - 'auth.emails.invitation.body' => 'ro.email.auth.invitation.tpl', + 'account.emails.team' => '%s Echipa', + 'account.emails.verification.title' => 'Confirmă Contul', + 'account.emails.verification.body' => 'ro.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Resetează Parola', + 'account.emails.recovery.body' => 'ro.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Invitație în Echipa %s la %s', + 'account.emails.invitation.body' => 'ro.email.auth.invitation.tpl', 'locale.country.unknown' => 'Necunoscut', diff --git a/app/config/locales/ru.php b/app/config/locales/ru.php index 49cd3f19e0..0d3afdc337 100644 --- a/app/config/locales/ru.php +++ b/app/config/locales/ru.php @@ -5,13 +5,13 @@ return [ 'settings.locale' => 'ru', 'settings.direction' => 'ltr', - 'auth.emails.team' => 'Команда %s', - 'auth.emails.confirm.title' => 'Подтверждение аккаунта', - 'auth.emails.confirm.body' => 'ru.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Сброс пароля', - 'auth.emails.recovery.body' => 'ru.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Приглашение в команду %s по проекту %s', - 'auth.emails.invitation.body' => 'ru.email.auth.invitation.tpl', + 'account.emails.team' => 'Команда %s', + 'account.emails.verification.title' => 'Подтверждение аккаунта', + 'account.emails.verification.body' => 'ru.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Сброс пароля', + 'account.emails.recovery.body' => 'ru.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Приглашение в команду %s по проекту %s', + 'account.emails.invitation.body' => 'ru.email.auth.invitation.tpl', 'locale.country.unknown' => 'Неизвестно', diff --git a/app/config/locales/si.php b/app/config/locales/si.php index bf09272469..8d6370c0c6 100644 --- a/app/config/locales/si.php +++ b/app/config/locales/si.php @@ -4,14 +4,14 @@ return [ 'settings.locale' => 'si', 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s කණ්ඩායම', - 'auth.emails.confirm.title' => 'ගිණුම් තහවුරු කිරීම', - 'auth.emails.confirm.body' => 'si.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'මුරපදය යළි පිහිටුවන්න', - 'auth.emails.recovery.body' => 'si.email.auth.recovery.tpl', + 'account.emails.team' => '%s කණ්ඩායම', + 'account.emails.verification.title' => 'ගිණුම් තහවුරු කිරීම', + 'account.emails.verification.body' => 'si.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'මුරපදය යළි පිහිටුවන්න', + 'account.emails.recovery.body' => 'si.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'ආරාධනයයි , %s කණ්ඩායමට %s ව්‍යාපෘතියෙහි', - 'auth.emails.invitation.body' => 'si.email.auth.invitation.tpl', + 'account.emails.invitation.title' => 'ආරාධනයයි , %s කණ්ඩායමට %s ව්‍යාපෘතියෙහි', + 'account.emails.invitation.body' => 'si.email.auth.invitation.tpl', 'locale.country.unknown' => 'Unknown', 'countries' => include 'si.countries.php', 'continents' => include 'si.continents.php', diff --git a/app/config/locales/sl.php b/app/config/locales/sl.php index 4098628c29..52830cbc1f 100644 --- a/app/config/locales/sl.php +++ b/app/config/locales/sl.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Ekipa', - 'auth.emails.confirm.title' => 'Potrditev računa', - 'auth.emails.confirm.body' => 'sl.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Ponastavitev gesla', - 'auth.emails.recovery.body' => 'sl.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Povabilo v %s Ekipo za %s', - 'auth.emails.invitation.body' => 'sl.email.auth.invitation.tpl', + 'account.emails.team' => '%s Ekipa', + 'account.emails.verification.title' => 'Potrditev računa', + 'account.emails.verification.body' => 'sl.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Ponastavitev gesla', + 'account.emails.recovery.body' => 'sl.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Povabilo v %s Ekipo za %s', + 'account.emails.invitation.body' => 'sl.email.auth.invitation.tpl', 'locale.country.unknown' => 'Neznano', diff --git a/app/config/locales/sq.php b/app/config/locales/sq.php index 235d2d6d98..2e0ad423cf 100644 --- a/app/config/locales/sq.php +++ b/app/config/locales/sq.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => 'Grup %s', - 'auth.emails.confirm.title' => 'Konfirmimi i llogarisë', - 'auth.emails.confirm.body' => 'sq.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Rivendosni fjalëkalimin', - 'auth.emails.recovery.body' => 'sq.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Ftesë në grup %s në %s', - 'auth.emails.invitation.body' => 'sq.email.auth.invitation.tpl', + 'account.emails.team' => 'Grup %s', + 'account.emails.verification.title' => 'Konfirmimi i llogarisë', + 'account.emails.verification.body' => 'sq.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Rivendosni fjalëkalimin', + 'account.emails.recovery.body' => 'sq.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Ftesë në grup %s në %s', + 'account.emails.invitation.body' => 'sq.email.auth.invitation.tpl', 'locale.country.unknown' => 'I panjohur', diff --git a/app/config/locales/sv.php b/app/config/locales/sv.php index 7101fc0629..9212e2f69b 100644 --- a/app/config/locales/sv.php +++ b/app/config/locales/sv.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s-teamet', - 'auth.emails.confirm.title' => 'Kontobekräftelse', - 'auth.emails.confirm.body' => 'sv.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Ändra lösenord', - 'auth.emails.recovery.body' => 'sv.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Inbjudan till %s-teamet i %s', - 'auth.emails.invitation.body' => 'sv.email.auth.invitation.tpl', + 'account.emails.team' => '%s-teamet', + 'account.emails.verification.title' => 'Kontobekräftelse', + 'account.emails.verification.body' => 'sv.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Ändra lösenord', + 'account.emails.recovery.body' => 'sv.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Inbjudan till %s-teamet i %s', + 'account.emails.invitation.body' => 'sv.email.auth.invitation.tpl', 'locale.country.unknown' => 'Okänt', diff --git a/app/config/locales/ta.php b/app/config/locales/ta.php index d5b08bca6a..ce984463c0 100644 --- a/app/config/locales/ta.php +++ b/app/config/locales/ta.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s குழு', - 'auth.emails.confirm.title' => 'கணக்கினை உறுதி செய்தல்', - 'auth.emails.confirm.body' => 'ta.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'கடவுச்சொல் மீட்டமைப்பு', - 'auth.emails.recovery.body' => 'ta.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => '%s குழுவின் அழைப்பு: %s', - 'auth.emails.invitation.body' => 'ta.email.auth.invitation.tpl', + 'account.emails.team' => '%s குழு', + 'account.emails.verification.title' => 'கணக்கினை உறுதி செய்தல்', + 'account.emails.verification.body' => 'ta.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'கடவுச்சொல் மீட்டமைப்பு', + 'account.emails.recovery.body' => 'ta.email.auth.recovery.tpl', + 'account.emails.invitation.title' => '%s குழுவின் அழைப்பு: %s', + 'account.emails.invitation.body' => 'ta.email.auth.invitation.tpl', 'locale.country.unknown' => 'அறியவில்லை', diff --git a/app/config/locales/templates/en.email.auth.recovery.tpl b/app/config/locales/templates/en.email.auth.recovery.tpl index 7a6fa2fa60..82b365546a 100644 --- a/app/config/locales/templates/en.email.auth.recovery.tpl +++ b/app/config/locales/templates/en.email.auth.recovery.tpl @@ -15,7 +15,7 @@ {{redirect}}

- If you didn’t ask to reset your password, you can ignore this message. + If you didn't ask to reset your password, you can ignore this message.

Thanks, diff --git a/app/config/locales/th.php b/app/config/locales/th.php index 841d97496f..95996668da 100644 --- a/app/config/locales/th.php +++ b/app/config/locales/th.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s ทีม', - 'auth.emails.confirm.title' => 'ยืนยันบัญชี', - 'auth.emails.confirm.body' => 'th.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'รีเซ็ตรหัสผ่าน', - 'auth.emails.recovery.body' => 'th.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'ขอเชิญเข้าร่วม %s ทีมที่ %s', - 'auth.emails.invitation.body' => 'th.email.auth.invitation.tpl', + 'account.emails.team' => '%s ทีม', + 'account.emails.verification.title' => 'ยืนยันบัญชี', + 'account.emails.verification.body' => 'th.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'รีเซ็ตรหัสผ่าน', + 'account.emails.recovery.body' => 'th.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'ขอเชิญเข้าร่วม %s ทีมที่ %s', + 'account.emails.invitation.body' => 'th.email.auth.invitation.tpl', 'locale.country.unknown' => 'ไม่ทราบ', diff --git a/app/config/locales/tr.php b/app/config/locales/tr.php index 2a25ee80e5..511ac45dfa 100644 --- a/app/config/locales/tr.php +++ b/app/config/locales/tr.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Takımı', - 'auth.emails.confirm.title' => 'Hesap Doğrulama', - 'auth.emails.confirm.body' => 'tr.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Şifre Sıfırlama', - 'auth.emails.recovery.body' => 'tr.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => '%s takımına davet %s', - 'auth.emails.invitation.body' => 'tr.email.auth.invitation.tpl', + 'account.emails.team' => '%s Takımı', + 'account.emails.verification.title' => 'Hesap Doğrulama', + 'account.emails.verification.body' => 'tr.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Şifre Sıfırlama', + 'account.emails.recovery.body' => 'tr.email.auth.recovery.tpl', + 'account.emails.invitation.title' => '%s takımına davet %s', + 'account.emails.invitation.body' => 'tr.email.auth.invitation.tpl', 'locale.country.unknown' => 'Bilinmeyen', diff --git a/app/config/locales/ua.php b/app/config/locales/ua.php index e50f4dae35..f1f251b67f 100644 --- a/app/config/locales/ua.php +++ b/app/config/locales/ua.php @@ -5,13 +5,13 @@ return [ 'settings.locale' => 'ua', 'settings.direction' => 'ltr', - 'auth.emails.team' => '%s Команда', - 'auth.emails.confirm.title' => 'Підтвердження Акаунту' , - 'auth.emails.confirm.body' => 'ua.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Скидання пароля', - 'auth.emails.recovery.body' => 'ua.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Запрошення до %s Команди у %s', - 'auth.emails.invitation.body' => 'ua.email.auth.invitation.tpl', + 'account.emails.team' => '%s Команда', + 'account.emails.verification.title' => 'Підтвердження Акаунту' , + 'account.emails.verification.body' => 'ua.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Скидання пароля', + 'account.emails.recovery.body' => 'ua.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Запрошення до %s Команди у %s', + 'account.emails.invitation.body' => 'ua.email.auth.invitation.tpl', 'locale.country.unknown' => 'Невідомо', diff --git a/app/config/locales/vi.php b/app/config/locales/vi.php index b444b11536..c4f2d0ca75 100644 --- a/app/config/locales/vi.php +++ b/app/config/locales/vi.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s Team', - 'auth.emails.confirm.title' => 'Xác nhận tài khoản', - 'auth.emails.confirm.body' => 'vi.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => 'Đặt lại mật khẩu', - 'auth.emails.recovery.body' => 'vi.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => 'Lời mới vào %s Team ở %s', - 'auth.emails.invitation.body' => 'vi.email.auth.invitation.tpl', + 'account.emails.team' => '%s Team', + 'account.emails.verification.title' => 'Xác nhận tài khoản', + 'account.emails.verification.body' => 'vi.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Đặt lại mật khẩu', + 'account.emails.recovery.body' => 'vi.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Lời mới vào %s Team ở %s', + 'account.emails.invitation.body' => 'vi.email.auth.invitation.tpl', 'locale.country.unknown' => 'Chưa xác định', diff --git a/app/config/locales/zh-cn.php b/app/config/locales/zh-cn.php index 5f56d10df3..145928bcb1 100644 --- a/app/config/locales/zh-cn.php +++ b/app/config/locales/zh-cn.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s 小组', - 'auth.emails.confirm.title' => '账户确认', - 'auth.emails.confirm.body' => 'zh.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => '重设密码', - 'auth.emails.recovery.body' => 'zh.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => '邀请加入%s小组(%s)', // I used brackets to keep the order - 'auth.emails.invitation.body' => 'zh.email.auth.invitation.tpl', + 'account.emails.team' => '%s 小组', + 'account.emails.verification.title' => '账户确认', + 'account.emails.verification.body' => 'zh.email.auth.confirm.tpl', + 'account.emails.recovery.title' => '重设密码', + 'account.emails.recovery.body' => 'zh.email.auth.recovery.tpl', + 'account.emails.invitation.title' => '邀请加入%s小组(%s)', // I used brackets to keep the order + 'account.emails.invitation.body' => 'zh.email.auth.invitation.tpl', 'locale.country.unknown' => '未知', diff --git a/app/config/locales/zh-tw.php b/app/config/locales/zh-tw.php index 6d4d83d461..c77c6245fe 100644 --- a/app/config/locales/zh-tw.php +++ b/app/config/locales/zh-tw.php @@ -6,13 +6,13 @@ return [ 'settings.direction' => 'ltr', // Service - Users - 'auth.emails.team' => '%s 小組', - 'auth.emails.confirm.title' => '賬戶確認', - 'auth.emails.confirm.body' => 'zh-tw.email.auth.confirm.tpl', - 'auth.emails.recovery.title' => '重設密碼', - 'auth.emails.recovery.body' => 'zh.email.auth.recovery.tpl', - 'auth.emails.invitation.title' => '邀請加入%s小組(%s)', - 'auth.emails.invitation.body' => 'zh-tw.email.auth.invitation.tpl', + 'account.emails.team' => '%s 小組', + 'account.emails.verification.title' => '賬戶確認', + 'account.emails.verification.body' => 'zh-tw.email.auth.confirm.tpl', + 'account.emails.recovery.title' => '重設密碼', + 'account.emails.recovery.body' => 'zh.email.auth.recovery.tpl', + 'account.emails.invitation.title' => '邀請加入%s小組(%s)', + 'account.emails.invitation.body' => 'zh-tw.email.auth.invitation.tpl', 'locale.country.unknown' => '未知', 'countries' => include 'zh-tw.countries.php', 'continents' => include 'zh-tw.continents.php', diff --git a/app/config/platforms.php b/app/config/platforms.php index 1c1a2442ee..25a21f2ac7 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -5,135 +5,243 @@ const APP_PLATFORM_IOS = 'ios'; const APP_PLATFORM_ANDROID = 'android'; const APP_PLATFORM_UNITY = 'unity'; const APP_PLATFORM_FLUTTER = 'flutter'; + const APP_PLATFORM_SERVER = 'server'; +const APP_PLATFORM_CLIENT = 'client'; +const APP_PLATFORM_CONSOLE = 'console'; return [ APP_PLATFORM_WEB => [ + 'key' => APP_PLATFORM_WEB, 'name' => 'Web', + 'description' => 'Client libraries for integrating with '.APP_NAME.' to build web-based applications and websites. Read the [getting started for web](/docs/getting-started-for-web) tutorial to start building your first web application.', 'enabled' => true, 'beta' => false, 'languages' => [ [ 'key' => 'javascript', - 'name' => 'JS', - 'repository' => 'https://github.com/appwrite/sdk-for-js', + 'name' => 'JavaScript', + 'version' => '1.0.28', + 'url' => 'https://github.com/appwrite/sdk-for-js', 'enabled' => true, 'beta' => false, + 'family' => APP_PLATFORM_CLIENT, 'prism' => 'javascript', - 'source' => realpath(__DIR__ . '/../sdks/js'), + 'source' => realpath(__DIR__ . '/../sdks/javascript'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-js.git', + 'gitRepoName' => 'sdk-for-js', + 'gitUserName' => 'appwrite', ], [ 'key' => 'typescript', 'name' => 'TypeScript', - 'repository' => '', - 'enabled' => true, - 'beta' => false, + 'url' => '', + 'enabled' => false, + 'beta' => true, + 'family' => APP_PLATFORM_CLIENT, 'prism' => 'typescript', - 'source' => '', + 'source' => false, + 'gitUrl' => 'git@github.com:appwrite/sdk-for-typescript.git', + 'gitRepoName' => 'sdk-for-typescript', + 'gitUserName' => 'appwrite', ], ], ], APP_PLATFORM_IOS => [ + 'key' => APP_PLATFORM_IOS, 'name' => 'iOS', + 'description' => 'Client libraries for integrating with '.APP_NAME.' to build iOS applications. Read the [getting started for iOS](/docs/getting-started-for-ios) tutorial to start building your first iOS application.', 'enabled' => false, 'beta' => false, 'languages' => [ [ 'key' => 'swift', 'name' => 'Swift', - 'repository' => '', + 'url' => '', 'enabled' => false, 'beta' => false, + 'family' => APP_PLATFORM_CLIENT, 'prism' => 'swift', - 'source' => '', + 'source' => false, + 'gitUrl' => 'git@github.com:appwrite/sdk-for-swift.git', + 'gitRepoName' => 'sdk-for-swift', + 'gitUserName' => 'appwrite', ], [ 'key' => 'objective-c', 'name' => 'Objective C', - 'repository' => '', + 'url' => '', 'enabled' => false, 'beta' => false, + 'family' => APP_PLATFORM_CLIENT, 'prism' => '', - 'source' => '', + 'source' => false, + 'gitUrl' => 'git@github.com:appwrite/sdk-for-objective-c.git', + 'gitRepoName' => 'sdk-for-objective-c', + 'gitUserName' => 'appwrite', ], ], ], APP_PLATFORM_ANDROID => [ + 'key' => APP_PLATFORM_ANDROID, 'name' => 'Android', + 'description' => 'Client libraries for integrating with '.APP_NAME.' to build Android applications. Read the [getting started for Android](/docs/getting-started-for-android) tutorial to start building your first Android application.', 'enabled' => false, 'beta' => false, 'languages' => [ [ 'key' => 'kotlin', 'name' => 'Kotlin', - 'repository' => '', + 'url' => '', 'enabled' => false, 'beta' => false, + 'family' => APP_PLATFORM_CLIENT, 'prism' => 'kotlin', 'source' => false, + 'gitUrl' => 'git@github.com:appwrite/sdk-for-kotlin.git', + 'gitRepoName' => 'sdk-for-kotlin', + 'gitUserName' => 'appwrite', ], [ 'key' => 'java', 'name' => 'Java', - 'repository' => '', + 'url' => '', 'enabled' => false, 'beta' => false, + 'family' => APP_PLATFORM_CLIENT, 'prism' => 'java', 'source' => false, + 'gitUrl' => 'git@github.com:appwrite/sdk-for-java.git', + 'gitRepoName' => 'sdk-for-java', + 'gitUserName' => 'appwrite', ], ], ], + APP_PLATFORM_FLUTTER => [ + 'key' => APP_PLATFORM_FLUTTER, + 'name' => 'Flutter', + 'description' => 'Client libraries for integrating with '.APP_NAME.' to build cross-platform Flutter applications. Read the [getting started for Flutter](/docs/getting-started-for-flutter) tutorial to start building your first Flutter application.', + 'enabled' => false, + 'beta' => true, + 'languages' => [ + [ + 'key' => 'dart', + 'name' => 'Dart', + 'version' => '0.0.6', + 'url' => 'https://github.com/appwrite/sdk-for-dart', + 'enabled' => true, + 'beta' => true, + 'family' => APP_PLATFORM_CLIENT, + 'prism' => 'dart', + 'source' => realpath(__DIR__ . '/../sdks/dart'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-dart.git', + 'gitRepoName' => 'sdk-for-dart', + 'gitUserName' => 'appwrite', + ], + ], + ], + + // APP_PLATFORM_CONSOLE => [ + // 'name' => 'Console', + // 'enabled' => false, + // 'beta' => false, + // 'languages' => [ + // [ + // 'key' => 'javascript', + // 'name' => 'JS', + // 'version' => '1.0.0', + // 'url' => 'https://github.com/appwrite/sdk-for-console', + // 'enabled' => true, + // 'beta' => false, + // 'family' => APP_PLATFORM_CONSOLE, + // 'prism' => 'console', + // 'source' => realpath(__DIR__ . '/../sdks/console'), + // 'gitUrl' => 'git@github.com:appwrite/sdk-for-console.git', + // 'gitRepoName' => 'sdk-for-console', + // 'gitUserName' => 'appwrite', + // ], + // ], + // ], + APP_PLATFORM_SERVER => [ + 'key' => APP_PLATFORM_SERVER, 'name' => 'Server', + 'description' => 'Libraries for integrating with '.APP_NAME.' to build server side integrations. Read the [getting started for server](/docs/getting-started-for-server) tutorial to start building your first server integration.', 'enabled' => true, 'beta' => false, 'languages' => [ [ 'key' => 'nodejs', 'name' => 'Node.js', - 'repository' => 'https://github.com/appwrite/sdk-for-node', + 'version' => '1.0.31', + 'url' => 'https://github.com/appwrite/sdk-for-node', 'enabled' => true, 'beta' => false, + 'family' => APP_PLATFORM_SERVER, 'prism' => 'javascript', - 'source' => realpath(__DIR__ . '/../sdks/node'), + 'source' => realpath(__DIR__ . '/../sdks/nodejs'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-node.git', + 'gitRepoName' => 'sdk-for-node', + 'gitUserName' => 'appwrite', ], [ 'key' => 'php', 'name' => 'PHP', - 'repository' => 'https://github.com/appwrite/sdk-for-php', + 'version' => '1.0.16', + 'url' => 'https://github.com/appwrite/sdk-for-php', 'enabled' => true, + 'beta' => false, + 'family' => APP_PLATFORM_SERVER, 'prism' => 'php', 'source' => realpath(__DIR__ . '/../sdks/php'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-php.git', + 'gitRepoName' => 'sdk-for-php', + 'gitUserName' => 'appwrite', ], [ 'key' => 'python', 'name' => 'Python', - 'repository' => 'https://github.com/appwrite/sdk-for-python', + 'version' => '0.0.3', + 'url' => 'https://github.com/appwrite/sdk-for-python', 'enabled' => true, 'beta' => true, + 'family' => APP_PLATFORM_SERVER, 'prism' => 'python', 'source' => realpath(__DIR__ . '/../sdks/python'), - ], - [ - 'key' => 'go', - 'name' => 'Go', - 'repository' => 'https://github.com/appwrite/sdk-for-go', - 'enabled' => true, - 'beta' => true, - 'prism' => 'go', - 'source' => realpath(__DIR__ . '/../sdks/go'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-python.git', + 'gitRepoName' => 'sdk-for-python', + 'gitUserName' => 'appwrite', ], [ 'key' => 'ruby', 'name' => 'Ruby', - 'repository' => 'https://github.com/appwrite/sdk-for-ruby', + 'version' => '1.0.8', + 'url' => 'https://github.com/appwrite/sdk-for-ruby', 'enabled' => true, 'beta' => true, + 'family' => APP_PLATFORM_SERVER, 'prism' => 'ruby', 'source' => realpath(__DIR__ . '/../sdks/ruby'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-ruby.git', + 'gitRepoName' => 'sdk-for-ruby', + 'gitUserName' => 'appwrite', + ], + [ + 'key' => 'go', + 'name' => 'Go', + 'version' => '0.0.5', + 'url' => 'https://github.com/appwrite/sdk-for-go', + 'enabled' => true, + 'beta' => true, + 'family' => APP_PLATFORM_SERVER, + 'prism' => 'go', + 'source' => realpath(__DIR__ . '/../sdks/go'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-go.git', + 'gitRepoName' => 'sdk-for-go', + 'gitUserName' => 'appwrite', ], ], ], diff --git a/app/config/roles.php b/app/config/roles.php index 81d3437840..e690783172 100644 --- a/app/config/roles.php +++ b/app/config/roles.php @@ -13,7 +13,6 @@ $logged = [ 'public', 'home', 'console', - 'auth', 'account', 'teams.read', 'teams.write', @@ -29,10 +28,27 @@ $logged = [ ]; $admins = [ + 'teams.read', + 'teams.write', + 'documents.read', + 'documents.write', + 'files.read', + 'files.write', 'users.read', 'users.write', 'collections.read', 'collections.write', + 'platforms.read', + 'platforms.write', + 'keys.read', + 'keys.write', + 'tasks.read', + 'tasks.write', + 'webhooks.read', + 'webhooks.write', + 'locale.read', + 'avatars.read', + 'health.read', ]; return [ @@ -42,7 +58,6 @@ return [ 'public', 'home', 'console', - 'auth', 'files.read', 'locale.read', 'avatars.read', @@ -55,11 +70,11 @@ return [ ], ROLE_ADMIN => [ 'label' => 'Admin', - 'scopes' => array_merge($logged, $admins, []), + 'scopes' => array_merge($admins, []), ], ROLE_DEVELOPER => [ 'label' => 'Developer', - 'scopes' => array_merge($logged, $admins, []), + 'scopes' => array_merge($admins, []), ], ROLE_OWNER => [ 'label' => 'Owner', @@ -67,6 +82,6 @@ return [ ], ROLE_APP => [ 'label' => 'Application', - 'scopes' => ['public'], + 'scopes' => ['health.read'], ], ]; diff --git a/app/config/scopes.php b/app/config/scopes.php new file mode 100644 index 0000000000..53b71dd78f --- /dev/null +++ b/app/config/scopes.php @@ -0,0 +1,24 @@ + 'JS', - 'versions' => ['v1.0.0'], - 'logo' => 'js.svg', - 'link' => 'https://github.com/appwrite/sdk-for-js', - ], - [ - 'label' => 'Node.js', - 'versions' => ['v1.0.0'], - 'logo' => 'nodejs.svg', - 'link' => 'https://github.com/appwrite/sdk-for-node', - ], - [ - 'label' => 'Ruby', - 'versions' => ['v1.0.0'], - 'logo' => 'ruby.svg', - 'link' => 'https://github.com/appwrite/sdk-for-ruby', - ], - [ - 'label' => 'Python', - 'versions' => ['v1.0.0'], - 'logo' => 'python.svg', - 'link' => 'https://github.com/appwrite/sdk-for-python', - ], - [ - 'label' => 'PHP', - 'versions' => ['v1.0.0'], - 'logo' => 'php.svg', - 'link' => 'https://github.com/appwrite/sdk-for-php', - ], - [ - 'label' => 'Go', - 'versions' => [], - 'logo' => 'go.svg', - 'link' => 'https://...', - 'tag' => 'Soon', - ], - [ - 'label' => 'Scala', - 'versions' => [], - 'logo' => 'scala.svg', - 'link' => 'https://...', - 'tag' => 'Soon', - ], - [ - 'label' => 'Swift', - 'versions' => [], - 'logo' => 'swift.svg', - 'link' => 'https://...', - 'tag' => 'Soon', - ], - [ - 'label' => 'C', - 'versions' => [], - 'logo' => 'c.svg', - 'link' => 'https://...', - 'tag' => 'Soon', - ], - [ - 'label' => 'C#', - 'versions' => [], - 'logo' => 'csharp.svg', - 'link' => 'https://...', - 'tag' => 'Soon', - ], - [ - 'label' => 'Erlang', - 'versions' => [], - 'logo' => 'erlang.svg', - 'link' => 'https://...', - 'tag' => 'Soon', - ], - [ - 'label' => 'Kotlin', - 'versions' => [], - 'logo' => 'kotlin.svg', - 'link' => 'https://...', - 'tag' => 'Soon', - ], - [ - 'label' => 'Java', - 'versions' => [], - 'logo' => 'java.svg', - 'link' => 'https://...', - 'tag' => 'Soon', - ], -]; diff --git a/app/config/services.php b/app/config/services.php index 0e4a3385c3..be0679153f 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -3,81 +3,74 @@ return [ '/' => [ 'name' => 'Homepage', - 'controller' => 'controllers/home.php', + 'controller' => 'controllers/web/home.php', 'sdk' => false, 'tests' => false, ], 'console/' => [ 'name' => 'Console', - 'controller' => 'controllers/console.php', + 'controller' => 'controllers/web/console.php', 'sdk' => false, 'tests' => false, ], 'v1/account' => [ 'name' => 'Account', 'description' => '/docs/services/account.md', - 'controller' => 'controllers/account.php', - 'sdk' => true, - 'tests' => false, - ], - 'v1/auth' => [ // Add to docs later: You can also learn how to [configure support for our supported OAuth providers](/docs/oauth) - 'name' => 'Auth', - 'description' => '/docs/services/auth.md', - 'controller' => 'controllers/auth.php', + 'controller' => 'controllers/api/account.php', 'sdk' => true, 'tests' => false, ], 'v1/avatars' => [ 'name' => 'Avatars', 'description' => '/docs/services/avatars.md', - 'controller' => 'controllers/avatars.php', + 'controller' => 'controllers/api/avatars.php', 'sdk' => true, 'tests' => false, ], 'v1/database' => [ 'name' => 'Database', 'description' => '/docs/services/database.md', - 'controller' => 'controllers/database.php', + 'controller' => 'controllers/api/database.php', 'sdk' => true, 'tests' => false, ], 'v1/locale' => [ 'name' => 'Locale', 'description' => '/docs/services/locale.md', - 'controller' => 'controllers/locale.php', + 'controller' => 'controllers/api/locale.php', 'sdk' => true, 'tests' => false, ], 'v1/health' => [ 'name' => 'Health', - 'controller' => 'controllers/health.php', + 'controller' => 'controllers/api/health.php', 'sdk' => false, 'tests' => false, ], 'v1/projects' => [ 'name' => 'Projects', - 'controller' => 'controllers/projects.php', + 'controller' => 'controllers/api/projects.php', 'sdk' => true, 'tests' => false, ], 'v1/storage' => [ 'name' => 'Storage', 'description' => '/docs/services/storage.md', - 'controller' => 'controllers/storage.php', + 'controller' => 'controllers/api/storage.php', 'sdk' => true, 'tests' => false, ], 'v1/teams' => [ 'name' => 'Teams', 'description' => '/docs/services/teams.md', - 'controller' => 'controllers/teams.php', + 'controller' => 'controllers/api/teams.php', 'sdk' => true, 'tests' => false, ], 'v1/users' => [ 'name' => 'Users', 'description' => '/docs/services/users.md', - 'controller' => 'controllers/users.php', + 'controller' => 'controllers/api/users.php', 'sdk' => true, 'tests' => false, ], @@ -88,4 +81,11 @@ return [ 'sdk' => false, 'tests' => true, ], + 'v1/graphql' => [ + 'name' => 'GraphQL', + 'description' => 'GraphQL Endpoint', + 'controller' => 'controllers/api/graphql.php', + 'sdk' => false, + 'tests' => false, + ], ]; diff --git a/app/controllers/account.php b/app/controllers/account.php deleted file mode 100644 index c1a0ff0f5f..0000000000 --- a/app/controllers/account.php +++ /dev/null @@ -1,357 +0,0 @@ -get('/v1/account') - ->desc('Get Account') - ->label('scope', 'account') - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'get') - ->label('sdk.description', '/docs/references/account/get.md') - ->action( - function () use ($response, &$user, $providers) { - $oauthKeys = []; - - foreach ($providers as $key => $provider) { - if (!$provider['enabled']) { - continue; - } - - $oauthKeys[] = 'oauth'.ucfirst($key); - $oauthKeys[] = 'oauth'.ucfirst($key).'AccessToken'; - } - - $response->json(array_merge($user->getArrayCopy(array_merge( - [ - '$uid', - 'email', - 'registration', - 'confirm', - 'name', - ], - $oauthKeys - )), ['roles' => Authorization::getRoles()])); - } - ); - -$utopia->get('/v1/account/prefs') - ->desc('Get Account Preferences') - ->label('scope', 'account') - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'getPrefs') - ->label('sdk.description', '/docs/references/account/get-prefs.md') - ->action( - function () use ($response, $user) { - $prefs = $user->getAttribute('prefs', '{}'); - - try { - $prefs = json_decode($prefs, true); - $prefs = ($prefs) ? $prefs : []; - } catch (\Exception $error) { - throw new Exception('Failed to parse prefs', 500); - } - - $response->json($prefs); - } - ); - -$utopia->get('/v1/account/sessions') - ->desc('Get Account Active Sessions') - ->label('scope', 'account') - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'getSessions') - ->label('sdk.description', '/docs/references/account/get-sessions.md') - ->action( - function () use ($response, $user) { - $tokens = $user->getAttribute('tokens', []); - $reader = new Reader(__DIR__.'/../db/DBIP/dbip-country-lite-2020-01.mmdb'); - $sessions = []; - $current = Auth::tokenVerify($tokens, Auth::TOKEN_TYPE_LOGIN, Auth::$secret); - $index = 0; - $countries = Locale::getText('countries'); - - foreach ($tokens as $token) { /* @var $token Document */ - if (Auth::TOKEN_TYPE_LOGIN != $token->getAttribute('type')) { - continue; - } - - $userAgent = (!empty($token->getAttribute('userAgent'))) ? $token->getAttribute('userAgent') : 'UNKNOWN'; - - $dd = new DeviceDetector($userAgent); - - // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) - // $dd->skipBotDetection(); - - $dd->parse(); - - $sessions[$index] = [ - 'id' => $token->getUid(), - 'OS' => $dd->getOs(), - 'client' => $dd->getClient(), - 'device' => $dd->getDevice(), - 'brand' => $dd->getBrand(), - 'model' => $dd->getModel(), - 'ip' => $token->getAttribute('ip', ''), - 'geo' => [], - 'current' => ($current == $token->getUid()) ? true : false, - ]; - - try { - $record = $reader->country($token->getAttribute('ip', '')); - $sessions[$index]['geo']['isoCode'] = strtolower($record->country->isoCode); - $sessions[$index]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); - } catch (\Exception $e) { - $sessions[$index]['geo']['isoCode'] = '--'; - $sessions[$index]['geo']['country'] = Locale::getText('locale.country.unknown'); - } - - ++$index; - } - - $response->json($sessions); - } - ); - -$utopia->get('/v1/account/security') - ->desc('Get Account Security Log') - ->label('scope', 'account') - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'getSecurity') - ->label('sdk.description', '/docs/references/account/get-security.md') - ->action( - function () use ($response, $register, $project, $user) { - $adapter = new AuditAdapter($register->get('db')); - $adapter->setNamespace('app_'.$project->getUid()); - $audit = new Audit($adapter); - $countries = Locale::getText('countries'); - - $logs = $audit->getLogsByUserAndActions($user->getUid(), [ - 'auth.register', - 'auth.confirm', - 'auth.login', - 'auth.logout', - 'auth.recovery', - 'auth.recovery.reset', - 'auth.oauth.login', - 'auth.invite', - 'auth.join', - 'auth.leave', - 'account.delete', - 'account.update.name', - 'account.update.email', - 'account.update.password', - ]); - - $reader = new Reader(__DIR__.'/../db/DBIP/dbip-country-lite-2020-01.mmdb'); - $output = []; - - foreach ($logs as $i => &$log) { - $log['userAgent'] = (!empty($log['userAgent'])) ? $log['userAgent'] : 'UNKNOWN'; - - $dd = new DeviceDetector($log['userAgent']); - - $dd->skipBotDetection(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) - - $dd->parse(); - - $output[$i] = [ - 'event' => $log['event'], - 'ip' => $log['ip'], - 'time' => strtotime($log['time']), - 'OS' => $dd->getOs(), - 'client' => $dd->getClient(), - 'device' => $dd->getDevice(), - 'brand' => $dd->getBrand(), - 'model' => $dd->getModel(), - 'geo' => [], - ]; - - try { - $record = $reader->country('79.176.229.216'); - $output[$i]['geo']['isoCode'] = strtolower($record->country->isoCode); - $output[$i]['geo']['country'] = $record->country->name; - $output[$i]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); - } catch (\Exception $e) { - $output[$i]['geo']['isoCode'] = '--'; - $output[$i]['geo']['country'] = Locale::getText('locale.country.unknown'); - } - } - - $response->json($output); - } - ); - -$utopia->patch('/v1/account/name') - ->desc('Update Account Name') - ->label('webhook', 'account.update-name') - ->label('scope', 'account') - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'updateName') - ->label('sdk.description', '/docs/references/account/update-name.md') - ->param('name', '', function () { return new Text(100); }, 'User name') - ->action( - function ($name) use ($response, $user, $projectDB, $audit) { - $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ - 'name' => $name, - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $audit->setParam('event', 'account.update.name'); - - $response->json(array('result' => 'success')); - } - ); - -$utopia->patch('/v1/account/password') - ->desc('Update Account Password') - ->label('webhook', 'account.update-password') - ->label('scope', 'account') - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'updatePassword') - ->label('sdk.description', '/docs/references/account/update-password.md') - ->param('password', '', function () { return new Password(); }, 'New password') - ->param('old-password', '', function () { return new Password(); }, 'Old password') - ->action( - function ($password, $oldPassword) use ($response, $user, $projectDB, $audit) { - if (!Auth::passwordVerify($oldPassword, $user->getAttribute('password'))) { // Double check user password - throw new Exception('Invalid credentials', 401); - } - - $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ - 'password' => Auth::passwordHash($password), - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $audit->setParam('event', 'account.update.password'); - - $response->json(array('result' => 'success')); - } - ); - -$utopia->patch('/v1/account/email') - ->desc('Update Account Email') - ->label('webhook', 'account.update-email') - ->label('scope', 'account') - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'updateEmail') - ->label('sdk.description', '/docs/references/account/update-email.md') - ->param('email', '', function () { return new Email(); }, 'Email Address') - ->param('password', '', function () { return new Password(); }, 'User Password') - ->action( - function ($email, $password) use ($response, $user, $projectDB, $audit) { - if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password - throw new Exception('Invalid credentials', 401); - } - - $profile = $projectDB->getCollection([ // Get user by email address - 'limit' => 1, - 'first' => true, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); - - if (!empty($profile)) { - throw new Exception('User already registered', 400); - } - - // TODO after this user needs to confirm mail again - - $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ - 'email' => $email, - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $audit->setParam('event', 'account.update.email'); - - $response->json(array('result' => 'success')); - } - ); - -$utopia->patch('/v1/account/prefs') - ->desc('Update Account Prefs') - ->label('webhook', 'account') - ->label('scope', 'account') - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'updatePrefs') - ->param('prefs', '', function () { return new Assoc();}, 'Prefs key-value JSON object.') - ->label('sdk.description', '/docs/references/account/update-prefs.md') - ->action( - function ($prefs) use ($response, $user, $projectDB, $audit) { - $old = json_decode($user->getAttribute('prefs', '{}'), true); - $old = ($old) ? $old : []; - $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ - 'prefs' => json_encode(array_merge($old, $prefs)), - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $audit->setParam('event', 'account.update.prefs'); - - $response->json(array('result' => 'success')); - } - ); - -$utopia->delete('/v1/account') - ->desc('Delete Account') - ->label('webhook', 'account.delete') - ->label('scope', 'account') - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'delete') - ->label('sdk.description', '/docs/references/account/delete.md') - ->action( - function () use ($response, $request, $user, $projectDB, $audit) { - $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ - 'status' => Auth::USER_STATUS_BLOCKED, - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - //TODO delete all tokens or only current session? - //TODO delete all user data according to GDPR. Make sure everything is backed up and backups are deleted later - /* - * Data to delete - * * Tokens - * * Memberships - */ - - $audit - ->setParam('event', 'account.delete') - ->setParam('data', $user->getArrayCopy()) - ; - - $response - ->addCookie(Auth::$cookieName, '', time() - 3600, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE) - ->json(array('result' => 'success')); - } - ); diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php new file mode 100644 index 0000000000..19d3d9fff3 --- /dev/null +++ b/app/controllers/api/account.php @@ -0,0 +1,1248 @@ +init(function() use ($providers, &$oauth2Keys) { + foreach ($providers as $key => $provider) { + if (!$provider['enabled']) { + continue; + } + + $oauth2Keys[] = 'oauth2'.ucfirst($key); + $oauth2Keys[] = 'oauth2'.ucfirst($key).'AccessToken'; + } + +}); + +$utopia->post('/v1/account') + ->desc('Create Account') + ->label('webhook', 'account.create') + ->label('scope', 'public') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'create') + ->label('sdk.description', '/docs/references/account/create.md') + ->label('abuse-limit', 10) + ->param('email', '', function () { return new Email(); }, 'User email.') + ->param('password', '', function () { return new Password(); }, 'User password.') + ->param('name', '', function () { return new Text(100); }, 'User name.', true) + ->action( + function ($email, $password, $name) use ($register, $request, $response, $audit, $projectDB, $project, $webhook, $oauth2Keys) { + if ('console' === $project->getId()) { + $whitlistEmails = $project->getAttribute('authWhitelistEmails'); + $whitlistIPs = $project->getAttribute('authWhitelistIPs'); + $whitlistDomains = $project->getAttribute('authWhitelistDomains'); + + if (!empty($whitlistEmails) && !in_array($email, $whitlistEmails)) { + throw new Exception('Console registration is restricted to specific emails. Contact your administrator for more information.', 401); + } + + if (!empty($whitlistIPs) && !in_array($request->getIP(), $whitlistIPs)) { + throw new Exception('Console registration is restricted to specific IPs. Contact your administrator for more information.', 401); + } + + if (!empty($whitlistDomains) && !in_array(substr(strrchr($email, '@'), 1), $whitlistDomains)) { + throw new Exception('Console registration is restricted to specific domains. Contact your administrator for more information.', 401); + } + } + + $profile = $projectDB->getCollection([ // Get user by email address + 'limit' => 1, + 'first' => true, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); + + if (!empty($profile)) { + throw new Exception('Account already exists', 409); + } + + Authorization::disable(); + + $user = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_USERS, + '$permissions' => [ + 'read' => ['*'], + 'write' => ['user:{self}'], + ], + 'email' => $email, + 'emailVerification' => false, + 'status' => Auth::USER_STATUS_UNACTIVATED, + 'password' => Auth::passwordHash($password), + 'password-update' => time(), + 'registration' => time(), + 'reset' => false, + 'name' => $name, + ]); + + Authorization::enable(); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $webhook + ->setParam('payload', [ + 'name' => $name, + 'email' => $email, + ]) + ; + + $audit + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.create') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->json(array_merge($user->getArrayCopy(array_merge( + [ + '$id', + 'email', + 'registration', + 'name', + ], + $oauth2Keys + )), ['roles' => Authorization::getRoles()])); + } + ); + +$utopia->post('/v1/account/sessions') + ->desc('Create Account Session') + ->label('webhook', 'account.sessions.create') + ->label('scope', 'public') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'createSession') + ->label('sdk.description', '/docs/references/account/create-session.md') + ->label('abuse-limit', 10) + ->label('abuse-key', 'url:{url},email:{param-email}') + ->param('email', '', function () { return new Email(); }, 'User email.') + ->param('password', '', function () { return new Password(); }, 'User password.') + ->action( + function ($email, $password) use ($response, $request, $projectDB, $audit, $webhook) { + $profile = $projectDB->getCollection([ // Get user by email address + 'limit' => 1, + 'first' => true, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); + + if (false == $profile || !Auth::passwordVerify($password, $profile->getAttribute('password'))) { + $audit + //->setParam('userId', $profile->getId()) + ->setParam('event', 'account.sesssions.failed') + ->setParam('resource', 'users/'.($profile ? $profile->getId() : '')) + ; + + throw new Exception('Invalid credentials', 401); // Wrong password or username + } + + $expiry = time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; + $secret = Auth::tokenGenerator(); + $session = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['user:'.$profile->getId()], 'write' => ['user:'.$profile->getId()]], + 'type' => Auth::TOKEN_TYPE_LOGIN, + 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak + 'expire' => $expiry, + 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), + 'ip' => $request->getIP(), + ]); + + Authorization::setRole('user:'.$profile->getId()); + + $session = $projectDB->createDocument($session->getArrayCopy()); + + if (false === $session) { + throw new Exception('Failed saving session to DB', 500); + } + + $profile->setAttribute('tokens', $session, Document::SET_TYPE_APPEND); + + $profile = $projectDB->updateDocument($profile->getArrayCopy()); + + if (false === $profile) { + throw new Exception('Failed saving user to DB', 500); + } + + $webhook + ->setParam('payload', [ + 'name' => $profile->getAttribute('name', ''), + 'email' => $profile->getAttribute('email', ''), + ]) + ; + + $audit + ->setParam('userId', $profile->getId()) + ->setParam('event', 'account.sessions.create') + ->setParam('resource', 'users/'.$profile->getId()) + ; + + $response + ->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($profile->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null) + ->addCookie(Auth::$cookieName, Auth::encodeSession($profile->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE) + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->json($session->getArrayCopy(['$id', 'type', 'expire'])) + ; + } + ); + +$utopia->get('/v1/account/sessions/oauth2/:provider') + ->desc('Create Account Session with OAuth2') + ->label('error', __DIR__.'/../../views/general/error.phtml') + ->label('scope', 'public') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'createOAuth2Session') + ->label('sdk.description', '/docs/references/account/create-session-oauth2.md') + ->label('sdk.response.code', 301) + ->label('sdk.response.type', 'text/html') + ->label('sdk.location', true) + ->label('abuse-limit', 50) + ->label('abuse-key', 'ip:{ip}') + ->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth2 Provider. Currently, supported providers are: ' . implode(', ', array_keys(array_filter($providers, function($node) {return (!$node['mock']);}))).'.') + ->param('success', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt.') + ->param('failure', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt.') + ->action( + function ($provider, $success, $failure) use ($response, $request, $project) { + $callback = $request->getServer('REQUEST_SCHEME', 'https').'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId(); + $appId = $project->getAttribute('usersOauth2'.ucfirst($provider).'Appid', ''); + $appSecret = $project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}'); + + $appSecret = json_decode($appSecret, true); + + if (!empty($appSecret) && isset($appSecret['version'])) { + $key = $request->getServer('_APP_OPENSSL_KEY_V'.$appSecret['version']); + $appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, hex2bin($appSecret['iv']), hex2bin($appSecret['tag'])); + } + + if (empty($appId) || empty($appSecret)) { + throw new Exception('Provider is undefined, configure provider app ID and app secret key to continue', 412); + } + + $classname = 'Auth\\OAuth2\\'.ucfirst($provider); + + if (!class_exists($classname)) { + throw new Exception('Provider is not supported', 501); + } + + $oauth2 = new $classname($appId, $appSecret, $callback, ['success' => $success, 'failure' => $failure]); + + $response->redirect($oauth2->getLoginURL()); + } + ); + +$utopia->get('/v1/account/sessions/oauth2/callback/:provider/:projectId') + ->desc('OAuth2 Callback') + ->label('error', __DIR__.'/../../views/general/error.phtml') + ->label('scope', 'public') + ->label('docs', false) + ->param('projectId', '', function () { return new Text(1024); }, 'Project unique ID.') + ->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth2 provider.') + ->param('code', '', function () { return new Text(1024); }, 'OAuth2 code.') + ->param('state', '', function () { return new Text(2048); }, 'Login state params.', true) + ->action( + function ($projectId, $provider, $code, $state) use ($response, $request, $domain) { + $response->redirect($request->getServer('REQUEST_SCHEME', 'https').'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?' + .http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state])); + } + ); + +$utopia->get('/v1/account/sessions/oauth2/:provider/redirect') + ->desc('OAuth2 Redirect') + ->label('error', __DIR__.'/../../views/general/error.phtml') + ->label('webhook', 'account.sessions.create') + ->label('scope', 'public') + ->label('abuse-limit', 50) + ->label('abuse-key', 'ip:{ip}') + ->label('docs', false) + ->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth2 provider.') + ->param('code', '', function () { return new Text(1024); }, 'OAuth2 code.') + ->param('state', '', function () { return new Text(2048); }, 'OAuth2 state params.', true) + ->action( + function ($provider, $code, $state) use ($response, $request, $user, $projectDB, $project, $audit) { + $callback = $request->getServer('REQUEST_SCHEME', 'https').'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId(); + $defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => '']; + $validateURL = new URL(); + + $appId = $project->getAttribute('usersOauth2'.ucfirst($provider).'Appid', ''); + $appSecret = $project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}'); + + $appSecret = json_decode($appSecret, true); + + if (!empty($appSecret) && isset($appSecret['version'])) { + $key = $request->getServer('_APP_OPENSSL_KEY_V'.$appSecret['version']); + $appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, hex2bin($appSecret['iv']), hex2bin($appSecret['tag'])); + } + + $classname = 'Auth\\OAuth2\\'.ucfirst($provider); + + if (!class_exists($classname)) { + throw new Exception('Provider is not supported', 501); + } + + $oauth2 = new $classname($appId, $appSecret, $callback); + + if (!empty($state)) { + try { + $state = array_merge($defaultState, $oauth2->parseState($state)); + } catch (\Exception $exception) { + throw new Exception('Failed to parse login state params as passed from OAuth2 provider'); + } + } else { + $state = $defaultState; + } + + if (!$validateURL->isValid($state['success'])) { + throw new Exception('Invalid redirect URL for success login', 400); + } + + if (!empty($state['failure']) && !$validateURL->isValid($state['failure'])) { + throw new Exception('Invalid redirect URL for failure login', 400); + } + $state['failure'] = null; + $accessToken = $oauth2->getAccessToken($code); + + if (empty($accessToken)) { + if (!empty($state['failure'])) { + $response->redirect($state['failure'], 301, 0); + } + + throw new Exception('Failed to obtain access token'); + } + + $oauth2ID = $oauth2->getUserID($accessToken); + + if (empty($oauth2ID)) { + if (!empty($state['failure'])) { + $response->redirect($state['failure'], 301, 0); + } + + throw new Exception('Missing ID from OAuth2 provider', 400); + } + + $current = Auth::tokenVerify($user->getAttribute('tokens', []), Auth::TOKEN_TYPE_LOGIN, Auth::$secret); + + if ($current) { + $projectDB->deleteDocument($current); //throw new Exception('User already logged in', 401); + } + + $user = (empty($user->getId())) ? $projectDB->getCollection([ // Get user by provider id + 'limit' => 1, + 'first' => true, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'oauth2'.ucfirst($provider).'='.$oauth2ID, + ], + ]) : $user; + + if (empty($user)) { // No user logged in or with OAuth2 provider ID, create new one or connect with account with same email + $name = $oauth2->getUserName($accessToken); + $email = $oauth2->getUserEmail($accessToken); + + $user = $projectDB->getCollection([ // Get user by provider email address + 'limit' => 1, + 'first' => true, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); + + if (!$user || empty($user->getId())) { // Last option -> create user alone, generate random password + Authorization::disable(); + + $user = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_USERS, + '$permissions' => ['read' => ['*'], 'write' => ['user:{self}']], + 'email' => $email, + 'emailVerification' => true, + 'status' => Auth::USER_STATUS_ACTIVATED, // Email should already be authenticated by OAuth2 provider + 'password' => Auth::passwordHash(Auth::passwordGenerator()), + 'password-update' => time(), + 'registration' => time(), + 'reset' => false, + 'name' => $name, + ]); + + Authorization::enable(); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + } + } + + // Create session token, verify user account and update OAuth2 ID and Access Token + + $secret = Auth::tokenGenerator(); + $expiry = time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; + $session = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['user:'.$user['$id']], 'write' => ['user:'.$user['$id']]], + 'type' => Auth::TOKEN_TYPE_LOGIN, + 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak + 'expire' => $expiry, + 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), + 'ip' => $request->getIP(), + ]); + + $user + ->setAttribute('oauth2'.ucfirst($provider), $oauth2ID) + ->setAttribute('oauth2'.ucfirst($provider).'AccessToken', $accessToken) + ->setAttribute('status', Auth::USER_STATUS_ACTIVATED) + ->setAttribute('tokens', $session, Document::SET_TYPE_APPEND) + ; + + Authorization::setRole('user:'.$user->getId()); + + $user = $projectDB->updateDocument($user->getArrayCopy()); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audit + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.sessions.create') + ->setParam('resource', 'users/'.$user->getId()) + ->setParam('data', ['provider' => $provider]) + ; + + $response + ->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null) + ->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE) + ->redirect($state['success']) + ; + } + ); + +$utopia->get('/v1/account') + ->desc('Get Account') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'get') + ->label('sdk.description', '/docs/references/account/get.md') + ->label('sdk.response', ['200' => 'user']) + ->action( + function () use ($response, &$user, $oauth2Keys) { + $response->json(array_merge($user->getArrayCopy(array_merge( + [ + '$id', + 'email', + 'registration', + 'name', + ], + $oauth2Keys + )), ['roles' => Authorization::getRoles()])); + } + ); + +$utopia->get('/v1/account/prefs') + ->desc('Get Account Preferences') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'getPrefs') + ->label('sdk.description', '/docs/references/account/get-prefs.md') + ->action( + function () use ($response, $user) { + $prefs = $user->getAttribute('prefs', '{}'); + + try { + $prefs = json_decode($prefs, true); + $prefs = ($prefs) ? $prefs : []; + } catch (\Exception $error) { + throw new Exception('Failed to parse prefs', 500); + } + + $response->json($prefs); + } + ); + +$utopia->get('/v1/account/sessions') + ->desc('Get Account Sessions') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'getSessions') + ->label('sdk.description', '/docs/references/account/get-sessions.md') + ->action( + function () use ($response, $user) { + $tokens = $user->getAttribute('tokens', []); + $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); + $sessions = []; + $current = Auth::tokenVerify($tokens, Auth::TOKEN_TYPE_LOGIN, Auth::$secret); + $index = 0; + $countries = Locale::getText('countries'); + + foreach ($tokens as $token) { /* @var $token Document */ + if (Auth::TOKEN_TYPE_LOGIN != $token->getAttribute('type')) { + continue; + } + + $userAgent = (!empty($token->getAttribute('userAgent'))) ? $token->getAttribute('userAgent') : 'UNKNOWN'; + + $dd = new DeviceDetector($userAgent); + + // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) + // $dd->skipBotDetection(); + + $dd->parse(); + + $sessions[$index] = [ + '$id' => $token->getId(), + 'OS' => $dd->getOs(), + 'client' => $dd->getClient(), + 'device' => $dd->getDevice(), + 'brand' => $dd->getBrand(), + 'model' => $dd->getModel(), + 'ip' => $token->getAttribute('ip', ''), + 'geo' => [], + 'current' => ($current == $token->getId()) ? true : false, + ]; + + try { + $record = $reader->country($token->getAttribute('ip', '')); + $sessions[$index]['geo']['isoCode'] = strtolower($record->country->isoCode); + $sessions[$index]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); + } catch (\Exception $e) { + $sessions[$index]['geo']['isoCode'] = '--'; + $sessions[$index]['geo']['country'] = Locale::getText('locale.country.unknown'); + } + + ++$index; + } + + $response->json($sessions); + } + ); + +$utopia->get('/v1/account/logs') + ->desc('Get Account Logs') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'getLogs') + ->label('sdk.description', '/docs/references/account/get-logs.md') + ->action( + function () use ($response, $register, $project, $user) { + $adapter = new AuditAdapter($register->get('db')); + $adapter->setNamespace('app_'.$project->getId()); + + $audit = new Audit($adapter); + $countries = Locale::getText('countries'); + + $logs = $audit->getLogsByUserAndActions($user->getId(), [ + 'account.create', + 'account.delete', + 'account.update.name', + 'account.update.email', + 'account.update.password', + 'account.update.prefs', + 'account.sessions.create', + 'account.sessions.delete', + 'account.recovery.create', + 'account.recovery.update', + 'account.verification.create', + 'account.verification.update', + 'teams.membership.create', + 'teams.membership.update', + 'teams.membership.delete', + ]); + + $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); + $output = []; + + foreach ($logs as $i => &$log) { + $log['userAgent'] = (!empty($log['userAgent'])) ? $log['userAgent'] : 'UNKNOWN'; + + $dd = new DeviceDetector($log['userAgent']); + + $dd->skipBotDetection(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) + + $dd->parse(); + + $output[$i] = [ + 'event' => $log['event'], + 'ip' => $log['ip'], + 'time' => strtotime($log['time']), + 'OS' => $dd->getOs(), + 'client' => $dd->getClient(), + 'device' => $dd->getDevice(), + 'brand' => $dd->getBrand(), + 'model' => $dd->getModel(), + 'geo' => [], + ]; + + try { + $record = $reader->country($log['ip']); + $output[$i]['geo']['isoCode'] = strtolower($record->country->isoCode); + $output[$i]['geo']['country'] = $record->country->name; + $output[$i]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); + } catch (\Exception $e) { + $output[$i]['geo']['isoCode'] = '--'; + $output[$i]['geo']['country'] = Locale::getText('locale.country.unknown'); + } + } + + $response->json($output); + } + ); + +$utopia->patch('/v1/account/name') + ->desc('Update Account Name') + ->label('webhook', 'account.update.name') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'updateName') + ->label('sdk.description', '/docs/references/account/update-name.md') + ->param('name', '', function () { return new Text(100); }, 'User name.') + ->action( + function ($name) use ($response, $user, $projectDB, $audit, $oauth2Keys) { + $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ + 'name' => $name, + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audit + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.update.name') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response->json(array_merge($user->getArrayCopy(array_merge( + [ + '$id', + 'email', + 'registration', + 'name', + ], + $oauth2Keys + )), ['roles' => Authorization::getRoles()])); + } + ); + +$utopia->patch('/v1/account/password') + ->desc('Update Account Password') + ->label('webhook', 'account.update.password') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'updatePassword') + ->label('sdk.description', '/docs/references/account/update-password.md') + ->param('password', '', function () { return new Password(); }, 'New user password.') + ->param('old-password', '', function () { return new Password(); }, 'Old user password.') + ->action( + function ($password, $oldPassword) use ($response, $user, $projectDB, $audit, $oauth2Keys) { + if (!Auth::passwordVerify($oldPassword, $user->getAttribute('password'))) { // Double check user password + throw new Exception('Invalid credentials', 401); + } + + $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ + 'password' => Auth::passwordHash($password), + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audit + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.update.password') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response->json(array_merge($user->getArrayCopy(array_merge( + [ + '$id', + 'email', + 'registration', + 'name', + ], + $oauth2Keys + )), ['roles' => Authorization::getRoles()])); + } + ); + +$utopia->patch('/v1/account/email') + ->desc('Update Account Email') + ->label('webhook', 'account.update.email') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'updateEmail') + ->label('sdk.description', '/docs/references/account/update-email.md') + ->param('email', '', function () { return new Email(); }, 'User email.') + ->param('password', '', function () { return new Password(); }, 'User password.') + ->action( + function ($email, $password) use ($response, $user, $projectDB, $audit, $oauth2Keys) { + if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password + throw new Exception('Invalid credentials', 401); + } + + $profile = $projectDB->getCollection([ // Get user by email address + 'limit' => 1, + 'first' => true, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); + + if (!empty($profile)) { + throw new Exception('User already registered', 400); + } + + // TODO after this user needs to confirm mail again + + $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ + 'email' => $email, + 'emailVerification' => false, + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audit + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.update.email') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response->json(array_merge($user->getArrayCopy(array_merge( + [ + '$id', + 'email', + 'registration', + 'name', + ], + $oauth2Keys + )), ['roles' => Authorization::getRoles()])); + } + ); + +$utopia->patch('/v1/account/prefs') + ->desc('Update Account Preferences') + ->label('webhook', 'account.update.prefs') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'updatePrefs') + ->param('prefs', '', function () { return new Assoc();}, 'Prefs key-value JSON object.') + ->label('sdk.description', '/docs/references/account/update-prefs.md') + ->action( + function ($prefs) use ($response, $user, $projectDB, $audit) { + $old = json_decode($user->getAttribute('prefs', '{}'), true); + $old = ($old) ? $old : []; + + $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ + 'prefs' => json_encode(array_merge($old, $prefs)), + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audit + ->setParam('event', 'account.update.prefs') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $prefs = $user->getAttribute('prefs', '{}'); + + try { + $prefs = json_decode($prefs, true); + $prefs = ($prefs) ? $prefs : []; + } catch (\Exception $error) { + throw new Exception('Failed to parse prefs', 500); + } + + $response->json($prefs); + } + ); + +$utopia->delete('/v1/account') + ->desc('Delete Account') + ->label('webhook', 'account.delete') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'delete') + ->label('sdk.description', '/docs/references/account/delete.md') + ->action( + function () use ($response, $request, $user, $projectDB, $audit, $webhook) { + $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ + 'status' => Auth::USER_STATUS_BLOCKED, + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + //TODO delete all tokens or only current session? + //TODO delete all user data according to GDPR. Make sure everything is backed up and backups are deleted later + /* + * Data to delete + * * Tokens + * * Memberships + */ + + $audit + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.delete') + ->setParam('resource', 'users/'.$user->getId()) + ->setParam('data', $user->getArrayCopy()) + ; + + $webhook + ->setParam('payload', [ + 'name' => $user->getAttribute('name', ''), + 'email' => $user->getAttribute('email', ''), + ]) + ; + + $response + ->addCookie(Auth::$cookieName.'_legacy', '', time() - 3600, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null) + ->addCookie(Auth::$cookieName, '', time() - 3600, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE) + ->noContent() + ; + } + ); + +$utopia->delete('/v1/account/sessions/:sessionId') + ->desc('Delete Account Session') + ->label('scope', 'account') + ->label('webhook', 'account.sessions.delete') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'deleteSession') + ->label('sdk.description', '/docs/references/account/delete-session.md') + ->label('abuse-limit', 100) + ->param('sessionId', null, function () { return new UID(); }, 'Session unique ID. Use the string \'current\' to delete the current device session.') + ->action( + function ($sessionId) use ($response, $request, $user, $projectDB, $webhook, $audit) { + $sessionId = ($sessionId === 'current') + ? Auth::tokenVerify($user->getAttribute('tokens'), Auth::TOKEN_TYPE_LOGIN, Auth::$secret) + : $sessionId; + + $tokens = $user->getAttribute('tokens', []); + + foreach ($tokens as $token) { /* @var $token Document */ + if (($sessionId == $token->getId()) && Auth::TOKEN_TYPE_LOGIN == $token->getAttribute('type')) { + if (!$projectDB->deleteDocument($token->getId())) { + throw new Exception('Failed to remove token from DB', 500); + } + + $audit + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.sessions.delete') + ->setParam('resource', '/user/'.$user->getId()) + ; + + $webhook + ->setParam('payload', [ + 'name' => $user->getAttribute('name', ''), + 'email' => $user->getAttribute('email', ''), + ]) + ; + + if ($token->getAttribute('secret') == Auth::hash(Auth::$secret)) { // If current session delete the cookies too + $response + ->addCookie(Auth::$cookieName.'_legacy', '', time() - 3600, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null) + ->addCookie(Auth::$cookieName, '', time() - 3600, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE) + ; + } + + return $response->noContent(); + } + } + + throw new Exception('Session not found', 404); + } + ); + +$utopia->delete('/v1/account/sessions') + ->desc('Delete All Account Sessions') + ->label('scope', 'account') + ->label('webhook', 'account.sessions.delete') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'deleteSessions') + ->label('sdk.description', '/docs/references/account/delete-sessions.md') + ->label('abuse-limit', 100) + ->action( + function () use ($response, $request, $user, $projectDB, $audit, $webhook) { + $tokens = $user->getAttribute('tokens', []); + + foreach ($tokens as $token) { /* @var $token Document */ + if (!$projectDB->deleteDocument($token->getId())) { + throw new Exception('Failed to remove token from DB', 500); + } + + $audit + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.sessions.delete') + ->setParam('resource', '/user/'.$user->getId()) + ; + + $webhook + ->setParam('payload', [ + 'name' => $user->getAttribute('name', ''), + 'email' => $user->getAttribute('email', ''), + ]) + ; + + if ($token->getAttribute('secret') == Auth::hash(Auth::$secret)) { // If current session delete the cookies too + $response + ->addCookie(Auth::$cookieName.'_legacy', '', time() - 3600, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null) + ->addCookie(Auth::$cookieName, '', time() - 3600, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE) + ; + } + } + + $response->noContent(); + } + ); + +$utopia->post('/v1/account/recovery') + ->desc('Create Password Recovery') + ->label('scope', 'public') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'createRecovery') + ->label('sdk.description', '/docs/references/account/create-recovery.md') + ->label('abuse-limit', 10) + ->label('abuse-key', 'url:{url},email:{param-email}') + ->param('email', '', function () { return new Email(); }, 'User email.') + ->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the recovery email.') + ->action( + function ($email, $url) use ($request, $response, $projectDB, $register, $audit, $project) { + $profile = $projectDB->getCollection([ // Get user by email address + 'limit' => 1, + 'first' => true, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); + + if (empty($profile)) { + throw new Exception('User not found', 404); // TODO maybe hide this + } + + $secret = Auth::tokenGenerator(); + $recovery = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['user:'.$profile->getId()], 'write' => ['user:'.$profile->getId()]], + 'type' => Auth::TOKEN_TYPE_RECOVERY, + 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak + 'expire' => time() + Auth::TOKEN_EXPIRATION_RECOVERY, + 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), + 'ip' => $request->getIP(), + ]); + + Authorization::setRole('user:'.$profile->getId()); + + $recovery = $projectDB->createDocument($recovery->getArrayCopy()); + + if (false === $recovery) { + throw new Exception('Failed saving recovery to DB', 500); + } + + $profile->setAttribute('tokens', $recovery, Document::SET_TYPE_APPEND); + + $profile = $projectDB->updateDocument($profile->getArrayCopy()); + + if (false === $profile) { + throw new Exception('Failed to save user to DB', 500); + } + + $url = Template::parseURL($url); + $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $profile->getId(), 'secret' => $secret]); + $url = Template::unParseURL($url); + + $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.recovery.body')); + $body + ->setParam('{{direction}}', Locale::getText('settings.direction')) + ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) + ->setParam('{{name}}', $profile->getAttribute('name')) + ->setParam('{{redirect}}', $url) + ; + + $mail = $register->get('smtp'); /* @var $mail \PHPMailer\PHPMailer\PHPMailer */ + + $mail->addAddress($profile->getAttribute('email', ''), $profile->getAttribute('name', '')); + + $mail->Subject = Locale::getText('account.emails.recovery.title'); + $mail->Body = $body->render(); + $mail->AltBody = strip_tags($body->render()); + + try { + $mail->send(); + } catch (\Exception $error) { + throw new Exception('Error sending mail: ' . $error->getMessage(), 500); + } + + $audit + ->setParam('userId', $profile->getId()) + ->setParam('event', 'account.recovery.create') + ->setParam('resource', 'users/'.$profile->getId()) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->json($recovery->getArrayCopy(['$id', 'type', 'expire'])) + ; + } + ); + +$utopia->put('/v1/account/recovery') + ->desc('Complete Password Recovery') + ->label('scope', 'public') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'updateRecovery') + ->label('sdk.description', '/docs/references/account/update-recovery.md') + ->label('abuse-limit', 10) + ->label('abuse-key', 'url:{url},userId:{param-userId}') + ->param('userId', '', function () { return new UID(); }, 'User account UID address.') + ->param('secret', '', function () { return new Text(256); }, 'Valid reset token.') + ->param('password-a', '', function () { return new Password(); }, 'New password.') + ->param('password-b', '', function () {return new Password(); }, 'New password again.') + ->action( + function ($userId, $secret, $passwordA, $passwordB) use ($response, $projectDB, $audit) { + if ($passwordA !== $passwordB) { + throw new Exception('Passwords must match', 400); + } + + $profile = $projectDB->getCollection([ // Get user by email address + 'limit' => 1, + 'first' => true, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + '$id='.$userId, + ], + ]); + + if (empty($profile)) { + throw new Exception('User not found', 404); // TODO maybe hide this + } + + $recovery = Auth::tokenVerify($profile->getAttribute('tokens', []), Auth::TOKEN_TYPE_RECOVERY, $secret); + + if (!$recovery) { + throw new Exception('Invalid recovery token', 401); + } + + Authorization::setRole('user:'.$profile->getId()); + + $profile = $projectDB->updateDocument(array_merge($profile->getArrayCopy(), [ + 'password' => Auth::passwordHash($passwordA), + 'password-update' => time(), + 'emailVerification' => true, + ])); + + if (false === $profile) { + throw new Exception('Failed saving user to DB', 500); + } + + /** + * We act like we're updating and validating + * the recovery token but actually we don't need it anymore. + */ + if (!$projectDB->deleteDocument($recovery)) { + throw new Exception('Failed to remove recovery from DB', 500); + } + + $audit + ->setParam('userId', $profile->getId()) + ->setParam('event', 'account.recovery.update') + ->setParam('resource', 'users/'.$profile->getId()) + ; + + $recovery = $profile->search('$id', $recovery, $profile->getAttribute('tokens', [])); + + $response->json($recovery->getArrayCopy(['$id', 'type', 'expire'])); + } + ); + +$utopia->post('/v1/account/verification') + ->desc('Create Email Verification') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'createVerification') + ->label('sdk.description', '/docs/references/account/create-verification.md') + ->label('abuse-limit', 10) + ->label('abuse-key', 'url:{url},email:{param-email}') + ->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email.') // TODO add built-in confirm page + ->action( + function ($url) use ($request, $response, $register, $user, $project, $projectDB, $audit) { + $verificationSecret = Auth::tokenGenerator(); + + $verification = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['user:'.$user->getId()], 'write' => ['user:'.$user->getId()]], + 'type' => Auth::TOKEN_TYPE_VERIFICATION, + 'secret' => Auth::hash($verificationSecret), // On way hash encryption to protect DB leak + 'expire' => time() + Auth::TOKEN_EXPIRATION_CONFIRM, + 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), + 'ip' => $request->getIP(), + ]); + + Authorization::setRole('user:'.$user->getId()); + + $verification = $projectDB->createDocument($verification->getArrayCopy()); + + if (false === $verification) { + throw new Exception('Failed saving verification to DB', 500); + } + + $user->setAttribute('tokens', $verification, Document::SET_TYPE_APPEND); + + $user = $projectDB->updateDocument($user->getArrayCopy()); + + if (false === $user) { + throw new Exception('Failed to save user to DB', 500); + } + + $url = Template::parseURL($url); + $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $user->getId(), 'secret' => $verificationSecret]); + $url = Template::unParseURL($url); + + $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.verification.body')); + $body + ->setParam('{{direction}}', Locale::getText('settings.direction')) + ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) + ->setParam('{{name}}', $user->getAttribute('name')) + ->setParam('{{redirect}}', $url) + ; + + $mail = $register->get('smtp'); /* @var $mail \PHPMailer\PHPMailer\PHPMailer */ + + $mail->addAddress($user->getAttribute('email'), $user->getAttribute('name')); + + $mail->Subject = Locale::getText('account.emails.verification.title'); + $mail->Body = $body->render(); + $mail->AltBody = strip_tags($body->render()); + + try { + $mail->send(); + } catch (\Exception $error) { + throw new Exception('Problem sending mail: ' . $error->getMessage(), 500); + } + + $audit + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.verification.create') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->json($verification->getArrayCopy(['$id', 'type', 'expire'])) + ; + } + ); + +$utopia->put('/v1/account/verification') + ->desc('Complete Email Verification') + ->label('scope', 'public') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'updateVerification') + ->label('sdk.description', '/docs/references/account/update-verification.md') + ->label('abuse-limit', 10) + ->label('abuse-key', 'url:{url},userId:{param-userId}') + ->param('userId', '', function () { return new UID(); }, 'User unique ID.') + ->param('secret', '', function () { return new Text(256); }, 'Valid verification token.') + ->action( + function ($userId, $secret) use ($response, $user, $projectDB, $audit) { + $profile = $projectDB->getCollection([ // Get user by email address + 'limit' => 1, + 'first' => true, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + '$id='.$userId, + ], + ]); + + if (empty($profile)) { + throw new Exception('User not found', 404); // TODO maybe hide this + } + + $verification = Auth::tokenVerify($profile->getAttribute('tokens', []), Auth::TOKEN_TYPE_VERIFICATION, $secret); + + if (!$verification) { + throw new Exception('Invalid verification token', 401); + } + + Authorization::setRole('user:'.$profile->getId()); + + $profile = $projectDB->updateDocument(array_merge($profile->getArrayCopy(), [ + 'emailVerification' => true, + ])); + + if (false === $profile) { + throw new Exception('Failed saving user to DB', 500); + } + + /** + * We act like we're updating and validating + * the verification token but actually we don't need it anymore. + */ + if (!$projectDB->deleteDocument($verification)) { + throw new Exception('Failed to remove verification from DB', 500); + } + + $audit + ->setParam('userId', $profile->getId()) + ->setParam('event', 'account.verification.update') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $verification = $profile->search('$id', $verification, $profile->getAttribute('tokens', [])); + + $response->json($verification->getArrayCopy(['$id', 'type', 'expire'])); + } + ); \ No newline at end of file diff --git a/app/controllers/avatars.php b/app/controllers/api/avatars.php similarity index 94% rename from app/controllers/avatars.php rename to app/controllers/api/avatars.php index 88d9aab0f2..90c0000f20 100644 --- a/app/controllers/avatars.php +++ b/app/controllers/api/avatars.php @@ -15,12 +15,12 @@ use BaconQrCode\Renderer\Image\ImagickImageBackEnd; use BaconQrCode\Renderer\RendererStyle\RendererStyle; use BaconQrCode\Writer; -include_once 'shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $types = [ - 'browsers' => include __DIR__.'/../config/avatars/browsers.php', - 'credit-cards' => include __DIR__.'/../config/avatars/credit-cards.php', - 'flags' => include __DIR__.'/../config/avatars/flags.php', + 'browsers' => include __DIR__.'/../../config/avatars/browsers.php', + 'credit-cards' => include __DIR__.'/../../config/avatars/credit-cards.php', + 'flags' => include __DIR__.'/../../config/avatars/flags.php', ]; $avatarCallback = function ($type, $code, $width, $height, $quality) use ($types, $response, $request) { @@ -90,10 +90,11 @@ $avatarCallback = function ($type, $code, $width, $height, $quality) use ($types $utopia->get('/v1/avatars/credit-cards/:code') ->desc('Get Credit Card Icon') ->param('code', '', function () use ($types) { return new WhiteList(array_keys($types['credit-cards'])); }, 'Credit Card Code. Possible values: '.implode(', ', array_keys($types['credit-cards'])).'.') - ->param('width', 100, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100', true) - ->param('height', 100, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100', true) - ->param('quality', 100, function () { return new Range(0, 100); }, 'Image quality. Pass an integer between 0 to 100. Defaults to 100', true) + ->param('width', 100, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) + ->param('height', 100, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) + ->param('quality', 100, function () { return new Range(0, 100); }, 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true) ->label('scope', 'avatars.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getCreditCard') ->label('sdk.description', '/docs/references/avatars/get-credit-card.md') @@ -103,10 +104,11 @@ $utopia->get('/v1/avatars/credit-cards/:code') $utopia->get('/v1/avatars/browsers/:code') ->desc('Get Browser Icon') ->param('code', '', function () use ($types) { return new WhiteList(array_keys($types['browsers'])); }, 'Browser Code.') - ->param('width', 100, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100', true) - ->param('height', 100, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100', true) - ->param('quality', 100, function () { return new Range(0, 100); }, 'Image quality. Pass an integer between 0 to 100. Defaults to 100', true) + ->param('width', 100, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) + ->param('height', 100, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) + ->param('quality', 100, function () { return new Range(0, 100); }, 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true) ->label('scope', 'avatars.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getBrowser') ->label('sdk.description', '/docs/references/avatars/get-browser.md') @@ -116,10 +118,11 @@ $utopia->get('/v1/avatars/browsers/:code') $utopia->get('/v1/avatars/flags/:code') ->desc('Get Country Flag') ->param('code', '', function () use ($types) { return new WhiteList(array_keys($types['flags'])); }, 'Country Code. ISO Alpha-2 country code format.') - ->param('width', 100, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100', true) - ->param('height', 100, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100', true) - ->param('quality', 100, function () { return new Range(0, 100); }, 'Image quality. Pass an integer between 0 to 100. Defaults to 100', true) + ->param('width', 100, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) + ->param('height', 100, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) + ->param('quality', 100, function () { return new Range(0, 100); }, 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true) ->label('scope', 'avatars.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getFlag') ->label('sdk.description', '/docs/references/avatars/get-flag.md') @@ -129,9 +132,10 @@ $utopia->get('/v1/avatars/flags/:code') $utopia->get('/v1/avatars/image') ->desc('Get Image from URL') ->param('url', '', function () { return new URL(); }, 'Image URL which you want to crop.') - ->param('width', 400, function () { return new Range(0, 2000); }, 'Resize preview image width, Pass an integer between 0 to 4000', true) - ->param('height', 400, function () { return new Range(0, 2000); }, 'Resize preview image height, Pass an integer between 0 to 4000', true) + ->param('width', 400, function () { return new Range(0, 2000); }, 'Resize preview image width, Pass an integer between 0 to 2000.', true) + ->param('height', 400, function () { return new Range(0, 2000); }, 'Resize preview image height, Pass an integer between 0 to 2000.', true) ->label('scope', 'avatars.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getImage') ->label('sdk.description', '/docs/references/avatars/get-image.md') @@ -197,6 +201,7 @@ $utopia->get('/v1/avatars/favicon') ->desc('Get Favicon') ->param('url', '', function () { return new URL(); }, 'Website URL which you want to fetch the favicon from.') ->label('scope', 'avatars.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getFavicon') ->label('sdk.description', '/docs/references/avatars/get-favicon.md') @@ -344,11 +349,12 @@ $utopia->get('/v1/avatars/favicon') $utopia->get('/v1/avatars/qr') ->desc('Get QR Code') - ->param('text', '', function () { return new Text(512); }, 'Plain text to be converted to QR code image') + ->param('text', '', function () { return new Text(512); }, 'Plain text to be converted to QR code image.') ->param('size', 400, function () { return new Range(0, 1000); }, 'QR code size. Pass an integer between 0 to 1000. Defaults to 400.', true) ->param('margin', 1, function () { return new Range(0, 10); }, 'Margin From Edge. Pass an integer between 0 to 10. Defaults to 1.', true) ->param('download', 0, function () { return new Range(0, 1); }, 'Return resulting image with \'Content-Disposition: attachment \' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.', true) ->label('scope', 'avatars.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getQR') ->label('sdk.description', '/docs/references/avatars/get-qr.md') diff --git a/app/controllers/database.php b/app/controllers/api/database.php similarity index 81% rename from app/controllers/database.php rename to app/controllers/api/database.php index 2cf404cd7b..04edc2ea79 100644 --- a/app/controllers/database.php +++ b/app/controllers/api/database.php @@ -19,87 +19,22 @@ use Database\Validator\Authorization; use Database\Exception\Authorization as AuthorizationException; use Database\Exception\Structure as StructureException; -include_once 'shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $isDev = (App::ENV_TYPE_PRODUCTION !== $utopia->getEnv()); -$utopia->get('/v1/database') - ->desc('List Collections') - ->label('scope', 'collections.read') - ->label('sdk.namespace', 'database') - ->label('sdk.method', 'listCollections') - ->label('sdk.description', '/docs/references/database/list-collections.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, 40000); }, '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) { - /*$vl = new Structure($projectDB); - - var_dump($vl->isValid(new Document([ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - '$permissions' => [ - 'read' => ['*'], - 'write' => ['*'], - ], - 'label' => 'Platforms', - 'key' => 'platforms', - 'type' => 'document', - 'default' => [], - 'required' => false, - 'array' => true, - 'options' => [Database::SYSTEM_COLLECTION_PLATFORMS], - ]))); - - var_dump($vl->getDescription());*/ - - $results = $projectDB->getCollection([ - 'limit' => $limit, - 'offset' => $offset, - 'orderField' => 'name', - 'orderType' => $orderType, - 'orderCast' => 'string', - 'search' => $search, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_COLLECTIONS, - ], - ]); - - $response->json(['sum' => $projectDB->getSum(), 'collections' => $results]); - } - ); - -$utopia->get('/v1/database/:collectionId') - ->desc('Get Collection') - ->label('scope', 'collections.read') - ->label('sdk.namespace', 'database') - ->label('sdk.method', 'getCollection') - ->label('sdk.description', '/docs/references/database/get-collection.md') - ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') - ->action( - function ($collectionId) use ($response, $projectDB) { - $collection = $projectDB->getDocument($collectionId, false); - - if (empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } - - $response->json($collection->getArrayCopy()); - } - ); - -$utopia->post('/v1/database') +$utopia->post('/v1/database/collections') ->desc('Create Collection') ->label('webhook', 'database.collections.create') ->label('scope', 'collections.write') ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.method', 'createCollection') ->label('sdk.description', '/docs/references/database/create-collection.md') ->param('name', '', function () { return new Text(256); }, 'Collection name.') ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('rules', [], function () use ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation') + ->param('rules', [], function () use ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.') ->action( function ($name, $read, $write, $rules) use ($response, $projectDB, $webhook, $audit) { $parsedRules = []; @@ -143,7 +78,7 @@ $utopia->post('/v1/database') $audit ->setParam('event', 'database.collections.create') - ->setParam('resource', 'database/collection/'.$data['$uid']) + ->setParam('resource', 'database/collection/'.$data['$id']) ->setParam('data', $data) ; @@ -157,22 +92,92 @@ $utopia->post('/v1/database') } ); -$utopia->put('/v1/database/:collectionId') +$utopia->get('/v1/database/collections') + ->desc('List Collections') + ->label('scope', 'collections.read') + ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.method', 'listCollections') + ->label('sdk.description', '/docs/references/database/list-collections.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, 40000); }, '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) { + /*$vl = new Structure($projectDB); + + var_dump($vl->isValid(new Document([ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + '$permissions' => [ + 'read' => ['*'], + 'write' => ['*'], + ], + 'label' => 'Platforms', + 'key' => 'platforms', + 'type' => 'document', + 'default' => [], + 'required' => false, + 'array' => true, + 'options' => [Database::SYSTEM_COLLECTION_PLATFORMS], + ]))); + + var_dump($vl->getDescription());*/ + + $results = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderField' => 'name', + 'orderType' => $orderType, + 'orderCast' => 'string', + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_COLLECTIONS, + ], + ]); + + $response->json(['sum' => $projectDB->getSum(), 'collections' => $results]); + } + ); + +$utopia->get('/v1/database/collections/:collectionId') + ->desc('Get Collection') + ->label('scope', 'collections.read') + ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.method', 'getCollection') + ->label('sdk.description', '/docs/references/database/get-collection.md') + ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') + ->action( + function ($collectionId) use ($response, $projectDB) { + $collection = $projectDB->getDocument($collectionId, false); + + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); + } + + $response->json($collection->getArrayCopy()); + } + ); + +$utopia->put('/v1/database/collections/:collectionId') ->desc('Update Collection') ->label('scope', 'collections.write') + ->label('webhook', 'database.collections.update') ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.method', 'updateCollection') ->label('sdk.description', '/docs/references/database/update-collection.md') ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') ->param('name', null, function () { return new Text(256); }, 'Collection name.') ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions(/docs/permissions) and get a full list of available permissions.') ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('rules', [], function () use ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation', true) + ->param('rules', [], function () use ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', true) ->action( - function ($collectionId, $name, $read, $write, $rules) use ($response, $projectDB) { + function ($collectionId, $name, $read, $write, $rules) use ($response, $projectDB, $webhook, $audit) { $collection = $projectDB->getDocument($collectionId, false); - if (empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { throw new Exception('Collection not found', 404); } @@ -203,157 +208,68 @@ $utopia->put('/v1/database/:collectionId') throw new Exception('Failed saving collection to DB', 500); } + $data = $collection->getArrayCopy(); + + $webhook + ->setParam('payload', $data) + ; + + $audit + ->setParam('event', 'database.collections.update') + ->setParam('resource', 'database/collections/'.$data['$id']) + ->setParam('data', $data) + ; + $response->json($collection->getArrayCopy()); } ); -$utopia->delete('/v1/database/:collectionId') +$utopia->delete('/v1/database/collections/:collectionId') ->desc('Delete Collection') ->label('scope', 'collections.write') + ->label('webhook', 'database.collections.delete') ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.method', 'deleteCollection') ->label('sdk.description', '/docs/references/database/delete-collection.md') ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') ->action( - function ($collectionId) use ($response, $projectDB, $audit) { + function ($collectionId) use ($response, $projectDB, $webhook, $audit) { $collection = $projectDB->getDocument($collectionId, false); - if (empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { throw new Exception('Collection not found', 404); } if (!$projectDB->deleteDocument($collectionId)) { throw new Exception('Failed to remove collection from DB', 500); } + + $data = $collection->getArrayCopy(); + + $webhook + ->setParam('payload', $data) + ; $audit - ->setParam('event', 'database.collections.create') - ->setParam('resource', 'database/collection/'.$collection->getUid()) - ->setParam('data', $collection->getArrayCopy()) // Audit document in case of malicious or disastrous action + ->setParam('event', 'database.collections.delete') + ->setParam('resource', 'database/collections/'.$data['$id']) + ->setParam('data', $data) ; $response->noContent(); } ); -$utopia->get('/v1/database/:collectionId/documents') - ->desc('List Documents') - ->label('scope', 'documents.read') - ->label('sdk.namespace', 'database') - ->label('sdk.method', 'listDocuments') - ->label('sdk.description', '/docs/references/database/list-documents.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID.') - ->param('filters', [], function () { return new ArrayList(new Text(128)); }, 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: \'name=John Doe\' or \'category.$uid>=5bed2d152c362\'', true) - ->param('offset', 0, function () { return new Range(0, 900000000); }, 'Offset value. Use this value to manage pagination.', true) - ->param('limit', 50, function () { return new Range(0, 1000); }, 'Maximum number of documents to return in response. Use this value to manage pagination.', true) - ->param('order-field', '$uid', function () { return new Text(128); }, 'Document field that results will be sorted by.', true) - ->param('order-type', 'ASC', function () { return new WhiteList(array('DESC', 'ASC')); }, 'Order direction. Possible values are DESC for descending order, or ASC for ascending order.', true) - ->param('order-cast', 'string', function () { return new WhiteList(array('int', 'string', 'date', 'time', 'datetime')); }, 'Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string.', true) - ->param('search', '', function () { return new Text(256); }, 'Search query. Enter any free text search. The database will try to find a match against all document attributes and children.', true) - ->param('first', 0, function () { return new Range(0, 1); }, 'Return only first document. Pass 1 for true or 0 for false. The default value is 0.', true) - ->param('last', 0, function () { return new Range(0, 1); }, 'Return only last document. Pass 1 for true or 0 for false. The default value is 0.', true) - ->action( - function ($collectionId, $filters, $offset, $limit, $orderField, $orderType, $orderCast, $search, $first, $last) use ($response, $projectDB, $isDev) { - $collection = $projectDB->getDocument($collectionId, $isDev); - - if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } - - $list = $projectDB->getCollection([ - 'limit' => $limit, - 'offset' => $offset, - 'orderField' => $orderField, - 'orderType' => $orderType, - 'orderCast' => $orderCast, - 'search' => $search, - 'first' => (bool) $first, - 'last' => (bool) $last, - 'filters' => array_merge($filters, [ - '$collection='.$collectionId, - ]), - ]); - - if ($first || $last) { - $response->json((!empty($list) ? $list->getArrayCopy() : [])); - } else { - if ($isDev) { - $collection - ->setAttribute('debug', $projectDB->getDebug()) - ->setAttribute('limit', $limit) - ->setAttribute('offset', $offset) - ->setAttribute('orderField', $orderField) - ->setAttribute('orderType', $orderType) - ->setAttribute('orderCast', $orderCast) - ->setAttribute('filters', $filters) - ; - } - - $collection - ->setAttribute('sum', $projectDB->getSum()) - ->setAttribute('documents', $list) - ; - - /* - * View - */ - $response->json($collection->getArrayCopy(/*['$uid', '$collection', 'name', 'documents']*/[], ['rules'])); - } - } - ); - -$utopia->get('/v1/database/:collectionId/documents/:documentId') - ->desc('Get Document') - ->label('scope', 'documents.read') - ->label('sdk.namespace', 'database') - ->label('sdk.method', 'getDocument') - ->label('sdk.description', '/docs/references/database/get-document.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID') - ->param('documentId', null, function () { return new UID(); }, 'Document unique ID') - ->action( - function ($collectionId, $documentId) use ($response, $request, $projectDB, $isDev) { - $document = $projectDB->getDocument($documentId, $isDev); - $collection = $projectDB->getDocument($collectionId, $isDev); - - if (empty($document->getArrayCopy()) || $document->getCollection() != $collection->getUid()) { // Check empty - throw new Exception('No document found', 404); - } - - $output = $document->getArrayCopy(); - - $paths = explode('/', $request->getParam('q', '')); - $paths = array_slice($paths, 6, count($paths)); - - if (count($paths) > 0) { - if (count($paths) % 2 == 1) { - $output = $document->getAttribute(implode('.', $paths)); - } else { - $id = (int) array_pop($paths); - $output = $document->search('$uid', $id, $document->getAttribute(implode('.', $paths))); - } - - $output = ($output instanceof Document) ? $output->getArrayCopy() : $output; - - if (!is_array($output)) { - throw new Exception('No document found', 404); - } - } - - /* - * View - */ - $response->json($output); - } - ); - -$utopia->post('/v1/database/:collectionId/documents') +$utopia->post('/v1/database/collections/:collectionId/documents') ->desc('Create Document') ->label('webhook', 'database.documents.create') ->label('scope', 'documents.write') ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.method', 'createDocument') ->label('sdk.description', '/docs/references/database/create-document.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID.') + ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).') ->param('data', [], function () { return new \Utopia\Validator\Mock(); }, 'Document data as JSON string.') ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') @@ -368,13 +284,13 @@ $utopia->post('/v1/database/:collectionId/documents') throw new Exception('Missing payload', 400); } - if (isset($data['$uid'])) { - throw new Exception('$uid is not allowed for creating new documents, try update instead', 400); + if (isset($data['$id'])) { + throw new Exception('$id is not allowed for creating new documents, try update instead', 400); } $collection = $projectDB->getDocument($collectionId/*, $isDev*/); - if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + if (is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { throw new Exception('Collection not found', 404); } @@ -438,7 +354,7 @@ $utopia->post('/v1/database/:collectionId/documents') $audit ->setParam('event', 'database.documents.create') - ->setParam('resource', 'database/document/'.$data['$uid']) + ->setParam('resource', 'database/document/'.$data['$id']) ->setParam('data', $data) ; @@ -452,16 +368,129 @@ $utopia->post('/v1/database/:collectionId/documents') } ); -$utopia->patch('/v1/database/:collectionId/documents/:documentId') +$utopia->get('/v1/database/collections/:collectionId/documents') + ->desc('List Documents') + ->label('scope', 'documents.read') + ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) + ->label('sdk.method', 'listDocuments') + ->label('sdk.description', '/docs/references/database/list-documents.md') + ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).') + ->param('filters', [], function () { return new ArrayList(new Text(128)); }, 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: \'name=John Doe\' or \'category.$id>=5bed2d152c362\'.', true) + ->param('offset', 0, function () { return new Range(0, 900000000); }, 'Offset value. Use this value to manage pagination.', true) + ->param('limit', 50, function () { return new Range(0, 1000); }, 'Maximum number of documents to return in response. Use this value to manage pagination.', true) + ->param('order-field', '$id', function () { return new Text(128); }, 'Document field that results will be sorted by.', true) + ->param('order-type', 'ASC', function () { return new WhiteList(array('DESC', 'ASC')); }, 'Order direction. Possible values are DESC for descending order, or ASC for ascending order.', true) + ->param('order-cast', 'string', function () { return new WhiteList(array('int', 'string', 'date', 'time', 'datetime')); }, 'Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string.', true) + ->param('search', '', function () { return new Text(256); }, 'Search query. Enter any free text search. The database will try to find a match against all document attributes and children.', true) + ->param('first', 0, function () { return new Range(0, 1); }, 'Return only first document. Pass 1 for true or 0 for false. The default value is 0.', true) + ->param('last', 0, function () { return new Range(0, 1); }, 'Return only last document. Pass 1 for true or 0 for false. The default value is 0.', true) + ->action( + function ($collectionId, $filters, $offset, $limit, $orderField, $orderType, $orderCast, $search, $first, $last) use ($response, $projectDB, $isDev) { + $collection = $projectDB->getDocument($collectionId, $isDev); + + if (is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); + } + + $list = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderField' => $orderField, + 'orderType' => $orderType, + 'orderCast' => $orderCast, + 'search' => $search, + 'first' => (bool) $first, + 'last' => (bool) $last, + 'filters' => array_merge($filters, [ + '$collection='.$collectionId, + ]), + ]); + + if ($first || $last) { + $response->json((!empty($list) ? $list->getArrayCopy() : [])); + } else { + if ($isDev) { + $collection + ->setAttribute('debug', $projectDB->getDebug()) + ->setAttribute('limit', $limit) + ->setAttribute('offset', $offset) + ->setAttribute('orderField', $orderField) + ->setAttribute('orderType', $orderType) + ->setAttribute('orderCast', $orderCast) + ->setAttribute('filters', $filters) + ; + } + + $collection + ->setAttribute('sum', $projectDB->getSum()) + ->setAttribute('documents', $list) + ; + + /* + * View + */ + $response->json($collection->getArrayCopy(/*['$id', '$collection', 'name', 'documents']*/[], ['rules'])); + } + } + ); + +$utopia->get('/v1/database/collections/:collectionId/documents/:documentId') + ->desc('Get Document') + ->label('scope', 'documents.read') + ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) + ->label('sdk.method', 'getDocument') + ->label('sdk.description', '/docs/references/database/get-document.md') + ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).') + ->param('documentId', null, function () { return new UID(); }, 'Document unique ID.') + ->action( + function ($collectionId, $documentId) use ($response, $request, $projectDB, $isDev) { + $document = $projectDB->getDocument($documentId, $isDev); + $collection = $projectDB->getDocument($collectionId, $isDev); + + if (empty($document->getArrayCopy()) || $document->getCollection() != $collection->getId()) { // Check empty + throw new Exception('No document found', 404); + } + + $output = $document->getArrayCopy(); + + $paths = explode('/', $request->getParam('q', '')); + $paths = array_slice($paths, 7, count($paths)); + + if (count($paths) > 0) { + if (count($paths) % 2 == 1) { + $output = $document->getAttribute(implode('.', $paths)); + } else { + $id = (int) array_pop($paths); + $output = $document->search('$id', $id, $document->getAttribute(implode('.', $paths))); + } + + $output = ($output instanceof Document) ? $output->getArrayCopy() : $output; + + if (!is_array($output)) { + throw new Exception('No document found', 404); + } + } + + /* + * View + */ + $response->json($output); + } + ); + +$utopia->patch('/v1/database/collections/:collectionId/documents/:documentId') ->desc('Update Document') - ->label('webhook', 'database.documents.patch') + ->label('webhook', 'database.documents.update') ->label('scope', 'documents.write') ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.method', 'updateDocument') ->label('sdk.description', '/docs/references/database/update-document.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID') - ->param('documentId', null, function () { return new UID(); }, 'Document unique ID') - ->param('data', [], function () { return new \Utopia\Validator\Mock(); }, 'Document data as JSON string') + ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).') + ->param('documentId', null, function () { return new UID(); }, 'Document unique ID.') + ->param('data', [], function () { return new \Utopia\Validator\Mock(); }, 'Document data as JSON string.') ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->action( @@ -475,7 +504,7 @@ $utopia->patch('/v1/database/:collectionId/documents/:documentId') throw new Exception('Data param should be a valid JSON', 400); } - if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + if (is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { throw new Exception('Collection not found', 404); } @@ -495,8 +524,8 @@ $utopia->patch('/v1/database/:collectionId/documents/:documentId') $data = array_merge($document->getArrayCopy(), $data); - $data['$collection'] = $collection->getUid(); // Make sure user don't switch collectionID - $data['$uid'] = $document->getUid(); // Make sure user don't switch document unique ID + $data['$collection'] = $collection->getId(); // Make sure user don't switch collectionID + $data['$id'] = $document->getId(); // Make sure user don't switch document unique ID if (empty($data)) { throw new Exception('Missing payload', 400); @@ -518,8 +547,8 @@ $utopia->patch('/v1/database/:collectionId/documents/:documentId') ; $audit - ->setParam('event', 'database.documents.patch') - ->setParam('resource', 'database/document/'.$data['$uid']) + ->setParam('event', 'database.documents.update') + ->setParam('resource', 'database/document/'.$data['$id']) ->setParam('data', $data) ; @@ -530,16 +559,18 @@ $utopia->patch('/v1/database/:collectionId/documents/:documentId') } ); -$utopia->delete('/v1/database/:collectionId/documents/:documentId') +$utopia->delete('/v1/database/collections/:collectionId/documents/:documentId') ->desc('Delete Document') ->label('scope', 'documents.write') + ->label('webhook', 'database.documents.delete') ->label('sdk.namespace', 'database') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.method', 'deleteDocument') ->label('sdk.description', '/docs/references/database/delete-document.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID') - ->param('documentId', null, function () { return new UID(); }, 'Document unique ID') + ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).') + ->param('documentId', null, function () { return new UID(); }, 'Document unique ID.') ->action( - function ($collectionId, $documentId) use ($response, $projectDB, $audit, $isDev) { + function ($collectionId, $documentId) use ($response, $projectDB, $audit, $webhook, $isDev) { $collection = $projectDB->getDocument($collectionId, $isDev); $document = $projectDB->getDocument($documentId, $isDev); @@ -547,7 +578,7 @@ $utopia->delete('/v1/database/:collectionId/documents/:documentId') throw new Exception('No document found', 404); } - if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + if (is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { throw new Exception('Collection not found', 404); } @@ -561,10 +592,16 @@ $utopia->delete('/v1/database/:collectionId/documents/:documentId') throw new Exception('Failed to remove document from DB', 500); } + $data = $document->getArrayCopy(); + + $webhook + ->setParam('payload', $data) + ; + $audit ->setParam('event', 'database.documents.delete') - ->setParam('resource', 'database/document/'.$documentId) - ->setParam('data', $document->getArrayCopy()) // Audit document in case of malicious or disastrous action + ->setParam('resource', 'database/document/'.$data['$id']) + ->setParam('data', $data) // Audit document in case of malicious or disastrous action ; $response->noContent(); diff --git a/app/controllers/api/graphql.php b/app/controllers/api/graphql.php new file mode 100644 index 0000000000..ce39d8e799 --- /dev/null +++ b/app/controllers/api/graphql.php @@ -0,0 +1,22 @@ +post('/v1/graphql') + ->desc('GraphQL Endpoint') + ->label('scope', 'public') + ->action( + function () { + throw new Exception('GraphQL support is coming soon!', 502); + } + ); diff --git a/app/controllers/health.php b/app/controllers/api/health.php similarity index 90% rename from app/controllers/health.php rename to app/controllers/api/health.php index 7741dfd067..ad1beef9a4 100644 --- a/app/controllers/health.php +++ b/app/controllers/api/health.php @@ -10,8 +10,9 @@ use Appwrite\ClamAV\Network; $utopia->get('/v1/health') ->desc('Check API HTTP Health') ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') - ->label('sdk.method', 'getDB') + ->label('sdk.method', 'get') ->label('docs', false) ->action( function () use ($response) { @@ -22,6 +23,7 @@ $utopia->get('/v1/health') $utopia->get('/v1/health/db') ->desc('Check DB Health') ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getDB') ->label('docs', false) @@ -36,6 +38,7 @@ $utopia->get('/v1/health/db') $utopia->get('/v1/health/cache') ->desc('Check Cache Health') ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getCache') ->label('docs', false) @@ -50,6 +53,7 @@ $utopia->get('/v1/health/cache') $utopia->get('/v1/health/time') ->desc('Check Webhooks Health') ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getTime') ->label('docs', false) @@ -96,6 +100,7 @@ $utopia->get('/v1/health/time') $utopia->get('/v1/health/webhooks') ->desc('Check Time Health') ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getWebhooks') ->label('docs', false) @@ -108,6 +113,7 @@ $utopia->get('/v1/health/webhooks') $utopia->get('/v1/health/storage/local') ->desc('Check File System Health') ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getStorageLocal') ->label('docs', false) @@ -130,6 +136,7 @@ $utopia->get('/v1/health/storage/local') $utopia->get('/v1/health/storage/anti-virus') ->desc('Check Anti virus Health') ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getStorageAntiVirus') ->label('docs', false) @@ -147,6 +154,7 @@ $utopia->get('/v1/health/storage/anti-virus') $utopia->get('/v1/health/stats') ->desc('System Stats') ->label('scope', 'god') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getStats') ->label('docs', false) @@ -164,9 +172,9 @@ $utopia->get('/v1/health/stats') 'version' => shell_exec('nginx -v 2>&1'), ], 'storage' => [ - 'used' => $device->human($device->getDirectorySize($device->getRoot().'/')), - 'partitionTotal' => $device->human($device->getPartitionTotalSpace()), - 'partitionFree' => $device->human($device->getPartitionFreeSpace()), + 'used' => Storage::human($device->getDirectorySize($device->getRoot().'/')), + 'partitionTotal' => Storage::human($device->getPartitionTotalSpace()), + 'partitionFree' => Storage::human($device->getPartitionFreeSpace()), ], 'cache' => [ 'uptime' => (isset($cacheStats['uptime_in_seconds'])) ? $cacheStats['uptime_in_seconds'] : 0, diff --git a/app/controllers/locale.php b/app/controllers/api/locale.php similarity index 84% rename from app/controllers/locale.php rename to app/controllers/api/locale.php index e90ccdd8a6..8b78dc66bf 100644 --- a/app/controllers/locale.php +++ b/app/controllers/api/locale.php @@ -6,19 +6,20 @@ use Utopia\App; use Utopia\Locale\Locale; use GeoIp2\Database\Reader; -include_once 'shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->get('/v1/locale') ->desc('Get User Locale') ->label('scope', 'locale.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'locale') - ->label('sdk.method', 'getLocale') + ->label('sdk.method', 'get') ->label('sdk.description', '/docs/references/locale/get-locale.md') ->action( function () use ($response, $request, $utopia) { - $eu = include __DIR__.'/../config/eu.php'; - $currencies = include __DIR__.'/../config/currencies.php'; - $reader = new Reader(__DIR__.'/../db/DBIP/dbip-country-lite-2020-01.mmdb'); + $eu = include __DIR__.'/../../config/eu.php'; + $currencies = include __DIR__.'/../../config/currencies.php'; + $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); $output = []; $ip = $request->getIP(); $time = (60 * 60 * 24 * 45); // 45 days cache @@ -68,6 +69,7 @@ $utopia->get('/v1/locale') $utopia->get('/v1/locale/countries') ->desc('List Countries') ->label('scope', 'locale.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getCountries') ->label('sdk.description', '/docs/references/locale/get-countries.md') @@ -84,13 +86,14 @@ $utopia->get('/v1/locale/countries') $utopia->get('/v1/locale/countries/eu') ->desc('List EU Countries') ->label('scope', 'locale.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getCountriesEU') ->label('sdk.description', '/docs/references/locale/get-countries-eu.md') ->action( function () use ($response) { $countries = Locale::getText('countries'); /* @var $countries array */ - $eu = include __DIR__.'/../config/eu.php'; + $eu = include __DIR__.'/../../config/eu.php'; $list = []; foreach ($eu as $code) { @@ -108,12 +111,13 @@ $utopia->get('/v1/locale/countries/eu') $utopia->get('/v1/locale/countries/phones') ->desc('List Countries Phone Codes') ->label('scope', 'locale.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getCountriesPhones') ->label('sdk.description', '/docs/references/locale/get-countries-phones.md') ->action( function () use ($response) { - $list = include __DIR__.'/../config/phones.php'; /* @var $list array */ + $list = include __DIR__.'/../../config/phones.php'; /* @var $list array */ $countries = Locale::getText('countries'); /* @var $countries array */ @@ -132,6 +136,7 @@ $utopia->get('/v1/locale/countries/phones') $utopia->get('/v1/locale/continents') ->desc('List Countries') ->label('scope', 'locale.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getContinents') ->label('sdk.description', '/docs/references/locale/get-continents.md') @@ -149,12 +154,13 @@ $utopia->get('/v1/locale/continents') $utopia->get('/v1/locale/currencies') ->desc('List Currencies') ->label('scope', 'locale.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getCurrencies') ->label('sdk.description', '/docs/references/locale/get-currencies.md') ->action( function () use ($response) { - $currencies = include __DIR__.'/../config/currencies.php'; + $currencies = include __DIR__.'/../../config/currencies.php'; $response->json($currencies); } diff --git a/app/controllers/projects.php b/app/controllers/api/projects.php similarity index 84% rename from app/controllers/projects.php rename to app/controllers/api/projects.php index 10f07e603f..f7cfb77399 100644 --- a/app/controllers/projects.php +++ b/app/controllers/api/projects.php @@ -2,6 +2,7 @@ global $utopia, $request, $response, $register, $user, $consoleDB, $projectDB, $providers; +use Auth\Auth; use Utopia\Exception; use Utopia\Response; use Utopia\Validator\ArrayList; @@ -16,26 +17,77 @@ use Database\Validator\UID; use OpenSSL\OpenSSL; use Cron\CronExpression; -include_once 'shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; -$scopes = [ // TODO sync with console UI list - 'users.read', - 'users.write', - 'teams.read', - 'teams.write', - 'collections.read', - 'collections.write', - 'documents.read', - 'documents.write', - 'files.read', - 'files.write', -]; +$scopes = include __DIR__.'/../../../app/config/scopes.php'; + +$utopia->post('/v1/projects') + ->desc('Create Project') + ->label('scope', 'projects.write') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'create') + ->param('name', null, function () { return new Text(100); }, 'Project name.') + ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') + ->param('description', '', function () { return new Text(255); }, 'Project description.', true) + ->param('logo', '', function () { return new Text(1024); }, 'Project logo.', true) + ->param('url', '', function () { return new URL(); }, 'Project URL.', true) + ->param('legalName', '', function () { return new Text(256); }, 'Project legal Name.', true) + ->param('legalCountry', '', function () { return new Text(256); }, 'Project legal Country.', true) + ->param('legalState', '', function () { return new Text(256); }, 'Project legal State.', true) + ->param('legalCity', '', function () { return new Text(256); }, 'Project legal City.', true) + ->param('legalAddress', '', function () { return new Text(256); }, 'Project legal Address.', true) + ->param('legalTaxId', '', function () { return new Text(256); }, 'Project legal Tax ID.', true) + ->action( + function ($name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId) use ($response, $user, $consoleDB, $projectDB) { + $team = $projectDB->getDocument($teamId); + + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + throw new Exception('Team not found', 404); + } + + $project = $consoleDB->createDocument( + [ + '$collection' => Database::SYSTEM_COLLECTION_PROJECTS, + '$permissions' => [ + 'read' => ['team:'.$teamId], + 'write' => ['team:'.$teamId.'/owner', 'team:'.$teamId.'/developer'], + ], + 'name' => $name, + 'description' => $description, + 'logo' => $logo, + 'url' => $url, + 'legalName' => $legalName, + 'legalCountry' => $legalCountry, + 'legalState' => $legalState, + 'legalCity' => $legalCity, + 'legalAddress' => $legalAddress, + 'legalTaxId' => $legalTaxId, + 'teamId' => $team->getId(), + 'platforms' => [], + 'webhooks' => [], + 'keys' => [], + 'tasks' => [], + ] + ); + + if (false === $project) { + throw new Exception('Failed saving project to DB', 500); + } + + $consoleDB->createNamespace($project->getId()); + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->json($project->getArrayCopy()) + ; + } + ); $utopia->get('/v1/projects') ->desc('List Projects') ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'listProjects') + ->label('sdk.method', 'list') ->action( function () use ($request, $response, $providers, $consoleDB) { $results = $consoleDB->getCollection([ @@ -51,11 +103,11 @@ $utopia->get('/v1/projects') foreach ($results as $project) { foreach ($providers as $provider => $node) { - $secret = json_decode($project->getAttribute('usersOauth'.ucfirst($provider).'Secret', '{}'), true); + $secret = json_decode($project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}'), true); if (!empty($secret) && isset($secret['version'])) { $key = $request->getServer('_APP_OPENSSL_KEY_V'.$secret['version']); - $project->setAttribute('usersOauth'.ucfirst($provider).'Secret', OpenSSL::decrypt($secret['data'], $secret['method'], $key, 0, hex2bin($secret['iv']), hex2bin($secret['tag']))); + $project->setAttribute('usersOauth2'.ucfirst($provider).'Secret', OpenSSL::decrypt($secret['data'], $secret['method'], $key, 0, hex2bin($secret['iv']), hex2bin($secret['tag']))); } } } @@ -68,22 +120,22 @@ $utopia->get('/v1/projects/:projectId') ->desc('Get Project') ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'getProject') + ->label('sdk.method', 'get') ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') ->action( function ($projectId) use ($request, $response, $providers, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } foreach ($providers as $provider => $node) { - $secret = json_decode($project->getAttribute('usersOauth'.ucfirst($provider).'Secret', '{}'), true); + $secret = json_decode($project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}'), true); if (!empty($secret) && isset($secret['version'])) { $key = $request->getServer('_APP_OPENSSL_KEY_V'.$secret['version']); - $project->setAttribute('usersOauth'.ucfirst($provider).'Secret', OpenSSL::decrypt($secret['data'], $secret['method'], $key, 0, hex2bin($secret['iv']), hex2bin($secret['tag']))); + $project->setAttribute('usersOauth2'.ucfirst($provider).'Secret', OpenSSL::decrypt($secret['data'], $secret['method'], $key, 0, hex2bin($secret['iv']), hex2bin($secret['tag']))); } } @@ -95,13 +147,13 @@ $utopia->get('/v1/projects/:projectId/usage') ->desc('Get Project') ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'getProjectUsage') + ->label('sdk.method', 'getUsage') ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') ->action( function ($projectId) use ($response, $consoleDB, $projectDB, $register) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } @@ -118,7 +170,7 @@ $utopia->get('/v1/projects/:projectId/usage') $database = $client->selectDB('telegraf'); // Requests - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getUid().'\' GROUP BY time(1d) FILL(null)'); + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time(1d) FILL(null)'); $points = $result->getPoints(); foreach ($points as $point) { @@ -129,7 +181,7 @@ $utopia->get('/v1/projects/:projectId/usage') } // Network - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getUid().'\' GROUP BY time(1d) FILL(null)'); + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time(1d) FILL(null)'); $points = $result->getPoints(); foreach ($points as $point) { @@ -171,7 +223,7 @@ $utopia->get('/v1/projects/:projectId/usage') 'limit' => 0, 'offset' => 0, 'filters' => [ - '$collection='.$collection['$uid'], + '$collection='.$collection['$id'], ], ]); @@ -225,87 +277,27 @@ $utopia->get('/v1/projects/:projectId/usage') } ); -$utopia->post('/v1/projects') - ->desc('Create Project') - ->label('scope', 'projects.write') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'createProject') - ->param('name', null, function () { return new Text(100); }, 'Project name') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('description', '', function () { return new Text(255); }, 'Project description', true) - ->param('logo', '', function () { return new Text(1024); }, 'Project logo', true) - ->param('url', '', function () { return new URL(); }, 'Project URL', true) - ->param('legalName', '', function () { return new Text(256); }, 'Project Legal Name', true) - ->param('legalCountry', '', function () { return new Text(256); }, 'Project Legal Country', true) - ->param('legalState', '', function () { return new Text(256); }, 'Project Legal State', true) - ->param('legalCity', '', function () { return new Text(256); }, 'Project Legal City', true) - ->param('legalAddress', '', function () { return new Text(256); }, 'Project Legal Address', true) - ->param('legalTaxId', '', function () { return new Text(256); }, 'Project Legal Tax ID', true) - ->action( - function ($name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId) use ($response, $user, $consoleDB, $projectDB) { - $team = $projectDB->getDocument($teamId); - - if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } - - $project = $consoleDB->createDocument( - [ - '$collection' => Database::SYSTEM_COLLECTION_PROJECTS, - '$permissions' => [ - 'read' => ['team:'.$teamId], - 'write' => ['team:'.$teamId.'/owner', 'team:'.$teamId.'/developer'], - ], - 'name' => $name, - 'description' => $description, - 'logo' => $logo, - 'url' => $url, - 'legalName' => $legalName, - 'legalCountry' => $legalCountry, - 'legalState' => $legalState, - 'legalCity' => $legalCity, - 'legalAddress' => $legalAddress, - 'legalTaxId' => $legalTaxId, - 'teamId' => $team->getUid(), - 'webhooks' => [], - 'keys' => [], - ] - ); - - if (false === $project) { - throw new Exception('Failed saving project to DB', 500); - } - - $consoleDB->createNamespace($project->getUid()); - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($project->getArrayCopy()) - ; - } - ); - $utopia->patch('/v1/projects/:projectId') ->desc('Update Project') ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'updateProject') + ->label('sdk.method', 'update') ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->param('name', null, function () { return new Text(100); }, 'Project name') - ->param('description', '', function () { return new Text(255); }, 'Project description', true) - ->param('logo', '', function () { return new Text(1024); }, 'Project logo', true) - ->param('url', '', function () { return new URL(); }, 'Project URL', true) - ->param('legalName', '', function () { return new Text(256); }, 'Project Legal Name', true) - ->param('legalCountry', '', function () { return new Text(256); }, 'Project Legal Country', true) - ->param('legalState', '', function () { return new Text(256); }, 'Project Legal State', true) - ->param('legalCity', '', function () { return new Text(256); }, 'Project Legal City', true) - ->param('legalAddress', '', function () { return new Text(256); }, 'Project Legal Address', true) - ->param('legalTaxId', '', function () { return new Text(256); }, 'Project Legal Tax ID', true) + ->param('name', null, function () { return new Text(100); }, 'Project name.') + ->param('description', '', function () { return new Text(255); }, 'Project description.', true) + ->param('logo', '', function () { return new Text(1024); }, 'Project logo.', true) + ->param('url', '', function () { return new URL(); }, 'Project URL.', true) + ->param('legalName', '', function () { return new Text(256); }, 'Project legal name.', true) + ->param('legalCountry', '', function () { return new Text(256); }, 'Project legal country..', true) + ->param('legalState', '', function () { return new Text(256); }, 'Project legal state.', true) + ->param('legalCity', '', function () { return new Text(256); }, 'Project legal city.', true) + ->param('legalAddress', '', function () { return new Text(256); }, 'Project legal address.', true) + ->param('legalTaxId', '', function () { return new Text(256); }, 'Project legal tax ID.', true) ->action( function ($projectId, $name, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId) use ($response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } @@ -330,20 +322,20 @@ $utopia->patch('/v1/projects/:projectId') } ); -$utopia->patch('/v1/projects/:projectId/oauth') - ->desc('Update Project OAuth') +$utopia->patch('/v1/projects/:projectId/oauth2') + ->desc('Update Project OAuth2') ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'updateProjectOAuth') + ->label('sdk.method', 'updateOAuth2') ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') ->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'Provider Name', false) - ->param('appId', '', function () { return new Text(256); }, 'Provider App ID', true) - ->param('secret', '', function () { return new text(256); }, 'Provider Secret Key', true) + ->param('appId', '', function () { return new Text(256); }, 'Provider app ID.', true) + ->param('secret', '', function () { return new text(256); }, 'Provider secret key.', true) ->action( function ($projectId, $provider, $appId, $secret) use ($request, $response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } @@ -359,8 +351,8 @@ $utopia->patch('/v1/projects/:projectId/oauth') ]); $project = $consoleDB->updateDocument(array_merge($project->getArrayCopy(), [ - 'usersOauth'.ucfirst($provider).'Appid' => $appId, - 'usersOauth'.ucfirst($provider).'Secret' => $secret, + 'usersOauth2'.ucfirst($provider).'Appid' => $appId, + 'usersOauth2'.ucfirst($provider).'Secret' => $secret, ])); if (false === $project) { @@ -375,13 +367,18 @@ $utopia->delete('/v1/projects/:projectId') ->desc('Delete Project') ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'deleteProject') + ->label('sdk.method', 'delete') ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') + ->param('password', '', function () { return new UID(); }, 'Your user password for confirmation.') ->action( - function ($projectId) use ($response, $consoleDB) { + function ($projectId, $password) use ($response, $consoleDB, $user) { + if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password + throw new Exception('Invalid credentials', 401); + } + $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } @@ -392,7 +389,7 @@ $utopia->delete('/v1/projects/:projectId') } // Delete all DBs - // $consoleDB->deleteNamespace($project->getUid()); + // $consoleDB->deleteNamespace($project->getId()); // Optimize DB? @@ -405,87 +402,23 @@ $utopia->delete('/v1/projects/:projectId') // Webhooks -$utopia->get('/v1/projects/:projectId/webhooks') - ->desc('List Webhooks') - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'listWebhooks') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $webhooks = $project->getAttribute('webhooks', []); - - foreach ($webhooks as $webhook) { /* @var $webhook Document */ - $httpPass = json_decode($webhook->getAttribute('httpPass', '{}'), true); - - if (empty($httpPass) || !isset($httpPass['version'])) { - continue; - } - - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); - - $webhook->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, hex2bin($httpPass['iv']), hex2bin($httpPass['tag']))); - } - - $response->json($webhooks); - } - ); - -$utopia->get('/v1/projects/:projectId/webhooks/:webhookId') - ->desc('Get Webhook') - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'getWebhook') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('webhookId', null, function () { return new UID(); }, 'Webhook unique ID.') - ->action( - function ($projectId, $webhookId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $webhook = $project->search('$uid', $webhookId, $project->getAttribute('webhooks', [])); - - if (empty($webhook) && $webhook instanceof Document) { - throw new Exception('Webhook not found', 404); - } - - $httpPass = json_decode($webhook->getAttribute('httpPass', '{}'), true); - - if (!empty($httpPass) && isset($httpPass['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); - $webhook->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, hex2bin($httpPass['iv']), hex2bin($httpPass['tag']))); - } - - $response->json($webhook->getArrayCopy()); - } - ); - $utopia->post('/v1/projects/:projectId/webhooks') ->desc('Create Webhook') ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createWebhook') ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Webhook name') - ->param('events', null, function () { return new ArrayList(new Text(256)); }, 'Webhook events list') - ->param('url', null, function () { return new Text(2000); }, 'Webhook URL') - ->param('security', null, function () { return new Range(0, 1); }, 'Certificate verification, 0 for disabled or 1 for enabled') - ->param('httpUser', '', function () { return new Text(256); }, 'Webhook HTTP user', true) - ->param('httpPass', '', function () { return new Text(256); }, 'Webhook HTTP password', true) + ->param('name', null, function () { return new Text(256); }, 'Webhook name.') + ->param('events', null, function () { return new ArrayList(new Text(256)); }, 'Webhook events list.') + ->param('url', null, function () { return new Text(2000); }, 'Webhook URL.') + ->param('security', null, function () { return new Range(0, 1); }, 'Certificate verification, 0 for disabled or 1 for enabled.') + ->param('httpUser', '', function () { return new Text(256); }, 'Webhook HTTP user.', true) + ->param('httpPass', '', function () { return new Text(256); }, 'Webhook HTTP password.', true) ->action( function ($projectId, $name, $events, $url, $security, $httpUser, $httpPass) use ($request, $response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } @@ -533,6 +466,71 @@ $utopia->post('/v1/projects/:projectId/webhooks') } ); +$utopia->get('/v1/projects/:projectId/webhooks') + ->desc('List Webhooks') + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'listWebhooks') + ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') + ->action( + function ($projectId) use ($request, $response, $consoleDB) { + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $webhooks = $project->getAttribute('webhooks', []); + + foreach ($webhooks as $webhook) { /* @var $webhook Document */ + $httpPass = json_decode($webhook->getAttribute('httpPass', '{}'), true); + + if (empty($httpPass) || !isset($httpPass['version'])) { + continue; + } + + $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); + + $webhook->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, hex2bin($httpPass['iv']), hex2bin($httpPass['tag']))); + } + + $response->json($webhooks); + } + ); + +$utopia->get('/v1/projects/:projectId/webhooks/:webhookId') + ->desc('Get Webhook') + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'getWebhook') + ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') + ->param('webhookId', null, function () { return new UID(); }, 'Webhook unique ID.') + ->action( + function ($projectId, $webhookId) use ($request, $response, $consoleDB) { + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', [])); + + if (empty($webhook) && $webhook instanceof Document) { + throw new Exception('Webhook not found', 404); + } + + $httpPass = json_decode($webhook->getAttribute('httpPass', '{}'), true); + + if (!empty($httpPass) && isset($httpPass['version'])) { + $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); + $webhook->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, hex2bin($httpPass['iv']), hex2bin($httpPass['tag']))); + } + + $response->json($webhook->getArrayCopy()); + } + ); + + $utopia->put('/v1/projects/:projectId/webhooks/:webhookId') ->desc('Update Webhook') ->label('scope', 'projects.write') @@ -540,17 +538,17 @@ $utopia->put('/v1/projects/:projectId/webhooks/:webhookId') ->label('sdk.method', 'updateWebhook') ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') ->param('webhookId', null, function () { return new UID(); }, 'Webhook unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Webhook name') - ->param('events', null, function () { return new ArrayList(new Text(256)); }, 'Webhook events list') - ->param('url', null, function () { return new Text(2000); }, 'Webhook URL') - ->param('security', null, function () { return new Range(0, 1); }, 'Certificate verification, 0 for disabled or 1 for enabled') - ->param('httpUser', '', function () { return new Text(256); }, 'Webhook HTTP user', true) - ->param('httpPass', '', function () { return new Text(256); }, 'Webhook HTTP password', true) + ->param('name', null, function () { return new Text(256); }, 'Webhook name.') + ->param('events', null, function () { return new ArrayList(new Text(256)); }, 'Webhook events list.') + ->param('url', null, function () { return new Text(2000); }, 'Webhook URL.') + ->param('security', null, function () { return new Range(0, 1); }, 'Certificate verification, 0 for disabled or 1 for enabled.') + ->param('httpUser', '', function () { return new Text(256); }, 'Webhook HTTP user.', true) + ->param('httpPass', '', function () { return new Text(256); }, 'Webhook HTTP password.', true) ->action( function ($projectId, $webhookId, $name, $events, $url, $security, $httpUser, $httpPass) use ($request, $response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } @@ -565,7 +563,7 @@ $utopia->put('/v1/projects/:projectId/webhooks/:webhookId') 'version' => '1', ]); - $webhook = $project->search('$uid', $webhookId, $project->getAttribute('webhooks', [])); + $webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', [])); if (empty($webhook) && $webhook instanceof Document) { throw new Exception('Webhook not found', 404); @@ -599,17 +597,17 @@ $utopia->delete('/v1/projects/:projectId/webhooks/:webhookId') function ($projectId, $webhookId) use ($response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } - $webhook = $project->search('$uid', $webhookId, $project->getAttribute('webhooks', [])); + $webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', [])); if (empty($webhook) && $webhook instanceof Document) { throw new Exception('Webhook not found', 404); } - if (!$consoleDB->deleteDocument($webhook->getUid())) { + if (!$consoleDB->deleteDocument($webhook->getId())) { throw new Exception('Failed to remove webhook from DB', 500); } @@ -619,62 +617,19 @@ $utopia->delete('/v1/projects/:projectId/webhooks/:webhookId') // Keys -$utopia->get('/v1/projects/:projectId/keys') - ->desc('List Keys') - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'listKeys') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $response->json($project->getAttribute('keys', [])); //FIXME make sure array objects return correctly - } - ); - -$utopia->get('/v1/projects/:projectId/keys/:keyId') - ->desc('Get Key') - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'getKey') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('keyId', null, function () { return new UID(); }, 'Key unique ID.') - ->action( - function ($projectId, $keyId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $key = $project->search('$uid', $keyId, $project->getAttribute('keys', [])); - - if (empty($key) && $key instanceof Document) { - throw new Exception('Key not found', 404); - } - - $response->json($key->getArrayCopy()); - } - ); - $utopia->post('/v1/projects/:projectId/keys') ->desc('Create Key') ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createKey') ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Key name') - ->param('scopes', null, function () use ($scopes) { return new ArrayList(new WhiteList($scopes)); }, 'Key scopes list') + ->param('name', null, function () { return new Text(256); }, 'Key name.') + ->param('scopes', null, function () use ($scopes) { return new ArrayList(new WhiteList($scopes)); }, 'Key scopes list.') ->action( function ($projectId, $name, $scopes) use ($response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } @@ -708,6 +663,49 @@ $utopia->post('/v1/projects/:projectId/keys') } ); +$utopia->get('/v1/projects/:projectId/keys') + ->desc('List Keys') + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'listKeys') + ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') + ->action( + function ($projectId) use ($response, $consoleDB) { + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $response->json($project->getAttribute('keys', [])); //FIXME make sure array objects return correctly + } + ); + +$utopia->get('/v1/projects/:projectId/keys/:keyId') + ->desc('Get Key') + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'getKey') + ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') + ->param('keyId', null, function () { return new UID(); }, 'Key unique ID.') + ->action( + function ($projectId, $keyId) use ($response, $consoleDB) { + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $key = $project->search('$id', $keyId, $project->getAttribute('keys', [])); + + if (empty($key) && $key instanceof Document) { + throw new Exception('Key not found', 404); + } + + $response->json($key->getArrayCopy()); + } + ); + $utopia->put('/v1/projects/:projectId/keys/:keyId') ->desc('Update Key') ->label('scope', 'projects.write') @@ -715,17 +713,17 @@ $utopia->put('/v1/projects/:projectId/keys/:keyId') ->label('sdk.method', 'updateKey') ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') ->param('keyId', null, function () { return new UID(); }, 'Key unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Key name') + ->param('name', null, function () { return new Text(256); }, 'Key name.') ->param('scopes', null, function () use ($scopes) { return new ArrayList(new WhiteList($scopes)); }, 'Key scopes list') ->action( function ($projectId, $keyId, $name, $scopes) use ($response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } - $key = $project->search('$uid', $keyId, $project->getAttribute('keys', [])); + $key = $project->search('$id', $keyId, $project->getAttribute('keys', [])); if (empty($key) && $key instanceof Document) { throw new Exception('Key not found', 404); @@ -755,17 +753,17 @@ $utopia->delete('/v1/projects/:projectId/keys/:keyId') function ($projectId, $keyId) use ($response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } - $key = $project->search('$uid', $keyId, $project->getAttribute('keys', [])); + $key = $project->search('$id', $keyId, $project->getAttribute('keys', [])); if (empty($key) && $key instanceof Document) { throw new Exception('Key not found', 404); } - if (!$consoleDB->deleteDocument($key->getUid())) { + if (!$consoleDB->deleteDocument($key->getId())) { throw new Exception('Failed to remove key from DB', 500); } @@ -775,90 +773,26 @@ $utopia->delete('/v1/projects/:projectId/keys/:keyId') // Tasks -$utopia->get('/v1/projects/:projectId/tasks') - ->desc('List Tasks') - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'listTasks') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $tasks = $project->getAttribute('tasks', []); - - foreach ($tasks as $task) { /* @var $task Document */ - $httpPass = json_decode($task->getAttribute('httpPass', '{}'), true); - - if (empty($httpPass) || !isset($httpPass['version'])) { - continue; - } - - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); - - $task->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, hex2bin($httpPass['iv']), hex2bin($httpPass['tag']))); - } - - $response->json($tasks); - } - ); - -$utopia->get('/v1/projects/:projectId/tasks/:taskId') - ->desc('Get Task') - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'getTask') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('taskId', null, function () { return new UID(); }, 'Task unique ID.') - ->action( - function ($projectId, $taskId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $task = $project->search('$uid', $taskId, $project->getAttribute('tasks', [])); - - if (empty($task) && $task instanceof Document) { - throw new Exception('Task not found', 404); - } - - $httpPass = json_decode($task->getAttribute('httpPass', '{}'), true); - - if (!empty($httpPass) && isset($httpPass['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); - $task->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, hex2bin($httpPass['iv']), hex2bin($httpPass['tag']))); - } - - $response->json($task->getArrayCopy()); - } - ); - $utopia->post('/v1/projects/:projectId/tasks') ->desc('Create Task') ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createTask') ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Task name') - ->param('status', null, function () { return new WhiteList(['play', 'pause']); }, 'Task status') - ->param('schedule', null, function () { return new Cron(); }, 'Task schedule syntax') - ->param('security', null, function () { return new Range(0, 1); }, 'Certificate verification, 0 for disabled or 1 for enabled') - ->param('httpMethod', '', function () { return new WhiteList(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT']); }, 'Task HTTP method') + ->param('name', null, function () { return new Text(256); }, 'Task name.') + ->param('status', null, function () { return new WhiteList(['play', 'pause']); }, 'Task status.') + ->param('schedule', null, function () { return new Cron(); }, 'Task schedule CRON syntax.') + ->param('security', null, function () { return new Range(0, 1); }, 'Certificate verification, 0 for disabled or 1 for enabled.') + ->param('httpMethod', '', function () { return new WhiteList(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT']); }, 'Task HTTP method.') ->param('httpUrl', '', function () { return new URL(); }, 'Task HTTP URL') - ->param('httpHeaders', null, function () { return new ArrayList(new Text(256)); }, 'Task HTTP headers list', true) - ->param('httpUser', '', function () { return new Text(256); }, 'Task HTTP user', true) - ->param('httpPass', '', function () { return new Text(256); }, 'Task HTTP password', true) + ->param('httpHeaders', null, function () { return new ArrayList(new Text(256)); }, 'Task HTTP headers list.', true) + ->param('httpUser', '', function () { return new Text(256); }, 'Task HTTP user.', true) + ->param('httpPass', '', function () { return new Text(256); }, 'Task HTTP password.', true) ->action( function ($projectId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass) use ($request, $response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } @@ -921,6 +855,70 @@ $utopia->post('/v1/projects/:projectId/tasks') } ); +$utopia->get('/v1/projects/:projectId/tasks') + ->desc('List Tasks') + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'listTasks') + ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') + ->action( + function ($projectId) use ($request, $response, $consoleDB) { + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $tasks = $project->getAttribute('tasks', []); + + foreach ($tasks as $task) { /* @var $task Document */ + $httpPass = json_decode($task->getAttribute('httpPass', '{}'), true); + + if (empty($httpPass) || !isset($httpPass['version'])) { + continue; + } + + $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); + + $task->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, hex2bin($httpPass['iv']), hex2bin($httpPass['tag']))); + } + + $response->json($tasks); + } + ); + +$utopia->get('/v1/projects/:projectId/tasks/:taskId') + ->desc('Get Task') + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'getTask') + ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') + ->param('taskId', null, function () { return new UID(); }, 'Task unique ID.') + ->action( + function ($projectId, $taskId) use ($request, $response, $consoleDB) { + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $task = $project->search('$id', $taskId, $project->getAttribute('tasks', [])); + + if (empty($task) && $task instanceof Document) { + throw new Exception('Task not found', 404); + } + + $httpPass = json_decode($task->getAttribute('httpPass', '{}'), true); + + if (!empty($httpPass) && isset($httpPass['version'])) { + $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); + $task->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, hex2bin($httpPass['iv']), hex2bin($httpPass['tag']))); + } + + $response->json($task->getArrayCopy()); + } + ); + $utopia->put('/v1/projects/:projectId/tasks/:taskId') ->desc('Update Task') ->label('scope', 'projects.write') @@ -928,24 +926,24 @@ $utopia->put('/v1/projects/:projectId/tasks/:taskId') ->label('sdk.method', 'updateTask') ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') ->param('taskId', null, function () { return new UID(); }, 'Task unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Task name') - ->param('status', null, function () { return new WhiteList(['play', 'pause']); }, 'Task status') - ->param('schedule', null, function () { return new Cron(); }, 'Task schedule syntax') - ->param('security', null, function () { return new Range(0, 1); }, 'Certificate verification, 0 for disabled or 1 for enabled') - ->param('httpMethod', '', function () { return new WhiteList(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT']); }, 'Task HTTP method') - ->param('httpUrl', '', function () { return new URL(); }, 'Task HTTP URL') - ->param('httpHeaders', null, function () { return new ArrayList(new Text(256)); }, 'Task HTTP headers list', true) - ->param('httpUser', '', function () { return new Text(256); }, 'Task HTTP user', true) - ->param('httpPass', '', function () { return new Text(256); }, 'Task HTTP password', true) + ->param('name', null, function () { return new Text(256); }, 'Task name.') + ->param('status', null, function () { return new WhiteList(['play', 'pause']); }, 'Task status.') + ->param('schedule', null, function () { return new Cron(); }, 'Task schedule CRON syntax.') + ->param('security', null, function () { return new Range(0, 1); }, 'Certificate verification, 0 for disabled or 1 for enabled.') + ->param('httpMethod', '', function () { return new WhiteList(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT']); }, 'Task HTTP method.') + ->param('httpUrl', '', function () { return new URL(); }, 'Task HTTP URL.') + ->param('httpHeaders', null, function () { return new ArrayList(new Text(256)); }, 'Task HTTP headers list.', true) + ->param('httpUser', '', function () { return new Text(256); }, 'Task HTTP user.', true) + ->param('httpPass', '', function () { return new Text(256); }, 'Task HTTP password.', true) ->action( function ($projectId, $taskId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass) use ($request, $response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } - $task = $project->search('$uid', $taskId, $project->getAttribute('tasks', [])); + $task = $project->search('$id', $taskId, $project->getAttribute('tasks', [])); if (empty($task) && $task instanceof Document) { throw new Exception('Task not found', 404); @@ -1002,17 +1000,17 @@ $utopia->delete('/v1/projects/:projectId/tasks/:taskId') function ($projectId, $taskId) use ($response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } - $task = $project->search('$uid', $taskId, $project->getAttribute('tasks', [])); + $task = $project->search('$id', $taskId, $project->getAttribute('tasks', [])); if (empty($task) && $task instanceof Document) { throw new Exception('Task not found', 404); } - if (!$consoleDB->deleteDocument($task->getUid())) { + if (!$consoleDB->deleteDocument($task->getId())) { throw new Exception('Failed to remove tasks from DB', 500); } @@ -1022,67 +1020,22 @@ $utopia->delete('/v1/projects/:projectId/tasks/:taskId') // Platforms -$utopia->get('/v1/projects/:projectId/platforms') - ->desc('List Platforms') - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'listPlatforms') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $platforms = $project->getAttribute('platforms', []); - - $response->json($platforms); - } - ); - -$utopia->get('/v1/projects/:projectId/platforms/:platformId') - ->desc('Get Platform') - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'getPlatform') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('platformId', null, function () { return new UID(); }, 'Platform unique ID.') - ->action( - function ($projectId, $platformId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $platform = $project->search('$uid', $platformId, $project->getAttribute('platforms', [])); - - if (empty($platform) && $platform instanceof Document) { - throw new Exception('Platform not found', 404); - } - - $response->json($platform->getArrayCopy()); - } - ); - $utopia->post('/v1/projects/:projectId/platforms') ->desc('Create Platform') ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createPlatform') ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('type', null, function () { return new WhiteList(['web', 'ios', 'android', 'unity']); }, 'Platform name') - ->param('name', null, function () { return new Text(256); }, 'Platform name') - ->param('key', '', function () { return new Text(256); }, 'Package name for android or bundle ID for iOS', true) - ->param('store', '', function () { return new Text(256); }, 'App store or Google Play store ID', true) - ->param('url', '', function () { return new URL(); }, 'Platform client URL', true) + ->param('type', null, function () { return new WhiteList(['web', 'ios', 'android', 'unity']); }, 'Platform type.') + ->param('name', null, function () { return new Text(256); }, 'Platform name.') + ->param('key', '', function () { return new Text(256); }, 'Package name for android or bundle ID for iOS.', true) + ->param('store', '', function () { return new Text(256); }, 'App store or Google Play store ID.', true) + ->param('url', '', function () { return new URL(); }, 'Platform client URL.', true) ->action( function ($projectId, $type, $name, $key, $store, $url) use ($response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } @@ -1119,6 +1072,51 @@ $utopia->post('/v1/projects/:projectId/platforms') ; } ); + +$utopia->get('/v1/projects/:projectId/platforms') + ->desc('List Platforms') + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'listPlatforms') + ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') + ->action( + function ($projectId) use ($request, $response, $consoleDB) { + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $platforms = $project->getAttribute('platforms', []); + + $response->json($platforms); + } + ); + +$utopia->get('/v1/projects/:projectId/platforms/:platformId') + ->desc('Get Platform') + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'getPlatform') + ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') + ->param('platformId', null, function () { return new UID(); }, 'Platform unique ID.') + ->action( + function ($projectId, $platformId) use ($request, $response, $consoleDB) { + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $platform = $project->search('$id', $platformId, $project->getAttribute('platforms', [])); + + if (empty($platform) && $platform instanceof Document) { + throw new Exception('Platform not found', 404); + } + + $response->json($platform->getArrayCopy()); + } + ); $utopia->put('/v1/projects/:projectId/platforms/:platformId') ->desc('Update Platform') @@ -1127,19 +1125,19 @@ $utopia->put('/v1/projects/:projectId/platforms/:platformId') ->label('sdk.method', 'updatePlatform') ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') ->param('platformId', null, function () { return new UID(); }, 'Platform unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Platform name') - ->param('key', '', function () { return new Text(256); }, 'Package name for android or bundle ID for iOS', true) - ->param('store', '', function () { return new Text(256); }, 'App store or Google Play store ID', true) - ->param('url', '', function () { return new URL(); }, 'Platform client URL', true) + ->param('name', null, function () { return new Text(256); }, 'Platform name.') + ->param('key', '', function () { return new Text(256); }, 'Package name for android or bundle ID for iOS.', true) + ->param('store', '', function () { return new Text(256); }, 'App store or Google Play store ID.', true) + ->param('url', '', function () { return new URL(); }, 'Platform client URL.', true) ->action( function ($projectId, $platformId, $name, $key, $store, $url) use ($response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } - $platform = $project->search('$uid', $platformId, $project->getAttribute('platforms', [])); + $platform = $project->search('$id', $platformId, $project->getAttribute('platforms', [])); if (empty($platform) && $platform instanceof Document) { throw new Exception('Platform not found', 404); @@ -1172,20 +1170,20 @@ $utopia->delete('/v1/projects/:projectId/platforms/:platformId') function ($projectId, $platformId) use ($response, $consoleDB) { $project = $consoleDB->getDocument($projectId); - if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } - $platform = $project->search('$uid', $platformId, $project->getAttribute('platforms', [])); + $platform = $project->search('$id', $platformId, $project->getAttribute('platforms', [])); if (empty($platform) && $platform instanceof Document) { throw new Exception('Platform not found', 404); } - if (!$consoleDB->deleteDocument($platform->getUid())) { + if (!$consoleDB->deleteDocument($platform->getId())) { throw new Exception('Failed to remove platform from DB', 500); } $response->noContent(); } - ); + ); \ No newline at end of file diff --git a/app/controllers/storage.php b/app/controllers/api/storage.php similarity index 75% rename from app/controllers/storage.php rename to app/controllers/api/storage.php index a8c342354f..5ded8df37a 100644 --- a/app/controllers/storage.php +++ b/app/controllers/api/storage.php @@ -23,9 +23,9 @@ use Storage\Compression\Algorithms\GZIP; use Resize\Resize; use OpenSSL\OpenSSL; -include_once 'shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; -Storage::addDevice('local', new Local('/storage/uploads/app-'.$project->getUid())); +Storage::addDevice('local', new Local('/storage/uploads/app-'.$project->getId())); $fileLogos = [ // Based on this list @see http://stackoverflow.com/a/4212908/2299554 'default' => 'default.gif', @@ -116,9 +116,144 @@ $mimes = [ 'application/pdf', ]; +$utopia->post('/v1/storage/files') + ->desc('Create File') + ->label('scope', 'files.write') + ->label('webhook', 'storage.files.create') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'storage') + ->label('sdk.method', 'createFile') + ->label('sdk.description', '/docs/references/storage/create-file.md') + ->label('sdk.consumes', 'multipart/form-data') + ->param('file', [], function () { return new File(); }, 'Binary File.', false) + ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') + ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') + // ->param('folderId', '', function () { return new UID(); }, 'Folder to associate files with.', true) + ->action( + function ($file, $read, $write, $folderId = '') use ($request, $response, $user, $projectDB, $webhook, $audit, $usage) { + $file = $request->getFiles('file'); + $read = (empty($read)) ? ['user:'.$user->getId()] : $read; + $write = (empty($write)) ? ['user:'.$user->getId()] : $write; + + /* + * Validators + */ + //$fileType = new FileType(array(FileType::FILE_TYPE_PNG, FileType::FILE_TYPE_GIF, FileType::FILE_TYPE_JPEG)); + $fileSize = new FileSize($request->getServer('_APP_STORAGE_LIMIT', 0)); + $upload = new Upload(); + + if (empty($file)) { + throw new Exception('No file sent', 400); + } + + // Make sure we handle a single file and multiple files the same way + $file['name'] = (is_array($file['name']) && isset($file['name'][0])) ? $file['name'][0] : $file['name']; + $file['tmp_name'] = (is_array($file['tmp_name']) && isset($file['tmp_name'][0])) ? $file['tmp_name'][0] : $file['tmp_name']; + $file['size'] = (is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size']; + + // Check if file type is allowed (feature for project settings?) + //if (!$fileType->isValid($file['tmp_name'])) { + //throw new Exception('File type not allowed', 400); + //} + + // Check if file size is exceeding allowed limit + if (!$fileSize->isValid($file['size'])) { + throw new Exception('File size not allowed', 400); + } + + $antiVirus = new Network('clamav', 3310); + + /* + * Models + */ + $list = []; + $device = Storage::getDevice('local'); + + if (!$upload->isValid($file['tmp_name'])) { + throw new Exception('Invalid file', 403); + } + + // Save to storage + $size = $device->getFileSize($file['tmp_name']); + $path = $device->getPath(uniqid().'.'.pathinfo($file['name'], PATHINFO_EXTENSION)); + + if (!$device->upload($file['tmp_name'], $path)) { // TODO deprecate 'upload' and replace with 'move' + throw new Exception('Failed moving file', 500); + } + + $mimeType = $device->getFileMimeType($path); // Get mime-type before compression and encryption + + // Check if file size is exceeding allowed limit + if (!$antiVirus->fileScan($path)) { + $device->delete($path); + throw new Exception('Invalid file', 403); + } + + // Compression + $compressor = new GZIP(); + $data = $device->read($path); + $data = $compressor->compress($data); + $key = $request->getServer('_APP_OPENSSL_KEY_V1'); + $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); + $data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag); + + if(!$device->write($path, $data)) { + throw new Exception('Failed to save file', 500); + } + + $sizeActual = $device->getFileSize($path); + + $file = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_FILES, + '$permissions' => [ + 'read' => $read, + 'write' => $write, + ], + 'dateCreated' => time(), + 'folderId' => $folderId, + 'name' => $file['name'], + 'path' => $path, + 'signature' => $device->getFileHash($path), + 'mimeType' => $mimeType, + 'sizeOriginal' => $size, + 'sizeActual' => $sizeActual, + 'algorithm' => $compressor->getName(), + 'token' => bin2hex(random_bytes(64)), + 'comment' => '', + 'fileOpenSSLVersion' => '1', + 'fileOpenSSLCipher' => OpenSSL::CIPHER_AES_128_GCM, + 'fileOpenSSLTag' => bin2hex($tag), + 'fileOpenSSLIV' => bin2hex($iv), + ]); + + if (false === $file) { + throw new Exception('Failed saving file to DB', 500); + } + + $webhook + ->setParam('payload', $file->getArrayCopy()) + ; + + $audit + ->setParam('event', 'storage.files.create') + ->setParam('resource', 'storage/files/'.$file->getId()) + ; + + $usage + ->setParam('storage', $sizeActual) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->json($file->getArrayCopy()) + ; + } + ); + $utopia->get('/v1/storage/files') ->desc('List Files') ->label('scope', 'files.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'listFiles') ->label('sdk.description', '/docs/references/storage/list-files.md') @@ -141,7 +276,7 @@ $utopia->get('/v1/storage/files') ]); $results = array_map(function ($value) { /* @var $value \Database\Document */ - return $value->getArrayCopy(['$uid', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal']); + return $value->getArrayCopy(['$id', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal']); }, $results); $response->json(['sum' => $projectDB->getSum(), 'files' => $results]); @@ -151,6 +286,7 @@ $utopia->get('/v1/storage/files') $utopia->get('/v1/storage/files/:fileId') ->desc('Get File') ->label('scope', 'files.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFile') ->label('sdk.description', '/docs/references/storage/get-file.md') @@ -159,26 +295,29 @@ $utopia->get('/v1/storage/files/:fileId') function ($fileId) use ($response, $projectDB) { $file = $projectDB->getDocument($fileId); - if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { throw new Exception('File not found', 404); } - $response->json($file->getArrayCopy(['$uid', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal'])); + $response->json($file->getArrayCopy(['$id', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal'])); } ); $utopia->get('/v1/storage/files/:fileId/preview') ->desc('Get File Preview') ->label('scope', 'files.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFilePreview') ->label('sdk.description', '/docs/references/storage/get-file-preview.md') + ->label('sdk.response.type', 'image/*') + ->label('sdk.location', true) ->param('fileId', '', function () { return new UID(); }, 'File unique ID') - ->param('width', 0, function () { return new Range(0, 4000); }, 'Resize preview image width, Pass an integer between 0 to 4000', true) - ->param('height', 0, function () { return new Range(0, 4000); }, 'Resize preview image height, Pass an integer between 0 to 4000', true) - ->param('quality', 100, function () { return new Range(0, 100); }, 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100', true) + ->param('width', 0, function () { return new Range(0, 4000); }, 'Resize preview image width, Pass an integer between 0 to 4000.', true) + ->param('height', 0, function () { return new Range(0, 4000); }, 'Resize preview image height, Pass an integer between 0 to 4000.', true) + ->param('quality', 100, function () { return new Range(0, 100); }, 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true) ->param('background', '', function () { return new HexColor(); }, 'Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.', true) - ->param('output', null, function () use ($outputs) { return new WhiteList(array_merge(array_keys($outputs), [null])); }, 'Output format type (jpeg, jpg, png, gif and webp)', true) + ->param('output', null, function () use ($outputs) { return new WhiteList(array_merge(array_keys($outputs), [null])); }, 'Output format type (jpeg, jpg, png, gif and webp).', true) //->param('storage', 'local', function () {return new WhiteList(array('local'));}, 'Selected storage device. defaults to local') //->param('token', '', function () {return new Text(128);}, 'Preview token', true) ->action( @@ -202,7 +341,7 @@ $utopia->get('/v1/storage/files/:fileId/preview') $file = $projectDB->getDocument($fileId); - if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { throw new Exception('File not found', 404); } @@ -218,7 +357,7 @@ $utopia->get('/v1/storage/files/:fileId/preview') throw new Exception('File not found in '.$path, 404); } - $cache = new Cache(new Filesystem('/storage/cache/app-'.$project->getUid())); // Limit file number or size + $cache = new Cache(new Filesystem('/storage/cache/app-'.$project->getId())); // Limit file number or size $data = $cache->load($key, 60 * 60 * 24 * 30 * 3 /* 3 months */); if ($data) { @@ -228,8 +367,10 @@ $utopia->get('/v1/storage/files/:fileId/preview') ->setContentType((in_array($output, $outputs)) ? $outputs[$output] : $outputs['jpg']) ->addHeader('Expires', $date) ->addHeader('X-Appwrite-Cache', 'hit') - ->send($data, 0) + ->send($data) ; + + return; } $source = $device->read($path); @@ -263,7 +404,7 @@ $utopia->get('/v1/storage/files/:fileId/preview') ->setContentType($outputs[$output]) ->addHeader('Expires', $date) ->addHeader('X-Appwrite-Cache', 'miss') - ->send('', null) + ->send('') ; $data = $resize->output($output, $quality); @@ -273,23 +414,24 @@ $utopia->get('/v1/storage/files/:fileId/preview') echo $data; unset($resize); - - exit(0); } ); $utopia->get('/v1/storage/files/:fileId/download') ->desc('Get File for Download') ->label('scope', 'files.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFileDownload') ->label('sdk.description', '/docs/references/storage/get-file-download.md') + ->label('sdk.response.type', '*') + ->label('sdk.location', true) ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') ->action( function ($fileId) use ($response, $request, $projectDB) { $file = $projectDB->getDocument($fileId); - if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { throw new Exception('File not found', 404); } @@ -331,16 +473,19 @@ $utopia->get('/v1/storage/files/:fileId/download') $utopia->get('/v1/storage/files/:fileId/view') ->desc('Get File for View') ->label('scope', 'files.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFileView') ->label('sdk.description', '/docs/references/storage/get-file-view.md') + ->label('sdk.response.type', '*') + ->label('sdk.location', true) ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') ->param('as', '', function () { return new WhiteList(['pdf', /*'html',*/ 'text']); }, 'Choose a file format to convert your file to. Currently you can only convert word and pdf files to pdf or txt. This option is currently experimental only, use at your own risk.', true) ->action( function ($fileId, $as) use ($response, $request, $projectDB, $mimes) { $file = $projectDB->getDocument($fileId); - if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { throw new Exception('File not found', 404); } @@ -395,146 +540,11 @@ $utopia->get('/v1/storage/files/:fileId/view') } ); -$utopia->post('/v1/storage/files') - ->desc('Create File') - ->label('scope', 'files.write') - ->label('sdk.namespace', 'storage') - ->label('sdk.method', 'createFile') - ->label('sdk.description', '/docs/references/storage/create-file.md') - ->label('sdk.consumes', 'multipart/form-data') - ->param('files', [], function () { return new File(); }, 'Binary Files.', false) - ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - // ->param('folderId', '', function () { return new UID(); }, 'Folder to associate files with.', true) - ->action( - function ($files, $read, $write, $folderId = '') use ($request, $response, $user, $projectDB, $audit, $usage) { - $files = $request->getFiles('files'); - $read = (empty($read)) ? ['user:'.$user->getUid()] : $read; - $write = (empty($write)) ? ['user:'.$user->getUid()] : $write; - - /* - * Validators - */ - //$fileType = new FileType(array(FileType::FILE_TYPE_PNG, FileType::FILE_TYPE_GIF, FileType::FILE_TYPE_JPEG)); - $fileSize = new FileSize(2097152 * 2); // 4MB - $upload = new Upload(); - - if (empty($files)) { - throw new Exception('No files sent', 400); - } - - // Make sure we handle single file and multiple files the same way - $files['name'] = (is_array($files['name'])) ? $files['name'] : [$files['name']]; - $files['tmp_name'] = (is_array($files['tmp_name'])) ? $files['tmp_name'] : [$files['tmp_name']]; - $files['size'] = (is_array($files['size'])) ? $files['size'] : [$files['size']]; - - // Check if file type is allowed - //foreach ($files['tmp_name'] as $tmpName) { - //if (!$fileType->isValid($tmpName)) { - //throw new Exception('File type not allowed', 400); - //} - //} - - // Check if file size is exceeding allowed limit - foreach ($files['size'] as $tmpSize) { - if (!$fileSize->isValid($tmpSize)) { - throw new Exception('File size not allowed', 400); - } - } - - $antiVirus = new Network('clamav', 3310); - - /* - * Models - */ - $list = []; - $device = Storage::getDevice('local'); - - foreach ($files['tmp_name'] as $i => $tmpName) { - if (!$upload->isValid($tmpName)) { - throw new Exception('Invalid file', 403); - } - - // Save to storage - $name = $files['name'][$i]; - $size = $device->getFileSize($tmpName); - $path = $device->getPath(uniqid().'.'.pathinfo($name, PATHINFO_EXTENSION)); - - if (!$device->upload($tmpName, $path)) { // TODO deprecate 'upload' and replace with 'move' - throw new Exception('Failed moving file', 500); - } - - $mimeType = $device->getFileMimeType($path); // Get mime-type before compression and encryption - - // Check if file size is exceeding allowed limit - if (!$antiVirus->fileScan($path)) { - $device->delete($path); - throw new Exception('Invalid file', 403); - } - - // Compression - $compressor = new GZIP(); - $data = $device->read($path); - $data = $compressor->compress($data); - $key = $request->getServer('_APP_OPENSSL_KEY_V1'); - $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); - $data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag); - - if(!$device->write($path, $data)) { - throw new Exception('Failed to save file', 500); - } - - $sizeActual = $device->getFileSize($path); - - $file = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_FILES, - '$permissions' => [ - 'read' => $read, - 'write' => $write, - ], - 'dateCreated' => time(), - 'folderId' => $folderId, - 'name' => $name, - 'path' => $path, - 'signature' => $device->getFileHash($path), - 'mimeType' => $mimeType, - 'sizeOriginal' => $size, - 'sizeActual' => $sizeActual, - 'algorithm' => $compressor->getName(), - 'token' => bin2hex(random_bytes(64)), - 'comment' => '', - 'fileOpenSSLVersion' => '1', - 'fileOpenSSLCipher' => OpenSSL::CIPHER_AES_128_GCM, - 'fileOpenSSLTag' => bin2hex($tag), - 'fileOpenSSLIV' => bin2hex($iv), - ]); - - if (false === $file) { - throw new Exception('Failed saving file to DB', 500); - } - - $audit - ->setParam('event', 'storage.upload') - ->setParam('resource', 'storage/file/'.$file->getUid()) - ; - - $usage - ->setParam('storage', $sizeActual) - ; - - $list[] = $file->getArrayCopy(); - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($list) - ; - } - ); - $utopia->put('/v1/storage/files/:fileId') ->desc('Update File') ->label('scope', 'files.write') + ->label('webhook', 'storage.files.update') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'updateFile') ->label('sdk.description', '/docs/references/storage/update-file.md') @@ -543,10 +553,10 @@ $utopia->put('/v1/storage/files/:fileId') ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') //->param('folderId', '', function () { return new UID(); }, 'Folder to associate files with.', true) ->action( - function ($fileId, $read, $write, $folderId = '') use ($response, $projectDB) { + function ($fileId, $read, $write, $folderId = '') use ($response, $projectDB, $audit, $webhook) { $file = $projectDB->getDocument($fileId); - if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { throw new Exception('File not found', 404); } @@ -562,6 +572,15 @@ $utopia->put('/v1/storage/files/:fileId') throw new Exception('Failed saving file to DB', 500); } + $webhook + ->setParam('payload', $file->getArrayCopy()) + ; + + $audit + ->setParam('event', 'storage.files.update') + ->setParam('resource', 'storage/files/'.$file->getId()) + ; + $response->json($file->getArrayCopy()); } ); @@ -569,15 +588,17 @@ $utopia->put('/v1/storage/files/:fileId') $utopia->delete('/v1/storage/files/:fileId') ->desc('Delete File') ->label('scope', 'files.write') + ->label('webhook', 'storage.files.delete') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'deleteFile') ->label('sdk.description', '/docs/references/storage/delete-file.md') ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') ->action( - function ($fileId) use ($response, $projectDB, $audit, $usage) { + function ($fileId) use ($response, $projectDB, $webhook, $audit, $usage) { $file = $projectDB->getDocument($fileId); - if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { throw new Exception('File not found', 404); } @@ -589,9 +610,13 @@ $utopia->delete('/v1/storage/files/:fileId') } } + $webhook + ->setParam('payload', $file->getArrayCopy()) + ; + $audit - ->setParam('event', 'storage.delete') - ->setParam('resource', 'storage/file/'.$file->getUid()) + ->setParam('event', 'storage.files.delete') + ->setParam('resource', 'storage/files/'.$file->getId()) ; $usage @@ -605,17 +630,17 @@ $utopia->delete('/v1/storage/files/:fileId') $utopia->get('/v1/storage/files/:fileId/scan') ->desc('Scan Storage') ->label('scope', 'god') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFileScan') ->label('sdk.hide', true) ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') - ->param('storage', 'local', function () { return new WhiteList(['local']); - }) + ->param('storage', 'local', function () { return new WhiteList(['local']);}) ->action( function ($fileId, $storage) use ($response, $request, $projectDB) { $file = $projectDB->getDocument($fileId); - if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { throw new Exception('File not found', 404); } diff --git a/app/controllers/teams.php b/app/controllers/api/teams.php similarity index 59% rename from app/controllers/teams.php rename to app/controllers/api/teams.php index f2715853f7..d14e9fb046 100644 --- a/app/controllers/teams.php +++ b/app/controllers/api/teams.php @@ -18,13 +18,77 @@ use Database\Validator\Authorization; use Template\Template; use Auth\Auth; -include_once 'shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; + +$utopia->post('/v1/teams') + ->desc('Create Team') + ->label('scope', 'teams.write') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'teams') + ->label('sdk.method', 'create') + ->label('sdk.description', '/docs/references/teams/create-team.md') + ->param('name', null, function () { return new Text(100); }, 'Team name.') + ->param('roles', ['owner'], function () { return new ArrayList(new Text(128)); }, 'Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions).', true) + ->action( + function ($name, $roles) use ($response, $projectDB, $user, $mode) { + Authorization::disable(); + + $team = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_TEAMS, + '$permissions' => [ + 'read' => ['team:{self}'], + 'write' => ['team:{self}/owner'], + ], + 'name' => $name, + 'sum' => ($mode !== APP_MODE_ADMIN && $user->getId()) ? 1 : 0, + 'dateCreated' => time(), + ]); + + Authorization::reset(); + + if (false === $team) { + throw new Exception('Failed saving team to DB', 500); + } + + if ($mode !== APP_MODE_ADMIN && $user->getId()) { // Don't add user on server mode + $membership = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, + '$permissions' => [ + 'read' => ['user:'.$user->getId(), 'team:'.$team->getId()], + 'write' => ['user:'.$user->getId(), 'team:'.$team->getId().'/owner'], + ], + 'userId' => $user->getId(), + 'teamId' => $team->getId(), + 'roles' => $roles, + 'invited' => time(), + 'joined' => time(), + 'confirm' => true, + 'secret' => '', + ]); + + // Attach user to team + $user->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND); + + $user = $projectDB->updateDocument($user->getArrayCopy()); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + } + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->json($team->getArrayCopy()) + ; + } + ); $utopia->get('/v1/teams') ->desc('List Teams') ->label('scope', 'teams.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'listTeams') + ->label('sdk.method', 'list') ->label('sdk.description', '/docs/references/teams/list-teams.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) @@ -51,15 +115,16 @@ $utopia->get('/v1/teams') $utopia->get('/v1/teams/:teamId') ->desc('Get Team') ->label('scope', 'teams.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'getTeam') + ->label('sdk.method', 'get') ->label('sdk.description', '/docs/references/teams/get-team.md') ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') ->action( function ($teamId) use ($response, $projectDB) { $team = $projectDB->getDocument($teamId); - if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { throw new Exception('Team not found', 404); } @@ -67,125 +132,12 @@ $utopia->get('/v1/teams/:teamId') } ); -$utopia->get('/v1/teams/:teamId/members') - ->desc('Get Team Members') - ->label('scope', 'teams.read') - ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'getTeamMembers') - ->label('sdk.description', '/docs/references/teams/get-team-members.md') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->action( - function ($teamId) use ($response, $projectDB) { - $team = $projectDB->getDocument($teamId); - - if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } - - $memberships = $projectDB->getCollection([ - 'limit' => 50, - 'offset' => 0, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS, - 'teamId='.$teamId, - ], - ]); - - $users = []; - - foreach ($memberships as $member) { - if (empty($member->getAttribute('userId', null))) { - continue; - } - - $temp = $projectDB->getDocument($member->getAttribute('userId', null))->getArrayCopy(['$uid', 'email', 'name']); - - $temp['inviteId'] = $member->getUid(); - $temp['roles'] = $member->getAttribute('roles', []); - $temp['confirm'] = $member->getAttribute('confirm', false); - $temp['joined'] = $member->getAttribute('joined', 0); - $users[] = $temp; - } - - usort($users, function ($a, $b) { - if ($a['joined'] === 0 || $b['joined'] === 0) { - return $b['joined'] - $a['joined']; - } - - return $a['joined'] - $b['joined']; - }); - - $response->json($users); - } - ); - -$utopia->post('/v1/teams') - ->desc('Create Team') - ->label('scope', 'teams.write') - ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'createTeam') - ->label('sdk.description', '/docs/references/teams/create-team.md') - ->param('name', null, function () { return new Text(100); }, 'Team name.') - ->param('roles', ['owner'], function () { return new ArrayList(new Text(128)); }, 'User roles array. Use this param to set the roles in the team for the user who created the team. The default role is **owner**, a role can be any string.', true) - ->action( - function ($name, $roles) use ($response, $projectDB, $user, $mode) { - Authorization::disable(); - - $team = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_TEAMS, - '$permissions' => [ - 'read' => ['team:{self}'], - 'write' => ['team:{self}/owner'], - ], - 'name' => $name, - 'sum' => ($mode !== APP_MODE_ADMIN) ? 1 : 0, - 'dateCreated' => time(), - ]); - - Authorization::enable(); - - if (false === $team) { - throw new Exception('Failed saving team to DB', 500); - } - - if ($mode !== APP_MODE_ADMIN) { // Don't add user on admin mode - $membership = new Document([ - '$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, - '$permissions' => [ - 'read' => ['user:'.$user->getUid(), 'team:'.$team->getUid()], - 'write' => ['user:'.$user->getUid(), 'team:'.$team->getUid().'/owner'], - ], - 'userId' => $user->getUid(), - 'teamId' => $team->getUid(), - 'roles' => $roles, - 'invited' => time(), - 'joined' => time(), - 'confirm' => true, - 'secret' => '', - ]); - - // Attach user to team - $user->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND); - - $user = $projectDB->updateDocument($user->getArrayCopy()); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($team->getArrayCopy()) - ; - } - ); - $utopia->put('/v1/teams/:teamId') ->desc('Update Team') ->label('scope', 'teams.write') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'updateTeam') + ->label('sdk.method', 'update') ->label('sdk.description', '/docs/references/teams/update-team.md') ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') ->param('name', null, function () { return new Text(100); }, 'Team name.') @@ -193,7 +145,7 @@ $utopia->put('/v1/teams/:teamId') function ($teamId, $name) use ($response, $projectDB) { $team = $projectDB->getDocument($teamId); - if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { throw new Exception('Team not found', 404); } @@ -212,15 +164,16 @@ $utopia->put('/v1/teams/:teamId') $utopia->delete('/v1/teams/:teamId') ->desc('Delete Team') ->label('scope', 'teams.write') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'deleteTeam') + ->label('sdk.method', 'delete') ->label('sdk.description', '/docs/references/teams/delete-team.md') ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') ->action( function ($teamId) use ($response, $projectDB) { $team = $projectDB->getDocument($teamId); - if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { throw new Exception('Team not found', 404); } @@ -234,7 +187,7 @@ $utopia->delete('/v1/teams/:teamId') ]); foreach ($memberships as $member) { - if (!$projectDB->deleteDocument($member)) { + if (!$projectDB->deleteDocument($member->getId())) { throw new Exception('Failed to remove membership for team from DB', 500); } } @@ -247,25 +200,24 @@ $utopia->delete('/v1/teams/:teamId') } ); -// Memberships - $utopia->post('/v1/teams/:teamId/memberships') ->desc('Create Team Membership') - ->label('scope', 'account') + ->label('scope', 'teams.write') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'createTeamMembership') + ->label('sdk.method', 'createMembership') ->label('sdk.description', '/docs/references/teams/create-team-membership.md') ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('email', '', function () { return new Email(); }, 'New team member email address.') + ->param('email', '', function () { return new Email(); }, 'New team member email.') ->param('name', '', function () { return new Text(100); }, 'New team member name.', true) - ->param('roles', [], function () { return new ArrayList(new Text(128)); }, 'Invite roles array. Learn more about [roles and permissions](/docs/permissions).') - ->param('redirect', '', function () use ($clients) { return new Host($clients); }, 'Reset page to redirect user back to your app from the invitation email.') + ->param('roles', [], function () { return new ArrayList(new Text(128)); }, 'Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions).') + ->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the invitation email.') // TODO add our own built-in confirm page ->action( - function ($teamId, $email, $name, $roles, $redirect) use ($response, $register, $project, $user, $audit, $projectDB) { + function ($teamId, $email, $name, $roles, $url) use ($response, $register, $project, $user, $audit, $projectDB) { $name = (empty($name)) ? $email : $name; $team = $projectDB->getDocument($teamId); - if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { throw new Exception('Team not found', 404); } @@ -274,7 +226,7 @@ $utopia->post('/v1/teams/:teamId/memberships') 'offset' => 0, 'filters' => [ '$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS, - 'teamId='.$team->getUid(), + 'teamId='.$team->getId(), ], ]); @@ -298,17 +250,17 @@ $utopia->post('/v1/teams/:teamId/memberships') 'write' => ['user:{self}'], ], 'email' => $email, + 'emailVerification' => false, 'status' => Auth::USER_STATUS_UNACTIVATED, 'password' => Auth::passwordHash(Auth::passwordGenerator()), 'password-update' => time(), 'registration' => time(), - 'confirm' => false, 'reset' => false, 'name' => $name, 'tokens' => [], ]); - Authorization::enable(); + Authorization::reset(); if (false === $invitee) { throw new Exception('Failed saving user to DB', 500); @@ -318,11 +270,11 @@ $utopia->post('/v1/teams/:teamId/memberships') $isOwner = false; foreach ($memberships as $member) { - if ($member->getAttribute('userId') == $invitee->getUid()) { - throw new Exception('User has already been invited or is already a member of this team', 400); + if ($member->getAttribute('userId') == $invitee->getId()) { + throw new Exception('User has already been invited or is already a member of this team', 409); } - if ($member->getAttribute('userId') == $user->getUid() && in_array('owner', $member->getAttribute('roles', []))) { + if ($member->getAttribute('userId') == $user->getId() && in_array('owner', $member->getAttribute('roles', []))) { $isOwner = true; } } @@ -337,10 +289,10 @@ $utopia->post('/v1/teams/:teamId/memberships') '$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, '$permissions' => [ 'read' => ['*'], - 'write' => ['user:'.$invitee->getUid(), 'team:'.$team->getUid().'/owner'], + 'write' => ['user:'.$invitee->getId(), 'team:'.$team->getId().'/owner'], ], - 'userId' => $invitee->getUid(), - 'teamId' => $team->getUid(), + 'userId' => $invitee->getId(), + 'teamId' => $team->getId(), 'roles' => $roles, 'invited' => time(), 'joined' => 0, @@ -354,210 +306,179 @@ $utopia->post('/v1/teams/:teamId/memberships') throw new Exception('Failed saving membership to DB', 500); } - $redirect = Template::parseURL($redirect); - $redirect['query'] = Template::mergeQuery(((isset($redirect['query'])) ? $redirect['query'] : ''), ['inviteId' => $membership->getUid(), 'teamId' => $team->getUid(), 'userId' => $invitee->getUid(), 'secret' => $secret]); - $redirect = Template::unParseURL($redirect); + $url = Template::parseURL($url); + $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['inviteId' => $membership->getId(), 'teamId' => $team->getId(), 'userId' => $invitee->getId(), 'secret' => $secret, 'teamId' => $teamId]); + $url = Template::unParseURL($url); - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.invitation.body')); + $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.invitation.body')); $body ->setParam('{{direction}}', Locale::getText('settings.direction')) ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) ->setParam('{{team}}', $team->getAttribute('name', '[TEAM-NAME]')) ->setParam('{{owner}}', $user->getAttribute('name', '')) - ->setParam('{{redirect}}', $redirect) + ->setParam('{{redirect}}', $url) ; $mail = $register->get('smtp'); /* @var $mail \PHPMailer\PHPMailer\PHPMailer */ $mail->addAddress($email, $name); - $mail->Subject = sprintf(Locale::getText('auth.emails.invitation.title'), $team->getAttribute('name', '[TEAM-NAME]'), $project->getAttribute('name', ['[APP-NAME]'])); + $mail->Subject = sprintf(Locale::getText('account.emails.invitation.title'), $team->getAttribute('name', '[TEAM-NAME]'), $project->getAttribute('name', ['[APP-NAME]'])); $mail->Body = $body->render(); $mail->AltBody = strip_tags($body->render()); try { $mail->send(); } catch (\Exception $error) { - //throw new Exception('Problem sending mail: ' . $error->getMessage(), 500); + throw new Exception('Error sending mail: ' . $error->getMessage(), 500); } $audit - ->setParam('userId', $invitee->getUid()) - ->setParam('event', 'auth.invite') + ->setParam('userId', $invitee->getId()) + ->setParam('event', 'teams.membership.create') + ->setParam('resource', 'teams/'.$teamId) ; $response - //->setStatusCode(Response::STATUS_CODE_CREATED) TODO change response of this endpoint - ->noContent(); + ->setStatusCode(Response::STATUS_CODE_CREATED) // TODO change response of this endpoint + ->json(array_merge($membership->getArrayCopy([ + '$id', + 'userId', + 'teamId', + 'roles', + 'invited', + 'joined', + 'confirm', + ]), [ + 'email' => $email, + 'name' => $name, + ])) + ; } ); -$utopia->post('/v1/teams/:teamId/memberships/:inviteId/resend') - ->desc('Create Team Membership (Resend)') - ->label('scope', 'account') +$utopia->get('/v1/teams/:teamId/memberships') + ->desc('Get Team Memberships') + ->label('scope', 'teams.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'createTeamMembershipResend') - ->label('sdk.description', '/docs/references/teams/create-team-membership-resend.md') + ->label('sdk.method', 'getMemberships') + ->label('sdk.description', '/docs/references/teams/get-team-members.md') ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('inviteId', '', function () { return new UID(); }, 'Invite unique ID.') - ->param('redirect', '', function () use ($clients) { return new Host($clients); }, 'Reset page to redirect user back to your app from the invitation email.') ->action( - function ($teamId, $inviteId, $redirect) use ($response, $register, $project, $user, $audit, $projectDB) { - $membership = $projectDB->getDocument($inviteId); + function ($teamId) use ($response, $projectDB) { + $team = $projectDB->getDocument($teamId); - if (empty($membership->getUid()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) { - throw new Exception('Membership not found', 404); - } - - $team = $projectDB->getDocument($membership->getAttribute('teamId')); - - if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { throw new Exception('Team not found', 404); } - if ($team->getUid() !== $teamId) { - throw new Exception('Team IDs don\'t match', 404); + $memberships = $projectDB->getCollection([ + 'limit' => 50, + 'offset' => 0, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS, + 'teamId='.$teamId, + ], + ]); + + $users = []; + + foreach ($memberships as $membership) { + if (empty($membership->getAttribute('userId', null))) { + continue; + } + + $temp = $projectDB->getDocument($membership->getAttribute('userId', null))->getArrayCopy(['email', 'name']); + + $users[] = array_merge($temp, $membership->getArrayCopy([ + '$id', + 'userId', + 'teamId', + 'roles', + 'invited', + 'joined', + 'confirm', + ])); } - $invitee = $projectDB->getDocument($membership->getAttribute('userId')); + usort($users, function ($a, $b) { + if ($a['joined'] === 0 || $b['joined'] === 0) { + return $b['joined'] - $a['joined']; + } - if (empty($invitee->getUid()) || Database::SYSTEM_COLLECTION_USERS != $invitee->getCollection()) { - throw new Exception('User not found', 404); - } + return $a['joined'] - $b['joined']; + }); - $secret = Auth::tokenGenerator(); - - $membership = $projectDB->updateDocument(array_merge($membership->getArrayCopy(), ['secret' => Auth::hash($secret)])); - - if (false === $membership) { - throw new Exception('Failed updating membership to DB', 500); - } - - $redirect = Template::parseURL($redirect); - $redirect['query'] = Template::mergeQuery(((isset($redirect['query'])) ? $redirect['query'] : ''), ['inviteId' => $membership->getUid(), 'userId' => $membership->getAttribute('userId'), 'secret' => $secret]); - $redirect = Template::unParseURL($redirect); - - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.invitation.body')); - $body - ->setParam('{{direction}}', Locale::getText('settings.direction')) - ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) - ->setParam('{{team}}', $team->getAttribute('name', '[TEAM-NAME]')) - ->setParam('{{owner}}', $user->getAttribute('name', '')) - ->setParam('{{redirect}}', $redirect) - ; - - $mail = $register->get('smtp'); /* @var $mail \PHPMailer\PHPMailer\PHPMailer */ - - $mail->addAddress($invitee->getAttribute('email'), $invitee->getAttribute('name')); - - $mail->Subject = sprintf(Locale::getText('auth.emails.invitation.title'), $team->getAttribute('name', '[TEAM-NAME]'), $project->getAttribute('name', ['[APP-NAME]'])); - $mail->Body = $body->render(); - $mail->AltBody = strip_tags($body->render()); - - try { - $mail->send(); - } catch (\Exception $error) { - //throw new Exception('Problem sending mail: ' . $error->getMessage(), 500); - } - - $audit - ->setParam('userId', $user->getUid()) - ->setParam('event', 'auth.invite.resend') - ; - - $response - // ->setStatusCode(Response::STATUS_CODE_CREATED) TODO change response of this endpoint - ->noContent() - ; + $response->json($users); } ); $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status') ->desc('Update Team Membership Status') - ->label('scope', 'auth') + ->label('scope', 'public') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'updateTeamMembershipStatus') + ->label('sdk.method', 'updateMembershipStatus') ->label('sdk.description', '/docs/references/teams/update-team-membership-status.md') - ->label('sdk.cookies', true) ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('inviteId', '', function () { return new UID(); }, 'Invite unique ID') - ->param('userId', '', function () { return new UID(); }, 'User unique ID') - ->param('secret', '', function () { return new Text(256); }, 'Secret Key') - ->param('success', null, function () use ($clients) { return new Host($clients); }, 'Redirect when registration succeed', true) - ->param('failure', null, function () use ($clients) { return new Host($clients); }, 'Redirect when registration failed', true) + ->param('inviteId', '', function () { return new UID(); }, 'Invite unique ID.') + ->param('userId', '', function () { return new UID(); }, 'User unique ID.') + ->param('secret', '', function () { return new Text(256); }, 'Secret key.') ->action( - function ($teamId, $inviteId, $userId, $secret, $success, $failure) use ($response, $request, $user, $audit, $projectDB) { - $invite = $projectDB->getDocument($inviteId); - - if (empty($invite->getUid()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $invite->getCollection()) { - if ($failure) { - $response->redirect($failure); - - return; - } + function ($teamId, $inviteId, $userId, $secret) use ($response, $request, $user, $audit, $projectDB) { + $membership = $projectDB->getDocument($inviteId); + if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) { throw new Exception('Invite not found', 404); } - if ($invite->getAttribute('teamId')->getUid() !== $teamId) { + if ($membership->getAttribute('teamId') !== $teamId) { throw new Exception('Team IDs don\'t match', 404); } - $team = $projectDB->getDocument($teamId); + Authorization::disable(); - if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + $team = $projectDB->getDocument($teamId); + + Authorization::reset(); + + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { throw new Exception('Team not found', 404); } - if (Auth::hash($secret) !== $invite->getAttribute('secret')) { - if ($failure) { - $response->redirect($failure); - - return; - } - + if (Auth::hash($secret) !== $membership->getAttribute('secret')) { throw new Exception('Secret key not valid', 401); } - if ($userId != $invite->getAttribute('userId')) { - if ($failure) { - $response->redirect($failure); - - return; - } - + if ($userId != $membership->getAttribute('userId')) { throw new Exception('Invite not belong to current user ('.$user->getAttribute('email').')', 401); } - if (empty($user->getUid())) { + if (empty($user->getId())) { $user = $projectDB->getCollection([ // Get user 'limit' => 1, 'first' => true, 'filters' => [ '$collection='.Database::SYSTEM_COLLECTION_USERS, - '$uid='.$userId, + '$id='.$userId, ], ]); } - if ($invite->getAttribute('userId') !== $user->getUid()) { - if ($failure) { - $response->redirect($failure); - - return; - } - + if ($membership->getAttribute('userId') !== $user->getId()) { throw new Exception('Invite not belong to current user ('.$user->getAttribute('email').')', 401); } - $invite // Attach user to team + $membership // Attach user to team ->setAttribute('joined', time()) ->setAttribute('confirm', true) ; $user - ->setAttribute('confirm', true) - ->setAttribute('memberships', $invite, Document::SET_TYPE_APPEND); + ->setAttribute('emailVerification', true) + ->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND) + ; // Log user in $expiry = time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; @@ -565,7 +486,7 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status') $user->setAttribute('tokens', new Document([ '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$user->getUid()], 'write' => ['user:'.$user->getUid()]], + '$permissions' => ['read' => ['user:'.$user->getId()], 'write' => ['user:'.$user->getId()]], 'type' => Auth::TOKEN_TYPE_LOGIN, 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak 'expire' => $expiry, @@ -581,56 +502,71 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status') throw new Exception('Failed saving user to DB', 500); } + Authorization::disable(); + $team = $projectDB->updateDocument(array_merge($team->getArrayCopy(), [ 'sum' => $team->getAttribute('sum', 0) + 1, ])); + Authorization::reset(); + if (false === $team) { throw new Exception('Failed saving team to DB', 500); } $audit - ->setParam('userId', $user->getUid()) - ->setParam('event', 'auth.join') + ->setParam('userId', $user->getId()) + ->setParam('event', 'teams.membership.update') + ->setParam('resource', 'teams/'.$teamId) ; - $response->addCookie(Auth::$cookieName, Auth::encodeSession($user->getUid(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE); - - if ($success) { - $response->redirect($success); - } - - $response->json(array('result' => 'success')); + $response + ->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null) + ->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE) + ->json(array_merge($membership->getArrayCopy([ + '$id', + 'userId', + 'teamId', + 'roles', + 'invited', + 'joined', + 'confirm', + ]), [ + 'email' => $user->getAttribute('email'), + 'name' => $user->getAttribute('name'), + ])) + ; } ); $utopia->delete('/v1/teams/:teamId/memberships/:inviteId') ->desc('Delete Team Membership') - ->label('scope', 'account') + ->label('scope', 'teams.write') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') - ->label('sdk.method', 'deleteTeamMembership') + ->label('sdk.method', 'deleteMembership') ->label('sdk.description', '/docs/references/teams/delete-team-membership.md') ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('inviteId', '', function () { return new UID(); }, 'Invite unique ID') + ->param('inviteId', '', function () { return new UID(); }, 'Invite unique ID.') ->action( function ($teamId, $inviteId) use ($response, $projectDB, $audit) { - $invite = $projectDB->getDocument($inviteId); + $membership = $projectDB->getDocument($inviteId); - if (empty($invite->getUid()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $invite->getCollection()) { + if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) { throw new Exception('Invite not found', 404); } - if ($invite->getAttribute('teamId') !== $teamId) { + if ($membership->getAttribute('teamId') !== $teamId) { throw new Exception('Team IDs don\'t match', 404); } $team = $projectDB->getDocument($teamId); - if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { throw new Exception('Team not found', 404); } - if (!$projectDB->deleteDocument($invite->getUid())) { + if (!$projectDB->deleteDocument($membership->getId())) { throw new Exception('Failed to remove membership from DB', 500); } @@ -643,8 +579,9 @@ $utopia->delete('/v1/teams/:teamId/memberships/:inviteId') } $audit - ->setParam('userId', $invite->getAttribute('userId')) - ->setParam('event', 'auth.leave') + ->setParam('userId', $membership->getAttribute('userId')) + ->setParam('event', 'teams.membership.delete') + ->setParam('resource', 'teams/'.$teamId) ; $response->noContent(); diff --git a/app/controllers/users.php b/app/controllers/api/users.php similarity index 78% rename from app/controllers/users.php rename to app/controllers/api/users.php index 998bbaee33..7e857c9def 100644 --- a/app/controllers/users.php +++ b/app/controllers/api/users.php @@ -6,6 +6,7 @@ use Auth\Auth; use Auth\Validator\Password; use Utopia\Exception; use Utopia\Response; +use Utopia\Validator\Assoc; use Utopia\Validator\WhiteList; use Utopia\Validator\Email; use Utopia\Validator\Text; @@ -18,13 +19,79 @@ use Database\Validator\UID; use DeviceDetector\DeviceDetector; use GeoIp2\Database\Reader; -include_once 'shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; +$utopia->post('/v1/users') + ->desc('Create User') + ->label('scope', 'users.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'users') + ->label('sdk.method', 'create') + ->label('sdk.description', '/docs/references/users/create-user.md') + ->param('email', '', function () { return new Email(); }, 'User email.') + ->param('password', '', function () { return new Password(); }, 'User password.') + ->param('name', '', function () { return new Text(100); }, 'User name.', true) + ->action( + function ($email, $password, $name) use ($response, $register, $projectDB, $providers) { + $profile = $projectDB->getCollection([ // Get user by email address + 'limit' => 1, + 'first' => true, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); + + if (!empty($profile)) { + throw new Exception('User already registered', 400); + } + + $user = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_USERS, + '$permissions' => [ + 'read' => ['*'], + 'write' => ['user:{self}'], + ], + 'email' => $email, + 'status' => Auth::USER_STATUS_UNACTIVATED, + 'password' => Auth::passwordHash($password), + 'password-update' => time(), + 'registration' => time(), + 'emailVerification' => false, + 'reset' => false, + 'name' => $name, + ]); + + $oauth2Keys = []; + + foreach ($providers as $key => $provider) { + if (!$provider['enabled']) { + continue; + } + + $oauth2Keys[] = 'oauth2'.ucfirst($key); + $oauth2Keys[] = 'oauth2'.ucfirst($key).'AccessToken'; + } + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->json(array_merge($user->getArrayCopy(array_merge([ + '$id', + 'status', + 'email', + 'registration', + 'emailVerification', + 'name', + ], $oauth2Keys)), ['roles' => []])); + } + ); + $utopia->get('/v1/users') ->desc('List Users') ->label('scope', 'users.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') - ->label('sdk.method', 'listUsers') + ->label('sdk.method', 'list') ->label('sdk.description', '/docs/references/users/list-users.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) @@ -44,28 +111,28 @@ $utopia->get('/v1/users') ], ]); - $oauthKeys = []; + $oauth2Keys = []; foreach ($providers as $key => $provider) { if (!$provider['enabled']) { continue; } - $oauthKeys[] = 'oauth'.ucfirst($key); - $oauthKeys[] = 'oauth'.ucfirst($key).'AccessToken'; + $oauth2Keys[] = 'oauth2'.ucfirst($key); + $oauth2Keys[] = 'oauth2'.ucfirst($key).'AccessToken'; } - $results = array_map(function ($value) use ($oauthKeys) { /* @var $value \Database\Document */ + $results = array_map(function ($value) use ($oauth2Keys) { /* @var $value \Database\Document */ return $value->getArrayCopy(array_merge( [ - '$uid', + '$id', 'status', 'email', 'registration', - 'confirm', + 'emailVerification', 'name', ], - $oauthKeys + $oauth2Keys )); }, $results); @@ -76,66 +143,65 @@ $utopia->get('/v1/users') $utopia->get('/v1/users/:userId') ->desc('Get User') ->label('scope', 'users.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') - ->label('sdk.method', 'getUser') + ->label('sdk.method', 'get') ->label('sdk.description', '/docs/references/users/get-user.md') ->param('userId', '', function () { return new UID(); }, 'User unique ID.') ->action( function ($userId) use ($response, $projectDB, $providers) { $user = $projectDB->getDocument($userId); - if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { throw new Exception('User not found', 404); } - $oauthKeys = []; + $oauth2Keys = []; foreach ($providers as $key => $provider) { if (!$provider['enabled']) { continue; } - $oauthKeys[] = 'oauth'.ucfirst($key); - $oauthKeys[] = 'oauth'.ucfirst($key).'AccessToken'; + $oauth2Keys[] = 'oauth2'.ucfirst($key); + $oauth2Keys[] = 'oauth2'.ucfirst($key).'AccessToken'; } $response->json(array_merge($user->getArrayCopy(array_merge( [ - '$uid', + '$id', 'status', 'email', 'registration', - 'confirm', + 'emailVerification', 'name', ], - $oauthKeys + $oauth2Keys )), ['roles' => []])); } ); $utopia->get('/v1/users/:userId/prefs') - ->desc('Get User Prefs') + ->desc('Get User Preferences') ->label('scope', 'users.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') - ->label('sdk.method', 'getUserPrefs') + ->label('sdk.method', 'getPrefs') ->label('sdk.description', '/docs/references/users/get-user-prefs.md') ->param('userId', '', function () { return new UID(); }, 'User unique ID.') ->action( function ($userId) use ($response, $projectDB) { $user = $projectDB->getDocument($userId); - if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { throw new Exception('User not found', 404); } $prefs = $user->getAttribute('prefs', ''); - if (empty($prefs)) { - $prefs = '[]'; - } - try { $prefs = json_decode($prefs, true); + $prefs = ($prefs) ? $prefs : []; } catch (\Exception $error) { throw new Exception('Failed to parse prefs', 500); } @@ -147,20 +213,21 @@ $utopia->get('/v1/users/:userId/prefs') $utopia->get('/v1/users/:userId/sessions') ->desc('Get User Sessions') ->label('scope', 'users.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') - ->label('sdk.method', 'getUserSessions') + ->label('sdk.method', 'getSessions') ->label('sdk.description', '/docs/references/users/get-user-sessions.md') ->param('userId', '', function () { return new UID(); }, 'User unique ID.') ->action( function ($userId) use ($response, $projectDB) { $user = $projectDB->getDocument($userId); - if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { throw new Exception('User not found', 404); } $tokens = $user->getAttribute('tokens', []); - $reader = new Reader(__DIR__.'/../db/DBIP/dbip-country-lite-2020-01.mmdb'); + $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); $sessions = []; $index = 0; $countries = Locale::getText('countries'); @@ -180,7 +247,7 @@ $utopia->get('/v1/users/:userId/sessions') $dd->parse(); $sessions[$index] = [ - '$uid' => $token->getUid(), + '$id' => $token->getId(), 'OS' => $dd->getOs(), 'client' => $dd->getClient(), 'device' => $dd->getDevice(), @@ -209,28 +276,29 @@ $utopia->get('/v1/users/:userId/sessions') $utopia->get('/v1/users/:userId/logs') ->desc('Get User Logs') ->label('scope', 'users.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') - ->label('sdk.method', 'getUserLogs') + ->label('sdk.method', 'getLogs') ->label('sdk.description', '/docs/references/users/get-user-logs.md') ->param('userId', '', function () { return new UID(); }, 'User unique ID.') ->action( function ($userId) use ($response, $register, $projectDB, $project) { $user = $projectDB->getDocument($userId); - if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { throw new Exception('User not found', 404); } $adapter = new AuditAdapter($register->get('db')); - $adapter->setNamespace('app_'.$project->getUid()); + $adapter->setNamespace('app_'.$project->getId()); $audit = new Audit($adapter); $countries = Locale::getText('countries'); - $logs = $audit->getLogsByUser($user->getUid()); + $logs = $audit->getLogsByUser($user->getId()); - $reader = new Reader(__DIR__.'/../db/DBIP/dbip-country-lite-2020-01.mmdb'); + $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); $output = []; foreach ($logs as $i => &$log) { @@ -269,75 +337,12 @@ $utopia->get('/v1/users/:userId/logs') } ); -$utopia->post('/v1/users') - ->desc('Create User') - ->label('scope', 'users.write') - ->label('sdk.namespace', 'users') - ->label('sdk.method', 'createUser') - ->label('sdk.description', '/docs/references/users/create-user.md') - ->param('email', '', function () { return new Email(); }, 'User account email.') - ->param('password', '', function () { return new Password(); }, 'User account password.') - ->param('name', '', function () { return new Text(100); }, 'User account name.', true) - ->action( - function ($email, $password, $name) use ($response, $register, $projectDB, $providers) { - $profile = $projectDB->getCollection([ // Get user by email address - 'limit' => 1, - 'first' => true, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); - - if (!empty($profile)) { - throw new Exception('User already registered', 400); - } - - $user = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_USERS, - '$permissions' => [ - 'read' => ['*'], - 'write' => ['user:{self}'], - ], - 'email' => $email, - 'status' => Auth::USER_STATUS_UNACTIVATED, - 'password' => Auth::passwordHash($password), - 'password-update' => time(), - 'registration' => time(), - 'confirm' => false, - 'reset' => false, - 'name' => $name, - ]); - - $oauthKeys = []; - - foreach ($providers as $key => $provider) { - if (!$provider['enabled']) { - continue; - } - - $oauthKeys[] = 'oauth'.ucfirst($key); - $oauthKeys[] = 'oauth'.ucfirst($key).'AccessToken'; - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json(array_merge($user->getArrayCopy(array_merge([ - '$uid', - 'status', - 'email', - 'registration', - 'confirm', - 'name', - ], $oauthKeys)), ['roles' => []])); - } - ); - $utopia->patch('/v1/users/:userId/status') ->desc('Update User Status') ->label('scope', 'users.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') - ->label('sdk.method', 'updateUserStatus') + ->label('sdk.method', 'updateStatus') ->label('sdk.description', '/docs/references/users/update-user-status.md') ->param('userId', '', function () { return new UID(); }, 'User unique ID.') ->param('status', '', function () { return new WhiteList([Auth::USER_STATUS_ACTIVATED, Auth::USER_STATUS_BLOCKED, Auth::USER_STATUS_UNACTIVATED]); }, 'User Status code. To activate the user pass '.Auth::USER_STATUS_ACTIVATED.', to block the user pass '.Auth::USER_STATUS_BLOCKED.' and for disabling the user pass '.Auth::USER_STATUS_UNACTIVATED) @@ -345,7 +350,7 @@ $utopia->patch('/v1/users/:userId/status') function ($userId, $status) use ($response, $projectDB, $providers) { $user = $projectDB->getDocument($userId); - if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { throw new Exception('User not found', 404); } @@ -357,47 +362,51 @@ $utopia->patch('/v1/users/:userId/status') throw new Exception('Failed saving user to DB', 500); } - $oauthKeys = []; + $oauth2Keys = []; foreach ($providers as $key => $provider) { if (!$provider['enabled']) { continue; } - $oauthKeys[] = 'oauth'.ucfirst($key); - $oauthKeys[] = 'oauth'.ucfirst($key).'AccessToken'; + $oauth2Keys[] = 'oauth2'.ucfirst($key); + $oauth2Keys[] = 'oauth2'.ucfirst($key).'AccessToken'; } $response ->json(array_merge($user->getArrayCopy(array_merge([ - '$uid', + '$id', 'status', 'email', 'registration', - 'confirm', + 'emailVerification', 'name', - ], $oauthKeys)), ['roles' => []])); + ], $oauth2Keys)), ['roles' => []])); } ); $utopia->patch('/v1/users/:userId/prefs') - ->desc('Update User Prefs') + ->desc('Update User Preferences') ->label('scope', 'users.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') - ->label('sdk.method', 'updateUserPrefs') + ->label('sdk.method', 'updatePrefs') ->label('sdk.description', '/docs/references/users/update-user-prefs.md') ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->param('prefs', '', function () { return new \Utopia\Validator\Mock(); }, 'Prefs key-value JSON object string.') + ->param('prefs', '', function () { return new Assoc();}, 'Prefs key-value JSON object.') ->action( function ($userId, $prefs) use ($response, $projectDB, $providers) { $user = $projectDB->getDocument($userId); - if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { throw new Exception('User not found', 404); } + $old = json_decode($user->getAttribute('prefs', '{}'), true); + $old = ($old) ? $old : []; + $user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [ - 'prefs' => json_encode(array_merge(json_decode($user->getAttribute('prefs', '{}'), true), $prefs)), + 'prefs' => json_encode(array_merge($old, $prefs)), ])); if (false === $user) { @@ -406,12 +415,9 @@ $utopia->patch('/v1/users/:userId/prefs') $prefs = $user->getAttribute('prefs', ''); - if (empty($prefs)) { - $prefs = '[]'; - } - try { $prefs = json_decode($prefs, true); + $prefs = ($prefs) ? $prefs : []; } catch (\Exception $error) { throw new Exception('Failed to parse prefs', 500); } @@ -424,8 +430,9 @@ $utopia->patch('/v1/users/:userId/prefs') $utopia->delete('/v1/users/:userId/sessions/:session') ->desc('Delete User Session') ->label('scope', 'users.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') - ->label('sdk.method', 'deleteUserSession') + ->label('sdk.method', 'deleteSession') ->label('sdk.description', '/docs/references/users/delete-user-session.md') ->label('abuse-limit', 100) ->param('userId', '', function () { return new UID(); }, 'User unique ID.') @@ -434,15 +441,15 @@ $utopia->delete('/v1/users/:userId/sessions/:session') function ($userId, $sessionId) use ($response, $request, $projectDB) { $user = $projectDB->getDocument($userId); - if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { throw new Exception('User not found', 404); } $tokens = $user->getAttribute('tokens', []); foreach ($tokens as $token) { /* @var $token Document */ - if ($sessionId == $token->getUid()) { - if (!$projectDB->deleteDocument($token->getUid())) { + if ($sessionId == $token->getId()) { + if (!$projectDB->deleteDocument($token->getId())) { throw new Exception('Failed to remove token from DB', 500); } } @@ -455,8 +462,9 @@ $utopia->delete('/v1/users/:userId/sessions/:session') $utopia->delete('/v1/users/:userId/sessions') ->desc('Delete User Sessions') ->label('scope', 'users.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') - ->label('sdk.method', 'deleteUserSessions') + ->label('sdk.method', 'deleteSessions') ->label('sdk.description', '/docs/references/users/delete-user-sessions.md') ->label('abuse-limit', 100) ->param('userId', '', function () { return new UID(); }, 'User unique ID.') @@ -464,14 +472,14 @@ $utopia->delete('/v1/users/:userId/sessions') function ($userId) use ($response, $request, $projectDB) { $user = $projectDB->getDocument($userId); - if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { throw new Exception('User not found', 404); } $tokens = $user->getAttribute('tokens', []); foreach ($tokens as $token) { /* @var $token Document */ - if (!$projectDB->deleteDocument($token->getUid())) { + if (!$projectDB->deleteDocument($token->getId())) { throw new Exception('Failed to remove token from DB', 500); } } diff --git a/app/controllers/auth.php b/app/controllers/auth.php deleted file mode 100644 index 253b478470..0000000000 --- a/app/controllers/auth.php +++ /dev/null @@ -1,822 +0,0 @@ -post('/v1/auth/register') - ->desc('Register') - ->label('webhook', 'auth.register') - ->label('scope', 'auth') - ->label('sdk.namespace', 'auth') - ->label('sdk.method', 'register') - ->label('sdk.description', '/docs/references/auth/register.md') - ->label('sdk.cookies', true) - ->label('abuse-limit', 10) - ->param('email', '', function () { return new Email(); }, 'Account email') - ->param('password', '', function () { return new Password(); }, 'User password') - ->param('confirm', '', function () use ($clients) { return new Host($clients); }, 'Confirmation URL to redirect user after confirm token has been sent to user email') // TODO add our own built-in confirm page - ->param('success', null, function () use ($clients) { return new Host($clients); }, 'Redirect when registration succeed', true) - ->param('failure', null, function () use ($clients) { return new Host($clients); }, 'Redirect when registration failed', true) - ->param('name', '', function () { return new Text(100); }, 'User name', true) - ->action( - function ($email, $password, $confirm, $success, $failure, $name) use ($request, $response, $register, $audit, $projectDB, $project, $webhook) { - if ('console' === $project->getUid()) { - $whitlistEmails = $project->getAttribute('authWhitelistEmails'); - $whitlistIPs = $project->getAttribute('authWhitelistIPs'); - $whitlistDomains = $project->getAttribute('authWhitelistDomains'); - - if (!empty($whitlistEmails) && !in_array($email, $whitlistEmails)) { - throw new Exception('Console registration is restricted to specific emails. Contact your administrator for more information.', 401); - } - - if (!empty($whitlistIPs) && !in_array($request->getIP(), $whitlistIPs)) { - throw new Exception('Console registration is restricted to specific IPs. Contact your administrator for more information.', 401); - } - - if (!empty($whitlistDomains) && !in_array(substr(strrchr($email, '@'), 1), $whitlistDomains)) { - throw new Exception('Console registration is restricted to specific domains. Contact your administrator for more information.', 401); - } - } - - $profile = $projectDB->getCollection([ // Get user by email address - 'limit' => 1, - 'first' => true, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); - - if (!empty($profile)) { - if ($failure) { - $response->redirect($failure); // .'?message=User already registered' - - return; - } - - throw new Exception('User already registered', 400); - } - - $expiry = time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; - $confirmSecret = Auth::tokenGenerator(); - $loginSecret = Auth::tokenGenerator(); - - Authorization::disable(); - - $user = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_USERS, - '$permissions' => [ - 'read' => ['*'], - 'write' => ['user:{self}'], - ], - 'email' => $email, - 'status' => Auth::USER_STATUS_UNACTIVATED, - 'password' => Auth::passwordHash($password), - 'password-update' => time(), - 'registration' => time(), - 'confirm' => false, - 'reset' => false, - 'name' => $name, - ]); - - Authorization::enable(); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - Authorization::setRole('user:'.$user->getUid()); - - $user - ->setAttribute('tokens', new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$user->getUid()], 'write' => ['user:'.$user->getUid()]], - 'type' => Auth::TOKEN_TYPE_CONFIRM, - 'secret' => Auth::hash($confirmSecret), // On way hash encryption to protect DB leak - 'expire' => time() + Auth::TOKEN_EXPIRATION_CONFIRM, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]), Document::SET_TYPE_APPEND) - ->setAttribute('tokens', new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$user->getUid()], 'write' => ['user:'.$user->getUid()]], - 'type' => Auth::TOKEN_TYPE_LOGIN, - 'secret' => Auth::hash($loginSecret), // On way hash encryption to protect DB leak - 'expire' => $expiry, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]), Document::SET_TYPE_APPEND) - ; - - $user = $projectDB->createDocument($user->getArrayCopy()); - - if (false === $user) { - throw new Exception('Failed saving tokens to DB', 500); - } - - // Send email address confirmation email - - $confirm = Template::parseURL($confirm); - $confirm['query'] = Template::mergeQuery(((isset($confirm['query'])) ? $confirm['query'] : ''), ['userId' => $user->getUid(), 'token' => $confirmSecret]); - $confirm = Template::unParseURL($confirm); - - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.confirm.body')); - $body - ->setParam('{{direction}}', Locale::getText('settings.direction')) - ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) - ->setParam('{{name}}', $name) - ->setParam('{{redirect}}', $confirm) - ; - - $mail = $register->get('smtp'); /* @var $mail \PHPMailer\PHPMailer\PHPMailer */ - - $mail->addAddress($email, $name); - - $mail->Subject = Locale::getText('auth.emails.confirm.title'); - $mail->Body = $body->render(); - $mail->AltBody = strip_tags($body->render()); - - try { - $mail->send(); - } catch (\Exception $error) { - // if($failure) { - // $response->redirect($failure); - // return; - // } - - // throw new Exception('Problem sending mail: ' . $error->getMessage(), 500); - } - - $webhook - ->setParam('payload', [ - 'name' => $name, - 'email' => $email, - ]) - ; - - $audit - ->setParam('userId', $user->getUid()) - ->setParam('event', 'auth.register') - ; - - $response - ->addCookie(Auth::$cookieName, Auth::encodeSession($user->getUid(), $loginSecret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE); - - if ($success) { - $response->redirect($success); - } - - $response->json(array('result' => 'success')); - } - ); - -$utopia->post('/v1/auth/register/confirm') - ->desc('Confirmation') - ->label('webhook', 'auth.confirm') - ->label('scope', 'public') - ->label('sdk.namespace', 'auth') - ->label('sdk.method', 'confirm') - ->label('sdk.description', '/docs/references/auth/confirm.md') - ->label('abuse-limit', 10) - ->label('abuse-key', 'url:{url},userId:{param-userId}') - ->param('userId', '', function () { return new UID(); }, 'User unique ID') - ->param('token', '', function () { return new Text(256); }, 'Confirmation secret token') - ->action( - function ($userId, $token) use ($response, $request, $projectDB, $audit) { - $profile = $projectDB->getCollection([ // Get user by email address - 'limit' => 1, - 'first' => true, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - '$uid='.$userId, - ], - ]); - - if (empty($profile)) { - throw new Exception('User not found', 404); // TODO maybe hide this - } - - $token = Auth::tokenVerify($profile->getAttribute('tokens', []), Auth::TOKEN_TYPE_CONFIRM, $token); - - if (!$token) { - throw new Exception('Confirmation token is not valid', 401); - } - - $profile = $projectDB->updateDocument(array_merge($profile->getArrayCopy(), [ - 'status' => Auth::USER_STATUS_ACTIVATED, - 'confirm' => true, - ])); - - if (false === $profile) { - throw new Exception('Failed saving user to DB', 500); - } - - if (!$projectDB->deleteDocument($token)) { - throw new Exception('Failed to remove token from DB', 500); - } - - $audit->setParam('event', 'auth.confirm'); - - $response->json(array('result' => 'success')); - } - ); - -$utopia->post('/v1/auth/register/confirm/resend') - ->desc('Resend Confirmation') - ->label('scope', 'account') - ->label('sdk.namespace', 'auth') - ->label('sdk.method', 'confirmResend') - ->label('sdk.description', '/docs/references/auth/confirm-resend.md') - ->label('abuse-limit', 10) - ->label('abuse-key', 'url:{url},userId:{param-userId}') - ->param('confirm', '', function () use ($clients) { return new Host($clients); }, 'Confirmation URL to redirect user to your app after confirm token has been sent to user email.') - ->action( - function ($confirm) use ($response, $request, $projectDB, $user, $register, $project) { - if ($user->getAttribute('confirm', false)) { - throw new Exception('Email address is already confirmed', 400); - } - - $secret = Auth::tokenGenerator(); - - $user->setAttribute('tokens', new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$user->getUid()], 'write' => ['user:'.$user->getUid()]], - 'type' => Auth::TOKEN_TYPE_CONFIRM, - 'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak - 'expire' => time() + Auth::TOKEN_EXPIRATION_CONFIRM, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]), Document::SET_TYPE_APPEND); - - $user = $projectDB->updateDocument($user->getArrayCopy()); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $confirm = Template::parseURL($confirm); - $confirm['query'] = Template::mergeQuery(((isset($confirm['query'])) ? $confirm['query'] : ''), ['userId' => $user->getUid(), 'token' => $secret]); - $confirm = Template::unParseURL($confirm); - - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.confirm.body')); - $body - ->setParam('{{direction}}', Locale::getText('settings.direction')) - ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) - ->setParam('{{name}}', $user->getAttribute('name')) - ->setParam('{{redirect}}', $confirm) - ; - - $mail = $register->get('smtp'); /* @var $mail \PHPMailer\PHPMailer\PHPMailer */ - - $mail->addAddress($user->getAttribute('email'), $user->getAttribute('name')); - - $mail->Subject = Locale::getText('auth.emails.confirm.title'); - $mail->Body = $body->render(); - $mail->AltBody = strip_tags($body->render()); - - try { - $mail->send(); - } catch (\Exception $error) { - //throw new Exception('Problem sending mail: ' . $error->getMessage(), 500); - } - - $response->json(array('result' => 'success')); - } - ); - -$utopia->post('/v1/auth/login') - ->desc('Login') - ->label('webhook', 'auth.login') - ->label('scope', 'auth') - ->label('sdk.namespace', 'auth') - ->label('sdk.method', 'login') - ->label('sdk.description', '/docs/references/auth/login.md') - ->label('sdk.cookies', true) - ->label('abuse-limit', 10) - ->label('abuse-key', 'url:{url},email:{param-email}') - ->param('email', '', function () { return new Email(); }, 'User account email address') - ->param('password', '', function () { return new Password(); }, 'User account password') - ->param('success', null, function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt.', true) - ->param('failure', null, function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt.', true) - ->action( - function ($email, $password, $success, $failure) use ($response, $request, $projectDB, $audit, $webhook) { - $profile = $projectDB->getCollection([ // Get user by email address - 'limit' => 1, - 'first' => true, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); - - if (!$profile || !Auth::passwordVerify($password, $profile->getAttribute('password'))) { - $audit - //->setParam('userId', $profile->getUid()) - ->setParam('event', 'auth.failure') - ; - - if ($failure) { - $response->redirect($failure); - - return; - } - - throw new Exception('Invalid credentials', 401); // Wrong password or username - } - - $expiry = time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; - $secret = Auth::tokenGenerator(); - - $profile->setAttribute('tokens', new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$profile->getUid()], 'write' => ['user:'.$profile->getUid()]], - 'type' => Auth::TOKEN_TYPE_LOGIN, - 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak - 'expire' => $expiry, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]), Document::SET_TYPE_APPEND); - - Authorization::setRole('user:'.$profile->getUid()); - - $profile = $projectDB->updateDocument($profile->getArrayCopy()); - - if (false === $profile) { - throw new Exception('Failed saving user to DB', 500); - } - - $webhook - ->setParam('payload', [ - 'name' => $profile->getAttribute('name', ''), - 'email' => $profile->getAttribute('email', ''), - ]) - ; - - $audit - ->setParam('userId', $profile->getUid()) - ->setParam('event', 'auth.login') - ; - - $response - ->addCookie(Auth::$cookieName, Auth::encodeSession($profile->getUid(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE); - - if ($success) { - $response->redirect($success); - } - - $response - ->json(array('result' => 'success')); - } - ); - -$utopia->get('/v1/auth/login/oauth/:provider') - ->desc('Login with OAuth') - ->label('error', __DIR__.'/../views/general/error.phtml') - ->label('scope', 'auth') - ->label('sdk.namespace', 'auth') - ->label('sdk.method', 'oauth') - ->label('sdk.description', '/docs/references/auth/login-oauth.md') - ->label('sdk.location', true) - ->label('sdk.cookies', true) - ->label('abuse-limit', 50) - ->label('abuse-key', 'ip:{ip}') - ->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth Provider. Currently, supported providers are: ' . implode(', ', array_keys($providers))) - ->param('success', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt.') - ->param('failure', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt.') - ->param('scopes', [], function () { return new ArrayList(new Text(128)); }, 'An array of string where each can be max 128 chars', true) - ->action( - function ($provider, $success, $failure, $scopes) use ($response, $request, $project) { - $callback = $request->getServer('REQUEST_SCHEME', 'https').'://'.$request->getServer('HTTP_HOST').'/v1/auth/login/oauth/callback/'.$provider.'/'.$project->getUid(); - $appId = $project->getAttribute('usersOauth'.ucfirst($provider).'Appid', ''); - $appSecret = $project->getAttribute('usersOauth'.ucfirst($provider).'Secret', '{}'); - - $appSecret = json_decode($appSecret, true); - - if (!empty($appSecret) && isset($appSecret['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$appSecret['version']); - $appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, hex2bin($appSecret['iv']), hex2bin($appSecret['tag'])); - } - - if (empty($appId) || empty($appSecret)) { - throw new Exception('Provider is undefined, configure provider app ID and app secret key to continue', 412); - } - - $classname = 'Auth\\OAuth\\'.ucfirst($provider); - - if (!class_exists($classname)) { - throw new Exception('Provider is not supported', 501); - } - - $oauth = new $classname($appId, $appSecret, $callback, ['success' => $success, 'failure' => $failure], $scopes); - - $response->redirect($oauth->getLoginURL()); - } - ); - -$utopia->get('/v1/auth/login/oauth/callback/:provider/:projectId') - ->desc('OAuth Callback') - ->label('error', __DIR__.'/../views/general/error.phtml') - ->label('scope', 'auth') - ->label('docs', false) - ->param('projectId', '', function () { return new Text(1024); }, 'Project unique ID') - ->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth provider') - ->param('code', '', function () { return new Text(1024); }, 'OAuth code') - ->param('state', '', function () { return new Text(2048); }, 'Login state params', true) - ->action( - function ($projectId, $provider, $code, $state) use ($response, $request, $domain) { - $response->redirect($request->getServer('REQUEST_SCHEME', 'https').'://'.$domain.'/v1/auth/login/oauth/'.$provider.'/redirect?' - .http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state])); - } - ); - -$utopia->get('/v1/auth/login/oauth/:provider/redirect') - ->desc('OAuth Redirect') - ->label('error', __DIR__.'/../views/general/error.phtml') - ->label('webhook', 'auth.oauth') - ->label('scope', 'auth') - ->label('abuse-limit', 50) - ->label('abuse-key', 'ip:{ip}') - ->label('docs', false) - ->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth provider') - ->param('code', '', function () { return new Text(1024); }, 'OAuth code') - ->param('state', '', function () { return new Text(2048); }, 'OAuth state params', true) - ->action( - function ($provider, $code, $state) use ($response, $request, $user, $projectDB, $project, $audit) { - $callback = $request->getServer('REQUEST_SCHEME', 'https').'://'.$request->getServer('HTTP_HOST').'/v1/auth/login/oauth/callback/'.$provider.'/'.$project->getUid(); - $defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => '']; - $validateURL = new URL(); - - $appId = $project->getAttribute('usersOauth'.ucfirst($provider).'Appid', ''); - $appSecret = $project->getAttribute('usersOauth'.ucfirst($provider).'Secret', '{}'); - - $appSecret = json_decode($appSecret, true); - - if (!empty($appSecret) && isset($appSecret['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$appSecret['version']); - $appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, hex2bin($appSecret['iv']), hex2bin($appSecret['tag'])); - } - - $classname = 'Auth\\OAuth\\'.ucfirst($provider); - - if (!class_exists($classname)) { - throw new Exception('Provider is not supported', 501); - } - - $oauth = new $classname($appId, $appSecret, $callback); - - if (!empty($state)) { - try { - $state = array_merge($defaultState, $oauth->parseState($state)); - } catch (\Exception $exception) { - throw new Exception('Failed to parse login state params as passed from OAuth provider'); - } - } else { - $state = $defaultState; - } - - if (!$validateURL->isValid($state['success'])) { - throw new Exception('Invalid redirect URL for success login', 400); - } - - if (!empty($state['failure']) && !$validateURL->isValid($state['failure'])) { - throw new Exception('Invalid redirect URL for failure login', 400); - } - - $accessToken = $oauth->getAccessToken($code); - - if (empty($accessToken)) { - if (!empty($state['failure'])) { - $response->redirect($state['failure'], 301, 0); - } - - throw new Exception('Failed to obtain access token'); - } - - $oauthID = $oauth->getUserID($accessToken); - - if (empty($oauthID)) { - if (!empty($state['failure'])) { - $response->redirect($state['failure'], 301, 0); - } - - throw new Exception('Missing ID from OAuth provider', 400); - } - - $current = Auth::tokenVerify($user->getAttribute('tokens', []), Auth::TOKEN_TYPE_LOGIN, Auth::$secret); - - if ($current) { - $projectDB->deleteDocument($current); //throw new Exception('User already logged in', 401); - } - - $user = (empty($user->getUid())) ? $projectDB->getCollection([ // Get user by provider id - 'limit' => 1, - 'first' => true, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'oauth'.ucfirst($provider).'='.$oauthID, - ], - ]) : $user; - - if (empty($user)) { // No user logged in or with oauth provider ID, create new one or connect with account with same email - $name = $oauth->getUserName($accessToken); - $email = $oauth->getUserEmail($accessToken); - - $user = $projectDB->getCollection([ // Get user by provider email address - 'limit' => 1, - 'first' => true, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); - - if (!$user || empty($user->getUid())) { // Last option -> create user alone, generate random password - Authorization::disable(); - - $user = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_USERS, - '$permissions' => ['read' => ['*'], 'write' => ['user:{self}']], - 'email' => $email, - 'status' => Auth::USER_STATUS_ACTIVATED, // Email should already be authenticated by OAuth provider - 'password' => Auth::passwordHash(Auth::passwordGenerator()), - 'password-update' => time(), - 'registration' => time(), - 'confirm' => true, - 'reset' => false, - 'name' => $name, - ]); - - Authorization::enable(); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - } - } - - // Create login token, confirm user account and update OAuth ID and Access Token - - $secret = Auth::tokenGenerator(); - $expiry = time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; - - $user - ->setAttribute('oauth'.ucfirst($provider), $oauthID) - ->setAttribute('oauth'.ucfirst($provider).'AccessToken', $accessToken) - ->setAttribute('status', Auth::USER_STATUS_ACTIVATED) - ->setAttribute('tokens', new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$user['$uid']], 'write' => ['user:'.$user['$uid']]], - 'type' => Auth::TOKEN_TYPE_LOGIN, - 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak - 'expire' => $expiry, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]), Document::SET_TYPE_APPEND) - ; - - Authorization::setRole('user:'.$user->getUid()); - - $user = $projectDB->updateDocument($user->getArrayCopy()); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $audit - ->setParam('userId', $user->getUid()) - ->setParam('event', 'auth.oauth.login') - ->setParam('data', ['provider' => $provider]) - ; - - $response - ->addCookie(Auth::$cookieName, Auth::encodeSession($user->getUid(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE) - ; - - $response->redirect($state['success']); - } - ); - -$utopia->delete('/v1/auth/logout') - ->desc('Logout Current Session') - ->label('webhook', 'auth.logout') - ->label('scope', 'account') - ->label('sdk.namespace', 'auth') - ->label('sdk.method', 'logout') - ->label('sdk.description', '/docs/references/auth/logout.md') - ->label('abuse-limit', 100) - ->action( - function () use ($response, $request, $user, $projectDB, $audit, $webhook) { - $token = Auth::tokenVerify($user->getAttribute('tokens'), Auth::TOKEN_TYPE_LOGIN, Auth::$secret); - - if (!$projectDB->deleteDocument($token)) { - throw new Exception('Failed to remove token from DB', 500); - } - - $webhook - ->setParam('payload', [ - 'name' => $user->getAttribute('name', ''), - 'email' => $user->getAttribute('email', ''), - ]) - ; - - $audit->setParam('event', 'auth.logout'); - - $response - ->addCookie(Auth::$cookieName, '', time() - 3600, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE) - ->json(array('result' => 'success')) - ; - } - ); - -$utopia->delete('/v1/auth/logout/:id') - ->desc('Logout Specific Session') - ->label('scope', 'account') - ->label('sdk.namespace', 'auth') - ->label('sdk.method', 'logoutBySession') - ->label('sdk.description', '/docs/references/auth/logout-by-session.md') - ->label('abuse-limit', 100) - ->param('id', null, function () { return new UID(); }, 'User specific session unique ID number. if 0 delete all sessions.') - ->action( - function ($id) use ($response, $request, $user, $projectDB, $audit) { - $tokens = $user->getAttribute('tokens', []); - - foreach ($tokens as $token) { /* @var $token Document */ - if (($id == $token->getUid() || ($id == 0)) && Auth::TOKEN_TYPE_LOGIN == $token->getAttribute('type')) { - if (!$projectDB->deleteDocument($token->getUid())) { - throw new Exception('Failed to remove token from DB', 500); - } - - $audit - ->setParam('event', 'auth.logout') - ->setParam('resource', '/auth/token/'.$token->getUid()) - ; - - if ($token->getAttribute('secret') == Auth::hash(Auth::$secret)) { // If current session delete cookies - $response->addCookie(Auth::$cookieName, '', time() - 3600, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE); - } - } - } - - $response->json(array('result' => 'success')); - } - ); - -$utopia->post('/v1/auth/recovery') - ->desc('Password Recovery') - ->label('scope', 'auth') - ->label('sdk.namespace', 'auth') - ->label('sdk.method', 'recovery') - ->label('sdk.description', '/docs/references/auth/recovery.md') - ->label('abuse-limit', 10) - ->label('abuse-key', 'url:{url},email:{param-email}') - ->param('email', '', function () { return new Email(); }, 'User account email address.') - ->param('reset', '', function () use ($clients) { return new Host($clients); }, 'Reset URL in your app to redirect the user after the reset token has been sent to the user email.') - ->action( - function ($email, $reset) use ($request, $response, $projectDB, $register, $audit, $project) { - $profile = $projectDB->getCollection([ // Get user by email address - 'limit' => 1, - 'first' => true, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); - - if (empty($profile)) { - throw new Exception('User not found', 404); // TODO maybe hide this - } - - $secret = Auth::tokenGenerator(); - - $profile->setAttribute('tokens', new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$profile->getUid()], 'write' => ['user:'.$profile->getUid()]], - 'type' => Auth::TOKEN_TYPE_RECOVERY, - 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak - 'expire' => time() + Auth::TOKEN_EXPIRATION_RECOVERY, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]), Document::SET_TYPE_APPEND); - - Authorization::setRole('user:'.$profile->getUid()); - - $profile = $projectDB->updateDocument($profile->getArrayCopy()); - - if (false === $profile) { - throw new Exception('Failed to save user to DB', 500); - } - - $reset = Template::parseURL($reset); - $reset['query'] = Template::mergeQuery(((isset($reset['query'])) ? $reset['query'] : ''), ['userId' => $profile->getUid(), 'token' => $secret]); - $reset = Template::unParseURL($reset); - - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.recovery.body')); - $body - ->setParam('{{direction}}', Locale::getText('settings.direction')) - ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) - ->setParam('{{name}}', $profile->getAttribute('name')) - ->setParam('{{redirect}}', $reset) - ; - - $mail = $register->get('smtp'); /* @var $mail \PHPMailer\PHPMailer\PHPMailer */ - - $mail->addAddress($profile->getAttribute('email', ''), $profile->getAttribute('name', '')); - - $mail->Subject = Locale::getText('auth.emails.recovery.title'); - $mail->Body = $body->render(); - $mail->AltBody = strip_tags($body->render()); - - try { - $mail->send(); - } catch (\Exception $error) { - //throw new Exception('Problem sending mail: ' . $error->getMessage(), 500); - } - - $audit - ->setParam('userId', $profile->getUid()) - ->setParam('event', 'auth.recovery') - ; - - $response->json(array('result' => 'success')); - } - ); - -$utopia->put('/v1/auth/recovery/reset') - ->desc('Password Reset') - ->label('scope', 'auth') - ->label('sdk.namespace', 'auth') - ->label('sdk.method', 'recoveryReset') - ->label('sdk.description', '/docs/references/auth/recovery-reset.md') - ->label('abuse-limit', 10) - ->label('abuse-key', 'url:{url},userId:{param-userId}') - ->param('userId', '', function () { return new UID(); }, 'User account email address.') - ->param('token', '', function () { return new Text(256); }, 'Valid reset token.') - ->param('password-a', '', function () { return new Password(); }, 'New password.') - ->param('password-b', '', function () {return new Password(); }, 'New password again.') - ->action( - function ($userId, $token, $passwordA, $passwordB) use ($response, $projectDB, $audit) { - if ($passwordA !== $passwordB) { - throw new Exception('Passwords must match', 400); - } - - $profile = $projectDB->getCollection([ // Get user by email address - 'limit' => 1, - 'first' => true, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - '$uid='.$userId, - ], - ]); - - if (empty($profile)) { - throw new Exception('User not found', 404); // TODO maybe hide this - } - - $token = Auth::tokenVerify($profile->getAttribute('tokens', []), Auth::TOKEN_TYPE_RECOVERY, $token); - - if (!$token) { - throw new Exception('Recovery token is not valid', 401); - } - - Authorization::setRole('user:'.$profile->getUid()); - - $profile = $projectDB->updateDocument(array_merge($profile->getArrayCopy(), [ - 'password' => Auth::passwordHash($passwordA), - 'password-update' => time(), - 'confirm' => true, - ])); - - if (false === $profile) { - throw new Exception('Failed saving user to DB', 500); - } - - if (!$projectDB->deleteDocument($token)) { - throw new Exception('Failed to remove token from DB', 500); - } - - $audit - ->setParam('userId', $profile->getUid()) - ->setParam('event', 'auth.recovery.reset') - ; - - $response->json(array('result' => 'success')); - } - ); \ No newline at end of file diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 0ee8b54014..2f1535b662 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -6,6 +6,7 @@ use Utopia\Validator\Numeric; use Utopia\Validator\Text; use Utopia\Validator\ArrayList; use Storage\Validators\File; +use Utopia\Response; use Utopia\Validator\Host; $result = []; @@ -175,9 +176,23 @@ $utopia->post('/v1/mock/tests/general/upload') function ($x, $y, $z, $file) use ($request) { $file = $request->getFiles('file'); $file['tmp_name'] = (is_array($file['tmp_name'])) ? $file['tmp_name'] : [$file['tmp_name']]; + $file['name'] = (is_array($file['name'])) ? $file['name'] : [$file['name']]; + $file['size'] = (is_array($file['size'])) ? $file['size'] : [$file['size']]; + + foreach ($file['name'] as $i => $name) { + if($name !== 'file.png') { + throw new Exception('Wrong file name', 400); + } + } + + foreach ($file['size'] as $i => $size) { + if($size !== 38756) { + throw new Exception('Wrong file size', 400); + } + } foreach ($file['tmp_name'] as $i => $tmpName) { - if(md5(file_get_contents($tmpName)) !== 'asdasdasd') { + if(md5(file_get_contents($tmpName)) !== 'd80e7e6999a3eb2ae0d631a96fe135a4') { throw new Exception('Wrong file uploaded', 400); } } @@ -216,38 +231,39 @@ $utopia->get('/v1/mock/tests/general/empty') ->action( function () use ($response) { $response->noContent(); + exit(); } ); -$utopia->get('/v1/mock/tests/general/oauth/login') - ->desc('Mock an OAuth login route') +$utopia->get('/v1/mock/tests/general/oauth2') + ->desc('Mock an OAuth2 login route') ->label('scope', 'public') ->label('docs', false) - ->param('client_id', '', function () { return new Text(100); }, 'OAuth Client ID.') - ->param('redirect_uri', '', function () { return new Host(['http://localhost']); }, 'OAuth Redirect URI.') // Important to deny an open redirect attack - ->param('scope', '', function () { return new Text(100); }, 'OAuth scope list.') - ->param('state', '', function () { return new Text(100); }, 'OAuth state.') + ->param('client_id', '', function () { return new Text(100); }, 'OAuth2 Client ID.') + ->param('redirect_uri', '', function () { return new Host(['http://localhost']); }, 'OAuth2 Redirect URI.') // Important to deny an open redirect attack + ->param('scope', '', function () { return new Text(100); }, 'OAuth2 scope list.') + ->param('state', '', function () { return new Text(1024); }, 'OAuth2 state.') ->action( function ($clientId, $redirectURI, $scope, $state) use ($response) { - $response->redirect($redirectURI); + $response->redirect($redirectURI.'?'.http_build_query(['code' => 'abcdef', 'state' => $state])); } ); -$utopia->get('/v1/mock/tests/general/oauth/token') - ->desc('Mock an OAuth login route') +$utopia->get('/v1/mock/tests/general/oauth2/token') + ->desc('Mock an OAuth2 login route') ->label('scope', 'public') ->label('docs', false) - ->param('client_id', '', function () { return new Text(100); }, 'OAuth Client ID.') - ->param('redirect_uri', '', function () { return new Host(['http://localhost']); }, 'OAuth Redirect URI.') - ->param('client_secret', '', function () { return new Text(100); }, 'OAuth scope list.') - ->param('code', '', function () { return new Text(100); }, 'OAuth state.') + ->param('client_id', '', function () { return new Text(100); }, 'OAuth2 Client ID.') + ->param('redirect_uri', '', function () { return new Host(['http://localhost']); }, 'OAuth2 Redirect URI.') + ->param('client_secret', '', function () { return new Text(100); }, 'OAuth2 scope list.') + ->param('code', '', function () { return new Text(100); }, 'OAuth2 state.') ->action( function ($clientId, $redirectURI, $clientSecret, $code) use ($response) { if($clientId != '1') { throw new Exception('Invalid client ID'); } - if($clientSecret != 'secret') { + if($clientSecret != '123456') { throw new Exception('Invalid client secret'); } @@ -259,11 +275,11 @@ $utopia->get('/v1/mock/tests/general/oauth/token') } ); -$utopia->get('/v1/mock/tests/general/oauth/user') - ->desc('Mock an OAuth user route') +$utopia->get('/v1/mock/tests/general/oauth2/user') + ->desc('Mock an OAuth2 user route') ->label('scope', 'public') ->label('docs', false) - ->param('token', '', function () { return new Text(100); }, 'OAuth Access Token.') + ->param('token', '', function () { return new Text(100); }, 'OAuth2 Access Token.') ->action( function ($token) use ($response) { if($token != '123456') { @@ -273,11 +289,35 @@ $utopia->get('/v1/mock/tests/general/oauth/user') $response->json([ 'id' => 1, 'name' => 'User Name', - 'email' => 'user@localhost', + 'email' => 'user@localhost.test', ]); } ); +$utopia->get('/v1/mock/tests/general/oauth2/success') + ->label('scope', 'public') + ->label('docs', false) + ->action( + function () use ($response) { + $response->json([ + 'result' => 'success', + ]); + } + ); + +$utopia->get('/v1/mock/tests/general/oauth2/failure') + ->label('scope', 'public') + ->label('docs', false) + ->action( + function () use ($response) { + $response + ->setStatusCode(Response::STATUS_CODE_BAD_REQUEST) + ->json([ + 'result' => 'failure', + ]); + } + ); + $utopia->shutdown(function() use ($response, $request, &$result, $utopia) { $route = $utopia->match($request); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 1d95f5fada..0430212be7 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -3,7 +3,6 @@ use Utopia\Exception; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; -use Database\Database; global $utopia, $request, $response, $register, $user, $project; @@ -17,9 +16,9 @@ $utopia->init(function () use ($utopia, $request, $response, $register, $user, $ $timeLimit = new TimeLimit($route->getLabel('abuse-key', 'url:{url},ip:{ip}'), $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600), function () use ($register) { return $register->get('db'); }); - $timeLimit->setNamespace('app_'.$project->getUid()); + $timeLimit->setNamespace('app_'.$project->getId()); $timeLimit - ->setParam('{userId}', $user->getUid()) + ->setParam('{userId}', $user->getId()) ->setParam('{userAgent}', $request->getServer('HTTP_USER_AGENT', '')) ->setParam('{ip}', $request->getIP()) ->setParam('{url}', $request->getServer('HTTP_HOST', '').$route->getURL()) diff --git a/app/controllers/shared/web.php b/app/controllers/shared/web.php index ffaa6a5b87..e23dc4f9c3 100644 --- a/app/controllers/shared/web.php +++ b/app/controllers/shared/web.php @@ -23,8 +23,7 @@ $layout ->setParam('protocol', $request->getServer('REQUEST_SCHEME', 'https')) ->setParam('domain', $domain) ->setParam('home', $request->getServer('_APP_HOME')) - ->setParam('api', $request->getServer('_APP_APPWRITE_HOST_CLIENT')) - ->setParam('project', $request->getServer('_APP_APPWRITE_ID')) + ->setParam('setup', $request->getServer('_APP_SETUP')) ->setParam('class', 'unknown') ->setParam('icon', '/images/favicon.png') ->setParam('roles', $roles) diff --git a/app/controllers/console.php b/app/controllers/web/console.php similarity index 77% rename from app/controllers/console.php rename to app/controllers/web/console.php index 95a15991ab..39ccaa930b 100644 --- a/app/controllers/console.php +++ b/app/controllers/web/console.php @@ -1,12 +1,13 @@ init(function () use ($layout, $utopia) { $layout @@ -15,8 +16,8 @@ $utopia->init(function () use ($layout, $utopia) { }); $utopia->shutdown(function () use ($utopia, $response, $request, $layout, $version) { - $header = new View(__DIR__.'/../views/console/comps/header.phtml'); - $footer = new View(__DIR__.'/../views/console/comps/footer.phtml'); + $header = new View(__DIR__.'/../../views/console/comps/header.phtml'); + $footer = new View(__DIR__.'/../../views/console/comps/footer.phtml'); $footer ->setParam('home', $request->getServer('_APP_HOME', '')) @@ -44,7 +45,7 @@ $utopia->get('/error/:code') ->label('scope', 'home') ->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false) ->action(function ($code) use ($layout) { - $page = new View(__DIR__.'/../views/error.phtml'); + $page = new View(__DIR__.'/../../views/error.phtml'); $page ->setParam('code', $code) @@ -59,7 +60,7 @@ $utopia->get('/console') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout, $request) { - $page = new View(__DIR__.'/../views/console/index.phtml'); + $page = new View(__DIR__.'/../../views/console/index.phtml'); $page ->setParam('home', $request->getServer('_APP_HOME', '')) @@ -74,9 +75,9 @@ $utopia->get('/console/account') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/account/index.phtml'); + $page = new View(__DIR__.'/../../views/console/account/index.phtml'); - $cc = new View(__DIR__.'/../views/console/forms/credit-card.phtml'); + $cc = new View(__DIR__.'/../../views/console/forms/credit-card.phtml'); $page ->setParam('cc', $cc) @@ -92,7 +93,7 @@ $utopia->get('/console/notifications') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/v1/console/notifications/index.phtml'); + $page = new View(__DIR__.'/../../views/v1/console/notifications/index.phtml'); $layout ->setParam('title', APP_NAME.' - Notifications') @@ -104,7 +105,7 @@ $utopia->get('/console/home') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/home/index.phtml'); + $page = new View(__DIR__.'/../../views/console/home/index.phtml'); $layout ->setParam('title', APP_NAME.' - Console') @@ -116,7 +117,7 @@ $utopia->get('/console/settings') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/settings/index.phtml'); + $page = new View(__DIR__.'/../../views/console/settings/index.phtml'); $layout ->setParam('title', APP_NAME.' - Settings') @@ -128,7 +129,7 @@ $utopia->get('/console/webhooks') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/webhooks/index.phtml'); + $page = new View(__DIR__.'/../../views/console/webhooks/index.phtml'); $layout ->setParam('title', APP_NAME.' - Webhooks') @@ -140,7 +141,10 @@ $utopia->get('/console/keys') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/keys/index.phtml'); + $scopes = include __DIR__.'/../../../app/config/scopes.php'; + $page = new View(__DIR__.'/../../views/console/keys/index.phtml'); + + $page->setParam('scopes', $scopes); $layout ->setParam('title', APP_NAME.' - API Keys') @@ -152,7 +156,7 @@ $utopia->get('/console/tasks') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/tasks/index.phtml'); + $page = new View(__DIR__.'/../../views/console/tasks/index.phtml'); $layout ->setParam('title', APP_NAME.' - Tasks') @@ -164,7 +168,7 @@ $utopia->get('/console/database') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/database/index.phtml'); + $page = new View(__DIR__.'/../../views/console/database/index.phtml'); $layout ->setParam('title', APP_NAME.' - Database') @@ -179,11 +183,11 @@ $utopia->get('/console/database/collection') ->action(function ($id) use ($layout, $projectDB) { $collection = $projectDB->getDocument($id, false); - if (empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { throw new Exception('Collection not found', 404); } - $page = new View(__DIR__.'/../views/console/database/collection.phtml'); + $page = new View(__DIR__.'/../../views/console/database/collection.phtml'); $page ->setParam('collection', $collection->getArrayCopy()) @@ -199,10 +203,12 @@ $utopia->get('/console/storage') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($request, $layout) { - $page = new View(__DIR__.'/../views/console/storage/index.phtml'); - + $page = new View(__DIR__.'/../../views/console/storage/index.phtml'); + $page - ->setParam('home', $request->getServer('_APP_HOME', '')) + ->setParam('home', $request->getServer('_APP_HOME', 0)) + ->setParam('fileLimit', $request->getServer('_APP_STORAGE_LIMIT', 0)) + ->setParam('fileLimitHuman', Storage::human($request->getServer('_APP_STORAGE_LIMIT', 0))) ; $layout @@ -215,7 +221,7 @@ $utopia->get('/console/users') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout, $providers) { - $page = new View(__DIR__.'/../views/console/users/index.phtml'); + $page = new View(__DIR__.'/../../views/console/users/index.phtml'); $page->setParam('providers', $providers); @@ -229,7 +235,7 @@ $utopia->get('/console/users/view') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout, $providers) { - $page = new View(__DIR__.'/../views/console/users/view.phtml'); + $page = new View(__DIR__.'/../../views/console/users/view.phtml'); $layout ->setParam('title', APP_NAME.' - View User') diff --git a/app/controllers/home.php b/app/controllers/web/home.php similarity index 80% rename from app/controllers/home.php rename to app/controllers/web/home.php index 67be50cd5e..1a758aac26 100644 --- a/app/controllers/home.php +++ b/app/controllers/web/home.php @@ -1,13 +1,13 @@ setParam('version', $version) @@ -40,7 +40,7 @@ $utopia->get('/auth/signin') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/signin.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/signin.phtml'); $layout ->setParam('title', 'Sign In - '.APP_NAME) @@ -52,7 +52,7 @@ $utopia->get('/auth/signup') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/signup.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/signup.phtml'); $layout ->setParam('title', 'Sign Up - '.APP_NAME) @@ -64,7 +64,7 @@ $utopia->get('/auth/recovery') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($request, $layout) { - $page = new View(__DIR__.'/../views/home/auth/recovery.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/recovery.phtml'); $layout ->setParam('title', 'Password Recovery - '.APP_NAME) @@ -76,7 +76,7 @@ $utopia->get('/auth/confirm') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/confirm.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/confirm.phtml'); $layout ->setParam('title', 'Account Confirmation - '.APP_NAME) @@ -88,7 +88,7 @@ $utopia->get('/auth/join') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/join.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/join.phtml'); $layout ->setParam('title', 'Invitation - '.APP_NAME) @@ -100,7 +100,7 @@ $utopia->get('/auth/recovery/reset') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/recovery/reset.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/recovery/reset.phtml'); $layout ->setParam('title', 'Password Reset - '.APP_NAME) @@ -113,7 +113,7 @@ $utopia->get('/error/:code') ->label('scope', 'home') ->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false) ->action(function ($code) use ($layout) { - $page = new View(__DIR__.'/../views/error.phtml'); + $page = new View(__DIR__.'/../../views/error.phtml'); $page ->setParam('code', $code) diff --git a/app/init.php b/app/init.php index d9289d0a4a..6a6b830321 100644 --- a/app/init.php +++ b/app/init.php @@ -25,7 +25,7 @@ const APP_EMAIL_SECURITY = 'security@'.APP_DOMAIN; const APP_USERAGENT = APP_NAME.'-Server/%s Please report abuse at '.APP_EMAIL_SECURITY; const APP_MODE_ADMIN = 'admin'; const APP_PAGING_LIMIT = 15; -const APP_VERSION_STABLE = '0.4.0'; +const APP_VERSION_STABLE = '0.5.0'; $register = new Registry(); $request = new Request(); @@ -37,10 +37,10 @@ $response = new Response(); $env = $request->getServer('_APP_ENV', App::ENV_TYPE_PRODUCTION); $domain = $request->getServer('HTTP_HOST', ''); $version = $request->getServer('_APP_VERSION', 'UNKNOWN'); -$providers = include __DIR__.'/../app/config/providers.php'; // OAuth providers list +$providers = include __DIR__.'/../app/config/providers.php'; // OAuth2 providers list $platforms = include __DIR__.'/../app/config/platforms.php'; -$locales = include __DIR__.'/../app/config/locales.php'; // OAuth providers list -$collections = include __DIR__.'/../app/config/collections.php'; // OAuth providers list +$locales = include __DIR__.'/../app/config/locales.php'; // Locales list +$collections = include __DIR__.'/../app/config/collections.php'; // Collections list $redisHost = $request->getServer('_APP_REDIS_HOST', ''); $redisPort = $request->getServer('_APP_REDIS_PORT', ''); $utopia = new App('Asia/Tel_Aviv', $env); @@ -57,7 +57,7 @@ define('COOKIE_DOMAIN', ) ? null : '.'.parse_url($scheme.'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_HOST)); -define('COOKIE_SAMESITE', null); // Response::COOKIE_SAMESITE_NONE +define('COOKIE_SAMESITE', Response::COOKIE_SAMESITE_NONE); /* * Registry @@ -112,8 +112,8 @@ $register->set('smtp', function () use ($request) { $mail->isSMTP(); - $username = $request->getServer('_APP_SMTP_USERNAME', ''); - $password = $request->getServer('_APP_SMTP_PASSWORD', ''); + $username = $request->getServer('_APP_SMTP_USERNAME', null); + $password = $request->getServer('_APP_SMTP_PASSWORD', null); $mail->XMailer = 'Appwrite Mailer'; $mail->Host = $request->getServer('_APP_SMTP_HOST', 'smtp'); @@ -121,10 +121,11 @@ $register->set('smtp', function () use ($request) { $mail->SMTPAuth = (!empty($username) && !empty($password)); $mail->Username = $username; $mail->Password = $password; - $mail->SMTPSecure = $request->getServer('_APP_SMTP_SECURE', ''); + $mail->SMTPSecure = $request->getServer('_APP_SMTP_SECURE', false); + $mail->SMTPAutoTLS = false; - $from = $request->getServer('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Team'); - $email = $request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', 'team@appwrite.io'); + $from = urldecode($request->getServer('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server')); + $email = $request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); $mail->setFrom($email, $from); $mail->addReplyTo($email, $from); @@ -219,19 +220,22 @@ $console = $consoleDB->getDocument('console'); $mode = $request->getParam('mode', $request->getHeader('X-Appwrite-Mode', 'default')); -Auth::setCookieName('a_session_'.$project->getUid()); +Auth::setCookieName('a_session_'.$project->getId()); if (APP_MODE_ADMIN === $mode) { - Auth::setCookieName('a_session_'.$console->getUid()); + Auth::setCookieName('a_session_'.$console->getId()); } -$session = Auth::decodeSession($request->getCookie(Auth::$cookieName, $request->getHeader('X-Appwrite-Key', ''))); +$session = Auth::decodeSession( + $request->getCookie(Auth::$cookieName, // Get sessions + $request->getCookie(Auth::$cookieName.'_legacy', // Get fallback session from old clients (no SameSite support) + $request->getHeader('X-Appwrite-Key', '')))); // Get API Key Auth::$unique = $session['id']; Auth::$secret = $session['secret']; $projectDB = new Database(); $projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); -$projectDB->setNamespace('app_'.$project->getUid()); +$projectDB->setNamespace('app_'.$project->getId()); $projectDB->setMocks($collections); $user = $projectDB->getDocument(Auth::$unique); @@ -240,23 +244,30 @@ if (APP_MODE_ADMIN === $mode) { $user = $consoleDB->getDocument(Auth::$unique); $user - ->setAttribute('$uid', 'admin-'.$user->getAttribute('$uid')) + ->setAttribute('$id', 'admin-'.$user->getAttribute('$id')) ; } -if (empty($user->getUid()) // Check a document has been found in the DB +if (empty($user->getId()) // Check a document has been found in the DB || Database::SYSTEM_COLLECTION_USERS !== $user->getCollection() // Validate returned document is really a user document || !Auth::tokenVerify($user->getAttribute('tokens', []), Auth::TOKEN_TYPE_LOGIN, Auth::$secret)) { // Validate user has valid login token - $user = new Document(['$uid' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]); + $user = new Document(['$id' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]); } if (APP_MODE_ADMIN === $mode) { if (!empty($user->search('teamId', $project->getAttribute('teamId'), $user->getAttribute('memberships')))) { Authorization::disable(); } else { - $user = new Document(['$uid' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]); + $user = new Document(['$id' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]); } } // Set project mail -$register->get('smtp')->setFrom(APP_EMAIL_TEAM, sprintf(Locale::getText('auth.emails.team'), $project->getAttribute('name'))); +$register->get('smtp') + ->setFrom( + $request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), + ($project->getId() === 'console') + ? urldecode($request->getServer('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server')) + : sprintf(Locale::getText('account.emails.team'), $project->getAttribute('name') + ) + ); diff --git a/app/sdks/dart/.packages b/app/sdks/dart/.packages deleted file mode 100644 index 8b327e4ec1..0000000000 --- a/app/sdks/dart/.packages +++ /dev/null @@ -1,14 +0,0 @@ -# Generated by pub on 2019-12-05 18:55:11.878585. -charcode:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/ -collection:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/collection-1.14.12/lib/ -cookie_jar:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/cookie_jar-1.0.1/lib/ -dio:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/dio-3.0.3/lib/ -dio_cookie_manager:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/dio_cookie_manager-1.0.0/lib/ -http_parser:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/http_parser-3.1.3/lib/ -meta:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/meta-1.1.7/lib/ -path:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/path-1.6.4/lib/ -source_span:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5/lib/ -string_scanner:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5/lib/ -term_glyph:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/ -typed_data:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/ -appwrite:lib/ diff --git a/app/sdks/dart/README.md b/app/sdks/dart/README.md index db1082d9e7..84bcd1d809 100644 --- a/app/sdks/dart/README.md +++ b/app/sdks/dart/README.md @@ -1,9 +1,9 @@ # Appwrite SDK for Dart ![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1) -**WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).** +**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.** Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/dart/lib/appwrite.dart b/app/sdks/dart/lib/appwrite.dart index 01930e9b60..905f90058b 100644 --- a/app/sdks/dart/lib/appwrite.dart +++ b/app/sdks/dart/lib/appwrite.dart @@ -1,11 +1,8 @@ export 'package:appwrite/services/account.dart'; -export 'package:appwrite/services/auth.dart'; export 'package:appwrite/services/avatars.dart'; export 'package:appwrite/services/database.dart'; export 'package:appwrite/services/locale.dart'; -export 'package:appwrite/services/projects.dart'; export 'package:appwrite/services/storage.dart'; export 'package:appwrite/services/teams.dart'; -export 'package:appwrite/services/users.dart'; export 'package:appwrite/client.dart'; export 'package:dio/dio.dart' show Response; \ No newline at end of file diff --git a/app/sdks/dart/lib/client.dart b/app/sdks/dart/lib/client.dart index 05a5370651..3954a783cb 100644 --- a/app/sdks/dart/lib/client.dart +++ b/app/sdks/dart/lib/client.dart @@ -23,7 +23,7 @@ class Client { } - /// Your Appwrite project ID + /// Your project ID Client setProject(value) { this.addHeader('X-Appwrite-Project', value); @@ -31,7 +31,7 @@ class Client { } - /// Your Appwrite project secret key + /// Your secret API key Client setKey(value) { this.addHeader('X-Appwrite-Key', value); diff --git a/app/sdks/dart/lib/services/account.dart b/app/sdks/dart/lib/services/account.dart index 4d191232d2..52f8c75c56 100644 --- a/app/sdks/dart/lib/services/account.dart +++ b/app/sdks/dart/lib/services/account.dart @@ -14,6 +14,23 @@ class Account extends Service { }; return await this.client.call('get', path: path, params: params); + } + /// Use this endpoint to allow a new user to register a new account in your + /// project. After the user registration completes successfully, you can use + /// the [/account/verfication](/docs/account#createVerification) route to start + /// verifying the user email address. To allow your new user to login to his + /// new account, you need to create a new [account + /// session](/docs/account#createSession). + Future create({email, password, name = null}) async { + String path = '/account'; + + Map params = { + 'email': email, + 'password': password, + 'name': name, + }; + + return await this.client.call('post', path: path, params: params); } /// Delete a currently logged in user account. Behind the scene, the user /// record is not deleted but permanently blocked from any access. This is done @@ -41,6 +58,16 @@ class Account extends Service { }; return await this.client.call('patch', path: path, params: params); + } + /// Get currently logged in user list of latest security activity logs. Each + /// log returns user IP address, location and date and time of log. + Future getLogs() async { + String path = '/account/logs'; + + Map params = { + }; + + return await this.client.call('get', path: path, params: params); } /// Update currently logged in user account name. Future updateName({name}) async { @@ -64,7 +91,7 @@ class Account extends Service { return await this.client.call('patch', path: path, params: params); } - /// Get currently logged in user preferences key-value object. + /// Get currently logged in user preferences as a key-value object. Future getPrefs() async { String path = '/account/prefs'; @@ -84,15 +111,42 @@ class Account extends Service { return await this.client.call('patch', path: path, params: params); } - /// Get currently logged in user list of latest security activity logs. Each - /// log returns user IP address, location and date and time of log. - Future getSecurity() async { - String path = '/account/security'; + /// Sends the user an email with a temporary secret key for password reset. + /// When the user clicks the confirmation link he is redirected back to your + /// app password reset URL with the secret key and email address values + /// attached to the URL query string. Use the query string params to submit a + /// request to the [PUT /account/recovery](/docs/account#updateRecovery) + /// endpoint to complete the process. + Future createRecovery({email, url}) async { + String path = '/account/recovery'; Map params = { + 'email': email, + 'url': url, }; - return await this.client.call('get', path: path, params: params); + return await this.client.call('post', path: path, params: params); + } + /// Use this endpoint to complete the user account password reset. Both the + /// **userId** and **secret** arguments will be passed as query parameters to + /// the redirect URL you have provided when sending your request to the [POST + /// /account/recovery](/docs/account#createRecovery) endpoint. + /// + /// Please note that in order to avoid a [Redirect + /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + /// the only valid redirect URLs are the ones from domains you have set when + /// adding your platforms in the console interface. + Future updateRecovery({userId, secret, passwordA, passwordB}) async { + String path = '/account/recovery'; + + Map params = { + 'userId': userId, + 'secret': secret, + 'password-a': passwordA, + 'password-b': passwordB, + }; + + return await this.client.call('put', path: path, params: params); } /// Get currently logged in user list of active sessions across different /// devices. @@ -104,4 +158,87 @@ class Account extends Service { return await this.client.call('get', path: path, params: params); } + /// Allow the user to login into his account by providing a valid email and + /// password combination. This route will create a new session for the user. + Future createSession({email, password}) async { + String path = '/account/sessions'; + + Map params = { + 'email': email, + 'password': password, + }; + + return await this.client.call('post', path: path, params: params); + } + /// Delete all sessions from the user account and remove any sessions cookies + /// from the end client. + Future deleteSessions() async { + String path = '/account/sessions'; + + Map params = { + }; + + return await this.client.call('delete', path: path, params: params); + } + /// Allow the user to login to his account using the OAuth provider of his + /// choice. Each OAuth provider should be enabled from the Appwrite console + /// first. Use the success and failure arguments to provide a redirect URL's + /// back to your app when login is completed. + Future createOAuth2Session({provider, success, failure}) async { + String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider); + + Map params = { + 'success': success, + 'failure': failure, + }; + + return await this.client.call('get', path: path, params: params); + } + /// Use this endpoint to log out the currently logged in user from all his + /// account sessions across all his different devices. When using the option id + /// argument, only the session unique ID provider will be deleted. + Future deleteSession({sessionId}) async { + String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId); + + Map params = { + }; + + return await this.client.call('delete', path: path, params: params); + } + /// Use this endpoint to send a verification message to your user email address + /// to confirm they are the valid owners of that address. Both the **userId** + /// and **secret** arguments will be passed as query parameters to the URL you + /// have provider to be attached to the verification email. The provided URL + /// should redirect the user back for your app and allow you to complete the + /// verification process by verifying both the **userId** and **secret** + /// parameters. Learn more about how to [complete the verification + /// process](/docs/account#updateAccountVerification). + /// + /// Please note that in order to avoid a [Redirect + /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + /// the only valid redirect URLs are the ones from domains you have set when + /// adding your platforms in the console interface. + Future createVerification({url}) async { + String path = '/account/verification'; + + Map params = { + 'url': url, + }; + + return await this.client.call('post', path: path, params: params); + } + /// Use this endpoint to complete the user email verification process. Use both + /// the **userId** and **secret** parameters that were attached to your app URL + /// to verify the user email ownership. If confirmed this route will return a + /// 200 status code. + Future updateVerification({userId, secret}) async { + String path = '/account/verification'; + + Map params = { + 'userId': userId, + 'secret': secret, + }; + + return await this.client.call('put', path: path, params: params); + } } \ No newline at end of file diff --git a/app/sdks/dart/lib/services/auth.dart b/app/sdks/dart/lib/services/auth.dart deleted file mode 100644 index 1fdb5aa134..0000000000 --- a/app/sdks/dart/lib/services/auth.dart +++ /dev/null @@ -1,173 +0,0 @@ -import "package:appwrite/service.dart"; -import "package:appwrite/client.dart"; -import 'package:dio/dio.dart'; - -class Auth extends Service { - - Auth(Client client): super(client); - - /// Allow the user to login into his account by providing a valid email and - /// password combination. Use the success and failure arguments to provide a - /// redirect URL\'s back to your app when login is completed. - /// - /// Please notice that in order to avoid a [Redirect - /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - /// the only valid redirect URLs are the ones from domains you have set when - /// adding your platforms in the console interface. - /// - /// When accessing this route using Javascript from the browser, success and - /// failure parameter URLs are required. Appwrite server will respond with a - /// 301 redirect status code and will set the user session cookie. This - /// behavior is enforced because modern browsers are limiting 3rd party cookies - /// in XHR of fetch requests to protect user privacy. - Future login({email, password, success = null, failure = null}) async { - String path = '/auth/login'; - - Map params = { - 'email': email, - 'password': password, - 'success': success, - 'failure': failure, - }; - - return await this.client.call('post', path: path, params: params); - } - /// Allow the user to login to his account using the OAuth provider of his - /// choice. Each OAuth provider should be enabled from the Appwrite console - /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - Future oauth({provider, success, failure}) async { - String path = '/auth/login/oauth/{provider}'.replaceAll(RegExp('{provider}'), provider); - - Map params = { - 'success': success, - 'failure': failure, - }; - - return await this.client.call('get', path: path, params: params); - } - /// Use this endpoint to log out the currently logged in user from his account. - /// When successful this endpoint will delete the user session and remove the - /// session secret cookie from the user client. - Future logout() async { - String path = '/auth/logout'; - - Map params = { - }; - - return await this.client.call('delete', path: path, params: params); - } - /// Use this endpoint to log out the currently logged in user from all his - /// account sessions across all his different devices. When using the option id - /// argument, only the session unique ID provider will be deleted. - Future logoutBySession({id}) async { - String path = '/auth/logout/{id}'.replaceAll(RegExp('{id}'), id); - - Map params = { - }; - - return await this.client.call('delete', path: path, params: params); - } - /// Sends the user an email with a temporary secret token for password reset. - /// When the user clicks the confirmation link he is redirected back to your - /// app password reset redirect URL with a secret token and email address - /// values attached to the URL query string. Use the query string params to - /// submit a request to the /auth/password/reset endpoint to complete the - /// process. - Future recovery({email, reset}) async { - String path = '/auth/recovery'; - - Map params = { - 'email': email, - 'reset': reset, - }; - - return await this.client.call('post', path: path, params: params); - } - /// Use this endpoint to complete the user account password reset. Both the - /// **userId** and **token** arguments will be passed as query parameters to - /// the redirect URL you have provided when sending your request to the - /// /auth/recovery endpoint. - /// - /// Please notice that in order to avoid a [Redirect - /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - /// the only valid redirect URLs are the ones from domains you have set when - /// adding your platforms in the console interface. - Future recoveryReset({userId, token, passwordA, passwordB}) async { - String path = '/auth/recovery/reset'; - - Map params = { - 'userId': userId, - 'token': token, - 'password-a': passwordA, - 'password-b': passwordB, - }; - - return await this.client.call('put', path: path, params: params); - } - /// Use this endpoint to allow a new user to register an account in your - /// project. Use the success and failure URLs to redirect users back to your - /// application after signup completes. - /// - /// If registration completes successfully user will be sent with a - /// confirmation email in order to confirm he is the owner of the account email - /// address. Use the confirmation parameter to redirect the user from the - /// confirmation email back to your app. When the user is redirected, use the - /// /auth/confirm endpoint to complete the account confirmation. - /// - /// Please notice that in order to avoid a [Redirect - /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - /// the only valid redirect URLs are the ones from domains you have set when - /// adding your platforms in the console interface. - /// - /// When accessing this route using Javascript from the browser, success and - /// failure parameter URLs are required. Appwrite server will respond with a - /// 301 redirect status code and will set the user session cookie. This - /// behavior is enforced because modern browsers are limiting 3rd party cookies - /// in XHR of fetch requests to protect user privacy. - Future register({email, password, confirm, success = null, failure = null, name = null}) async { - String path = '/auth/register'; - - Map params = { - 'email': email, - 'password': password, - 'confirm': confirm, - 'success': success, - 'failure': failure, - 'name': name, - }; - - return await this.client.call('post', path: path, params: params); - } - /// Use this endpoint to complete the confirmation of the user account email - /// address. Both the **userId** and **token** arguments will be passed as - /// query parameters to the redirect URL you have provided when sending your - /// request to the /auth/register endpoint. - Future confirm({userId, token}) async { - String path = '/auth/register/confirm'; - - Map params = { - 'userId': userId, - 'token': token, - }; - - return await this.client.call('post', path: path, params: params); - } - /// This endpoint allows the user to request your app to resend him his email - /// confirmation message. The redirect arguments act the same way as in - /// /auth/register endpoint. - /// - /// Please notice that in order to avoid a [Redirect - /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - /// the only valid redirect URLs are the ones from domains you have set when - /// adding your platforms in the console interface. - Future confirmResend({confirm}) async { - String path = '/auth/register/confirm/resend'; - - Map params = { - 'confirm': confirm, - }; - - return await this.client.call('post', path: path, params: params); - } -} \ No newline at end of file diff --git a/app/sdks/dart/lib/services/database.dart b/app/sdks/dart/lib/services/database.dart index 1c9a2a743a..edb7be6759 100644 --- a/app/sdks/dart/lib/services/database.dart +++ b/app/sdks/dart/lib/services/database.dart @@ -6,74 +6,12 @@ class Database extends Service { Database(Client client): super(client); - /// Get a list of all the user collections. You can use the query params to - /// filter your results. On admin mode, this endpoint will return a list of all - /// of the project collections. [Learn more about different API - /// modes](/docs/admin). - Future listCollections({search = null, limit = 25, offset = null, orderType = 'ASC'}) async { - String path = '/database'; - - Map params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType, - }; - - return await this.client.call('get', path: path, params: params); - } - /// Create a new Collection. - Future createCollection({name, read, write, rules}) async { - String path = '/database'; - - Map params = { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules, - }; - - return await this.client.call('post', path: path, params: params); - } - /// Get collection by its unique ID. This endpoint response returns a JSON - /// object with the collection metadata. - Future getCollection({collectionId}) async { - String path = '/database/{collectionId}'.replaceAll(RegExp('{collectionId}'), collectionId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - /// Update collection by its unique ID. - Future updateCollection({collectionId, name, read, write, rules = const []}) async { - String path = '/database/{collectionId}'.replaceAll(RegExp('{collectionId}'), collectionId); - - Map params = { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules, - }; - - return await this.client.call('put', path: path, params: params); - } - /// Delete a collection by its unique ID. Only users with write permissions - /// have access to delete this resource. - Future deleteCollection({collectionId}) async { - String path = '/database/{collectionId}'.replaceAll(RegExp('{collectionId}'), collectionId); - - Map params = { - }; - - return await this.client.call('delete', path: path, params: params); - } /// Get a list of all the user documents. You can use the query params to /// filter your results. On admin mode, this endpoint will return a list of all /// of the project documents. [Learn more about different API /// modes](/docs/admin). Future listDocuments({collectionId, filters = const [], offset = null, limit = 50, orderField = '\$uid', orderType = 'ASC', orderCast = 'string', search = null, first = null, last = null}) async { - String path = '/database/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); + String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); Map params = { 'filters': filters, @@ -91,7 +29,7 @@ class Database extends Service { } /// Create a new Document. Future createDocument({collectionId, data, read, write, parentDocument = null, parentProperty = null, parentPropertyType = 'assign'}) async { - String path = '/database/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); + String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); Map params = { 'data': data, @@ -107,7 +45,7 @@ class Database extends Service { /// Get document by its unique ID. This endpoint response returns a JSON object /// with the document data. Future getDocument({collectionId, documentId}) async { - String path = '/database/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); + String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); Map params = { }; @@ -115,7 +53,7 @@ class Database extends Service { return await this.client.call('get', path: path, params: params); } Future updateDocument({collectionId, documentId, data, read, write}) async { - String path = '/database/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); + String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); Map params = { 'data': data, @@ -129,7 +67,7 @@ class Database extends Service { /// documents, his attributes and relations to other documents. Child documents /// **will not** be deleted. Future deleteDocument({collectionId, documentId}) async { - String path = '/database/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); + String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); Map params = { }; diff --git a/app/sdks/dart/lib/services/locale.dart b/app/sdks/dart/lib/services/locale.dart index 6112ada3e3..208c72bd08 100644 --- a/app/sdks/dart/lib/services/locale.dart +++ b/app/sdks/dart/lib/services/locale.dart @@ -10,7 +10,9 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - Future getLocale() async { + /// + /// ([IP Geolocation by DB-IP](https://db-ip.com)) + Future get() async { String path = '/locale'; Map params = { @@ -39,8 +41,7 @@ class Locale extends Service { return await this.client.call('get', path: path, params: params); } /// List of all countries that are currently members of the EU. You can use the - /// locale header to get the data in a supported language. UK brexit date is - /// currently set to 2019-10-31 and will be updated if and when needed. + /// locale header to get the data in a supported language. Future getCountriesEU() async { String path = '/locale/countries/eu'; diff --git a/app/sdks/dart/lib/services/projects.dart b/app/sdks/dart/lib/services/projects.dart deleted file mode 100644 index d4f9df3639..0000000000 --- a/app/sdks/dart/lib/services/projects.dart +++ /dev/null @@ -1,292 +0,0 @@ -import "package:appwrite/service.dart"; -import "package:appwrite/client.dart"; -import 'package:dio/dio.dart'; - -class Projects extends Service { - - Projects(Client client): super(client); - - Future listProjects() async { - String path = '/projects'; - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future createProject({name, teamId, description = null, logo = null, url = null, legalName = null, legalCountry = null, legalState = null, legalCity = null, legalAddress = null, legalTaxId = null}) async { - String path = '/projects'; - - Map params = { - 'name': name, - 'teamId': teamId, - 'description': description, - 'logo': logo, - 'url': url, - 'legalName': legalName, - 'legalCountry': legalCountry, - 'legalState': legalState, - 'legalCity': legalCity, - 'legalAddress': legalAddress, - 'legalTaxId': legalTaxId, - }; - - return await this.client.call('post', path: path, params: params); - } - Future getProject({projectId}) async { - String path = '/projects/{projectId}'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future updateProject({projectId, name, description = null, logo = null, url = null, legalName = null, legalCountry = null, legalState = null, legalCity = null, legalAddress = null, legalTaxId = null}) async { - String path = '/projects/{projectId}'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - 'name': name, - 'description': description, - 'logo': logo, - 'url': url, - 'legalName': legalName, - 'legalCountry': legalCountry, - 'legalState': legalState, - 'legalCity': legalCity, - 'legalAddress': legalAddress, - 'legalTaxId': legalTaxId, - }; - - return await this.client.call('patch', path: path, params: params); - } - Future deleteProject({projectId}) async { - String path = '/projects/{projectId}'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - }; - - return await this.client.call('delete', path: path, params: params); - } - Future listKeys({projectId}) async { - String path = '/projects/{projectId}/keys'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future createKey({projectId, name, scopes}) async { - String path = '/projects/{projectId}/keys'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - 'name': name, - 'scopes': scopes, - }; - - return await this.client.call('post', path: path, params: params); - } - Future getKey({projectId, keyId}) async { - String path = '/projects/{projectId}/keys/{keyId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{keyId}'), keyId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future updateKey({projectId, keyId, name, scopes}) async { - String path = '/projects/{projectId}/keys/{keyId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{keyId}'), keyId); - - Map params = { - 'name': name, - 'scopes': scopes, - }; - - return await this.client.call('put', path: path, params: params); - } - Future deleteKey({projectId, keyId}) async { - String path = '/projects/{projectId}/keys/{keyId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{keyId}'), keyId); - - Map params = { - }; - - return await this.client.call('delete', path: path, params: params); - } - Future updateProjectOAuth({projectId, provider, appId = null, secret = null}) async { - String path = '/projects/{projectId}/oauth'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - 'provider': provider, - 'appId': appId, - 'secret': secret, - }; - - return await this.client.call('patch', path: path, params: params); - } - Future listPlatforms({projectId}) async { - String path = '/projects/{projectId}/platforms'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future createPlatform({projectId, type, name, key = null, store = null, url = null}) async { - String path = '/projects/{projectId}/platforms'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - 'type': type, - 'name': name, - 'key': key, - 'store': store, - 'url': url, - }; - - return await this.client.call('post', path: path, params: params); - } - Future getPlatform({projectId, platformId}) async { - String path = '/projects/{projectId}/platforms/{platformId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{platformId}'), platformId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future updatePlatform({projectId, platformId, name, key = null, store = null, url = null}) async { - String path = '/projects/{projectId}/platforms/{platformId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{platformId}'), platformId); - - Map params = { - 'name': name, - 'key': key, - 'store': store, - 'url': url, - }; - - return await this.client.call('put', path: path, params: params); - } - Future deletePlatform({projectId, platformId}) async { - String path = '/projects/{projectId}/platforms/{platformId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{platformId}'), platformId); - - Map params = { - }; - - return await this.client.call('delete', path: path, params: params); - } - Future listTasks({projectId}) async { - String path = '/projects/{projectId}/tasks'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future createTask({projectId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = null, httpUser = null, httpPass = null}) async { - String path = '/projects/{projectId}/tasks'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - 'name': name, - 'status': status, - 'schedule': schedule, - 'security': security, - 'httpMethod': httpMethod, - 'httpUrl': httpUrl, - 'httpHeaders': httpHeaders, - 'httpUser': httpUser, - 'httpPass': httpPass, - }; - - return await this.client.call('post', path: path, params: params); - } - Future getTask({projectId, taskId}) async { - String path = '/projects/{projectId}/tasks/{taskId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{taskId}'), taskId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future updateTask({projectId, taskId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = null, httpUser = null, httpPass = null}) async { - String path = '/projects/{projectId}/tasks/{taskId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{taskId}'), taskId); - - Map params = { - 'name': name, - 'status': status, - 'schedule': schedule, - 'security': security, - 'httpMethod': httpMethod, - 'httpUrl': httpUrl, - 'httpHeaders': httpHeaders, - 'httpUser': httpUser, - 'httpPass': httpPass, - }; - - return await this.client.call('put', path: path, params: params); - } - Future deleteTask({projectId, taskId}) async { - String path = '/projects/{projectId}/tasks/{taskId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{taskId}'), taskId); - - Map params = { - }; - - return await this.client.call('delete', path: path, params: params); - } - Future getProjectUsage({projectId}) async { - String path = '/projects/{projectId}/usage'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future listWebhooks({projectId}) async { - String path = '/projects/{projectId}/webhooks'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future createWebhook({projectId, name, events, url, security, httpUser = null, httpPass = null}) async { - String path = '/projects/{projectId}/webhooks'.replaceAll(RegExp('{projectId}'), projectId); - - Map params = { - 'name': name, - 'events': events, - 'url': url, - 'security': security, - 'httpUser': httpUser, - 'httpPass': httpPass, - }; - - return await this.client.call('post', path: path, params: params); - } - Future getWebhook({projectId, webhookId}) async { - String path = '/projects/{projectId}/webhooks/{webhookId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{webhookId}'), webhookId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - Future updateWebhook({projectId, webhookId, name, events, url, security, httpUser = null, httpPass = null}) async { - String path = '/projects/{projectId}/webhooks/{webhookId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{webhookId}'), webhookId); - - Map params = { - 'name': name, - 'events': events, - 'url': url, - 'security': security, - 'httpUser': httpUser, - 'httpPass': httpPass, - }; - - return await this.client.call('put', path: path, params: params); - } - Future deleteWebhook({projectId, webhookId}) async { - String path = '/projects/{projectId}/webhooks/{webhookId}'.replaceAll(RegExp('{projectId}'), projectId).replaceAll(RegExp('{webhookId}'), webhookId); - - Map params = { - }; - - return await this.client.call('delete', path: path, params: params); - } -} \ No newline at end of file diff --git a/app/sdks/dart/lib/services/storage.dart b/app/sdks/dart/lib/services/storage.dart index c46dba5af6..da71e7cad4 100644 --- a/app/sdks/dart/lib/services/storage.dart +++ b/app/sdks/dart/lib/services/storage.dart @@ -24,11 +24,11 @@ class Storage extends Service { /// Create a new file. The user who creates the file will automatically be /// assigned to read and write access unless he has passed custom values for /// read and write arguments. - Future createFile({files, read, write}) async { + Future createFile({file, read, write}) async { String path = '/storage/files'; Map params = { - 'files': files, + 'file': file, 'read': read, 'write': write, }; @@ -78,9 +78,9 @@ class Storage extends Service { return await this.client.call('get', path: path, params: params); } - /// Get file preview image. Currently, this method supports preview for image + /// Get a file preview image. Currently, this method supports preview for image /// files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - /// and spreadsheets will return file icon image. You can also pass query + /// and spreadsheets, will return the file icon image. You can also pass query /// string arguments for cutting and resizing your preview image. Future getFilePreview({fileId, width = null, height = null, quality = 100, background = null, output = null}) async { String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId); diff --git a/app/sdks/dart/lib/services/teams.dart b/app/sdks/dart/lib/services/teams.dart index ab91cc70d2..fb5ce16c00 100644 --- a/app/sdks/dart/lib/services/teams.dart +++ b/app/sdks/dart/lib/services/teams.dart @@ -9,7 +9,7 @@ class Teams extends Service { /// Get a list of all the current user teams. You can use the query params to /// filter your results. On admin mode, this endpoint will return a list of all /// of the project teams. [Learn more about different API modes](/docs/admin). - Future listTeams({search = null, limit = 25, offset = null, orderType = 'ASC'}) async { + Future list({search = null, limit = 25, offset = null, orderType = 'ASC'}) async { String path = '/teams'; Map params = { @@ -25,7 +25,7 @@ class Teams extends Service { /// assigned as the owner of the team. The team owner can invite new members, /// who will be able add new owners and update or delete the team from your /// project. - Future createTeam({name, roles = const ["owner"]}) async { + Future create({name, roles = const ["owner"]}) async { String path = '/teams'; Map params = { @@ -37,7 +37,7 @@ class Teams extends Service { } /// Get team by its unique ID. All team members have read access for this /// resource. - Future getTeam({teamId}) async { + Future get({teamId}) async { String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); Map params = { @@ -47,7 +47,7 @@ class Teams extends Service { } /// Update team by its unique ID. Only team owners have write access for this /// resource. - Future updateTeam({teamId, name}) async { + Future update({teamId, name}) async { String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); Map params = { @@ -58,7 +58,7 @@ class Teams extends Service { } /// Delete team by its unique ID. Only team owners have write access for this /// resource. - Future deleteTeam({teamId}) async { + Future delete({teamId}) async { String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); Map params = { @@ -68,42 +68,43 @@ class Teams extends Service { } /// Get team members by the team unique ID. All team members have read access /// for this list of resources. - Future getTeamMembers({teamId}) async { - String path = '/teams/{teamId}/members'.replaceAll(RegExp('{teamId}'), teamId); + Future getMemberships({teamId}) async { + String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); Map params = { }; return await this.client.call('get', path: path, params: params); } - /// Use this endpoint to invite a new member to your team. An email with a link - /// to join the team will be sent to the new member email address. If member - /// doesn't exists in the project it will be automatically created. + /// Use this endpoint to invite a new member to join your team. An email with a + /// link to join the team will be sent to the new member email address if the + /// member doesn't exist in the project it will be created automatically. /// - /// Use the redirect parameter to redirect the user from the invitation email - /// back to your app. When the user is redirected, use the - /// /teams/{teamId}/memberships/{inviteId}/status endpoint to finally join the - /// user to the team. + /// Use the 'URL' parameter to redirect the user from the invitation email back + /// to your app. When the user is redirected, use the [Update Team Membership + /// Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to + /// accept the invitation to the team. /// - /// Please notice that in order to avoid a [Redirect + /// Please note that in order to avoid a [Redirect /// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URL's are the once from domains you have set when /// added your platforms in the console interface. - Future createTeamMembership({teamId, email, roles, redirect, name = null}) async { + Future createMembership({teamId, email, roles, url, name = null}) async { String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); Map params = { 'email': email, 'name': name, 'roles': roles, - 'redirect': redirect, + 'url': url, }; return await this.client.call('post', path: path, params: params); } /// This endpoint allows a user to leave a team or for a team owner to delete - /// the membership of any other team member. - Future deleteTeamMembership({teamId, inviteId}) async { + /// the membership of any other team member. You can also use this endpoint to + /// delete a user membership even if he didn't accept it. + Future deleteMembership({teamId, inviteId}) async { String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); Map params = { @@ -111,40 +112,15 @@ class Teams extends Service { return await this.client.call('delete', path: path, params: params); } - /// Use this endpoint to resend your invitation email for a user to join a - /// team. - Future createTeamMembershipResend({teamId, inviteId, redirect}) async { - String path = '/teams/{teamId}/memberships/{inviteId}/resend'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); - - Map params = { - 'redirect': redirect, - }; - - return await this.client.call('post', path: path, params: params); - } - /// Use this endpoint to let user accept an invitation to join a team after he - /// is being redirect back to your app from the invitation email. Use the - /// success and failure URL's to redirect users back to your application after - /// the request completes. - /// - /// Please notice that in order to avoid a [Redirect - /// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - /// the only valid redirect URL's are the once from domains you have set when - /// added your platforms in the console interface. - /// - /// When not using the success or failure redirect arguments this endpoint will - /// result with a 200 status code on success and with 401 status error on - /// failure. This behavior was applied to help the web clients deal with - /// browsers who don't allow to set 3rd party HTTP cookies needed for saving - /// the account session token. - Future updateTeamMembershipStatus({teamId, inviteId, userId, secret, success = null, failure = null}) async { + /// Use this endpoint to allow a user to accept an invitation to join a team + /// after he is being redirected back to your app from the invitation email he + /// was sent. + Future updateMembershipStatus({teamId, inviteId, userId, secret}) async { String path = '/teams/{teamId}/memberships/{inviteId}/status'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); Map params = { 'userId': userId, 'secret': secret, - 'success': success, - 'failure': failure, }; return await this.client.call('patch', path: path, params: params); diff --git a/app/sdks/dart/lib/services/users.dart b/app/sdks/dart/lib/services/users.dart deleted file mode 100644 index 3e84ddd287..0000000000 --- a/app/sdks/dart/lib/services/users.dart +++ /dev/null @@ -1,111 +0,0 @@ -import "package:appwrite/service.dart"; -import "package:appwrite/client.dart"; -import 'package:dio/dio.dart'; - -class Users extends Service { - - Users(Client client): super(client); - - /// Get a list of all the project users. You can use the query params to filter - /// your results. - Future listUsers({search = null, limit = 25, offset = null, orderType = 'ASC'}) async { - String path = '/users'; - - Map params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType, - }; - - return await this.client.call('get', path: path, params: params); - } - /// Create a new user. - Future createUser({email, password, name = null}) async { - String path = '/users'; - - Map params = { - 'email': email, - 'password': password, - 'name': name, - }; - - return await this.client.call('post', path: path, params: params); - } - /// Get user by its unique ID. - Future getUser({userId}) async { - String path = '/users/{userId}'.replaceAll(RegExp('{userId}'), userId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - /// Get user activity logs list by its unique ID. - Future getUserLogs({userId}) async { - String path = '/users/{userId}/logs'.replaceAll(RegExp('{userId}'), userId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - /// Get user preferences by its unique ID. - Future getUserPrefs({userId}) async { - String path = '/users/{userId}/prefs'.replaceAll(RegExp('{userId}'), userId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - /// Update user preferences by its unique ID. You can pass only the specific - /// settings you wish to update. - Future updateUserPrefs({userId, prefs}) async { - String path = '/users/{userId}/prefs'.replaceAll(RegExp('{userId}'), userId); - - Map params = { - 'prefs': prefs, - }; - - return await this.client.call('patch', path: path, params: params); - } - /// Get user sessions list by its unique ID. - Future getUserSessions({userId}) async { - String path = '/users/{userId}/sessions'.replaceAll(RegExp('{userId}'), userId); - - Map params = { - }; - - return await this.client.call('get', path: path, params: params); - } - /// Delete all user sessions by its unique ID. - Future deleteUserSessions({userId}) async { - String path = '/users/{userId}/sessions'.replaceAll(RegExp('{userId}'), userId); - - Map params = { - }; - - return await this.client.call('delete', path: path, params: params); - } - /// Delete user sessions by its unique ID. - Future deleteUserSession({userId, sessionId}) async { - String path = '/users/{userId}/sessions/:session'.replaceAll(RegExp('{userId}'), userId); - - Map params = { - 'sessionId': sessionId, - }; - - return await this.client.call('delete', path: path, params: params); - } - /// Update user status by its unique ID. - Future updateUserStatus({userId, status}) async { - String path = '/users/{userId}/status'.replaceAll(RegExp('{userId}'), userId); - - Map params = { - 'status': status, - }; - - return await this.client.call('patch', path: path, params: params); - } -} \ No newline at end of file diff --git a/app/sdks/dart/pubspec.lock b/app/sdks/dart/pubspec.lock deleted file mode 100644 index 98d3035608..0000000000 --- a/app/sdks/dart/pubspec.lock +++ /dev/null @@ -1,89 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.2" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.14.12" - cookie_jar: - dependency: "direct main" - description: - name: cookie_jar - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - dio: - dependency: "direct main" - description: - name: dio - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.3" - dio_cookie_manager: - dependency: "direct main" - description: - name: dio_cookie_manager - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.3" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.7" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.4" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.5" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.6" -sdks: - dart: ">2.4.0 <3.0.0" diff --git a/app/sdks/go/README.md b/app/sdks/go/README.md index 672d0fa488..f11b213ddf 100644 --- a/app/sdks/go/README.md +++ b/app/sdks/go/README.md @@ -1,9 +1,9 @@ # Appwrite SDK for Go ![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1) -**WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).** +**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.** Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/go/account.go b/app/sdks/go/account.go deleted file mode 100644 index debadc42f5..0000000000 --- a/app/sdks/go/account.go +++ /dev/null @@ -1,116 +0,0 @@ -package appwrite - -import ( -) - -// Account service -type Account struct { - client *Client -} - -// Get get currently logged in user data as JSON object. -func (srv *Account) Get() (map[string]interface{}, error) { - path := "/account" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// Delete delete a currently logged in user account. Behind the scene, the -// user record is not deleted but permanently blocked from any access. This is -// done to avoid deleted accounts being overtaken by new users with the same -// email address. Any user-related resources like documents or storage files -// should be deleted separately. -func (srv *Account) Delete() (map[string]interface{}, error) { - path := "/account" - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// UpdateEmail update currently logged in user account email address. After -// changing user address, user confirmation status is being reset and a new -// confirmation mail is sent. For security measures, user password is required -// to complete this request. -func (srv *Account) UpdateEmail(Email string, Password string) (map[string]interface{}, error) { - path := "/account/email" - - params := map[string]interface{}{ - "email": Email, - "password": Password, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// UpdateName update currently logged in user account name. -func (srv *Account) UpdateName(Name string) (map[string]interface{}, error) { - path := "/account/name" - - params := map[string]interface{}{ - "name": Name, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// UpdatePassword update currently logged in user password. For validation, -// user is required to pass the password twice. -func (srv *Account) UpdatePassword(Password string, OldPassword string) (map[string]interface{}, error) { - path := "/account/password" - - params := map[string]interface{}{ - "password": Password, - "old-password": OldPassword, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// GetPrefs get currently logged in user preferences key-value object. -func (srv *Account) GetPrefs() (map[string]interface{}, error) { - path := "/account/prefs" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdatePrefs update currently logged in user account preferences. You can -// pass only the specific settings you wish to update. -func (srv *Account) UpdatePrefs(Prefs string) (map[string]interface{}, error) { - path := "/account/prefs" - - params := map[string]interface{}{ - "prefs": Prefs, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// GetSecurity get currently logged in user list of latest security activity -// logs. Each log returns user IP address, location and date and time of log. -func (srv *Account) GetSecurity() (map[string]interface{}, error) { - path := "/account/security" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetSessions get currently logged in user list of active sessions across -// different devices. -func (srv *Account) GetSessions() (map[string]interface{}, error) { - path := "/account/sessions" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} diff --git a/app/sdks/go/auth.go b/app/sdks/go/auth.go deleted file mode 100644 index b869140bb8..0000000000 --- a/app/sdks/go/auth.go +++ /dev/null @@ -1,186 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Auth service -type Auth struct { - client *Client -} - -// Login allow the user to login into his account by providing a valid email -// and password combination. Use the success and failure arguments to provide -// a redirect URL\'s back to your app when login is completed. -// -// Please notice that in order to avoid a [Redirect -// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) -// the only valid redirect URLs are the ones from domains you have set when -// adding your platforms in the console interface. -// -// When accessing this route using Javascript from the browser, success and -// failure parameter URLs are required. Appwrite server will respond with a -// 301 redirect status code and will set the user session cookie. This -// behavior is enforced because modern browsers are limiting 3rd party cookies -// in XHR of fetch requests to protect user privacy. -func (srv *Auth) Login(Email string, Password string, Success string, Failure string) (map[string]interface{}, error) { - path := "/auth/login" - - params := map[string]interface{}{ - "email": Email, - "password": Password, - "success": Success, - "failure": Failure, - } - - return srv.client.Call("POST", path, nil, params) -} - -// Oauth allow the user to login to his account using the OAuth provider of -// his choice. Each OAuth provider should be enabled from the Appwrite console -// first. Use the success and failure arguments to provide a redirect URL's -// back to your app when login is completed. -func (srv *Auth) Oauth(Provider string, Success string, Failure string) (map[string]interface{}, error) { - r := strings.NewReplacer("{provider}", Provider) - path := r.Replace("/auth/login/oauth/{provider}") - - params := map[string]interface{}{ - "success": Success, - "failure": Failure, - } - - return srv.client.Call("GET", path, nil, params) -} - -// Logout use this endpoint to log out the currently logged in user from his -// account. When successful this endpoint will delete the user session and -// remove the session secret cookie from the user client. -func (srv *Auth) Logout() (map[string]interface{}, error) { - path := "/auth/logout" - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// LogoutBySession use this endpoint to log out the currently logged in user -// from all his account sessions across all his different devices. When using -// the option id argument, only the session unique ID provider will be -// deleted. -func (srv *Auth) LogoutBySession(Id string) (map[string]interface{}, error) { - r := strings.NewReplacer("{id}", Id) - path := r.Replace("/auth/logout/{id}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// Recovery sends the user an email with a temporary secret token for password -// reset. When the user clicks the confirmation link he is redirected back to -// your app password reset redirect URL with a secret token and email address -// values attached to the URL query string. Use the query string params to -// submit a request to the /auth/password/reset endpoint to complete the -// process. -func (srv *Auth) Recovery(Email string, Reset string) (map[string]interface{}, error) { - path := "/auth/recovery" - - params := map[string]interface{}{ - "email": Email, - "reset": Reset, - } - - return srv.client.Call("POST", path, nil, params) -} - -// RecoveryReset use this endpoint to complete the user account password -// reset. Both the **userId** and **token** arguments will be passed as query -// parameters to the redirect URL you have provided when sending your request -// to the /auth/recovery endpoint. -// -// Please notice that in order to avoid a [Redirect -// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) -// the only valid redirect URLs are the ones from domains you have set when -// adding your platforms in the console interface. -func (srv *Auth) RecoveryReset(UserId string, Token string, PasswordA string, PasswordB string) (map[string]interface{}, error) { - path := "/auth/recovery/reset" - - params := map[string]interface{}{ - "userId": UserId, - "token": Token, - "password-a": PasswordA, - "password-b": PasswordB, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// Register use this endpoint to allow a new user to register an account in -// your project. Use the success and failure URLs to redirect users back to -// your application after signup completes. -// -// If registration completes successfully user will be sent with a -// confirmation email in order to confirm he is the owner of the account email -// address. Use the confirmation parameter to redirect the user from the -// confirmation email back to your app. When the user is redirected, use the -// /auth/confirm endpoint to complete the account confirmation. -// -// Please notice that in order to avoid a [Redirect -// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) -// the only valid redirect URLs are the ones from domains you have set when -// adding your platforms in the console interface. -// -// When accessing this route using Javascript from the browser, success and -// failure parameter URLs are required. Appwrite server will respond with a -// 301 redirect status code and will set the user session cookie. This -// behavior is enforced because modern browsers are limiting 3rd party cookies -// in XHR of fetch requests to protect user privacy. -func (srv *Auth) Register(Email string, Password string, Confirm string, Success string, Failure string, Name string) (map[string]interface{}, error) { - path := "/auth/register" - - params := map[string]interface{}{ - "email": Email, - "password": Password, - "confirm": Confirm, - "success": Success, - "failure": Failure, - "name": Name, - } - - return srv.client.Call("POST", path, nil, params) -} - -// Confirm use this endpoint to complete the confirmation of the user account -// email address. Both the **userId** and **token** arguments will be passed -// as query parameters to the redirect URL you have provided when sending your -// request to the /auth/register endpoint. -func (srv *Auth) Confirm(UserId string, Token string) (map[string]interface{}, error) { - path := "/auth/register/confirm" - - params := map[string]interface{}{ - "userId": UserId, - "token": Token, - } - - return srv.client.Call("POST", path, nil, params) -} - -// ConfirmResend this endpoint allows the user to request your app to resend -// him his email confirmation message. The redirect arguments act the same way -// as in /auth/register endpoint. -// -// Please notice that in order to avoid a [Redirect -// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) -// the only valid redirect URLs are the ones from domains you have set when -// adding your platforms in the console interface. -func (srv *Auth) ConfirmResend(Confirm string) (map[string]interface{}, error) { - path := "/auth/register/confirm/resend" - - params := map[string]interface{}{ - "confirm": Confirm, - } - - return srv.client.Call("POST", path, nil, params) -} diff --git a/app/sdks/go/avatars.go b/app/sdks/go/avatars.go index 286f644f8d..feafa9da31 100644 --- a/app/sdks/go/avatars.go +++ b/app/sdks/go/avatars.go @@ -6,7 +6,15 @@ import ( // Avatars service type Avatars struct { - client *Client + client Client +} + +func NewAvatars(clt Client) Avatars { + service := Avatars{ + client: clt, + } + + return service } // GetBrowser you can use this endpoint to show different browser icons to diff --git a/app/sdks/go/client.go b/app/sdks/go/client.go index 94f2546cff..36fb2f28e5 100644 --- a/app/sdks/go/client.go +++ b/app/sdks/go/client.go @@ -2,7 +2,7 @@ package appwrite import ( "encoding/json" - "io/ioutil" + "io/ioutil" "net/http" "net/url" "strings" @@ -31,23 +31,21 @@ func (clt *Client) AddHeader(key string, value string) { clt.headers[key] = value } -// SetProjectHeader add the 'X-Appwrite-Project' header for the Client. Your Appwrite project ID -func (clt *Client) SetProjectHeader(value string) { +// Your project ID +func (clt *Client) SetProject(value string) { clt.headers["X-Appwrite-Project"] = value } -// SetKeyHeader add the 'X-Appwrite-Key' header for the Client. Your Appwrite project secret key -func (clt *Client) SetKeyHeader(value string) { +// Your secret API key +func (clt *Client) SetKey(value string) { clt.headers["X-Appwrite-Key"] = value } -// SetLocaleHeader add the 'X-Appwrite-Locale' header for the Client. -func (clt *Client) SetLocaleHeader(value string) { +func (clt *Client) SetLocale(value string) { clt.headers["X-Appwrite-Locale"] = value } -// SetModeHeader add the 'X-Appwrite-Mode' header for the Client. -func (clt *Client) SetModeHeader(value string) { +func (clt *Client) SetMode(value string) { clt.headers["X-Appwrite-Mode"] = value } diff --git a/app/sdks/go/database.go b/app/sdks/go/database.go index b1e58e746b..7e5f686bdb 100644 --- a/app/sdks/go/database.go +++ b/app/sdks/go/database.go @@ -6,7 +6,15 @@ import ( // Database service type Database struct { - client *Client + client Client +} + +func NewDatabase(clt Client) Database { + service := Database{ + client: clt, + } + + return service } // ListCollections get a list of all the user collections. You can use the @@ -14,7 +22,7 @@ type Database struct { // return a list of all of the project collections. [Learn more about // different API modes](/docs/admin). func (srv *Database) ListCollections(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { - path := "/database" + path := "/database/collections" params := map[string]interface{}{ "search": Search, @@ -28,7 +36,7 @@ func (srv *Database) ListCollections(Search string, Limit int, Offset int, Order // CreateCollection create a new Collection. func (srv *Database) CreateCollection(Name string, Read []interface{}, Write []interface{}, Rules []interface{}) (map[string]interface{}, error) { - path := "/database" + path := "/database/collections" params := map[string]interface{}{ "name": Name, @@ -44,7 +52,7 @@ func (srv *Database) CreateCollection(Name string, Read []interface{}, Write []i // returns a JSON object with the collection metadata. func (srv *Database) GetCollection(CollectionId string) (map[string]interface{}, error) { r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/{collectionId}") + path := r.Replace("/database/collections/{collectionId}") params := map[string]interface{}{ } @@ -55,7 +63,7 @@ func (srv *Database) GetCollection(CollectionId string) (map[string]interface{}, // UpdateCollection update collection by its unique ID. func (srv *Database) UpdateCollection(CollectionId string, Name string, Read []interface{}, Write []interface{}, Rules []interface{}) (map[string]interface{}, error) { r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/{collectionId}") + path := r.Replace("/database/collections/{collectionId}") params := map[string]interface{}{ "name": Name, @@ -71,7 +79,7 @@ func (srv *Database) UpdateCollection(CollectionId string, Name string, Read []i // write permissions have access to delete this resource. func (srv *Database) DeleteCollection(CollectionId string) (map[string]interface{}, error) { r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/{collectionId}") + path := r.Replace("/database/collections/{collectionId}") params := map[string]interface{}{ } @@ -85,7 +93,7 @@ func (srv *Database) DeleteCollection(CollectionId string) (map[string]interface // modes](/docs/admin). func (srv *Database) ListDocuments(CollectionId string, Filters []interface{}, Offset int, Limit int, OrderField string, OrderType string, OrderCast string, Search string, First int, Last int) (map[string]interface{}, error) { r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/{collectionId}/documents") + path := r.Replace("/database/collections/{collectionId}/documents") params := map[string]interface{}{ "filters": Filters, @@ -103,9 +111,9 @@ func (srv *Database) ListDocuments(CollectionId string, Filters []interface{}, O } // CreateDocument create a new Document. -func (srv *Database) CreateDocument(CollectionId string, Data string, Read []interface{}, Write []interface{}, ParentDocument string, ParentProperty string, ParentPropertyType string) (map[string]interface{}, error) { +func (srv *Database) CreateDocument(CollectionId string, Data object, Read []interface{}, Write []interface{}, ParentDocument string, ParentProperty string, ParentPropertyType string) (map[string]interface{}, error) { r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/{collectionId}/documents") + path := r.Replace("/database/collections/{collectionId}/documents") params := map[string]interface{}{ "data": Data, @@ -123,7 +131,7 @@ func (srv *Database) CreateDocument(CollectionId string, Data string, Read []int // JSON object with the document data. func (srv *Database) GetDocument(CollectionId string, DocumentId string) (map[string]interface{}, error) { r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId) - path := r.Replace("/database/{collectionId}/documents/{documentId}") + path := r.Replace("/database/collections/{collectionId}/documents/{documentId}") params := map[string]interface{}{ } @@ -132,9 +140,9 @@ func (srv *Database) GetDocument(CollectionId string, DocumentId string) (map[st } // UpdateDocument -func (srv *Database) UpdateDocument(CollectionId string, DocumentId string, Data string, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { +func (srv *Database) UpdateDocument(CollectionId string, DocumentId string, Data object, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId) - path := r.Replace("/database/{collectionId}/documents/{documentId}") + path := r.Replace("/database/collections/{collectionId}/documents/{documentId}") params := map[string]interface{}{ "data": Data, @@ -150,7 +158,7 @@ func (srv *Database) UpdateDocument(CollectionId string, DocumentId string, Data // Child documents **will not** be deleted. func (srv *Database) DeleteDocument(CollectionId string, DocumentId string) (map[string]interface{}, error) { r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId) - path := r.Replace("/database/{collectionId}/documents/{documentId}") + path := r.Replace("/database/collections/{collectionId}/documents/{documentId}") params := map[string]interface{}{ } diff --git a/app/sdks/go/docs/examples/Account/Delete.md b/app/sdks/go/docs/examples/Account/Delete.md deleted file mode 100644 index a029c47c14..0000000000 --- a/app/sdks/go/docs/examples/Account/Delete.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## Delete - -```go - package appwrite-delete - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call Delete method and handle results - var res, err := srv.Delete() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/Get.md b/app/sdks/go/docs/examples/Account/Get.md deleted file mode 100644 index a6dd237a5d..0000000000 --- a/app/sdks/go/docs/examples/Account/Get.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## Get - -```go - package appwrite-get - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call Get method and handle results - var res, err := srv.Get() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/GetPrefs.md b/app/sdks/go/docs/examples/Account/GetPrefs.md deleted file mode 100644 index 0e4cfea354..0000000000 --- a/app/sdks/go/docs/examples/Account/GetPrefs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## GetPrefs - -```go - package appwrite-getprefs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call GetPrefs method and handle results - var res, err := srv.GetPrefs() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/GetSecurity.md b/app/sdks/go/docs/examples/Account/GetSecurity.md deleted file mode 100644 index 113eb16ae5..0000000000 --- a/app/sdks/go/docs/examples/Account/GetSecurity.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## GetSecurity - -```go - package appwrite-getsecurity - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call GetSecurity method and handle results - var res, err := srv.GetSecurity() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/GetSessions.md b/app/sdks/go/docs/examples/Account/GetSessions.md deleted file mode 100644 index 153b8e3fe9..0000000000 --- a/app/sdks/go/docs/examples/Account/GetSessions.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## GetSessions - -```go - package appwrite-getsessions - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call GetSessions method and handle results - var res, err := srv.GetSessions() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/UpdateEmail.md b/app/sdks/go/docs/examples/Account/UpdateEmail.md deleted file mode 100644 index 6f9895257e..0000000000 --- a/app/sdks/go/docs/examples/Account/UpdateEmail.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## UpdateEmail - -```go - package appwrite-updateemail - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call UpdateEmail method and handle results - var res, err := srv.UpdateEmail("email@example.com", "password") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/UpdateName.md b/app/sdks/go/docs/examples/Account/UpdateName.md deleted file mode 100644 index 3172a94fa6..0000000000 --- a/app/sdks/go/docs/examples/Account/UpdateName.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## UpdateName - -```go - package appwrite-updatename - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call UpdateName method and handle results - var res, err := srv.UpdateName("[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/UpdatePassword.md b/app/sdks/go/docs/examples/Account/UpdatePassword.md deleted file mode 100644 index 2aa8543fcd..0000000000 --- a/app/sdks/go/docs/examples/Account/UpdatePassword.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## UpdatePassword - -```go - package appwrite-updatepassword - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call UpdatePassword method and handle results - var res, err := srv.UpdatePassword("password", "password") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/UpdatePrefs.md b/app/sdks/go/docs/examples/Account/UpdatePrefs.md deleted file mode 100644 index 869e12572d..0000000000 --- a/app/sdks/go/docs/examples/Account/UpdatePrefs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## UpdatePrefs - -```go - package appwrite-updateprefs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call UpdatePrefs method and handle results - var res, err := srv.UpdatePrefs("{}") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/get-prefs.md b/app/sdks/go/docs/examples/Account/get-prefs.md deleted file mode 100644 index 0e4cfea354..0000000000 --- a/app/sdks/go/docs/examples/Account/get-prefs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## GetPrefs - -```go - package appwrite-getprefs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call GetPrefs method and handle results - var res, err := srv.GetPrefs() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/get-security.md b/app/sdks/go/docs/examples/Account/get-security.md deleted file mode 100644 index 113eb16ae5..0000000000 --- a/app/sdks/go/docs/examples/Account/get-security.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## GetSecurity - -```go - package appwrite-getsecurity - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call GetSecurity method and handle results - var res, err := srv.GetSecurity() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/get-sessions.md b/app/sdks/go/docs/examples/Account/get-sessions.md deleted file mode 100644 index 153b8e3fe9..0000000000 --- a/app/sdks/go/docs/examples/Account/get-sessions.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## GetSessions - -```go - package appwrite-getsessions - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call GetSessions method and handle results - var res, err := srv.GetSessions() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/update-email.md b/app/sdks/go/docs/examples/Account/update-email.md deleted file mode 100644 index 6f9895257e..0000000000 --- a/app/sdks/go/docs/examples/Account/update-email.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## UpdateEmail - -```go - package appwrite-updateemail - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call UpdateEmail method and handle results - var res, err := srv.UpdateEmail("email@example.com", "password") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/update-name.md b/app/sdks/go/docs/examples/Account/update-name.md deleted file mode 100644 index 3172a94fa6..0000000000 --- a/app/sdks/go/docs/examples/Account/update-name.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## UpdateName - -```go - package appwrite-updatename - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call UpdateName method and handle results - var res, err := srv.UpdateName("[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/update-password.md b/app/sdks/go/docs/examples/Account/update-password.md deleted file mode 100644 index 2aa8543fcd..0000000000 --- a/app/sdks/go/docs/examples/Account/update-password.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## UpdatePassword - -```go - package appwrite-updatepassword - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call UpdatePassword method and handle results - var res, err := srv.UpdatePassword("password", "password") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Account/update-prefs.md b/app/sdks/go/docs/examples/Account/update-prefs.md deleted file mode 100644 index 869e12572d..0000000000 --- a/app/sdks/go/docs/examples/Account/update-prefs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Account Examples - -## UpdatePrefs - -```go - package appwrite-updateprefs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Account service passing Client - var srv := appwrite.Account{ - client: &clt - } - - // Call UpdatePrefs method and handle results - var res, err := srv.UpdatePrefs("{}") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/Confirm.md b/app/sdks/go/docs/examples/Auth/Confirm.md deleted file mode 100644 index c7305d378a..0000000000 --- a/app/sdks/go/docs/examples/Auth/Confirm.md +++ /dev/null @@ -1,33 +0,0 @@ -# Auth Examples - -## Confirm - -```go - package appwrite-confirm - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call Confirm method and handle results - var res, err := srv.Confirm("[USER_ID]", "[TOKEN]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/ConfirmResend.md b/app/sdks/go/docs/examples/Auth/ConfirmResend.md deleted file mode 100644 index 42750db217..0000000000 --- a/app/sdks/go/docs/examples/Auth/ConfirmResend.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## ConfirmResend - -```go - package appwrite-confirmresend - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call ConfirmResend method and handle results - var res, err := srv.ConfirmResend("https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/Login.md b/app/sdks/go/docs/examples/Auth/Login.md deleted file mode 100644 index 2f60a9ffd3..0000000000 --- a/app/sdks/go/docs/examples/Auth/Login.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## Login - -```go - package appwrite-login - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call Login method and handle results - var res, err := srv.Login("email@example.com", "password") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/Logout.md b/app/sdks/go/docs/examples/Auth/Logout.md deleted file mode 100644 index 4a3d126e7e..0000000000 --- a/app/sdks/go/docs/examples/Auth/Logout.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## Logout - -```go - package appwrite-logout - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call Logout method and handle results - var res, err := srv.Logout() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/LogoutBySession.md b/app/sdks/go/docs/examples/Auth/LogoutBySession.md deleted file mode 100644 index 239e764b16..0000000000 --- a/app/sdks/go/docs/examples/Auth/LogoutBySession.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## LogoutBySession - -```go - package appwrite-logoutbysession - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call LogoutBySession method and handle results - var res, err := srv.LogoutBySession("[ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/Oauth.md b/app/sdks/go/docs/examples/Auth/Oauth.md deleted file mode 100644 index 0cfb46726d..0000000000 --- a/app/sdks/go/docs/examples/Auth/Oauth.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## Oauth - -```go - package appwrite-oauth - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call Oauth method and handle results - var res, err := srv.Oauth("bitbucket", "https://example.com", "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/Recovery.md b/app/sdks/go/docs/examples/Auth/Recovery.md deleted file mode 100644 index 4e4e88093c..0000000000 --- a/app/sdks/go/docs/examples/Auth/Recovery.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## Recovery - -```go - package appwrite-recovery - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call Recovery method and handle results - var res, err := srv.Recovery("email@example.com", "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/RecoveryReset.md b/app/sdks/go/docs/examples/Auth/RecoveryReset.md deleted file mode 100644 index d5922708aa..0000000000 --- a/app/sdks/go/docs/examples/Auth/RecoveryReset.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## RecoveryReset - -```go - package appwrite-recoveryreset - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call RecoveryReset method and handle results - var res, err := srv.RecoveryReset("[USER_ID]", "[TOKEN]", "password", "password") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/Register.md b/app/sdks/go/docs/examples/Auth/Register.md deleted file mode 100644 index 8e64c96fcb..0000000000 --- a/app/sdks/go/docs/examples/Auth/Register.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## Register - -```go - package appwrite-register - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call Register method and handle results - var res, err := srv.Register("email@example.com", "password", "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/confirm-resend.md b/app/sdks/go/docs/examples/Auth/confirm-resend.md deleted file mode 100644 index 42750db217..0000000000 --- a/app/sdks/go/docs/examples/Auth/confirm-resend.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## ConfirmResend - -```go - package appwrite-confirmresend - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call ConfirmResend method and handle results - var res, err := srv.ConfirmResend("https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/logout-by-session.md b/app/sdks/go/docs/examples/Auth/logout-by-session.md deleted file mode 100644 index 239e764b16..0000000000 --- a/app/sdks/go/docs/examples/Auth/logout-by-session.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## LogoutBySession - -```go - package appwrite-logoutbysession - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call LogoutBySession method and handle results - var res, err := srv.LogoutBySession("[ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Auth/recovery-reset.md b/app/sdks/go/docs/examples/Auth/recovery-reset.md deleted file mode 100644 index d5922708aa..0000000000 --- a/app/sdks/go/docs/examples/Auth/recovery-reset.md +++ /dev/null @@ -1,35 +0,0 @@ -# Auth Examples - -## RecoveryReset - -```go - package appwrite-recoveryreset - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Auth service passing Client - var srv := appwrite.Auth{ - client: &clt - } - - // Call RecoveryReset method and handle results - var res, err := srv.RecoveryReset("[USER_ID]", "[TOKEN]", "password", "password") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/GetBrowser.md b/app/sdks/go/docs/examples/Avatars/GetBrowser.md deleted file mode 100644 index 9628da910b..0000000000 --- a/app/sdks/go/docs/examples/Avatars/GetBrowser.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetBrowser - -```go - package appwrite-getbrowser - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetBrowser method and handle results - var res, err := srv.GetBrowser("aa") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/GetCreditCard.md b/app/sdks/go/docs/examples/Avatars/GetCreditCard.md deleted file mode 100644 index 488077cfc3..0000000000 --- a/app/sdks/go/docs/examples/Avatars/GetCreditCard.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetCreditCard - -```go - package appwrite-getcreditcard - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetCreditCard method and handle results - var res, err := srv.GetCreditCard("amex") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/GetFavicon.md b/app/sdks/go/docs/examples/Avatars/GetFavicon.md deleted file mode 100644 index c235967d6b..0000000000 --- a/app/sdks/go/docs/examples/Avatars/GetFavicon.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetFavicon - -```go - package appwrite-getfavicon - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetFavicon method and handle results - var res, err := srv.GetFavicon("https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/GetFlag.md b/app/sdks/go/docs/examples/Avatars/GetFlag.md deleted file mode 100644 index 955c96c530..0000000000 --- a/app/sdks/go/docs/examples/Avatars/GetFlag.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetFlag - -```go - package appwrite-getflag - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetFlag method and handle results - var res, err := srv.GetFlag("af") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/GetImage.md b/app/sdks/go/docs/examples/Avatars/GetImage.md deleted file mode 100644 index 11d1c6523d..0000000000 --- a/app/sdks/go/docs/examples/Avatars/GetImage.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetImage - -```go - package appwrite-getimage - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetImage method and handle results - var res, err := srv.GetImage("https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/GetQR.md b/app/sdks/go/docs/examples/Avatars/GetQR.md deleted file mode 100644 index 0874c0e6be..0000000000 --- a/app/sdks/go/docs/examples/Avatars/GetQR.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetQR - -```go - package appwrite-getqr - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetQR method and handle results - var res, err := srv.GetQR("[TEXT]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/get-browser.md b/app/sdks/go/docs/examples/Avatars/get-browser.md deleted file mode 100644 index 9628da910b..0000000000 --- a/app/sdks/go/docs/examples/Avatars/get-browser.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetBrowser - -```go - package appwrite-getbrowser - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetBrowser method and handle results - var res, err := srv.GetBrowser("aa") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/get-credit-card.md b/app/sdks/go/docs/examples/Avatars/get-credit-card.md deleted file mode 100644 index 488077cfc3..0000000000 --- a/app/sdks/go/docs/examples/Avatars/get-credit-card.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetCreditCard - -```go - package appwrite-getcreditcard - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetCreditCard method and handle results - var res, err := srv.GetCreditCard("amex") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/get-favicon.md b/app/sdks/go/docs/examples/Avatars/get-favicon.md deleted file mode 100644 index c235967d6b..0000000000 --- a/app/sdks/go/docs/examples/Avatars/get-favicon.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetFavicon - -```go - package appwrite-getfavicon - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetFavicon method and handle results - var res, err := srv.GetFavicon("https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/get-flag.md b/app/sdks/go/docs/examples/Avatars/get-flag.md deleted file mode 100644 index 955c96c530..0000000000 --- a/app/sdks/go/docs/examples/Avatars/get-flag.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetFlag - -```go - package appwrite-getflag - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetFlag method and handle results - var res, err := srv.GetFlag("af") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/get-image.md b/app/sdks/go/docs/examples/Avatars/get-image.md deleted file mode 100644 index 11d1c6523d..0000000000 --- a/app/sdks/go/docs/examples/Avatars/get-image.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetImage - -```go - package appwrite-getimage - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetImage method and handle results - var res, err := srv.GetImage("https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Avatars/get-q-r.md b/app/sdks/go/docs/examples/Avatars/get-q-r.md deleted file mode 100644 index 0874c0e6be..0000000000 --- a/app/sdks/go/docs/examples/Avatars/get-q-r.md +++ /dev/null @@ -1,35 +0,0 @@ -# Avatars Examples - -## GetQR - -```go - package appwrite-getqr - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Avatars service passing Client - var srv := appwrite.Avatars{ - client: &clt - } - - // Call GetQR method and handle results - var res, err := srv.GetQR("[TEXT]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/CreateCollection.md b/app/sdks/go/docs/examples/Database/CreateCollection.md deleted file mode 100644 index f4f2ab1fc3..0000000000 --- a/app/sdks/go/docs/examples/Database/CreateCollection.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## CreateCollection - -```go - package appwrite-createcollection - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call CreateCollection method and handle results - var res, err := srv.CreateCollection("[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/CreateDocument.md b/app/sdks/go/docs/examples/Database/CreateDocument.md deleted file mode 100644 index ab9aa9e602..0000000000 --- a/app/sdks/go/docs/examples/Database/CreateDocument.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## CreateDocument - -```go - package appwrite-createdocument - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call CreateDocument method and handle results - var res, err := srv.CreateDocument("[COLLECTION_ID]", "{}") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/DeleteCollection.md b/app/sdks/go/docs/examples/Database/DeleteCollection.md deleted file mode 100644 index 85928bde3b..0000000000 --- a/app/sdks/go/docs/examples/Database/DeleteCollection.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## DeleteCollection - -```go - package appwrite-deletecollection - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call DeleteCollection method and handle results - var res, err := srv.DeleteCollection("[COLLECTION_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/DeleteDocument.md b/app/sdks/go/docs/examples/Database/DeleteDocument.md deleted file mode 100644 index 256a0abccb..0000000000 --- a/app/sdks/go/docs/examples/Database/DeleteDocument.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## DeleteDocument - -```go - package appwrite-deletedocument - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call DeleteDocument method and handle results - var res, err := srv.DeleteDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/GetCollection.md b/app/sdks/go/docs/examples/Database/GetCollection.md deleted file mode 100644 index 120ad0a19e..0000000000 --- a/app/sdks/go/docs/examples/Database/GetCollection.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## GetCollection - -```go - package appwrite-getcollection - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call GetCollection method and handle results - var res, err := srv.GetCollection("[COLLECTION_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/GetDocument.md b/app/sdks/go/docs/examples/Database/GetDocument.md deleted file mode 100644 index 8866442b6b..0000000000 --- a/app/sdks/go/docs/examples/Database/GetDocument.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## GetDocument - -```go - package appwrite-getdocument - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call GetDocument method and handle results - var res, err := srv.GetDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/ListCollections.md b/app/sdks/go/docs/examples/Database/ListCollections.md deleted file mode 100644 index 1db6530df7..0000000000 --- a/app/sdks/go/docs/examples/Database/ListCollections.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## ListCollections - -```go - package appwrite-listcollections - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call ListCollections method and handle results - var res, err := srv.ListCollections() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/ListDocuments.md b/app/sdks/go/docs/examples/Database/ListDocuments.md deleted file mode 100644 index 6c46ead8db..0000000000 --- a/app/sdks/go/docs/examples/Database/ListDocuments.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## ListDocuments - -```go - package appwrite-listdocuments - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call ListDocuments method and handle results - var res, err := srv.ListDocuments("[COLLECTION_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/UpdateCollection.md b/app/sdks/go/docs/examples/Database/UpdateCollection.md deleted file mode 100644 index f6ab2b17e1..0000000000 --- a/app/sdks/go/docs/examples/Database/UpdateCollection.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## UpdateCollection - -```go - package appwrite-updatecollection - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call UpdateCollection method and handle results - var res, err := srv.UpdateCollection("[COLLECTION_ID]", "[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/UpdateDocument.md b/app/sdks/go/docs/examples/Database/UpdateDocument.md deleted file mode 100644 index 6a2775e71a..0000000000 --- a/app/sdks/go/docs/examples/Database/UpdateDocument.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## UpdateDocument - -```go - package appwrite-updatedocument - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call UpdateDocument method and handle results - var res, err := srv.UpdateDocument("[COLLECTION_ID]", "[DOCUMENT_ID]", "{}") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/create-collection.md b/app/sdks/go/docs/examples/Database/create-collection.md deleted file mode 100644 index 48e5977c60..0000000000 --- a/app/sdks/go/docs/examples/Database/create-collection.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## CreateCollection - -```go - package appwrite-createcollection - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call CreateCollection method and handle results - var res, err := srv.CreateCollection("[NAME]", [], [], []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/create-document.md b/app/sdks/go/docs/examples/Database/create-document.md deleted file mode 100644 index ccaa02f578..0000000000 --- a/app/sdks/go/docs/examples/Database/create-document.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## CreateDocument - -```go - package appwrite-createdocument - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call CreateDocument method and handle results - var res, err := srv.CreateDocument("[COLLECTION_ID]", "{}", [], []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/delete-collection.md b/app/sdks/go/docs/examples/Database/delete-collection.md deleted file mode 100644 index 85928bde3b..0000000000 --- a/app/sdks/go/docs/examples/Database/delete-collection.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## DeleteCollection - -```go - package appwrite-deletecollection - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call DeleteCollection method and handle results - var res, err := srv.DeleteCollection("[COLLECTION_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/delete-document.md b/app/sdks/go/docs/examples/Database/delete-document.md deleted file mode 100644 index 256a0abccb..0000000000 --- a/app/sdks/go/docs/examples/Database/delete-document.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## DeleteDocument - -```go - package appwrite-deletedocument - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call DeleteDocument method and handle results - var res, err := srv.DeleteDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/get-collection.md b/app/sdks/go/docs/examples/Database/get-collection.md deleted file mode 100644 index 120ad0a19e..0000000000 --- a/app/sdks/go/docs/examples/Database/get-collection.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## GetCollection - -```go - package appwrite-getcollection - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call GetCollection method and handle results - var res, err := srv.GetCollection("[COLLECTION_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/get-document.md b/app/sdks/go/docs/examples/Database/get-document.md deleted file mode 100644 index 8866442b6b..0000000000 --- a/app/sdks/go/docs/examples/Database/get-document.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## GetDocument - -```go - package appwrite-getdocument - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call GetDocument method and handle results - var res, err := srv.GetDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/list-collections.md b/app/sdks/go/docs/examples/Database/list-collections.md deleted file mode 100644 index 1db6530df7..0000000000 --- a/app/sdks/go/docs/examples/Database/list-collections.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## ListCollections - -```go - package appwrite-listcollections - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call ListCollections method and handle results - var res, err := srv.ListCollections() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/list-documents.md b/app/sdks/go/docs/examples/Database/list-documents.md deleted file mode 100644 index 6c46ead8db..0000000000 --- a/app/sdks/go/docs/examples/Database/list-documents.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## ListDocuments - -```go - package appwrite-listdocuments - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call ListDocuments method and handle results - var res, err := srv.ListDocuments("[COLLECTION_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/update-collection.md b/app/sdks/go/docs/examples/Database/update-collection.md deleted file mode 100644 index 7cf07ac2c0..0000000000 --- a/app/sdks/go/docs/examples/Database/update-collection.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## UpdateCollection - -```go - package appwrite-updatecollection - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call UpdateCollection method and handle results - var res, err := srv.UpdateCollection("[COLLECTION_ID]", "[NAME]", [], []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Database/update-document.md b/app/sdks/go/docs/examples/Database/update-document.md deleted file mode 100644 index 88f57eefa9..0000000000 --- a/app/sdks/go/docs/examples/Database/update-document.md +++ /dev/null @@ -1,35 +0,0 @@ -# Database Examples - -## UpdateDocument - -```go - package appwrite-updatedocument - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Database service passing Client - var srv := appwrite.Database{ - client: &clt - } - - // Call UpdateDocument method and handle results - var res, err := srv.UpdateDocument("[COLLECTION_ID]", "[DOCUMENT_ID]", "{}", [], []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/GetCountries.md b/app/sdks/go/docs/examples/Locale/GetCountries.md deleted file mode 100644 index be286c1979..0000000000 --- a/app/sdks/go/docs/examples/Locale/GetCountries.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetCountries - -```go - package appwrite-getcountries - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetCountries method and handle results - var res, err := srv.GetCountries() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/GetCountriesEU.md b/app/sdks/go/docs/examples/Locale/GetCountriesEU.md deleted file mode 100644 index ca8ed7ca48..0000000000 --- a/app/sdks/go/docs/examples/Locale/GetCountriesEU.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetCountriesEU - -```go - package appwrite-getcountrieseu - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetCountriesEU method and handle results - var res, err := srv.GetCountriesEU() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/GetCountriesPhones.md b/app/sdks/go/docs/examples/Locale/GetCountriesPhones.md deleted file mode 100644 index 8847258258..0000000000 --- a/app/sdks/go/docs/examples/Locale/GetCountriesPhones.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetCountriesPhones - -```go - package appwrite-getcountriesphones - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetCountriesPhones method and handle results - var res, err := srv.GetCountriesPhones() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/GetCurrencies.md b/app/sdks/go/docs/examples/Locale/GetCurrencies.md deleted file mode 100644 index fcbb679fd3..0000000000 --- a/app/sdks/go/docs/examples/Locale/GetCurrencies.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetCurrencies - -```go - package appwrite-getcurrencies - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetCurrencies method and handle results - var res, err := srv.GetCurrencies() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/GetLocale.md b/app/sdks/go/docs/examples/Locale/GetLocale.md deleted file mode 100644 index 67cfcdccc9..0000000000 --- a/app/sdks/go/docs/examples/Locale/GetLocale.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetLocale - -```go - package appwrite-getlocale - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetLocale method and handle results - var res, err := srv.GetLocale() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/get-continents.md b/app/sdks/go/docs/examples/Locale/get-continents.md deleted file mode 100644 index faeab3a977..0000000000 --- a/app/sdks/go/docs/examples/Locale/get-continents.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetContinents - -```go - package appwrite-getcontinents - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetContinents method and handle results - var res, err := srv.GetContinents() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/get-countries-e-u.md b/app/sdks/go/docs/examples/Locale/get-countries-e-u.md deleted file mode 100644 index ca8ed7ca48..0000000000 --- a/app/sdks/go/docs/examples/Locale/get-countries-e-u.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetCountriesEU - -```go - package appwrite-getcountrieseu - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetCountriesEU method and handle results - var res, err := srv.GetCountriesEU() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/get-countries-phones.md b/app/sdks/go/docs/examples/Locale/get-countries-phones.md deleted file mode 100644 index 8847258258..0000000000 --- a/app/sdks/go/docs/examples/Locale/get-countries-phones.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetCountriesPhones - -```go - package appwrite-getcountriesphones - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetCountriesPhones method and handle results - var res, err := srv.GetCountriesPhones() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/get-countries.md b/app/sdks/go/docs/examples/Locale/get-countries.md deleted file mode 100644 index be286c1979..0000000000 --- a/app/sdks/go/docs/examples/Locale/get-countries.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetCountries - -```go - package appwrite-getcountries - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetCountries method and handle results - var res, err := srv.GetCountries() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/get-currencies.md b/app/sdks/go/docs/examples/Locale/get-currencies.md deleted file mode 100644 index fcbb679fd3..0000000000 --- a/app/sdks/go/docs/examples/Locale/get-currencies.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetCurrencies - -```go - package appwrite-getcurrencies - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetCurrencies method and handle results - var res, err := srv.GetCurrencies() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Locale/get-locale.md b/app/sdks/go/docs/examples/Locale/get-locale.md deleted file mode 100644 index 67cfcdccc9..0000000000 --- a/app/sdks/go/docs/examples/Locale/get-locale.md +++ /dev/null @@ -1,35 +0,0 @@ -# Locale Examples - -## GetLocale - -```go - package appwrite-getlocale - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Locale service passing Client - var srv := appwrite.Locale{ - client: &clt - } - - // Call GetLocale method and handle results - var res, err := srv.GetLocale() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/CreateKey.md b/app/sdks/go/docs/examples/Projects/CreateKey.md deleted file mode 100644 index 7fa69e4b67..0000000000 --- a/app/sdks/go/docs/examples/Projects/CreateKey.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreateKey - -```go - package appwrite-createkey - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreateKey method and handle results - var res, err := srv.CreateKey("[PROJECT_ID]", "[NAME]", []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/CreatePlatform.md b/app/sdks/go/docs/examples/Projects/CreatePlatform.md deleted file mode 100644 index 7f2d247741..0000000000 --- a/app/sdks/go/docs/examples/Projects/CreatePlatform.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreatePlatform - -```go - package appwrite-createplatform - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreatePlatform method and handle results - var res, err := srv.CreatePlatform("[PROJECT_ID]", "web", "[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/CreateProject.md b/app/sdks/go/docs/examples/Projects/CreateProject.md deleted file mode 100644 index 44525bdcd2..0000000000 --- a/app/sdks/go/docs/examples/Projects/CreateProject.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreateProject - -```go - package appwrite-createproject - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreateProject method and handle results - var res, err := srv.CreateProject("[NAME]", "[TEAM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/CreateTask.md b/app/sdks/go/docs/examples/Projects/CreateTask.md deleted file mode 100644 index 25c617ec9b..0000000000 --- a/app/sdks/go/docs/examples/Projects/CreateTask.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreateTask - -```go - package appwrite-createtask - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreateTask method and handle results - var res, err := srv.CreateTask("[PROJECT_ID]", "[NAME]", "play", "", 0, "GET", "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/CreateWebhook.md b/app/sdks/go/docs/examples/Projects/CreateWebhook.md deleted file mode 100644 index 58e5dc548f..0000000000 --- a/app/sdks/go/docs/examples/Projects/CreateWebhook.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreateWebhook - -```go - package appwrite-createwebhook - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreateWebhook method and handle results - var res, err := srv.CreateWebhook("[PROJECT_ID]", "[NAME]", [], "[URL]", 0) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/DeleteKey.md b/app/sdks/go/docs/examples/Projects/DeleteKey.md deleted file mode 100644 index 3160b37d1c..0000000000 --- a/app/sdks/go/docs/examples/Projects/DeleteKey.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeleteKey - -```go - package appwrite-deletekey - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeleteKey method and handle results - var res, err := srv.DeleteKey("[PROJECT_ID]", "[KEY_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/DeletePlatform.md b/app/sdks/go/docs/examples/Projects/DeletePlatform.md deleted file mode 100644 index a9e3f0d3b9..0000000000 --- a/app/sdks/go/docs/examples/Projects/DeletePlatform.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeletePlatform - -```go - package appwrite-deleteplatform - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeletePlatform method and handle results - var res, err := srv.DeletePlatform("[PROJECT_ID]", "[PLATFORM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/DeleteProject.md b/app/sdks/go/docs/examples/Projects/DeleteProject.md deleted file mode 100644 index 446f640c0d..0000000000 --- a/app/sdks/go/docs/examples/Projects/DeleteProject.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeleteProject - -```go - package appwrite-deleteproject - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeleteProject method and handle results - var res, err := srv.DeleteProject("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/DeleteTask.md b/app/sdks/go/docs/examples/Projects/DeleteTask.md deleted file mode 100644 index a5275e3b04..0000000000 --- a/app/sdks/go/docs/examples/Projects/DeleteTask.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeleteTask - -```go - package appwrite-deletetask - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeleteTask method and handle results - var res, err := srv.DeleteTask("[PROJECT_ID]", "[TASK_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/DeleteWebhook.md b/app/sdks/go/docs/examples/Projects/DeleteWebhook.md deleted file mode 100644 index 377708f6a3..0000000000 --- a/app/sdks/go/docs/examples/Projects/DeleteWebhook.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeleteWebhook - -```go - package appwrite-deletewebhook - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeleteWebhook method and handle results - var res, err := srv.DeleteWebhook("[PROJECT_ID]", "[WEBHOOK_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/GetKey.md b/app/sdks/go/docs/examples/Projects/GetKey.md deleted file mode 100644 index abe636ba31..0000000000 --- a/app/sdks/go/docs/examples/Projects/GetKey.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetKey - -```go - package appwrite-getkey - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetKey method and handle results - var res, err := srv.GetKey("[PROJECT_ID]", "[KEY_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/GetPlatform.md b/app/sdks/go/docs/examples/Projects/GetPlatform.md deleted file mode 100644 index 14a9d3bda5..0000000000 --- a/app/sdks/go/docs/examples/Projects/GetPlatform.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetPlatform - -```go - package appwrite-getplatform - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetPlatform method and handle results - var res, err := srv.GetPlatform("[PROJECT_ID]", "[PLATFORM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/GetProject.md b/app/sdks/go/docs/examples/Projects/GetProject.md deleted file mode 100644 index 8e0986f592..0000000000 --- a/app/sdks/go/docs/examples/Projects/GetProject.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetProject - -```go - package appwrite-getproject - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetProject method and handle results - var res, err := srv.GetProject("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/GetProjectUsage.md b/app/sdks/go/docs/examples/Projects/GetProjectUsage.md deleted file mode 100644 index 2bb6bc4dc5..0000000000 --- a/app/sdks/go/docs/examples/Projects/GetProjectUsage.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetProjectUsage - -```go - package appwrite-getprojectusage - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetProjectUsage method and handle results - var res, err := srv.GetProjectUsage("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/GetTask.md b/app/sdks/go/docs/examples/Projects/GetTask.md deleted file mode 100644 index c6efdf553b..0000000000 --- a/app/sdks/go/docs/examples/Projects/GetTask.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetTask - -```go - package appwrite-gettask - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetTask method and handle results - var res, err := srv.GetTask("[PROJECT_ID]", "[TASK_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/GetWebhook.md b/app/sdks/go/docs/examples/Projects/GetWebhook.md deleted file mode 100644 index b46bf392b5..0000000000 --- a/app/sdks/go/docs/examples/Projects/GetWebhook.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetWebhook - -```go - package appwrite-getwebhook - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetWebhook method and handle results - var res, err := srv.GetWebhook("[PROJECT_ID]", "[WEBHOOK_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/ListKeys.md b/app/sdks/go/docs/examples/Projects/ListKeys.md deleted file mode 100644 index e084035bb5..0000000000 --- a/app/sdks/go/docs/examples/Projects/ListKeys.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListKeys - -```go - package appwrite-listkeys - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListKeys method and handle results - var res, err := srv.ListKeys("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/ListPlatforms.md b/app/sdks/go/docs/examples/Projects/ListPlatforms.md deleted file mode 100644 index ecce7449e1..0000000000 --- a/app/sdks/go/docs/examples/Projects/ListPlatforms.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListPlatforms - -```go - package appwrite-listplatforms - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListPlatforms method and handle results - var res, err := srv.ListPlatforms("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/ListProjects.md b/app/sdks/go/docs/examples/Projects/ListProjects.md deleted file mode 100644 index f17ea76beb..0000000000 --- a/app/sdks/go/docs/examples/Projects/ListProjects.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListProjects - -```go - package appwrite-listprojects - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListProjects method and handle results - var res, err := srv.ListProjects() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/ListTasks.md b/app/sdks/go/docs/examples/Projects/ListTasks.md deleted file mode 100644 index 84f5356c34..0000000000 --- a/app/sdks/go/docs/examples/Projects/ListTasks.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListTasks - -```go - package appwrite-listtasks - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListTasks method and handle results - var res, err := srv.ListTasks("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/ListWebhooks.md b/app/sdks/go/docs/examples/Projects/ListWebhooks.md deleted file mode 100644 index aee6b8da62..0000000000 --- a/app/sdks/go/docs/examples/Projects/ListWebhooks.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListWebhooks - -```go - package appwrite-listwebhooks - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListWebhooks method and handle results - var res, err := srv.ListWebhooks("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/UpdateKey.md b/app/sdks/go/docs/examples/Projects/UpdateKey.md deleted file mode 100644 index 205caef8c8..0000000000 --- a/app/sdks/go/docs/examples/Projects/UpdateKey.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateKey - -```go - package appwrite-updatekey - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateKey method and handle results - var res, err := srv.UpdateKey("[PROJECT_ID]", "[KEY_ID]", "[NAME]", []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/UpdatePlatform.md b/app/sdks/go/docs/examples/Projects/UpdatePlatform.md deleted file mode 100644 index bc966f73a8..0000000000 --- a/app/sdks/go/docs/examples/Projects/UpdatePlatform.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdatePlatform - -```go - package appwrite-updateplatform - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdatePlatform method and handle results - var res, err := srv.UpdatePlatform("[PROJECT_ID]", "[PLATFORM_ID]", "[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/UpdateProject.md b/app/sdks/go/docs/examples/Projects/UpdateProject.md deleted file mode 100644 index 7663ec4c4e..0000000000 --- a/app/sdks/go/docs/examples/Projects/UpdateProject.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateProject - -```go - package appwrite-updateproject - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateProject method and handle results - var res, err := srv.UpdateProject("[PROJECT_ID]", "[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/UpdateProjectOAuth.md b/app/sdks/go/docs/examples/Projects/UpdateProjectOAuth.md deleted file mode 100644 index 58f23b698b..0000000000 --- a/app/sdks/go/docs/examples/Projects/UpdateProjectOAuth.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateProjectOAuth - -```go - package appwrite-updateprojectoauth - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateProjectOAuth method and handle results - var res, err := srv.UpdateProjectOAuth("[PROJECT_ID]", "bitbucket") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/UpdateTask.md b/app/sdks/go/docs/examples/Projects/UpdateTask.md deleted file mode 100644 index f977fd5540..0000000000 --- a/app/sdks/go/docs/examples/Projects/UpdateTask.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateTask - -```go - package appwrite-updatetask - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateTask method and handle results - var res, err := srv.UpdateTask("[PROJECT_ID]", "[TASK_ID]", "[NAME]", "play", "", 0, "GET", "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/UpdateWebhook.md b/app/sdks/go/docs/examples/Projects/UpdateWebhook.md deleted file mode 100644 index 0120707ad5..0000000000 --- a/app/sdks/go/docs/examples/Projects/UpdateWebhook.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateWebhook - -```go - package appwrite-updatewebhook - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateWebhook method and handle results - var res, err := srv.UpdateWebhook("[PROJECT_ID]", "[WEBHOOK_ID]", "[NAME]", [], "[URL]", 0) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/create-key.md b/app/sdks/go/docs/examples/Projects/create-key.md deleted file mode 100644 index 7fa69e4b67..0000000000 --- a/app/sdks/go/docs/examples/Projects/create-key.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreateKey - -```go - package appwrite-createkey - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreateKey method and handle results - var res, err := srv.CreateKey("[PROJECT_ID]", "[NAME]", []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/create-platform.md b/app/sdks/go/docs/examples/Projects/create-platform.md deleted file mode 100644 index 7f2d247741..0000000000 --- a/app/sdks/go/docs/examples/Projects/create-platform.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreatePlatform - -```go - package appwrite-createplatform - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreatePlatform method and handle results - var res, err := srv.CreatePlatform("[PROJECT_ID]", "web", "[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/create-project.md b/app/sdks/go/docs/examples/Projects/create-project.md deleted file mode 100644 index 44525bdcd2..0000000000 --- a/app/sdks/go/docs/examples/Projects/create-project.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreateProject - -```go - package appwrite-createproject - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreateProject method and handle results - var res, err := srv.CreateProject("[NAME]", "[TEAM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/create-task.md b/app/sdks/go/docs/examples/Projects/create-task.md deleted file mode 100644 index 25c617ec9b..0000000000 --- a/app/sdks/go/docs/examples/Projects/create-task.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreateTask - -```go - package appwrite-createtask - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreateTask method and handle results - var res, err := srv.CreateTask("[PROJECT_ID]", "[NAME]", "play", "", 0, "GET", "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/create-webhook.md b/app/sdks/go/docs/examples/Projects/create-webhook.md deleted file mode 100644 index 58e5dc548f..0000000000 --- a/app/sdks/go/docs/examples/Projects/create-webhook.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## CreateWebhook - -```go - package appwrite-createwebhook - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call CreateWebhook method and handle results - var res, err := srv.CreateWebhook("[PROJECT_ID]", "[NAME]", [], "[URL]", 0) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/delete-key.md b/app/sdks/go/docs/examples/Projects/delete-key.md deleted file mode 100644 index 3160b37d1c..0000000000 --- a/app/sdks/go/docs/examples/Projects/delete-key.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeleteKey - -```go - package appwrite-deletekey - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeleteKey method and handle results - var res, err := srv.DeleteKey("[PROJECT_ID]", "[KEY_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/delete-platform.md b/app/sdks/go/docs/examples/Projects/delete-platform.md deleted file mode 100644 index a9e3f0d3b9..0000000000 --- a/app/sdks/go/docs/examples/Projects/delete-platform.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeletePlatform - -```go - package appwrite-deleteplatform - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeletePlatform method and handle results - var res, err := srv.DeletePlatform("[PROJECT_ID]", "[PLATFORM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/delete-project.md b/app/sdks/go/docs/examples/Projects/delete-project.md deleted file mode 100644 index 446f640c0d..0000000000 --- a/app/sdks/go/docs/examples/Projects/delete-project.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeleteProject - -```go - package appwrite-deleteproject - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeleteProject method and handle results - var res, err := srv.DeleteProject("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/delete-task.md b/app/sdks/go/docs/examples/Projects/delete-task.md deleted file mode 100644 index a5275e3b04..0000000000 --- a/app/sdks/go/docs/examples/Projects/delete-task.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeleteTask - -```go - package appwrite-deletetask - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeleteTask method and handle results - var res, err := srv.DeleteTask("[PROJECT_ID]", "[TASK_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/delete-webhook.md b/app/sdks/go/docs/examples/Projects/delete-webhook.md deleted file mode 100644 index 377708f6a3..0000000000 --- a/app/sdks/go/docs/examples/Projects/delete-webhook.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## DeleteWebhook - -```go - package appwrite-deletewebhook - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call DeleteWebhook method and handle results - var res, err := srv.DeleteWebhook("[PROJECT_ID]", "[WEBHOOK_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/get-key.md b/app/sdks/go/docs/examples/Projects/get-key.md deleted file mode 100644 index abe636ba31..0000000000 --- a/app/sdks/go/docs/examples/Projects/get-key.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetKey - -```go - package appwrite-getkey - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetKey method and handle results - var res, err := srv.GetKey("[PROJECT_ID]", "[KEY_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/get-platform.md b/app/sdks/go/docs/examples/Projects/get-platform.md deleted file mode 100644 index 14a9d3bda5..0000000000 --- a/app/sdks/go/docs/examples/Projects/get-platform.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetPlatform - -```go - package appwrite-getplatform - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetPlatform method and handle results - var res, err := srv.GetPlatform("[PROJECT_ID]", "[PLATFORM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/get-project-usage.md b/app/sdks/go/docs/examples/Projects/get-project-usage.md deleted file mode 100644 index 2bb6bc4dc5..0000000000 --- a/app/sdks/go/docs/examples/Projects/get-project-usage.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetProjectUsage - -```go - package appwrite-getprojectusage - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetProjectUsage method and handle results - var res, err := srv.GetProjectUsage("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/get-project.md b/app/sdks/go/docs/examples/Projects/get-project.md deleted file mode 100644 index 8e0986f592..0000000000 --- a/app/sdks/go/docs/examples/Projects/get-project.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetProject - -```go - package appwrite-getproject - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetProject method and handle results - var res, err := srv.GetProject("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/get-task.md b/app/sdks/go/docs/examples/Projects/get-task.md deleted file mode 100644 index c6efdf553b..0000000000 --- a/app/sdks/go/docs/examples/Projects/get-task.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetTask - -```go - package appwrite-gettask - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetTask method and handle results - var res, err := srv.GetTask("[PROJECT_ID]", "[TASK_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/get-webhook.md b/app/sdks/go/docs/examples/Projects/get-webhook.md deleted file mode 100644 index b46bf392b5..0000000000 --- a/app/sdks/go/docs/examples/Projects/get-webhook.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## GetWebhook - -```go - package appwrite-getwebhook - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call GetWebhook method and handle results - var res, err := srv.GetWebhook("[PROJECT_ID]", "[WEBHOOK_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/list-keys.md b/app/sdks/go/docs/examples/Projects/list-keys.md deleted file mode 100644 index e084035bb5..0000000000 --- a/app/sdks/go/docs/examples/Projects/list-keys.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListKeys - -```go - package appwrite-listkeys - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListKeys method and handle results - var res, err := srv.ListKeys("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/list-platforms.md b/app/sdks/go/docs/examples/Projects/list-platforms.md deleted file mode 100644 index ecce7449e1..0000000000 --- a/app/sdks/go/docs/examples/Projects/list-platforms.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListPlatforms - -```go - package appwrite-listplatforms - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListPlatforms method and handle results - var res, err := srv.ListPlatforms("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/list-projects.md b/app/sdks/go/docs/examples/Projects/list-projects.md deleted file mode 100644 index f17ea76beb..0000000000 --- a/app/sdks/go/docs/examples/Projects/list-projects.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListProjects - -```go - package appwrite-listprojects - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListProjects method and handle results - var res, err := srv.ListProjects() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/list-tasks.md b/app/sdks/go/docs/examples/Projects/list-tasks.md deleted file mode 100644 index 84f5356c34..0000000000 --- a/app/sdks/go/docs/examples/Projects/list-tasks.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListTasks - -```go - package appwrite-listtasks - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListTasks method and handle results - var res, err := srv.ListTasks("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/list-webhooks.md b/app/sdks/go/docs/examples/Projects/list-webhooks.md deleted file mode 100644 index aee6b8da62..0000000000 --- a/app/sdks/go/docs/examples/Projects/list-webhooks.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## ListWebhooks - -```go - package appwrite-listwebhooks - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call ListWebhooks method and handle results - var res, err := srv.ListWebhooks("[PROJECT_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/update-key.md b/app/sdks/go/docs/examples/Projects/update-key.md deleted file mode 100644 index 205caef8c8..0000000000 --- a/app/sdks/go/docs/examples/Projects/update-key.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateKey - -```go - package appwrite-updatekey - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateKey method and handle results - var res, err := srv.UpdateKey("[PROJECT_ID]", "[KEY_ID]", "[NAME]", []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/update-platform.md b/app/sdks/go/docs/examples/Projects/update-platform.md deleted file mode 100644 index bc966f73a8..0000000000 --- a/app/sdks/go/docs/examples/Projects/update-platform.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdatePlatform - -```go - package appwrite-updateplatform - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdatePlatform method and handle results - var res, err := srv.UpdatePlatform("[PROJECT_ID]", "[PLATFORM_ID]", "[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/update-project-o-auth.md b/app/sdks/go/docs/examples/Projects/update-project-o-auth.md deleted file mode 100644 index 58f23b698b..0000000000 --- a/app/sdks/go/docs/examples/Projects/update-project-o-auth.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateProjectOAuth - -```go - package appwrite-updateprojectoauth - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateProjectOAuth method and handle results - var res, err := srv.UpdateProjectOAuth("[PROJECT_ID]", "bitbucket") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/update-project.md b/app/sdks/go/docs/examples/Projects/update-project.md deleted file mode 100644 index 7663ec4c4e..0000000000 --- a/app/sdks/go/docs/examples/Projects/update-project.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateProject - -```go - package appwrite-updateproject - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateProject method and handle results - var res, err := srv.UpdateProject("[PROJECT_ID]", "[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/update-task.md b/app/sdks/go/docs/examples/Projects/update-task.md deleted file mode 100644 index f977fd5540..0000000000 --- a/app/sdks/go/docs/examples/Projects/update-task.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateTask - -```go - package appwrite-updatetask - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateTask method and handle results - var res, err := srv.UpdateTask("[PROJECT_ID]", "[TASK_ID]", "[NAME]", "play", "", 0, "GET", "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Projects/update-webhook.md b/app/sdks/go/docs/examples/Projects/update-webhook.md deleted file mode 100644 index 0120707ad5..0000000000 --- a/app/sdks/go/docs/examples/Projects/update-webhook.md +++ /dev/null @@ -1,35 +0,0 @@ -# Projects Examples - -## UpdateWebhook - -```go - package appwrite-updatewebhook - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Projects service passing Client - var srv := appwrite.Projects{ - client: &clt - } - - // Call UpdateWebhook method and handle results - var res, err := srv.UpdateWebhook("[PROJECT_ID]", "[WEBHOOK_ID]", "[NAME]", [], "[URL]", 0) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/CreateFile.md b/app/sdks/go/docs/examples/Storage/CreateFile.md deleted file mode 100644 index 2b33879f54..0000000000 --- a/app/sdks/go/docs/examples/Storage/CreateFile.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## CreateFile - -```go - package appwrite-createfile - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call CreateFile method and handle results - var res, err := srv.CreateFile(file) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/DeleteFile.md b/app/sdks/go/docs/examples/Storage/DeleteFile.md deleted file mode 100644 index c6ecabdf99..0000000000 --- a/app/sdks/go/docs/examples/Storage/DeleteFile.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## DeleteFile - -```go - package appwrite-deletefile - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call DeleteFile method and handle results - var res, err := srv.DeleteFile("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/GetFile.md b/app/sdks/go/docs/examples/Storage/GetFile.md deleted file mode 100644 index 0e7bff0952..0000000000 --- a/app/sdks/go/docs/examples/Storage/GetFile.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## GetFile - -```go - package appwrite-getfile - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call GetFile method and handle results - var res, err := srv.GetFile("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/GetFileDownload.md b/app/sdks/go/docs/examples/Storage/GetFileDownload.md deleted file mode 100644 index 4513337425..0000000000 --- a/app/sdks/go/docs/examples/Storage/GetFileDownload.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## GetFileDownload - -```go - package appwrite-getfiledownload - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call GetFileDownload method and handle results - var res, err := srv.GetFileDownload("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/GetFilePreview.md b/app/sdks/go/docs/examples/Storage/GetFilePreview.md deleted file mode 100644 index a30a271d93..0000000000 --- a/app/sdks/go/docs/examples/Storage/GetFilePreview.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## GetFilePreview - -```go - package appwrite-getfilepreview - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call GetFilePreview method and handle results - var res, err := srv.GetFilePreview("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/GetFileView.md b/app/sdks/go/docs/examples/Storage/GetFileView.md deleted file mode 100644 index 7782cb3b1e..0000000000 --- a/app/sdks/go/docs/examples/Storage/GetFileView.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## GetFileView - -```go - package appwrite-getfileview - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call GetFileView method and handle results - var res, err := srv.GetFileView("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/ListFiles.md b/app/sdks/go/docs/examples/Storage/ListFiles.md deleted file mode 100644 index 7c5d800f6e..0000000000 --- a/app/sdks/go/docs/examples/Storage/ListFiles.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## ListFiles - -```go - package appwrite-listfiles - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call ListFiles method and handle results - var res, err := srv.ListFiles() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/UpdateFile.md b/app/sdks/go/docs/examples/Storage/UpdateFile.md deleted file mode 100644 index 157d44b7a4..0000000000 --- a/app/sdks/go/docs/examples/Storage/UpdateFile.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## UpdateFile - -```go - package appwrite-updatefile - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call UpdateFile method and handle results - var res, err := srv.UpdateFile("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/create-file.md b/app/sdks/go/docs/examples/Storage/create-file.md deleted file mode 100644 index 1d0bf35af8..0000000000 --- a/app/sdks/go/docs/examples/Storage/create-file.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## CreateFile - -```go - package appwrite-createfile - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call CreateFile method and handle results - var res, err := srv.CreateFile(file, [], []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/delete-file.md b/app/sdks/go/docs/examples/Storage/delete-file.md deleted file mode 100644 index c6ecabdf99..0000000000 --- a/app/sdks/go/docs/examples/Storage/delete-file.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## DeleteFile - -```go - package appwrite-deletefile - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call DeleteFile method and handle results - var res, err := srv.DeleteFile("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/get-file-download.md b/app/sdks/go/docs/examples/Storage/get-file-download.md deleted file mode 100644 index 4513337425..0000000000 --- a/app/sdks/go/docs/examples/Storage/get-file-download.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## GetFileDownload - -```go - package appwrite-getfiledownload - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call GetFileDownload method and handle results - var res, err := srv.GetFileDownload("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/get-file-preview.md b/app/sdks/go/docs/examples/Storage/get-file-preview.md deleted file mode 100644 index a30a271d93..0000000000 --- a/app/sdks/go/docs/examples/Storage/get-file-preview.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## GetFilePreview - -```go - package appwrite-getfilepreview - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call GetFilePreview method and handle results - var res, err := srv.GetFilePreview("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/get-file-view.md b/app/sdks/go/docs/examples/Storage/get-file-view.md deleted file mode 100644 index 7782cb3b1e..0000000000 --- a/app/sdks/go/docs/examples/Storage/get-file-view.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## GetFileView - -```go - package appwrite-getfileview - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call GetFileView method and handle results - var res, err := srv.GetFileView("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/get-file.md b/app/sdks/go/docs/examples/Storage/get-file.md deleted file mode 100644 index 0e7bff0952..0000000000 --- a/app/sdks/go/docs/examples/Storage/get-file.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## GetFile - -```go - package appwrite-getfile - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call GetFile method and handle results - var res, err := srv.GetFile("[FILE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/list-files.md b/app/sdks/go/docs/examples/Storage/list-files.md deleted file mode 100644 index 7c5d800f6e..0000000000 --- a/app/sdks/go/docs/examples/Storage/list-files.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## ListFiles - -```go - package appwrite-listfiles - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call ListFiles method and handle results - var res, err := srv.ListFiles() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Storage/update-file.md b/app/sdks/go/docs/examples/Storage/update-file.md deleted file mode 100644 index 01b44bc620..0000000000 --- a/app/sdks/go/docs/examples/Storage/update-file.md +++ /dev/null @@ -1,35 +0,0 @@ -# Storage Examples - -## UpdateFile - -```go - package appwrite-updatefile - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Storage service passing Client - var srv := appwrite.Storage{ - client: &clt - } - - // Call UpdateFile method and handle results - var res, err := srv.UpdateFile("[FILE_ID]", [], []) - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/CreateTeam.md b/app/sdks/go/docs/examples/Teams/CreateTeam.md deleted file mode 100644 index 7922f904f8..0000000000 --- a/app/sdks/go/docs/examples/Teams/CreateTeam.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## CreateTeam - -```go - package appwrite-createteam - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call CreateTeam method and handle results - var res, err := srv.CreateTeam("[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/CreateTeamMembership.md b/app/sdks/go/docs/examples/Teams/CreateTeamMembership.md deleted file mode 100644 index 9d74105ec5..0000000000 --- a/app/sdks/go/docs/examples/Teams/CreateTeamMembership.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## CreateTeamMembership - -```go - package appwrite-createteammembership - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call CreateTeamMembership method and handle results - var res, err := srv.CreateTeamMembership("[TEAM_ID]", "email@example.com", [], "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/CreateTeamMembershipResend.md b/app/sdks/go/docs/examples/Teams/CreateTeamMembershipResend.md deleted file mode 100644 index 9925df6e95..0000000000 --- a/app/sdks/go/docs/examples/Teams/CreateTeamMembershipResend.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## CreateTeamMembershipResend - -```go - package appwrite-createteammembershipresend - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call CreateTeamMembershipResend method and handle results - var res, err := srv.CreateTeamMembershipResend("[TEAM_ID]", "[INVITE_ID]", "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/DeleteTeam.md b/app/sdks/go/docs/examples/Teams/DeleteTeam.md deleted file mode 100644 index fa15cce6d6..0000000000 --- a/app/sdks/go/docs/examples/Teams/DeleteTeam.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## DeleteTeam - -```go - package appwrite-deleteteam - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call DeleteTeam method and handle results - var res, err := srv.DeleteTeam("[TEAM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/DeleteTeamMembership.md b/app/sdks/go/docs/examples/Teams/DeleteTeamMembership.md deleted file mode 100644 index 80cdc936b0..0000000000 --- a/app/sdks/go/docs/examples/Teams/DeleteTeamMembership.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## DeleteTeamMembership - -```go - package appwrite-deleteteammembership - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call DeleteTeamMembership method and handle results - var res, err := srv.DeleteTeamMembership("[TEAM_ID]", "[INVITE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/GetTeam.md b/app/sdks/go/docs/examples/Teams/GetTeam.md deleted file mode 100644 index 8418da4d14..0000000000 --- a/app/sdks/go/docs/examples/Teams/GetTeam.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## GetTeam - -```go - package appwrite-getteam - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call GetTeam method and handle results - var res, err := srv.GetTeam("[TEAM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/GetTeamMembers.md b/app/sdks/go/docs/examples/Teams/GetTeamMembers.md deleted file mode 100644 index 35dd4aa047..0000000000 --- a/app/sdks/go/docs/examples/Teams/GetTeamMembers.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## GetTeamMembers - -```go - package appwrite-getteammembers - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call GetTeamMembers method and handle results - var res, err := srv.GetTeamMembers("[TEAM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/ListTeams.md b/app/sdks/go/docs/examples/Teams/ListTeams.md deleted file mode 100644 index 089daf4697..0000000000 --- a/app/sdks/go/docs/examples/Teams/ListTeams.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## ListTeams - -```go - package appwrite-listteams - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call ListTeams method and handle results - var res, err := srv.ListTeams() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/UpdateTeam.md b/app/sdks/go/docs/examples/Teams/UpdateTeam.md deleted file mode 100644 index d32a67800a..0000000000 --- a/app/sdks/go/docs/examples/Teams/UpdateTeam.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## UpdateTeam - -```go - package appwrite-updateteam - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call UpdateTeam method and handle results - var res, err := srv.UpdateTeam("[TEAM_ID]", "[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/UpdateTeamMembershipStatus.md b/app/sdks/go/docs/examples/Teams/UpdateTeamMembershipStatus.md deleted file mode 100644 index 7d4346d2a3..0000000000 --- a/app/sdks/go/docs/examples/Teams/UpdateTeamMembershipStatus.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## UpdateTeamMembershipStatus - -```go - package appwrite-updateteammembershipstatus - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call UpdateTeamMembershipStatus method and handle results - var res, err := srv.UpdateTeamMembershipStatus("[TEAM_ID]", "[INVITE_ID]", "[USER_ID]", "[SECRET]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/create-team-membership-resend.md b/app/sdks/go/docs/examples/Teams/create-team-membership-resend.md deleted file mode 100644 index 9925df6e95..0000000000 --- a/app/sdks/go/docs/examples/Teams/create-team-membership-resend.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## CreateTeamMembershipResend - -```go - package appwrite-createteammembershipresend - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call CreateTeamMembershipResend method and handle results - var res, err := srv.CreateTeamMembershipResend("[TEAM_ID]", "[INVITE_ID]", "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/create-team-membership.md b/app/sdks/go/docs/examples/Teams/create-team-membership.md deleted file mode 100644 index 9d74105ec5..0000000000 --- a/app/sdks/go/docs/examples/Teams/create-team-membership.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## CreateTeamMembership - -```go - package appwrite-createteammembership - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call CreateTeamMembership method and handle results - var res, err := srv.CreateTeamMembership("[TEAM_ID]", "email@example.com", [], "https://example.com") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/create-team.md b/app/sdks/go/docs/examples/Teams/create-team.md deleted file mode 100644 index 7922f904f8..0000000000 --- a/app/sdks/go/docs/examples/Teams/create-team.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## CreateTeam - -```go - package appwrite-createteam - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call CreateTeam method and handle results - var res, err := srv.CreateTeam("[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/delete-team-membership.md b/app/sdks/go/docs/examples/Teams/delete-team-membership.md deleted file mode 100644 index 80cdc936b0..0000000000 --- a/app/sdks/go/docs/examples/Teams/delete-team-membership.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## DeleteTeamMembership - -```go - package appwrite-deleteteammembership - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call DeleteTeamMembership method and handle results - var res, err := srv.DeleteTeamMembership("[TEAM_ID]", "[INVITE_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/delete-team.md b/app/sdks/go/docs/examples/Teams/delete-team.md deleted file mode 100644 index fa15cce6d6..0000000000 --- a/app/sdks/go/docs/examples/Teams/delete-team.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## DeleteTeam - -```go - package appwrite-deleteteam - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call DeleteTeam method and handle results - var res, err := srv.DeleteTeam("[TEAM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/get-team-members.md b/app/sdks/go/docs/examples/Teams/get-team-members.md deleted file mode 100644 index 35dd4aa047..0000000000 --- a/app/sdks/go/docs/examples/Teams/get-team-members.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## GetTeamMembers - -```go - package appwrite-getteammembers - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call GetTeamMembers method and handle results - var res, err := srv.GetTeamMembers("[TEAM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/get-team.md b/app/sdks/go/docs/examples/Teams/get-team.md deleted file mode 100644 index 8418da4d14..0000000000 --- a/app/sdks/go/docs/examples/Teams/get-team.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## GetTeam - -```go - package appwrite-getteam - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call GetTeam method and handle results - var res, err := srv.GetTeam("[TEAM_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/list-teams.md b/app/sdks/go/docs/examples/Teams/list-teams.md deleted file mode 100644 index 089daf4697..0000000000 --- a/app/sdks/go/docs/examples/Teams/list-teams.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## ListTeams - -```go - package appwrite-listteams - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call ListTeams method and handle results - var res, err := srv.ListTeams() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/update-team-membership-status.md b/app/sdks/go/docs/examples/Teams/update-team-membership-status.md deleted file mode 100644 index 7d4346d2a3..0000000000 --- a/app/sdks/go/docs/examples/Teams/update-team-membership-status.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## UpdateTeamMembershipStatus - -```go - package appwrite-updateteammembershipstatus - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call UpdateTeamMembershipStatus method and handle results - var res, err := srv.UpdateTeamMembershipStatus("[TEAM_ID]", "[INVITE_ID]", "[USER_ID]", "[SECRET]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Teams/update-team.md b/app/sdks/go/docs/examples/Teams/update-team.md deleted file mode 100644 index d32a67800a..0000000000 --- a/app/sdks/go/docs/examples/Teams/update-team.md +++ /dev/null @@ -1,35 +0,0 @@ -# Teams Examples - -## UpdateTeam - -```go - package appwrite-updateteam - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Teams service passing Client - var srv := appwrite.Teams{ - client: &clt - } - - // Call UpdateTeam method and handle results - var res, err := srv.UpdateTeam("[TEAM_ID]", "[NAME]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/CreateUser.md b/app/sdks/go/docs/examples/Users/CreateUser.md deleted file mode 100644 index b790840277..0000000000 --- a/app/sdks/go/docs/examples/Users/CreateUser.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## CreateUser - -```go - package appwrite-createuser - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call CreateUser method and handle results - var res, err := srv.CreateUser("email@example.com", "password") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/DeleteUserSession.md b/app/sdks/go/docs/examples/Users/DeleteUserSession.md deleted file mode 100644 index 6bc880b88a..0000000000 --- a/app/sdks/go/docs/examples/Users/DeleteUserSession.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## DeleteUserSession - -```go - package appwrite-deleteusersession - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call DeleteUserSession method and handle results - var res, err := srv.DeleteUserSession("[USER_ID]", "[SESSION_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/DeleteUserSessions.md b/app/sdks/go/docs/examples/Users/DeleteUserSessions.md deleted file mode 100644 index 8d36d951d5..0000000000 --- a/app/sdks/go/docs/examples/Users/DeleteUserSessions.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## DeleteUserSessions - -```go - package appwrite-deleteusersessions - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call DeleteUserSessions method and handle results - var res, err := srv.DeleteUserSessions("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/GetUser.md b/app/sdks/go/docs/examples/Users/GetUser.md deleted file mode 100644 index d61430718b..0000000000 --- a/app/sdks/go/docs/examples/Users/GetUser.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## GetUser - -```go - package appwrite-getuser - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call GetUser method and handle results - var res, err := srv.GetUser("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/GetUserLogs.md b/app/sdks/go/docs/examples/Users/GetUserLogs.md deleted file mode 100644 index 227d123413..0000000000 --- a/app/sdks/go/docs/examples/Users/GetUserLogs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## GetUserLogs - -```go - package appwrite-getuserlogs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call GetUserLogs method and handle results - var res, err := srv.GetUserLogs("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/GetUserPrefs.md b/app/sdks/go/docs/examples/Users/GetUserPrefs.md deleted file mode 100644 index fc9515a4af..0000000000 --- a/app/sdks/go/docs/examples/Users/GetUserPrefs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## GetUserPrefs - -```go - package appwrite-getuserprefs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call GetUserPrefs method and handle results - var res, err := srv.GetUserPrefs("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/GetUserSessions.md b/app/sdks/go/docs/examples/Users/GetUserSessions.md deleted file mode 100644 index 99dd8b3fff..0000000000 --- a/app/sdks/go/docs/examples/Users/GetUserSessions.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## GetUserSessions - -```go - package appwrite-getusersessions - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call GetUserSessions method and handle results - var res, err := srv.GetUserSessions("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/ListUsers.md b/app/sdks/go/docs/examples/Users/ListUsers.md deleted file mode 100644 index 8332347ba8..0000000000 --- a/app/sdks/go/docs/examples/Users/ListUsers.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## ListUsers - -```go - package appwrite-listusers - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call ListUsers method and handle results - var res, err := srv.ListUsers() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/UpdateUserPrefs.md b/app/sdks/go/docs/examples/Users/UpdateUserPrefs.md deleted file mode 100644 index 50614f238e..0000000000 --- a/app/sdks/go/docs/examples/Users/UpdateUserPrefs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## UpdateUserPrefs - -```go - package appwrite-updateuserprefs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call UpdateUserPrefs method and handle results - var res, err := srv.UpdateUserPrefs("[USER_ID]", "{}") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/UpdateUserStatus.md b/app/sdks/go/docs/examples/Users/UpdateUserStatus.md deleted file mode 100644 index d5570ca041..0000000000 --- a/app/sdks/go/docs/examples/Users/UpdateUserStatus.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## UpdateUserStatus - -```go - package appwrite-updateuserstatus - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call UpdateUserStatus method and handle results - var res, err := srv.UpdateUserStatus("[USER_ID]", "1") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/create-user.md b/app/sdks/go/docs/examples/Users/create-user.md deleted file mode 100644 index b790840277..0000000000 --- a/app/sdks/go/docs/examples/Users/create-user.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## CreateUser - -```go - package appwrite-createuser - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call CreateUser method and handle results - var res, err := srv.CreateUser("email@example.com", "password") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/delete-user-session.md b/app/sdks/go/docs/examples/Users/delete-user-session.md deleted file mode 100644 index 6bc880b88a..0000000000 --- a/app/sdks/go/docs/examples/Users/delete-user-session.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## DeleteUserSession - -```go - package appwrite-deleteusersession - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call DeleteUserSession method and handle results - var res, err := srv.DeleteUserSession("[USER_ID]", "[SESSION_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/delete-user-sessions.md b/app/sdks/go/docs/examples/Users/delete-user-sessions.md deleted file mode 100644 index 8d36d951d5..0000000000 --- a/app/sdks/go/docs/examples/Users/delete-user-sessions.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## DeleteUserSessions - -```go - package appwrite-deleteusersessions - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call DeleteUserSessions method and handle results - var res, err := srv.DeleteUserSessions("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/get-user-logs.md b/app/sdks/go/docs/examples/Users/get-user-logs.md deleted file mode 100644 index 227d123413..0000000000 --- a/app/sdks/go/docs/examples/Users/get-user-logs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## GetUserLogs - -```go - package appwrite-getuserlogs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call GetUserLogs method and handle results - var res, err := srv.GetUserLogs("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/get-user-prefs.md b/app/sdks/go/docs/examples/Users/get-user-prefs.md deleted file mode 100644 index fc9515a4af..0000000000 --- a/app/sdks/go/docs/examples/Users/get-user-prefs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## GetUserPrefs - -```go - package appwrite-getuserprefs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call GetUserPrefs method and handle results - var res, err := srv.GetUserPrefs("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/get-user-sessions.md b/app/sdks/go/docs/examples/Users/get-user-sessions.md deleted file mode 100644 index 99dd8b3fff..0000000000 --- a/app/sdks/go/docs/examples/Users/get-user-sessions.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## GetUserSessions - -```go - package appwrite-getusersessions - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call GetUserSessions method and handle results - var res, err := srv.GetUserSessions("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/get-user.md b/app/sdks/go/docs/examples/Users/get-user.md deleted file mode 100644 index d61430718b..0000000000 --- a/app/sdks/go/docs/examples/Users/get-user.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## GetUser - -```go - package appwrite-getuser - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call GetUser method and handle results - var res, err := srv.GetUser("[USER_ID]") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/list-users.md b/app/sdks/go/docs/examples/Users/list-users.md deleted file mode 100644 index 8332347ba8..0000000000 --- a/app/sdks/go/docs/examples/Users/list-users.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## ListUsers - -```go - package appwrite-listusers - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call ListUsers method and handle results - var res, err := srv.ListUsers() - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/update-user-prefs.md b/app/sdks/go/docs/examples/Users/update-user-prefs.md deleted file mode 100644 index 50614f238e..0000000000 --- a/app/sdks/go/docs/examples/Users/update-user-prefs.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## UpdateUserPrefs - -```go - package appwrite-updateuserprefs - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call UpdateUserPrefs method and handle results - var res, err := srv.UpdateUserPrefs("[USER_ID]", "{}") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/Users/update-user-status.md b/app/sdks/go/docs/examples/Users/update-user-status.md deleted file mode 100644 index d5570ca041..0000000000 --- a/app/sdks/go/docs/examples/Users/update-user-status.md +++ /dev/null @@ -1,35 +0,0 @@ -# Users Examples - -## UpdateUserStatus - -```go - package appwrite-updateuserstatus - - import ( - "fmt" - "os" - "github.com/appwrite/sdk-for-go" - ) - - func main() { - // Create a Client - var clt := appwrite.Client{} - - // Set Client required headers - clt.SetProject("") - clt.SetKey("") - - // Create a new Users service passing Client - var srv := appwrite.Users{ - client: &clt - } - - // Call UpdateUserStatus method and handle results - var res, err := srv.UpdateUserStatus("[USER_ID]", "1") - if err != nil { - panic(err) - } - - fmt.Println(res) - } -``` \ No newline at end of file diff --git a/app/sdks/go/docs/examples/avatars/get-browser.md b/app/sdks/go/docs/examples/avatars/get-browser.md new file mode 100644 index 0000000000..b307cd8dbc --- /dev/null +++ b/app/sdks/go/docs/examples/avatars/get-browser.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Avatars{ + client: &client + } + + var response, error := service.GetBrowser("aa", 0, 0, 0) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/avatars/get-credit-card.md b/app/sdks/go/docs/examples/avatars/get-credit-card.md new file mode 100644 index 0000000000..ffc748d052 --- /dev/null +++ b/app/sdks/go/docs/examples/avatars/get-credit-card.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Avatars{ + client: &client + } + + var response, error := service.GetCreditCard("amex", 0, 0, 0) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/avatars/get-favicon.md b/app/sdks/go/docs/examples/avatars/get-favicon.md new file mode 100644 index 0000000000..596a9d9fd3 --- /dev/null +++ b/app/sdks/go/docs/examples/avatars/get-favicon.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Avatars{ + client: &client + } + + var response, error := service.GetFavicon("https://example.com") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/avatars/get-flag.md b/app/sdks/go/docs/examples/avatars/get-flag.md new file mode 100644 index 0000000000..63042ef0a6 --- /dev/null +++ b/app/sdks/go/docs/examples/avatars/get-flag.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Avatars{ + client: &client + } + + var response, error := service.GetFlag("af", 0, 0, 0) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/avatars/get-image.md b/app/sdks/go/docs/examples/avatars/get-image.md new file mode 100644 index 0000000000..7095ee3658 --- /dev/null +++ b/app/sdks/go/docs/examples/avatars/get-image.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Avatars{ + client: &client + } + + var response, error := service.GetImage("https://example.com", 0, 0) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/avatars/get-q-r.md b/app/sdks/go/docs/examples/avatars/get-q-r.md new file mode 100644 index 0000000000..37425a463e --- /dev/null +++ b/app/sdks/go/docs/examples/avatars/get-q-r.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Avatars{ + client: &client + } + + var response, error := service.GetQR("[TEXT]", 0, 0, 0) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/create-collection.md b/app/sdks/go/docs/examples/database/create-collection.md new file mode 100644 index 0000000000..947ce799ff --- /dev/null +++ b/app/sdks/go/docs/examples/database/create-collection.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.CreateCollection("[NAME]", [], [], []) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/create-document.md b/app/sdks/go/docs/examples/database/create-document.md new file mode 100644 index 0000000000..5b63002464 --- /dev/null +++ b/app/sdks/go/docs/examples/database/create-document.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.CreateDocument("[COLLECTION_ID]", , [], [], "[PARENT_DOCUMENT]", "", "assign") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/delete-collection.md b/app/sdks/go/docs/examples/database/delete-collection.md new file mode 100644 index 0000000000..2b5744730b --- /dev/null +++ b/app/sdks/go/docs/examples/database/delete-collection.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.DeleteCollection("[COLLECTION_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/delete-document.md b/app/sdks/go/docs/examples/database/delete-document.md new file mode 100644 index 0000000000..5dfa23e1b1 --- /dev/null +++ b/app/sdks/go/docs/examples/database/delete-document.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.DeleteDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/get-collection.md b/app/sdks/go/docs/examples/database/get-collection.md new file mode 100644 index 0000000000..bc6d9f7746 --- /dev/null +++ b/app/sdks/go/docs/examples/database/get-collection.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.GetCollection("[COLLECTION_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/get-document.md b/app/sdks/go/docs/examples/database/get-document.md new file mode 100644 index 0000000000..ba4b063f57 --- /dev/null +++ b/app/sdks/go/docs/examples/database/get-document.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.GetDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/list-collections.md b/app/sdks/go/docs/examples/database/list-collections.md new file mode 100644 index 0000000000..0dda37d5e3 --- /dev/null +++ b/app/sdks/go/docs/examples/database/list-collections.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.ListCollections("[SEARCH]", 0, 0, "ASC") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/list-documents.md b/app/sdks/go/docs/examples/database/list-documents.md new file mode 100644 index 0000000000..9f2e36d591 --- /dev/null +++ b/app/sdks/go/docs/examples/database/list-documents.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.ListDocuments("[COLLECTION_ID]", [], 0, 0, "[ORDER_FIELD]", "DESC", "int", "[SEARCH]", 0, 0) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/update-collection.md b/app/sdks/go/docs/examples/database/update-collection.md new file mode 100644 index 0000000000..2b5e7f6d37 --- /dev/null +++ b/app/sdks/go/docs/examples/database/update-collection.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.UpdateCollection("[COLLECTION_ID]", "[NAME]", [], [], []) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/database/update-document.md b/app/sdks/go/docs/examples/database/update-document.md new file mode 100644 index 0000000000..65a3eefa4a --- /dev/null +++ b/app/sdks/go/docs/examples/database/update-document.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.UpdateDocument("[COLLECTION_ID]", "[DOCUMENT_ID]", , [], []) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/locale/get-continents.md b/app/sdks/go/docs/examples/locale/get-continents.md new file mode 100644 index 0000000000..dd9b96ca66 --- /dev/null +++ b/app/sdks/go/docs/examples/locale/get-continents.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Locale{ + client: &client + } + + var response, error := service.GetContinents() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/locale/get-countries-e-u.md b/app/sdks/go/docs/examples/locale/get-countries-e-u.md new file mode 100644 index 0000000000..01a2fedc1b --- /dev/null +++ b/app/sdks/go/docs/examples/locale/get-countries-e-u.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Locale{ + client: &client + } + + var response, error := service.GetCountriesEU() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/locale/get-countries-phones.md b/app/sdks/go/docs/examples/locale/get-countries-phones.md new file mode 100644 index 0000000000..87de9bb2f5 --- /dev/null +++ b/app/sdks/go/docs/examples/locale/get-countries-phones.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Locale{ + client: &client + } + + var response, error := service.GetCountriesPhones() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/locale/get-countries.md b/app/sdks/go/docs/examples/locale/get-countries.md new file mode 100644 index 0000000000..58c74f5f73 --- /dev/null +++ b/app/sdks/go/docs/examples/locale/get-countries.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Locale{ + client: &client + } + + var response, error := service.GetCountries() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/locale/get-currencies.md b/app/sdks/go/docs/examples/locale/get-currencies.md new file mode 100644 index 0000000000..c736db8336 --- /dev/null +++ b/app/sdks/go/docs/examples/locale/get-currencies.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Locale{ + client: &client + } + + var response, error := service.GetCurrencies() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/locale/get.md b/app/sdks/go/docs/examples/locale/get.md new file mode 100644 index 0000000000..3245b79cb5 --- /dev/null +++ b/app/sdks/go/docs/examples/locale/get.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Locale{ + client: &client + } + + var response, error := service.Get() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/storage/create-file.md b/app/sdks/go/docs/examples/storage/create-file.md new file mode 100644 index 0000000000..1348acb40b --- /dev/null +++ b/app/sdks/go/docs/examples/storage/create-file.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Storage{ + client: &client + } + + var response, error := service.CreateFile(file, [], []) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/storage/delete-file.md b/app/sdks/go/docs/examples/storage/delete-file.md new file mode 100644 index 0000000000..6b00581d75 --- /dev/null +++ b/app/sdks/go/docs/examples/storage/delete-file.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Storage{ + client: &client + } + + var response, error := service.DeleteFile("[FILE_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/storage/get-file-download.md b/app/sdks/go/docs/examples/storage/get-file-download.md new file mode 100644 index 0000000000..6c68b14c3b --- /dev/null +++ b/app/sdks/go/docs/examples/storage/get-file-download.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Storage{ + client: &client + } + + var response, error := service.GetFileDownload("[FILE_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/storage/get-file-preview.md b/app/sdks/go/docs/examples/storage/get-file-preview.md new file mode 100644 index 0000000000..86212c82d3 --- /dev/null +++ b/app/sdks/go/docs/examples/storage/get-file-preview.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Storage{ + client: &client + } + + var response, error := service.GetFilePreview("[FILE_ID]", 0, 0, 0, "", "jpg") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/storage/get-file-view.md b/app/sdks/go/docs/examples/storage/get-file-view.md new file mode 100644 index 0000000000..b9ddb637de --- /dev/null +++ b/app/sdks/go/docs/examples/storage/get-file-view.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Storage{ + client: &client + } + + var response, error := service.GetFileView("[FILE_ID]", "pdf") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/storage/get-file.md b/app/sdks/go/docs/examples/storage/get-file.md new file mode 100644 index 0000000000..f9aaa6eb81 --- /dev/null +++ b/app/sdks/go/docs/examples/storage/get-file.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Storage{ + client: &client + } + + var response, error := service.GetFile("[FILE_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/storage/list-files.md b/app/sdks/go/docs/examples/storage/list-files.md new file mode 100644 index 0000000000..53e7e37d5c --- /dev/null +++ b/app/sdks/go/docs/examples/storage/list-files.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Storage{ + client: &client + } + + var response, error := service.ListFiles("[SEARCH]", 0, 0, "ASC") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/storage/update-file.md b/app/sdks/go/docs/examples/storage/update-file.md new file mode 100644 index 0000000000..1ec409de9f --- /dev/null +++ b/app/sdks/go/docs/examples/storage/update-file.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Storage{ + client: &client + } + + var response, error := service.UpdateFile("[FILE_ID]", [], []) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/teams/create-membership.md b/app/sdks/go/docs/examples/teams/create-membership.md new file mode 100644 index 0000000000..a346deaa64 --- /dev/null +++ b/app/sdks/go/docs/examples/teams/create-membership.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Teams{ + client: &client + } + + var response, error := service.CreateMembership("[TEAM_ID]", "email@example.com", [], "https://example.com", "[NAME]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/teams/create.md b/app/sdks/go/docs/examples/teams/create.md new file mode 100644 index 0000000000..8e3a100573 --- /dev/null +++ b/app/sdks/go/docs/examples/teams/create.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Teams{ + client: &client + } + + var response, error := service.Create("[NAME]", []) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/teams/delete-membership.md b/app/sdks/go/docs/examples/teams/delete-membership.md new file mode 100644 index 0000000000..809413a3bf --- /dev/null +++ b/app/sdks/go/docs/examples/teams/delete-membership.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Teams{ + client: &client + } + + var response, error := service.DeleteMembership("[TEAM_ID]", "[INVITE_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/teams/delete.md b/app/sdks/go/docs/examples/teams/delete.md new file mode 100644 index 0000000000..5cf65c2f6f --- /dev/null +++ b/app/sdks/go/docs/examples/teams/delete.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Teams{ + client: &client + } + + var response, error := service.Delete("[TEAM_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/teams/get-memberships.md b/app/sdks/go/docs/examples/teams/get-memberships.md new file mode 100644 index 0000000000..b59a8ff33b --- /dev/null +++ b/app/sdks/go/docs/examples/teams/get-memberships.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Teams{ + client: &client + } + + var response, error := service.GetMemberships("[TEAM_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/teams/get.md b/app/sdks/go/docs/examples/teams/get.md new file mode 100644 index 0000000000..2920f547f2 --- /dev/null +++ b/app/sdks/go/docs/examples/teams/get.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Teams{ + client: &client + } + + var response, error := service.Get("[TEAM_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/teams/list.md b/app/sdks/go/docs/examples/teams/list.md new file mode 100644 index 0000000000..5cd9e3e29e --- /dev/null +++ b/app/sdks/go/docs/examples/teams/list.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Teams{ + client: &client + } + + var response, error := service.List("[SEARCH]", 0, 0, "ASC") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/teams/update.md b/app/sdks/go/docs/examples/teams/update.md new file mode 100644 index 0000000000..40178c8424 --- /dev/null +++ b/app/sdks/go/docs/examples/teams/update.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Teams{ + client: &client + } + + var response, error := service.Update("[TEAM_ID]", "[NAME]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/create.md b/app/sdks/go/docs/examples/users/create.md new file mode 100644 index 0000000000..3a27b00f54 --- /dev/null +++ b/app/sdks/go/docs/examples/users/create.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.Create("email@example.com", "password", "[NAME]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/delete-session.md b/app/sdks/go/docs/examples/users/delete-session.md new file mode 100644 index 0000000000..e1840ba133 --- /dev/null +++ b/app/sdks/go/docs/examples/users/delete-session.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.DeleteSession("[USER_ID]", "[SESSION_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/delete-sessions.md b/app/sdks/go/docs/examples/users/delete-sessions.md new file mode 100644 index 0000000000..682ea0cada --- /dev/null +++ b/app/sdks/go/docs/examples/users/delete-sessions.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.DeleteSessions("[USER_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/get-logs.md b/app/sdks/go/docs/examples/users/get-logs.md new file mode 100644 index 0000000000..6917cc71db --- /dev/null +++ b/app/sdks/go/docs/examples/users/get-logs.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.GetLogs("[USER_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/get-prefs.md b/app/sdks/go/docs/examples/users/get-prefs.md new file mode 100644 index 0000000000..17676eaa36 --- /dev/null +++ b/app/sdks/go/docs/examples/users/get-prefs.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.GetPrefs("[USER_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/get-sessions.md b/app/sdks/go/docs/examples/users/get-sessions.md new file mode 100644 index 0000000000..cc53abfdab --- /dev/null +++ b/app/sdks/go/docs/examples/users/get-sessions.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.GetSessions("[USER_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/get.md b/app/sdks/go/docs/examples/users/get.md new file mode 100644 index 0000000000..8809d1b29b --- /dev/null +++ b/app/sdks/go/docs/examples/users/get.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.Get("[USER_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/list.md b/app/sdks/go/docs/examples/users/list.md new file mode 100644 index 0000000000..ad37e72219 --- /dev/null +++ b/app/sdks/go/docs/examples/users/list.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.List("[SEARCH]", 0, 0, "ASC") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/update-prefs.md b/app/sdks/go/docs/examples/users/update-prefs.md new file mode 100644 index 0000000000..9789b90f25 --- /dev/null +++ b/app/sdks/go/docs/examples/users/update-prefs.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.UpdatePrefs("[USER_ID]", ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/docs/examples/users/update-status.md b/app/sdks/go/docs/examples/users/update-status.md new file mode 100644 index 0000000000..eff2fb5072 --- /dev/null +++ b/app/sdks/go/docs/examples/users/update-status.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Users{ + client: &client + } + + var response, error := service.UpdateStatus("[USER_ID]", "1") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/go/locale.go b/app/sdks/go/locale.go index fa66971182..ecadd889cb 100644 --- a/app/sdks/go/locale.go +++ b/app/sdks/go/locale.go @@ -5,14 +5,24 @@ import ( // Locale service type Locale struct { - client *Client + client Client } -// GetLocale get the current user location based on IP. Returns an object with -// user country code, country name, continent name, continent code, ip address -// and suggested currency. You can use the locale header to get the data in a +func NewLocale(clt Client) Locale { + service := Locale{ + client: clt, + } + + return service +} + +// Get get the current user location based on IP. Returns an object with user +// country code, country name, continent name, continent code, ip address and +// suggested currency. You can use the locale header to get the data in a // supported language. -func (srv *Locale) GetLocale() (map[string]interface{}, error) { +// +// ([IP Geolocation by DB-IP](https://db-ip.com)) +func (srv *Locale) Get() (map[string]interface{}, error) { path := "/locale" params := map[string]interface{}{ @@ -44,9 +54,7 @@ func (srv *Locale) GetCountries() (map[string]interface{}, error) { } // GetCountriesEU list of all countries that are currently members of the EU. -// You can use the locale header to get the data in a supported language. UK -// brexit date is currently set to 2019-10-31 and will be updated if and when -// needed. +// You can use the locale header to get the data in a supported language. func (srv *Locale) GetCountriesEU() (map[string]interface{}, error) { path := "/locale/countries/eu" diff --git a/app/sdks/go/projects.go b/app/sdks/go/projects.go deleted file mode 100644 index d3a425a52c..0000000000 --- a/app/sdks/go/projects.go +++ /dev/null @@ -1,372 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Projects service -type Projects struct { - client *Client -} - -// ListProjects -func (srv *Projects) ListProjects() (map[string]interface{}, error) { - path := "/projects" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateProject -func (srv *Projects) CreateProject(Name string, TeamId string, Description string, Logo string, Url string, LegalName string, LegalCountry string, LegalState string, LegalCity string, LegalAddress string, LegalTaxId string) (map[string]interface{}, error) { - path := "/projects" - - params := map[string]interface{}{ - "name": Name, - "teamId": TeamId, - "description": Description, - "logo": Logo, - "url": Url, - "legalName": LegalName, - "legalCountry": LegalCountry, - "legalState": LegalState, - "legalCity": LegalCity, - "legalAddress": LegalAddress, - "legalTaxId": LegalTaxId, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetProject -func (srv *Projects) GetProject(ProjectId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateProject -func (srv *Projects) UpdateProject(ProjectId string, Name string, Description string, Logo string, Url string, LegalName string, LegalCountry string, LegalState string, LegalCity string, LegalAddress string, LegalTaxId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}") - - params := map[string]interface{}{ - "name": Name, - "description": Description, - "logo": Logo, - "url": Url, - "legalName": LegalName, - "legalCountry": LegalCountry, - "legalState": LegalState, - "legalCity": LegalCity, - "legalAddress": LegalAddress, - "legalTaxId": LegalTaxId, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// DeleteProject -func (srv *Projects) DeleteProject(ProjectId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// ListKeys -func (srv *Projects) ListKeys(ProjectId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/keys") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateKey -func (srv *Projects) CreateKey(ProjectId string, Name string, Scopes []interface{}) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/keys") - - params := map[string]interface{}{ - "name": Name, - "scopes": Scopes, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetKey -func (srv *Projects) GetKey(ProjectId string, KeyId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{keyId}", KeyId) - path := r.Replace("/projects/{projectId}/keys/{keyId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateKey -func (srv *Projects) UpdateKey(ProjectId string, KeyId string, Name string, Scopes []interface{}) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{keyId}", KeyId) - path := r.Replace("/projects/{projectId}/keys/{keyId}") - - params := map[string]interface{}{ - "name": Name, - "scopes": Scopes, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// DeleteKey -func (srv *Projects) DeleteKey(ProjectId string, KeyId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{keyId}", KeyId) - path := r.Replace("/projects/{projectId}/keys/{keyId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// UpdateProjectOAuth -func (srv *Projects) UpdateProjectOAuth(ProjectId string, Provider string, AppId string, Secret string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/oauth") - - params := map[string]interface{}{ - "provider": Provider, - "appId": AppId, - "secret": Secret, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// ListPlatforms -func (srv *Projects) ListPlatforms(ProjectId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/platforms") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreatePlatform -func (srv *Projects) CreatePlatform(ProjectId string, Type string, Name string, Key string, Store string, Url string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/platforms") - - params := map[string]interface{}{ - "type": Type, - "name": Name, - "key": Key, - "store": Store, - "url": Url, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetPlatform -func (srv *Projects) GetPlatform(ProjectId string, PlatformId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{platformId}", PlatformId) - path := r.Replace("/projects/{projectId}/platforms/{platformId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdatePlatform -func (srv *Projects) UpdatePlatform(ProjectId string, PlatformId string, Name string, Key string, Store string, Url string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{platformId}", PlatformId) - path := r.Replace("/projects/{projectId}/platforms/{platformId}") - - params := map[string]interface{}{ - "name": Name, - "key": Key, - "store": Store, - "url": Url, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// DeletePlatform -func (srv *Projects) DeletePlatform(ProjectId string, PlatformId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{platformId}", PlatformId) - path := r.Replace("/projects/{projectId}/platforms/{platformId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// ListTasks -func (srv *Projects) ListTasks(ProjectId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/tasks") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateTask -func (srv *Projects) CreateTask(ProjectId string, Name string, Status string, Schedule string, Security int, HttpMethod string, HttpUrl string, HttpHeaders []interface{}, HttpUser string, HttpPass string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/tasks") - - params := map[string]interface{}{ - "name": Name, - "status": Status, - "schedule": Schedule, - "security": Security, - "httpMethod": HttpMethod, - "httpUrl": HttpUrl, - "httpHeaders": HttpHeaders, - "httpUser": HttpUser, - "httpPass": HttpPass, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetTask -func (srv *Projects) GetTask(ProjectId string, TaskId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{taskId}", TaskId) - path := r.Replace("/projects/{projectId}/tasks/{taskId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateTask -func (srv *Projects) UpdateTask(ProjectId string, TaskId string, Name string, Status string, Schedule string, Security int, HttpMethod string, HttpUrl string, HttpHeaders []interface{}, HttpUser string, HttpPass string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{taskId}", TaskId) - path := r.Replace("/projects/{projectId}/tasks/{taskId}") - - params := map[string]interface{}{ - "name": Name, - "status": Status, - "schedule": Schedule, - "security": Security, - "httpMethod": HttpMethod, - "httpUrl": HttpUrl, - "httpHeaders": HttpHeaders, - "httpUser": HttpUser, - "httpPass": HttpPass, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// DeleteTask -func (srv *Projects) DeleteTask(ProjectId string, TaskId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{taskId}", TaskId) - path := r.Replace("/projects/{projectId}/tasks/{taskId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// GetProjectUsage -func (srv *Projects) GetProjectUsage(ProjectId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/usage") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// ListWebhooks -func (srv *Projects) ListWebhooks(ProjectId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/webhooks") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateWebhook -func (srv *Projects) CreateWebhook(ProjectId string, Name string, Events []interface{}, Url string, Security int, HttpUser string, HttpPass string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId) - path := r.Replace("/projects/{projectId}/webhooks") - - params := map[string]interface{}{ - "name": Name, - "events": Events, - "url": Url, - "security": Security, - "httpUser": HttpUser, - "httpPass": HttpPass, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetWebhook -func (srv *Projects) GetWebhook(ProjectId string, WebhookId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{webhookId}", WebhookId) - path := r.Replace("/projects/{projectId}/webhooks/{webhookId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateWebhook -func (srv *Projects) UpdateWebhook(ProjectId string, WebhookId string, Name string, Events []interface{}, Url string, Security int, HttpUser string, HttpPass string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{webhookId}", WebhookId) - path := r.Replace("/projects/{projectId}/webhooks/{webhookId}") - - params := map[string]interface{}{ - "name": Name, - "events": Events, - "url": Url, - "security": Security, - "httpUser": HttpUser, - "httpPass": HttpPass, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// DeleteWebhook -func (srv *Projects) DeleteWebhook(ProjectId string, WebhookId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{projectId}", ProjectId, "{webhookId}", WebhookId) - path := r.Replace("/projects/{projectId}/webhooks/{webhookId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} diff --git a/app/sdks/go/storage.go b/app/sdks/go/storage.go index c0023cf9af..7ede9c3255 100644 --- a/app/sdks/go/storage.go +++ b/app/sdks/go/storage.go @@ -6,7 +6,15 @@ import ( // Storage service type Storage struct { - client *Client + client Client +} + +func NewStorage(clt Client) Storage { + service := Storage{ + client: clt, + } + + return service } // ListFiles get a list of all the user files. You can use the query params to @@ -28,11 +36,11 @@ func (srv *Storage) ListFiles(Search string, Limit int, Offset int, OrderType st // CreateFile create a new file. The user who creates the file will // automatically be assigned to read and write access unless he has passed // custom values for read and write arguments. -func (srv *Storage) CreateFile(Files string, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { +func (srv *Storage) CreateFile(File string, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { path := "/storage/files" params := map[string]interface{}{ - "files": Files, + "file": File, "read": Read, "write": Write, } @@ -91,10 +99,10 @@ func (srv *Storage) GetFileDownload(FileId string) (map[string]interface{}, erro return srv.client.Call("GET", path, nil, params) } -// GetFilePreview get file preview image. Currently, this method supports +// GetFilePreview get a file preview image. Currently, this method supports // preview for image files (jpg, png, and gif), other supported formats, like -// pdf, docs, slides, and spreadsheets will return file icon image. You can -// also pass query string arguments for cutting and resizing your preview +// pdf, docs, slides, and spreadsheets, will return the file icon image. You +// can also pass query string arguments for cutting and resizing your preview // image. func (srv *Storage) GetFilePreview(FileId string, Width int, Height int, Quality int, Background string, Output string) (map[string]interface{}, error) { r := strings.NewReplacer("{fileId}", FileId) diff --git a/app/sdks/go/teams.go b/app/sdks/go/teams.go index 7a4263f593..14b89e0dda 100644 --- a/app/sdks/go/teams.go +++ b/app/sdks/go/teams.go @@ -6,14 +6,22 @@ import ( // Teams service type Teams struct { - client *Client + client Client } -// ListTeams get a list of all the current user teams. You can use the query -// params to filter your results. On admin mode, this endpoint will return a -// list of all of the project teams. [Learn more about different API +func NewTeams(clt Client) Teams { + service := Teams{ + client: clt, + } + + return service +} + +// List get a list of all the current user teams. You can use the query params +// to filter your results. On admin mode, this endpoint will return a list of +// all of the project teams. [Learn more about different API // modes](/docs/admin). -func (srv *Teams) ListTeams(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { +func (srv *Teams) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { path := "/teams" params := map[string]interface{}{ @@ -26,11 +34,11 @@ func (srv *Teams) ListTeams(Search string, Limit int, Offset int, OrderType stri return srv.client.Call("GET", path, nil, params) } -// CreateTeam create a new team. The user who creates the team will -// automatically be assigned as the owner of the team. The team owner can -// invite new members, who will be able add new owners and update or delete -// the team from your project. -func (srv *Teams) CreateTeam(Name string, Roles []interface{}) (map[string]interface{}, error) { +// Create create a new team. The user who creates the team will automatically +// be assigned as the owner of the team. The team owner can invite new +// members, who will be able add new owners and update or delete the team from +// your project. +func (srv *Teams) Create(Name string, Roles []interface{}) (map[string]interface{}, error) { path := "/teams" params := map[string]interface{}{ @@ -41,9 +49,9 @@ func (srv *Teams) CreateTeam(Name string, Roles []interface{}) (map[string]inter return srv.client.Call("POST", path, nil, params) } -// GetTeam get team by its unique ID. All team members have read access for -// this resource. -func (srv *Teams) GetTeam(TeamId string) (map[string]interface{}, error) { +// Get get team by its unique ID. All team members have read access for this +// resource. +func (srv *Teams) Get(TeamId string) (map[string]interface{}, error) { r := strings.NewReplacer("{teamId}", TeamId) path := r.Replace("/teams/{teamId}") @@ -53,9 +61,9 @@ func (srv *Teams) GetTeam(TeamId string) (map[string]interface{}, error) { return srv.client.Call("GET", path, nil, params) } -// UpdateTeam update team by its unique ID. Only team owners have write access -// for this resource. -func (srv *Teams) UpdateTeam(TeamId string, Name string) (map[string]interface{}, error) { +// Update update team by its unique ID. Only team owners have write access for +// this resource. +func (srv *Teams) Update(TeamId string, Name string) (map[string]interface{}, error) { r := strings.NewReplacer("{teamId}", TeamId) path := r.Replace("/teams/{teamId}") @@ -66,9 +74,9 @@ func (srv *Teams) UpdateTeam(TeamId string, Name string) (map[string]interface{} return srv.client.Call("PUT", path, nil, params) } -// DeleteTeam delete team by its unique ID. Only team owners have write access -// for this resource. -func (srv *Teams) DeleteTeam(TeamId string) (map[string]interface{}, error) { +// Delete delete team by its unique ID. Only team owners have write access for +// this resource. +func (srv *Teams) Delete(TeamId string) (map[string]interface{}, error) { r := strings.NewReplacer("{teamId}", TeamId) path := r.Replace("/teams/{teamId}") @@ -78,11 +86,11 @@ func (srv *Teams) DeleteTeam(TeamId string) (map[string]interface{}, error) { return srv.client.Call("DELETE", path, nil, params) } -// GetTeamMembers get team members by the team unique ID. All team members +// GetMemberships get team members by the team unique ID. All team members // have read access for this list of resources. -func (srv *Teams) GetTeamMembers(TeamId string) (map[string]interface{}, error) { +func (srv *Teams) GetMemberships(TeamId string) (map[string]interface{}, error) { r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}/members") + path := r.Replace("/teams/{teamId}/memberships") params := map[string]interface{}{ } @@ -90,21 +98,21 @@ func (srv *Teams) GetTeamMembers(TeamId string) (map[string]interface{}, error) return srv.client.Call("GET", path, nil, params) } -// CreateTeamMembership use this endpoint to invite a new member to your team. -// An email with a link to join the team will be sent to the new member email -// address. If member doesn't exists in the project it will be automatically -// created. +// CreateMembership use this endpoint to invite a new member to join your +// team. An email with a link to join the team will be sent to the new member +// email address if the member doesn't exist in the project it will be created +// automatically. // -// Use the redirect parameter to redirect the user from the invitation email -// back to your app. When the user is redirected, use the -// /teams/{teamId}/memberships/{inviteId}/status endpoint to finally join the -// user to the team. +// Use the 'URL' parameter to redirect the user from the invitation email back +// to your app. When the user is redirected, use the [Update Team Membership +// Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to +// accept the invitation to the team. // -// Please notice that in order to avoid a [Redirect +// Please note that in order to avoid a [Redirect // Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) // the only valid redirect URL's are the once from domains you have set when // added your platforms in the console interface. -func (srv *Teams) CreateTeamMembership(TeamId string, Email string, Roles []interface{}, Redirect string, Name string) (map[string]interface{}, error) { +func (srv *Teams) CreateMembership(TeamId string, Email string, Roles []interface{}, Url string, Name string) (map[string]interface{}, error) { r := strings.NewReplacer("{teamId}", TeamId) path := r.Replace("/teams/{teamId}/memberships") @@ -112,15 +120,16 @@ func (srv *Teams) CreateTeamMembership(TeamId string, Email string, Roles []inte "email": Email, "name": Name, "roles": Roles, - "redirect": Redirect, + "url": Url, } return srv.client.Call("POST", path, nil, params) } -// DeleteTeamMembership this endpoint allows a user to leave a team or for a -// team owner to delete the membership of any other team member. -func (srv *Teams) DeleteTeamMembership(TeamId string, InviteId string) (map[string]interface{}, error) { +// DeleteMembership this endpoint allows a user to leave a team or for a team +// owner to delete the membership of any other team member. You can also use +// this endpoint to delete a user membership even if he didn't accept it. +func (srv *Teams) DeleteMembership(TeamId string, InviteId string) (map[string]interface{}, error) { r := strings.NewReplacer("{teamId}", TeamId, "{inviteId}", InviteId) path := r.Replace("/teams/{teamId}/memberships/{inviteId}") @@ -129,45 +138,3 @@ func (srv *Teams) DeleteTeamMembership(TeamId string, InviteId string) (map[stri return srv.client.Call("DELETE", path, nil, params) } - -// CreateTeamMembershipResend use this endpoint to resend your invitation -// email for a user to join a team. -func (srv *Teams) CreateTeamMembershipResend(TeamId string, InviteId string, Redirect string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId, "{inviteId}", InviteId) - path := r.Replace("/teams/{teamId}/memberships/{inviteId}/resend") - - params := map[string]interface{}{ - "redirect": Redirect, - } - - return srv.client.Call("POST", path, nil, params) -} - -// UpdateTeamMembershipStatus use this endpoint to let user accept an -// invitation to join a team after he is being redirect back to your app from -// the invitation email. Use the success and failure URL's to redirect users -// back to your application after the request completes. -// -// Please notice that in order to avoid a [Redirect -// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) -// the only valid redirect URL's are the once from domains you have set when -// added your platforms in the console interface. -// -// When not using the success or failure redirect arguments this endpoint will -// result with a 200 status code on success and with 401 status error on -// failure. This behavior was applied to help the web clients deal with -// browsers who don't allow to set 3rd party HTTP cookies needed for saving -// the account session token. -func (srv *Teams) UpdateTeamMembershipStatus(TeamId string, InviteId string, UserId string, Secret string, Success string, Failure string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId, "{inviteId}", InviteId) - path := r.Replace("/teams/{teamId}/memberships/{inviteId}/status") - - params := map[string]interface{}{ - "userId": UserId, - "secret": Secret, - "success": Success, - "failure": Failure, - } - - return srv.client.Call("PATCH", path, nil, params) -} diff --git a/app/sdks/go/users.go b/app/sdks/go/users.go index 6ef84d510a..dc1b6be977 100644 --- a/app/sdks/go/users.go +++ b/app/sdks/go/users.go @@ -6,12 +6,20 @@ import ( // Users service type Users struct { - client *Client + client Client } -// ListUsers get a list of all the project users. You can use the query params -// to filter your results. -func (srv *Users) ListUsers(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { +func NewUsers(clt Client) Users { + service := Users{ + client: clt, + } + + return service +} + +// List get a list of all the project users. You can use the query params to +// filter your results. +func (srv *Users) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { path := "/users" params := map[string]interface{}{ @@ -24,8 +32,8 @@ func (srv *Users) ListUsers(Search string, Limit int, Offset int, OrderType stri return srv.client.Call("GET", path, nil, params) } -// CreateUser create a new user. -func (srv *Users) CreateUser(Email string, Password string, Name string) (map[string]interface{}, error) { +// Create create a new user. +func (srv *Users) Create(Email string, Password string, Name string) (map[string]interface{}, error) { path := "/users" params := map[string]interface{}{ @@ -37,8 +45,8 @@ func (srv *Users) CreateUser(Email string, Password string, Name string) (map[st return srv.client.Call("POST", path, nil, params) } -// GetUser get user by its unique ID. -func (srv *Users) GetUser(UserId string) (map[string]interface{}, error) { +// Get get user by its unique ID. +func (srv *Users) Get(UserId string) (map[string]interface{}, error) { r := strings.NewReplacer("{userId}", UserId) path := r.Replace("/users/{userId}") @@ -48,8 +56,8 @@ func (srv *Users) GetUser(UserId string) (map[string]interface{}, error) { return srv.client.Call("GET", path, nil, params) } -// GetUserLogs get user activity logs list by its unique ID. -func (srv *Users) GetUserLogs(UserId string) (map[string]interface{}, error) { +// GetLogs get user activity logs list by its unique ID. +func (srv *Users) GetLogs(UserId string) (map[string]interface{}, error) { r := strings.NewReplacer("{userId}", UserId) path := r.Replace("/users/{userId}/logs") @@ -59,8 +67,8 @@ func (srv *Users) GetUserLogs(UserId string) (map[string]interface{}, error) { return srv.client.Call("GET", path, nil, params) } -// GetUserPrefs get user preferences by its unique ID. -func (srv *Users) GetUserPrefs(UserId string) (map[string]interface{}, error) { +// GetPrefs get user preferences by its unique ID. +func (srv *Users) GetPrefs(UserId string) (map[string]interface{}, error) { r := strings.NewReplacer("{userId}", UserId) path := r.Replace("/users/{userId}/prefs") @@ -70,9 +78,9 @@ func (srv *Users) GetUserPrefs(UserId string) (map[string]interface{}, error) { return srv.client.Call("GET", path, nil, params) } -// UpdateUserPrefs update user preferences by its unique ID. You can pass only -// the specific settings you wish to update. -func (srv *Users) UpdateUserPrefs(UserId string, Prefs string) (map[string]interface{}, error) { +// UpdatePrefs update user preferences by its unique ID. You can pass only the +// specific settings you wish to update. +func (srv *Users) UpdatePrefs(UserId string, Prefs object) (map[string]interface{}, error) { r := strings.NewReplacer("{userId}", UserId) path := r.Replace("/users/{userId}/prefs") @@ -83,8 +91,8 @@ func (srv *Users) UpdateUserPrefs(UserId string, Prefs string) (map[string]inter return srv.client.Call("PATCH", path, nil, params) } -// GetUserSessions get user sessions list by its unique ID. -func (srv *Users) GetUserSessions(UserId string) (map[string]interface{}, error) { +// GetSessions get user sessions list by its unique ID. +func (srv *Users) GetSessions(UserId string) (map[string]interface{}, error) { r := strings.NewReplacer("{userId}", UserId) path := r.Replace("/users/{userId}/sessions") @@ -94,8 +102,8 @@ func (srv *Users) GetUserSessions(UserId string) (map[string]interface{}, error) return srv.client.Call("GET", path, nil, params) } -// DeleteUserSessions delete all user sessions by its unique ID. -func (srv *Users) DeleteUserSessions(UserId string) (map[string]interface{}, error) { +// DeleteSessions delete all user sessions by its unique ID. +func (srv *Users) DeleteSessions(UserId string) (map[string]interface{}, error) { r := strings.NewReplacer("{userId}", UserId) path := r.Replace("/users/{userId}/sessions") @@ -105,8 +113,8 @@ func (srv *Users) DeleteUserSessions(UserId string) (map[string]interface{}, err return srv.client.Call("DELETE", path, nil, params) } -// DeleteUserSession delete user sessions by its unique ID. -func (srv *Users) DeleteUserSession(UserId string, SessionId string) (map[string]interface{}, error) { +// DeleteSession delete user sessions by its unique ID. +func (srv *Users) DeleteSession(UserId string, SessionId string) (map[string]interface{}, error) { r := strings.NewReplacer("{userId}", UserId) path := r.Replace("/users/{userId}/sessions/:session") @@ -117,8 +125,8 @@ func (srv *Users) DeleteUserSession(UserId string, SessionId string) (map[string return srv.client.Call("DELETE", path, nil, params) } -// UpdateUserStatus update user status by its unique ID. -func (srv *Users) UpdateUserStatus(UserId string, Status string) (map[string]interface{}, error) { +// UpdateStatus update user status by its unique ID. +func (srv *Users) UpdateStatus(UserId string, Status string) (map[string]interface{}, error) { r := strings.NewReplacer("{userId}", UserId) path := r.Replace("/users/{userId}/status") diff --git a/app/sdks/js/LICENSE b/app/sdks/javascript/LICENSE similarity index 100% rename from app/sdks/js/LICENSE rename to app/sdks/javascript/LICENSE diff --git a/app/sdks/js/README.md b/app/sdks/javascript/README.md similarity index 71% rename from app/sdks/js/README.md rename to app/sdks/javascript/README.md index f104da6caa..fcd2a9abbe 100644 --- a/app/sdks/js/README.md +++ b/app/sdks/javascript/README.md @@ -1,9 +1,7 @@ # Appwrite SDK for JavaScript ![License](https://img.shields.io/github/license/appwrite/sdk-for-js.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1) - -**This SDK is compatible with Appwrite server version 0.4.0. For older versions, please check previous releases.** +![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1) Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -33,21 +31,6 @@ To install with a CDN (content delivery network) add the following scripts to th ``` -## Getting Started - -Initialise the Appwrite SDK in your code, and setup your API credentials: - -```js - -// Init your JS SDK -var appwrite = new Appwrite(); - -appwrite - .setEndpoint('http://localhost/v1') // Set only when using self-hosted solution - .setProject('455x34dfkj') // Your Appwrite Project UID -; - -``` ## License diff --git a/app/sdks/javascript/docs/examples/account/create-o-auth-session.md b/app/sdks/javascript/docs/examples/account/create-o-auth-session.md new file mode 100644 index 0000000000..a201c8b4c1 --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/create-o-auth-session.md @@ -0,0 +1,9 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let result = sdk.account.createOAuthSession('bitbucket', 'https://example.com', 'https://example.com'); + +console.log(result); // Resource URL diff --git a/app/sdks/javascript/docs/examples/account/create-o-auth2session.md b/app/sdks/javascript/docs/examples/account/create-o-auth2session.md new file mode 100644 index 0000000000..ee4b20402d --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/create-o-auth2session.md @@ -0,0 +1,9 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let result = sdk.account.createOAuth2Session('bitbucket', 'https://example.com', 'https://example.com'); + +console.log(result); // Resource URL diff --git a/app/sdks/javascript/docs/examples/account/create-recovery.md b/app/sdks/javascript/docs/examples/account/create-recovery.md new file mode 100644 index 0000000000..0647f3e468 --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/create-recovery.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.createRecovery('email@example.com', 'https://example.com'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/account/create-session.md b/app/sdks/javascript/docs/examples/account/create-session.md new file mode 100644 index 0000000000..1a02c4c131 --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/create-session.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.createSession('email@example.com', 'password'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/account/create-verification.md b/app/sdks/javascript/docs/examples/account/create-verification.md new file mode 100644 index 0000000000..69488635f4 --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/create-verification.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.createVerification('https://example.com'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/account/create.md b/app/sdks/javascript/docs/examples/account/create.md new file mode 100644 index 0000000000..fb6e235aa3 --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/create.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.create('email@example.com', 'password'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/account/delete-session.md b/app/sdks/javascript/docs/examples/account/delete-session.md new file mode 100644 index 0000000000..598c9269ec --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/delete-session.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.deleteSession('[SESSION_ID]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/account/delete-sessions.md b/app/sdks/javascript/docs/examples/account/delete-sessions.md new file mode 100644 index 0000000000..7c988afa33 --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/delete-sessions.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.deleteSessions(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/account/delete.md b/app/sdks/javascript/docs/examples/account/delete.md similarity index 51% rename from app/sdks/js/docs/examples/account/delete.md rename to app/sdks/javascript/docs/examples/account/delete.md index c199f0f719..2679c444b0 100644 --- a/app/sdks/js/docs/examples/account/delete.md +++ b/app/sdks/javascript/docs/examples/account/delete.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.account.delete(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/account/get-logs.md b/app/sdks/javascript/docs/examples/account/get-logs.md new file mode 100644 index 0000000000..b1234e1929 --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/get-logs.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.getLogs(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/account/get-prefs.md b/app/sdks/javascript/docs/examples/account/get-prefs.md similarity index 51% rename from app/sdks/js/docs/examples/account/get-prefs.md rename to app/sdks/javascript/docs/examples/account/get-prefs.md index 39f8950138..7e9a1df84f 100644 --- a/app/sdks/js/docs/examples/account/get-prefs.md +++ b/app/sdks/javascript/docs/examples/account/get-prefs.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.account.getPrefs(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/account/get-sessions.md b/app/sdks/javascript/docs/examples/account/get-sessions.md similarity index 52% rename from app/sdks/js/docs/examples/account/get-sessions.md rename to app/sdks/javascript/docs/examples/account/get-sessions.md index 963400deeb..96eefa6422 100644 --- a/app/sdks/js/docs/examples/account/get-sessions.md +++ b/app/sdks/javascript/docs/examples/account/get-sessions.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.account.getSessions(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/account/get.md b/app/sdks/javascript/docs/examples/account/get.md similarity index 50% rename from app/sdks/js/docs/examples/account/get.md rename to app/sdks/javascript/docs/examples/account/get.md index 682e09fbd8..0a0c7a2ccc 100644 --- a/app/sdks/js/docs/examples/account/get.md +++ b/app/sdks/javascript/docs/examples/account/get.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.account.get(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/account/update-email.md b/app/sdks/javascript/docs/examples/account/update-email.md similarity index 57% rename from app/sdks/js/docs/examples/account/update-email.md rename to app/sdks/javascript/docs/examples/account/update-email.md index e9fb9c9ed2..4beeeb8cf8 100644 --- a/app/sdks/js/docs/examples/account/update-email.md +++ b/app/sdks/javascript/docs/examples/account/update-email.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.account.updateEmail('email@example.com', 'password'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/account/update-name.md b/app/sdks/javascript/docs/examples/account/update-name.md similarity index 53% rename from app/sdks/js/docs/examples/account/update-name.md rename to app/sdks/javascript/docs/examples/account/update-name.md index 2e5531e4c3..0464d29405 100644 --- a/app/sdks/js/docs/examples/account/update-name.md +++ b/app/sdks/javascript/docs/examples/account/update-name.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.account.updateName('[NAME]'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/account/update-password.md b/app/sdks/javascript/docs/examples/account/update-password.md similarity index 56% rename from app/sdks/js/docs/examples/account/update-password.md rename to app/sdks/javascript/docs/examples/account/update-password.md index e4ddc7fc49..14180f4b5b 100644 --- a/app/sdks/js/docs/examples/account/update-password.md +++ b/app/sdks/javascript/docs/examples/account/update-password.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.account.updatePassword('password', 'password'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/account/update-prefs.md b/app/sdks/javascript/docs/examples/account/update-prefs.md new file mode 100644 index 0000000000..0e7d005134 --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/update-prefs.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.updatePrefs({}); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/account/update-recovery.md b/app/sdks/javascript/docs/examples/account/update-recovery.md new file mode 100644 index 0000000000..9c16f06cb5 --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/update-recovery.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.updateRecovery('[USER_ID]', '[SECRET]', 'password', 'password'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/account/update-verification.md b/app/sdks/javascript/docs/examples/account/update-verification.md new file mode 100644 index 0000000000..f01eeb26db --- /dev/null +++ b/app/sdks/javascript/docs/examples/account/update-verification.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.account.updateVerification('[USER_ID]', '[SECRET]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/avatars/get-browser.md b/app/sdks/javascript/docs/examples/avatars/get-browser.md similarity index 52% rename from app/sdks/js/docs/examples/avatars/get-browser.md rename to app/sdks/javascript/docs/examples/avatars/get-browser.md index 84c992621e..0e76e4050c 100644 --- a/app/sdks/js/docs/examples/avatars/get-browser.md +++ b/app/sdks/javascript/docs/examples/avatars/get-browser.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.avatars.getBrowser('aa'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/avatars/get-credit-card.md b/app/sdks/javascript/docs/examples/avatars/get-credit-card.md similarity index 53% rename from app/sdks/js/docs/examples/avatars/get-credit-card.md rename to app/sdks/javascript/docs/examples/avatars/get-credit-card.md index c9fb87edc7..584f24d8a0 100644 --- a/app/sdks/js/docs/examples/avatars/get-credit-card.md +++ b/app/sdks/javascript/docs/examples/avatars/get-credit-card.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.avatars.getCreditCard('amex'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/avatars/get-favicon.md b/app/sdks/javascript/docs/examples/avatars/get-favicon.md similarity index 55% rename from app/sdks/js/docs/examples/avatars/get-favicon.md rename to app/sdks/javascript/docs/examples/avatars/get-favicon.md index 5876eb2b5a..292a4f4403 100644 --- a/app/sdks/js/docs/examples/avatars/get-favicon.md +++ b/app/sdks/javascript/docs/examples/avatars/get-favicon.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.avatars.getFavicon('https://example.com'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/avatars/get-flag.md b/app/sdks/javascript/docs/examples/avatars/get-flag.md similarity index 52% rename from app/sdks/js/docs/examples/avatars/get-flag.md rename to app/sdks/javascript/docs/examples/avatars/get-flag.md index 694c6b399e..fc5e6ff644 100644 --- a/app/sdks/js/docs/examples/avatars/get-flag.md +++ b/app/sdks/javascript/docs/examples/avatars/get-flag.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.avatars.getFlag('af'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/avatars/get-image.md b/app/sdks/javascript/docs/examples/avatars/get-image.md similarity index 55% rename from app/sdks/js/docs/examples/avatars/get-image.md rename to app/sdks/javascript/docs/examples/avatars/get-image.md index b807ff734e..7f5468d4a9 100644 --- a/app/sdks/js/docs/examples/avatars/get-image.md +++ b/app/sdks/javascript/docs/examples/avatars/get-image.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.avatars.getImage('https://example.com'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/avatars/get-q-r.md b/app/sdks/javascript/docs/examples/avatars/get-q-r.md similarity index 52% rename from app/sdks/js/docs/examples/avatars/get-q-r.md rename to app/sdks/javascript/docs/examples/avatars/get-q-r.md index e64d83a5c4..33ae75a2d4 100644 --- a/app/sdks/js/docs/examples/avatars/get-q-r.md +++ b/app/sdks/javascript/docs/examples/avatars/get-q-r.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.avatars.getQR('[TEXT]'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/database/create-document.md b/app/sdks/javascript/docs/examples/database/create-document.md new file mode 100644 index 0000000000..200a752a07 --- /dev/null +++ b/app/sdks/javascript/docs/examples/database/create-document.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.database.createDocument('[COLLECTION_ID]', {}, [], []); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/delete-document.md b/app/sdks/javascript/docs/examples/database/delete-document.md similarity index 58% rename from app/sdks/js/docs/examples/database/delete-document.md rename to app/sdks/javascript/docs/examples/database/delete-document.md index 7dd7fc4db4..d40c106ae2 100644 --- a/app/sdks/js/docs/examples/database/delete-document.md +++ b/app/sdks/javascript/docs/examples/database/delete-document.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.database.deleteDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/get-document.md b/app/sdks/javascript/docs/examples/database/get-document.md similarity index 57% rename from app/sdks/js/docs/examples/database/get-document.md rename to app/sdks/javascript/docs/examples/database/get-document.md index 1bcb5b00ac..a554fe21b9 100644 --- a/app/sdks/js/docs/examples/database/get-document.md +++ b/app/sdks/javascript/docs/examples/database/get-document.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.database.getDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/list-documents.md b/app/sdks/javascript/docs/examples/database/list-documents.md similarity index 55% rename from app/sdks/js/docs/examples/database/list-documents.md rename to app/sdks/javascript/docs/examples/database/list-documents.md index 68ce8d6c23..aab086d8be 100644 --- a/app/sdks/js/docs/examples/database/list-documents.md +++ b/app/sdks/javascript/docs/examples/database/list-documents.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.database.listDocuments('[COLLECTION_ID]'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/update-document.md b/app/sdks/javascript/docs/examples/database/update-document.md similarity index 51% rename from app/sdks/js/docs/examples/database/update-document.md rename to app/sdks/javascript/docs/examples/database/update-document.md index 7809b97bfd..b299576b93 100644 --- a/app/sdks/js/docs/examples/database/update-document.md +++ b/app/sdks/javascript/docs/examples/database/update-document.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; -let promise = sdk.database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', '{}', [], []); +let promise = sdk.database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {}, [], []); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/locale/get-continents.md b/app/sdks/javascript/docs/examples/locale/get-continents.md similarity index 52% rename from app/sdks/js/docs/examples/locale/get-continents.md rename to app/sdks/javascript/docs/examples/locale/get-continents.md index a8de63eb91..54bfeee869 100644 --- a/app/sdks/js/docs/examples/locale/get-continents.md +++ b/app/sdks/javascript/docs/examples/locale/get-continents.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.locale.getContinents(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/locale/get-countries-e-u.md b/app/sdks/javascript/docs/examples/locale/get-countries-e-u.md similarity index 52% rename from app/sdks/js/docs/examples/locale/get-countries-e-u.md rename to app/sdks/javascript/docs/examples/locale/get-countries-e-u.md index 44ceffd7e7..19444cbeb2 100644 --- a/app/sdks/js/docs/examples/locale/get-countries-e-u.md +++ b/app/sdks/javascript/docs/examples/locale/get-countries-e-u.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.locale.getCountriesEU(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/locale/get-countries-phones.md b/app/sdks/javascript/docs/examples/locale/get-countries-phones.md similarity index 53% rename from app/sdks/js/docs/examples/locale/get-countries-phones.md rename to app/sdks/javascript/docs/examples/locale/get-countries-phones.md index afd084f5d4..b32ddea06e 100644 --- a/app/sdks/js/docs/examples/locale/get-countries-phones.md +++ b/app/sdks/javascript/docs/examples/locale/get-countries-phones.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.locale.getCountriesPhones(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/locale/get-countries.md b/app/sdks/javascript/docs/examples/locale/get-countries.md similarity index 52% rename from app/sdks/js/docs/examples/locale/get-countries.md rename to app/sdks/javascript/docs/examples/locale/get-countries.md index 521195bfaa..7ea903cf74 100644 --- a/app/sdks/js/docs/examples/locale/get-countries.md +++ b/app/sdks/javascript/docs/examples/locale/get-countries.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.locale.getCountries(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/locale/get-currencies.md b/app/sdks/javascript/docs/examples/locale/get-currencies.md similarity index 52% rename from app/sdks/js/docs/examples/locale/get-currencies.md rename to app/sdks/javascript/docs/examples/locale/get-currencies.md index 8032307f86..56b5ba8a7d 100644 --- a/app/sdks/js/docs/examples/locale/get-currencies.md +++ b/app/sdks/javascript/docs/examples/locale/get-currencies.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.locale.getCurrencies(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/locale/get.md b/app/sdks/javascript/docs/examples/locale/get.md new file mode 100644 index 0000000000..1358ced165 --- /dev/null +++ b/app/sdks/javascript/docs/examples/locale/get.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.locale.get(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/storage/create-file.md b/app/sdks/javascript/docs/examples/storage/create-file.md similarity index 59% rename from app/sdks/js/docs/examples/storage/create-file.md rename to app/sdks/javascript/docs/examples/storage/create-file.md index 53157d19a3..0cfd25a3f0 100644 --- a/app/sdks/js/docs/examples/storage/create-file.md +++ b/app/sdks/javascript/docs/examples/storage/create-file.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.storage.createFile(document.getElementById('uploader').files[0], [], []); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/storage/delete-file.md b/app/sdks/javascript/docs/examples/storage/delete-file.md similarity index 53% rename from app/sdks/js/docs/examples/storage/delete-file.md rename to app/sdks/javascript/docs/examples/storage/delete-file.md index 4e39bd9811..54c3c217c7 100644 --- a/app/sdks/js/docs/examples/storage/delete-file.md +++ b/app/sdks/javascript/docs/examples/storage/delete-file.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.storage.deleteFile('[FILE_ID]'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/storage/get-file-download.md b/app/sdks/javascript/docs/examples/storage/get-file-download.md new file mode 100644 index 0000000000..817388b206 --- /dev/null +++ b/app/sdks/javascript/docs/examples/storage/get-file-download.md @@ -0,0 +1,9 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let result = sdk.storage.getFileDownload('[FILE_ID]'); + +console.log(result); // Resource URL diff --git a/app/sdks/javascript/docs/examples/storage/get-file-preview.md b/app/sdks/javascript/docs/examples/storage/get-file-preview.md new file mode 100644 index 0000000000..81fd86c4fc --- /dev/null +++ b/app/sdks/javascript/docs/examples/storage/get-file-preview.md @@ -0,0 +1,9 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let result = sdk.storage.getFilePreview('[FILE_ID]'); + +console.log(result); // Resource URL diff --git a/app/sdks/javascript/docs/examples/storage/get-file-view.md b/app/sdks/javascript/docs/examples/storage/get-file-view.md new file mode 100644 index 0000000000..c9bd9c3c69 --- /dev/null +++ b/app/sdks/javascript/docs/examples/storage/get-file-view.md @@ -0,0 +1,9 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let result = sdk.storage.getFileView('[FILE_ID]'); + +console.log(result); // Resource URL diff --git a/app/sdks/js/docs/examples/storage/get-file.md b/app/sdks/javascript/docs/examples/storage/get-file.md similarity index 53% rename from app/sdks/js/docs/examples/storage/get-file.md rename to app/sdks/javascript/docs/examples/storage/get-file.md index 32b11a2175..abe4f6993f 100644 --- a/app/sdks/js/docs/examples/storage/get-file.md +++ b/app/sdks/javascript/docs/examples/storage/get-file.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.storage.getFile('[FILE_ID]'); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/storage/list-files.md b/app/sdks/javascript/docs/examples/storage/list-files.md similarity index 51% rename from app/sdks/js/docs/examples/storage/list-files.md rename to app/sdks/javascript/docs/examples/storage/list-files.md index 0033bb254d..75e4b1c480 100644 --- a/app/sdks/js/docs/examples/storage/list-files.md +++ b/app/sdks/javascript/docs/examples/storage/list-files.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.storage.listFiles(); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/storage/update-file.md b/app/sdks/javascript/docs/examples/storage/update-file.md similarity index 55% rename from app/sdks/js/docs/examples/storage/update-file.md rename to app/sdks/javascript/docs/examples/storage/update-file.md index 72d6ee3166..32a5afd8aa 100644 --- a/app/sdks/js/docs/examples/storage/update-file.md +++ b/app/sdks/javascript/docs/examples/storage/update-file.md @@ -1,13 +1,13 @@ let sdk = new Appwrite(); sdk - .setProject('') + .setProject('5df5acd0d48c2') // Your project ID ; let promise = sdk.storage.updateFile('[FILE_ID]', [], []); promise.then(function (response) { - console.log(response); + console.log(response); // Success }, function (error) { - console.log(error); + console.log(error); // Failure }); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/teams/create-membership.md b/app/sdks/javascript/docs/examples/teams/create-membership.md new file mode 100644 index 0000000000..b2baa405a1 --- /dev/null +++ b/app/sdks/javascript/docs/examples/teams/create-membership.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.teams.createMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/teams/create.md b/app/sdks/javascript/docs/examples/teams/create.md new file mode 100644 index 0000000000..2e7cf60c38 --- /dev/null +++ b/app/sdks/javascript/docs/examples/teams/create.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.teams.create('[NAME]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/teams/delete-membership.md b/app/sdks/javascript/docs/examples/teams/delete-membership.md new file mode 100644 index 0000000000..a17ad4f009 --- /dev/null +++ b/app/sdks/javascript/docs/examples/teams/delete-membership.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.teams.deleteMembership('[TEAM_ID]', '[INVITE_ID]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/teams/delete.md b/app/sdks/javascript/docs/examples/teams/delete.md new file mode 100644 index 0000000000..85415016c7 --- /dev/null +++ b/app/sdks/javascript/docs/examples/teams/delete.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.teams.delete('[TEAM_ID]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/teams/get-memberships.md b/app/sdks/javascript/docs/examples/teams/get-memberships.md new file mode 100644 index 0000000000..1ab6bf3ffe --- /dev/null +++ b/app/sdks/javascript/docs/examples/teams/get-memberships.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.teams.getMemberships('[TEAM_ID]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/teams/get.md b/app/sdks/javascript/docs/examples/teams/get.md new file mode 100644 index 0000000000..3e0c4d7fac --- /dev/null +++ b/app/sdks/javascript/docs/examples/teams/get.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.teams.get('[TEAM_ID]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/teams/list.md b/app/sdks/javascript/docs/examples/teams/list.md new file mode 100644 index 0000000000..d74fa47e8c --- /dev/null +++ b/app/sdks/javascript/docs/examples/teams/list.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.teams.list(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/teams/update-membership-status.md b/app/sdks/javascript/docs/examples/teams/update-membership-status.md new file mode 100644 index 0000000000..25f858ebf8 --- /dev/null +++ b/app/sdks/javascript/docs/examples/teams/update-membership-status.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.teams.updateMembershipStatus('[TEAM_ID]', '[INVITE_ID]', '[USER_ID]', '[SECRET]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/javascript/docs/examples/teams/update.md b/app/sdks/javascript/docs/examples/teams/update.md new file mode 100644 index 0000000000..dedfb63557 --- /dev/null +++ b/app/sdks/javascript/docs/examples/teams/update.md @@ -0,0 +1,13 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let promise = sdk.teams.update('[TEAM_ID]', '[NAME]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/js/package.json b/app/sdks/javascript/package.json similarity index 91% rename from app/sdks/js/package.json rename to app/sdks/javascript/package.json index 0c3d5e7b03..e718733189 100644 --- a/app/sdks/js/package.json +++ b/app/sdks/javascript/package.json @@ -7,7 +7,7 @@ "main": "src/sdk.js", "repository": { "type": "git", - "url": "https://github.com/appwrite/sdk-for-js.git" + "url": "https://github.com/appwrite/sdk-for-js" }, "devDependencies": {}, "dependencies": {} diff --git a/app/sdks/javascript/src/sdk.js b/app/sdks/javascript/src/sdk.js new file mode 100644 index 0000000000..0d7d5b0738 --- /dev/null +++ b/app/sdks/javascript/src/sdk.js @@ -0,0 +1,2180 @@ +(function (window) { + + 'use strict'; + + window.Appwrite = function () { + + let config = { + endpoint: 'https://appwrite.io/v1', + project: '', + key: '', + locale: '', + mode: '', + }; + + /** + * @param {string} endpoint + * @returns {this} + */ + let setEndpoint = function(endpoint) { + config.endpoint = endpoint; + + return this; + }; + + /** + * Set Project + * + * Your project ID + * + * @param value string + * + * @return this + */ + let setProject = function (value) + { + http.addGlobalHeader('X-Appwrite-Project', value); + + config.project = value; + + return this; + }; + + /** + * Set Key + * + * Your secret API key + * + * @param value string + * + * @return this + */ + let setKey = function (value) + { + http.addGlobalHeader('X-Appwrite-Key', value); + + config.key = value; + + return this; + }; + + /** + * Set Locale + * + * @param value string + * + * @return this + */ + let setLocale = function (value) + { + http.addGlobalHeader('X-Appwrite-Locale', value); + + config.locale = value; + + return this; + }; + + /** + * Set Mode + * + * @param value string + * + * @return this + */ + let setMode = function (value) + { + http.addGlobalHeader('X-Appwrite-Mode', value); + + config.mode = value; + + return this; + }; + + let http = function(document) { + let globalParams = [], + globalHeaders = []; + + let addParam = function (url, param, value) { + let a = document.createElement('a'), regex = /(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g; + let match, str = []; + a.href = url; + param = encodeURIComponent(param); + + while (match = regex.exec(a.search)) if (param !== match[1]) str.push(match[1] + (match[2] ? "=" + match[2] : "")); + + str.push(param + (value ? "=" + encodeURIComponent(value) : "")); + + a.search = str.join("&"); + + return a.href; + }; + + /** + * @param {Object} params + * @returns {string} + */ + let buildQuery = function(params) { + let str = []; + + for (let p in params) { + if(Array.isArray(params[p])) { + for (let index = 0; index < params[p].length; index++) { + let param = params[p][index]; + str.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); + } + } + else { + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(params[p])); + } + } + + return str.join("&"); + }; + + let addGlobalHeader = function(key, value) { + globalHeaders[key] = {key: key.toLowerCase(), value: value.toLowerCase()}; + }; + + let addGlobalParam = function(key, value) { + globalParams.push({key: key, value: value}); + }; + + addGlobalHeader('x-sdk-version', 'appwrite:javascript:1.0.28'); + addGlobalHeader('content-type', ''); + + /** + * @param {string} method + * @param {string} path string + * @param {Object} headers + * @param {Object} params + * @param {function} progress + * @returns {Promise} + */ + let call = function (method, path, headers = {}, params = {}, progress = null) { + let i; + + path = config.endpoint + path; + + if (-1 === ['GET', 'POST', 'PUT', 'DELETE', 'TRACE', 'HEAD', 'OPTIONS', 'CONNECT', 'PATCH'].indexOf(method)) { + throw new Error('var method must contain a valid HTTP method name'); + } + + if (typeof path !== 'string') { + throw new Error('var path must be of type string'); + } + + if (typeof headers !== 'object') { + throw new Error('var headers must be of type object'); + } + + for (i = 0; i < globalParams.length; i++) { // Add global params to URL + path = addParam(path, globalParams[i].key, globalParams[i].value); + } + + for (let key in globalHeaders) { // Add Global Headers + if (globalHeaders.hasOwnProperty(key)) { + if (!headers[globalHeaders[key].key]) { + headers[globalHeaders[key].key] = globalHeaders[key].value; + } + } + } + + if(method === 'GET') { + for (let param in params) { + if (param.hasOwnProperty(key)) { + path = addParam(path, key + (Array.isArray(param) ? '[]' : ''), params[key]); + } + } + } + + switch (headers['content-type']) { // Parse request by content type + case 'application/json': + params = JSON.stringify(params); + break; + + case 'multipart/form-data': + let formData = new FormData(); + + Object.keys(params).forEach(function(key) { + let param = params[key]; + formData.append(key + (Array.isArray(param) ? '[]' : ''), param); + }); + + params = formData; + break; + } + + return new Promise(function (resolve, reject) { + + let request = new XMLHttpRequest(), key; + + request.withCredentials = true; + request.open(method, path, true); + + for (key in headers) { // Set Headers + if (headers.hasOwnProperty(key)) { + if (key === 'content-type' && headers[key] === 'multipart/form-data') { // Skip to avoid missing boundary + continue; + } + + request.setRequestHeader(key, headers[key]); + } + } + + request.onload = function () { + if (4 === request.readyState && 399 >= request.status) { + let data = request.response; + let contentType = this.getResponseHeader('content-type') || ''; + contentType = contentType.substring(0, contentType.indexOf(';')); + + switch (contentType) { + case 'application/json': + data = JSON.parse(data); + break; + } + + resolve(data); + + } else { + reject(new Error(request.statusText)); + } + }; + + if (progress) { + request.addEventListener('progress', progress); + request.upload.addEventListener('progress', progress, false); + } + + // Handle network errors + request.onerror = function () { + reject(new Error("Network Error")); + }; + + request.send(params); + }) + }; + + return { + 'get': function(path, headers = {}, params = {}) { + return call('GET', path + ((Object.keys(params).length > 0) ? '?' + buildQuery(params) : ''), headers, {}); + }, + 'post': function(path, headers = {}, params = {}, progress = null) { + return call('POST', path, headers, params, progress); + }, + 'put': function(path, headers = {}, params = {}, progress = null) { + return call('PUT', path, headers, params, progress); + }, + 'patch': function(path, headers = {}, params = {}, progress = null) { + return call('PATCH', path, headers, params, progress); + }, + 'delete': function(path, headers = {}, params = {}, progress = null) { + return call('DELETE', path, headers, params, progress); + }, + 'addGlobalParam': addGlobalParam, + 'addGlobalHeader': addGlobalHeader + } + }(window.document); + + let iframe = function(method, url, params) { + let form = document.createElement('form'); + + form.setAttribute('method', method); + form.setAttribute('action', config.endpoint + url); + + for(let key in params) { + if(params.hasOwnProperty(key)) { + let hiddenField = document.createElement("input"); + hiddenField.setAttribute("type", "hidden"); + hiddenField.setAttribute("name", key); + hiddenField.setAttribute("value", params[key]); + + form.appendChild(hiddenField); + } + } + + document.body.appendChild(form); + + return form.submit(); + }; + + let account = { + + /** + * Get Account + * + * Get currently logged in user data as JSON object. + * + * @throws {Error} + * @return {Promise} + */ + get: function() { + let path = '/account'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Create Account + * + * Use this endpoint to allow a new user to register a new account in your + * project. After the user registration completes successfully, you can use + * the [/account/verfication](/docs/account#createVerification) route to start + * verifying the user email address. To allow your new user to login to his + * new account, you need to create a new [account + * session](/docs/account#createSession). + * + * @param {string} email + * @param {string} password + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + create: function(email, password, name = '') { + if(email === undefined) { + throw new Error('Missing required parameter: "email"'); + } + + if(password === undefined) { + throw new Error('Missing required parameter: "password"'); + } + + let path = '/account'; + + let payload = {}; + + if(email) { + payload['email'] = email; + } + + if(password) { + payload['password'] = password; + } + + if(name) { + payload['name'] = name; + } + + return http + .post(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Delete Account + * + * Delete a currently logged in user account. Behind the scene, the user + * record is not deleted but permanently blocked from any access. This is done + * to avoid deleted accounts being overtaken by new users with the same email + * address. Any user-related resources like documents or storage files should + * be deleted separately. + * + * @throws {Error} + * @return {Promise} + */ + delete: function() { + let path = '/account'; + + let payload = {}; + + return http + .delete(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Update Account Email + * + * Update currently logged in user account email address. After changing user + * address, user confirmation status is being reset and a new confirmation + * mail is sent. For security measures, user password is required to complete + * this request. + * + * @param {string} email + * @param {string} password + * @throws {Error} + * @return {Promise} + */ + updateEmail: function(email, password) { + if(email === undefined) { + throw new Error('Missing required parameter: "email"'); + } + + if(password === undefined) { + throw new Error('Missing required parameter: "password"'); + } + + let path = '/account/email'; + + let payload = {}; + + if(email) { + payload['email'] = email; + } + + if(password) { + payload['password'] = password; + } + + return http + .patch(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Account Logs + * + * Get currently logged in user list of latest security activity logs. Each + * log returns user IP address, location and date and time of log. + * + * @throws {Error} + * @return {Promise} + */ + getLogs: function() { + let path = '/account/logs'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Update Account Name + * + * Update currently logged in user account name. + * + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + updateName: function(name) { + if(name === undefined) { + throw new Error('Missing required parameter: "name"'); + } + + let path = '/account/name'; + + let payload = {}; + + if(name) { + payload['name'] = name; + } + + return http + .patch(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Update Account Password + * + * Update currently logged in user password. For validation, user is required + * to pass the password twice. + * + * @param {string} password + * @param {string} oldPassword + * @throws {Error} + * @return {Promise} + */ + updatePassword: function(password, oldPassword) { + if(password === undefined) { + throw new Error('Missing required parameter: "password"'); + } + + if(oldPassword === undefined) { + throw new Error('Missing required parameter: "oldPassword"'); + } + + let path = '/account/password'; + + let payload = {}; + + if(password) { + payload['password'] = password; + } + + if(oldPassword) { + payload['old-password'] = oldPassword; + } + + return http + .patch(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Account Preferences + * + * Get currently logged in user preferences as a key-value object. + * + * @throws {Error} + * @return {Promise} + */ + getPrefs: function() { + let path = '/account/prefs'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Update Account Preferences + * + * Update currently logged in user account preferences. You can pass only the + * specific settings you wish to update. + * + * @param {object} prefs + * @throws {Error} + * @return {Promise} + */ + updatePrefs: function(prefs) { + if(prefs === undefined) { + throw new Error('Missing required parameter: "prefs"'); + } + + let path = '/account/prefs'; + + let payload = {}; + + if(prefs) { + payload['prefs'] = prefs; + } + + return http + .patch(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Create Password Recovery + * + * Sends the user an email with a temporary secret key for password reset. + * When the user clicks the confirmation link he is redirected back to your + * app password reset URL with the secret key and email address values + * attached to the URL query string. Use the query string params to submit a + * request to the [PUT /account/recovery](/docs/account#updateRecovery) + * endpoint to complete the process. + * + * @param {string} email + * @param {string} url + * @throws {Error} + * @return {Promise} + */ + createRecovery: function(email, url) { + if(email === undefined) { + throw new Error('Missing required parameter: "email"'); + } + + if(url === undefined) { + throw new Error('Missing required parameter: "url"'); + } + + let path = '/account/recovery'; + + let payload = {}; + + if(email) { + payload['email'] = email; + } + + if(url) { + payload['url'] = url; + } + + return http + .post(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Complete Password Recovery + * + * Use this endpoint to complete the user account password reset. Both the + * **userId** and **secret** arguments will be passed as query parameters to + * the redirect URL you have provided when sending your request to the [POST + * /account/recovery](/docs/account#createRecovery) endpoint. + * + * Please note that in order to avoid a [Redirect + * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URLs are the ones from domains you have set when + * adding your platforms in the console interface. + * + * @param {string} userId + * @param {string} secret + * @param {string} passwordA + * @param {string} passwordB + * @throws {Error} + * @return {Promise} + */ + updateRecovery: function(userId, secret, passwordA, passwordB) { + if(userId === undefined) { + throw new Error('Missing required parameter: "userId"'); + } + + if(secret === undefined) { + throw new Error('Missing required parameter: "secret"'); + } + + if(passwordA === undefined) { + throw new Error('Missing required parameter: "passwordA"'); + } + + if(passwordB === undefined) { + throw new Error('Missing required parameter: "passwordB"'); + } + + let path = '/account/recovery'; + + let payload = {}; + + if(userId) { + payload['userId'] = userId; + } + + if(secret) { + payload['secret'] = secret; + } + + if(passwordA) { + payload['password-a'] = passwordA; + } + + if(passwordB) { + payload['password-b'] = passwordB; + } + + return http + .put(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Account Sessions + * + * Get currently logged in user list of active sessions across different + * devices. + * + * @throws {Error} + * @return {Promise} + */ + getSessions: function() { + let path = '/account/sessions'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Create Account Session + * + * Allow the user to login into his account by providing a valid email and + * password combination. This route will create a new session for the user. + * + * @param {string} email + * @param {string} password + * @throws {Error} + * @return {Promise} + */ + createSession: function(email, password) { + if(email === undefined) { + throw new Error('Missing required parameter: "email"'); + } + + if(password === undefined) { + throw new Error('Missing required parameter: "password"'); + } + + let path = '/account/sessions'; + + let payload = {}; + + if(email) { + payload['email'] = email; + } + + if(password) { + payload['password'] = password; + } + + return http + .post(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Delete All Account Sessions + * + * Delete all sessions from the user account and remove any sessions cookies + * from the end client. + * + * @throws {Error} + * @return {Promise} + */ + deleteSessions: function() { + let path = '/account/sessions'; + + let payload = {}; + + return http + .delete(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Create Account Session with OAuth2 + * + * Allow the user to login to his account using the OAuth provider of his + * choice. Each OAuth provider should be enabled from the Appwrite console + * first. Use the success and failure arguments to provide a redirect URL's + * back to your app when login is completed. + * + * @param {string} provider + * @param {string} success + * @param {string} failure + * @throws {Error} + * @return {string} + */ + createOAuth2Session: function(provider, success, failure) { + if(provider === undefined) { + throw new Error('Missing required parameter: "provider"'); + } + + if(success === undefined) { + throw new Error('Missing required parameter: "success"'); + } + + if(failure === undefined) { + throw new Error('Missing required parameter: "failure"'); + } + + let path = '/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}', 'g'), provider); + + let payload = {}; + + if(success) { + payload['success'] = success; + } + + if(failure) { + payload['failure'] = failure; + } + + payload['project'] = config.project; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); + }, + + /** + * Delete Account Session + * + * Use this endpoint to log out the currently logged in user from all his + * account sessions across all his different devices. When using the option id + * argument, only the session unique ID provider will be deleted. + * + * @param {string} sessionId + * @throws {Error} + * @return {Promise} + */ + deleteSession: function(sessionId) { + if(sessionId === undefined) { + throw new Error('Missing required parameter: "sessionId"'); + } + + let path = '/account/sessions/{sessionId}'.replace(new RegExp('{sessionId}', 'g'), sessionId); + + let payload = {}; + + return http + .delete(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Create Email Verification + * + * Use this endpoint to send a verification message to your user email address + * to confirm they are the valid owners of that address. Both the **userId** + * and **secret** arguments will be passed as query parameters to the URL you + * have provider to be attached to the verification email. The provided URL + * should redirect the user back for your app and allow you to complete the + * verification process by verifying both the **userId** and **secret** + * parameters. Learn more about how to [complete the verification + * process](/docs/account#updateAccountVerification). + * + * Please note that in order to avoid a [Redirect + * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URLs are the ones from domains you have set when + * adding your platforms in the console interface. + * + * @param {string} url + * @throws {Error} + * @return {Promise} + */ + createVerification: function(url) { + if(url === undefined) { + throw new Error('Missing required parameter: "url"'); + } + + let path = '/account/verification'; + + let payload = {}; + + if(url) { + payload['url'] = url; + } + + return http + .post(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Complete Email Verification + * + * Use this endpoint to complete the user email verification process. Use both + * the **userId** and **secret** parameters that were attached to your app URL + * to verify the user email ownership. If confirmed this route will return a + * 200 status code. + * + * @param {string} userId + * @param {string} secret + * @throws {Error} + * @return {Promise} + */ + updateVerification: function(userId, secret) { + if(userId === undefined) { + throw new Error('Missing required parameter: "userId"'); + } + + if(secret === undefined) { + throw new Error('Missing required parameter: "secret"'); + } + + let path = '/account/verification'; + + let payload = {}; + + if(userId) { + payload['userId'] = userId; + } + + if(secret) { + payload['secret'] = secret; + } + + return http + .put(path, { + 'content-type': 'application/json', + }, payload); + } + }; + + let avatars = { + + /** + * Get Browser Icon + * + * You can use this endpoint to show different browser icons to your users. + * The code argument receives the browser code as it appears in your user + * /account/sessions endpoint. Use width, height and quality arguments to + * change the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {Error} + * @return {Promise} + */ + getBrowser: function(code, width = 100, height = 100, quality = 100) { + if(code === undefined) { + throw new Error('Missing required parameter: "code"'); + } + + let path = '/avatars/browsers/{code}'.replace(new RegExp('{code}', 'g'), code); + + let payload = {}; + + if(width) { + payload['width'] = width; + } + + if(height) { + payload['height'] = height; + } + + if(quality) { + payload['quality'] = quality; + } + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Credit Card Icon + * + * Need to display your users with your billing method or their payment + * methods? The credit card endpoint will return you the icon of the credit + * card provider you need. Use width, height and quality arguments to change + * the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {Error} + * @return {Promise} + */ + getCreditCard: function(code, width = 100, height = 100, quality = 100) { + if(code === undefined) { + throw new Error('Missing required parameter: "code"'); + } + + let path = '/avatars/credit-cards/{code}'.replace(new RegExp('{code}', 'g'), code); + + let payload = {}; + + if(width) { + payload['width'] = width; + } + + if(height) { + payload['height'] = height; + } + + if(quality) { + payload['quality'] = quality; + } + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Favicon + * + * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote + * website URL. + * + * @param {string} url + * @throws {Error} + * @return {Promise} + */ + getFavicon: function(url) { + if(url === undefined) { + throw new Error('Missing required parameter: "url"'); + } + + let path = '/avatars/favicon'; + + let payload = {}; + + if(url) { + payload['url'] = url; + } + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Country Flag + * + * You can use this endpoint to show different country flags icons to your + * users. The code argument receives the 2 letter country code. Use width, + * height and quality arguments to change the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {Error} + * @return {Promise} + */ + getFlag: function(code, width = 100, height = 100, quality = 100) { + if(code === undefined) { + throw new Error('Missing required parameter: "code"'); + } + + let path = '/avatars/flags/{code}'.replace(new RegExp('{code}', 'g'), code); + + let payload = {}; + + if(width) { + payload['width'] = width; + } + + if(height) { + payload['height'] = height; + } + + if(quality) { + payload['quality'] = quality; + } + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Image from URL + * + * Use this endpoint to fetch a remote image URL and crop it to any image size + * you want. This endpoint is very useful if you need to crop and display + * remote images in your app or in case you want to make sure a 3rd party + * image is properly served using a TLS protocol. + * + * @param {string} url + * @param {number} width + * @param {number} height + * @throws {Error} + * @return {Promise} + */ + getImage: function(url, width = 400, height = 400) { + if(url === undefined) { + throw new Error('Missing required parameter: "url"'); + } + + let path = '/avatars/image'; + + let payload = {}; + + if(url) { + payload['url'] = url; + } + + if(width) { + payload['width'] = width; + } + + if(height) { + payload['height'] = height; + } + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get QR Code + * + * Converts a given plain text to a QR code image. You can use the query + * parameters to change the size and style of the resulting image. + * + * @param {string} text + * @param {number} size + * @param {number} margin + * @param {number} download + * @throws {Error} + * @return {Promise} + */ + 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; + } + + if(download) { + payload['download'] = download; + } + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + } + }; + + let database = { + + /** + * List Documents + * + * Get a list of all the user documents. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project documents. [Learn more about different API + * modes](/docs/admin). + * + * @param {string} collectionId + * @param {array} filters + * @param {number} offset + * @param {number} limit + * @param {string} orderField + * @param {string} orderType + * @param {string} orderCast + * @param {string} search + * @param {number} first + * @param {number} last + * @throws {Error} + * @return {Promise} + */ + listDocuments: function(collectionId, filters = [], offset = 0, limit = 50, orderField = '$uid', orderType = 'ASC', orderCast = 'string', search = '', first = 0, last = 0) { + if(collectionId === undefined) { + throw new Error('Missing required parameter: "collectionId"'); + } + + let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + let payload = {}; + + if(filters) { + payload['filters'] = filters; + } + + if(offset) { + payload['offset'] = offset; + } + + if(limit) { + payload['limit'] = limit; + } + + if(orderField) { + payload['order-field'] = orderField; + } + + if(orderType) { + payload['order-type'] = orderType; + } + + if(orderCast) { + payload['order-cast'] = orderCast; + } + + if(search) { + payload['search'] = search; + } + + if(first) { + payload['first'] = first; + } + + if(last) { + payload['last'] = last; + } + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Create Document + * + * Create a new Document. + * + * @param {string} collectionId + * @param {object} data + * @param {array} read + * @param {array} write + * @param {string} parentDocument + * @param {string} parentProperty + * @param {string} parentPropertyType + * @throws {Error} + * @return {Promise} + */ + createDocument: function(collectionId, data, read, write, parentDocument = '', parentProperty = '', parentPropertyType = 'assign') { + if(collectionId === undefined) { + throw new Error('Missing required parameter: "collectionId"'); + } + + if(data === undefined) { + throw new Error('Missing required parameter: "data"'); + } + + if(read === undefined) { + throw new Error('Missing required parameter: "read"'); + } + + if(write === undefined) { + throw new Error('Missing required parameter: "write"'); + } + + let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + let payload = {}; + + if(data) { + payload['data'] = data; + } + + if(read) { + payload['read'] = read; + } + + if(write) { + payload['write'] = write; + } + + if(parentDocument) { + payload['parentDocument'] = parentDocument; + } + + if(parentProperty) { + payload['parentProperty'] = parentProperty; + } + + if(parentPropertyType) { + payload['parentPropertyType'] = parentPropertyType; + } + + return http + .post(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Document + * + * Get document by its unique ID. This endpoint response returns a JSON object + * with the document data. + * + * @param {string} collectionId + * @param {string} documentId + * @throws {Error} + * @return {Promise} + */ + getDocument: 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 + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Update Document + * + * + * @param {string} collectionId + * @param {string} documentId + * @param {object} data + * @param {array} read + * @param {array} write + * @throws {Error} + * @return {Promise} + */ + updateDocument: function(collectionId, documentId, data, read, write) { + if(collectionId === undefined) { + throw new Error('Missing required parameter: "collectionId"'); + } + + if(documentId === undefined) { + throw new Error('Missing required parameter: "documentId"'); + } + + if(data === undefined) { + throw new Error('Missing required parameter: "data"'); + } + + if(read === undefined) { + throw new Error('Missing required parameter: "read"'); + } + + if(write === undefined) { + throw new Error('Missing required parameter: "write"'); + } + + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); + + let payload = {}; + + if(data) { + payload['data'] = data; + } + + if(read) { + payload['read'] = read; + } + + if(write) { + payload['write'] = write; + } + + return http + .patch(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Delete Document + * + * Delete document by its unique ID. This endpoint deletes only the parent + * documents, his attributes and relations to other documents. Child documents + * **will not** be deleted. + * + * @param {string} collectionId + * @param {string} documentId + * @throws {Error} + * @return {Promise} + */ + 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); + } + }; + + let locale = { + + /** + * Get User Locale + * + * Get the current user location based on IP. Returns an object with user + * country code, country name, continent name, continent code, ip address and + * suggested currency. You can use the locale header to get the data in a + * supported language. + * + * ([IP Geolocation by DB-IP](https://db-ip.com)) + * + * @throws {Error} + * @return {Promise} + */ + get: function() { + let path = '/locale'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * List Countries + * + * List of all continents. You can use the locale header to get the data in a + * supported language. + * + * @throws {Error} + * @return {Promise} + */ + getContinents: function() { + let path = '/locale/continents'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * List Countries + * + * List of all countries. You can use the locale header to get the data in a + * supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCountries: function() { + let path = '/locale/countries'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * List EU Countries + * + * List of all countries that are currently members of the EU. You can use the + * locale header to get the data in a supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCountriesEU: function() { + let path = '/locale/countries/eu'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * List Countries Phone Codes + * + * List of all countries phone codes. You can use the locale header to get the + * data in a supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCountriesPhones: function() { + let path = '/locale/countries/phones'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * List Currencies + * + * List of all currencies, including currency symol, name, plural, and decimal + * digits for all major and minor currencies. You can use the locale header to + * get the data in a supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCurrencies: function() { + let path = '/locale/currencies'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + } + }; + + let storage = { + + /** + * List Files + * + * Get a list of all the user files. You can use the query params to filter + * your results. On admin mode, this endpoint will return a list of all of the + * project files. [Learn more about different API modes](/docs/admin). + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {Error} + * @return {Promise} + */ + listFiles: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { + let path = '/storage/files'; + + 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 File + * + * Create a new file. The user who creates the file will automatically be + * assigned to read and write access unless he has passed custom values for + * read and write arguments. + * + * @param {File} file + * @param {array} read + * @param {array} write + * @throws {Error} + * @return {Promise} + */ + createFile: function(file, read, write) { + if(file === undefined) { + throw new Error('Missing required parameter: "file"'); + } + + if(read === undefined) { + throw new Error('Missing required parameter: "read"'); + } + + if(write === undefined) { + throw new Error('Missing required parameter: "write"'); + } + + let path = '/storage/files'; + + let payload = {}; + + if(file) { + payload['file'] = file; + } + + if(read) { + payload['read'] = read; + } + + if(write) { + payload['write'] = write; + } + + return http + .post(path, { + 'content-type': 'multipart/form-data', + }, payload); + }, + + /** + * Get File + * + * Get file by its unique ID. This endpoint response returns a JSON object + * with the file metadata. + * + * @param {string} fileId + * @throws {Error} + * @return {Promise} + */ + getFile: function(fileId) { + if(fileId === undefined) { + throw new Error('Missing required parameter: "fileId"'); + } + + let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Update File + * + * Update file by its unique ID. Only users with write permissions have access + * to update this resource. + * + * @param {string} fileId + * @param {array} read + * @param {array} write + * @throws {Error} + * @return {Promise} + */ + updateFile: function(fileId, read, write) { + if(fileId === undefined) { + throw new Error('Missing required parameter: "fileId"'); + } + + if(read === undefined) { + throw new Error('Missing required parameter: "read"'); + } + + if(write === undefined) { + throw new Error('Missing required parameter: "write"'); + } + + let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); + + let payload = {}; + + if(read) { + payload['read'] = read; + } + + if(write) { + payload['write'] = write; + } + + return http + .put(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Delete File + * + * Delete a file by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param {string} fileId + * @throws {Error} + * @return {Promise} + */ + deleteFile: function(fileId) { + if(fileId === undefined) { + throw new Error('Missing required parameter: "fileId"'); + } + + let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); + + let payload = {}; + + return http + .delete(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get File for Download + * + * Get file content by its unique ID. The endpoint response return with a + * 'Content-Disposition: attachment' header that tells the browser to start + * downloading the file to user downloads directory. + * + * @param {string} fileId + * @throws {Error} + * @return {string} + */ + getFileDownload: function(fileId) { + if(fileId === undefined) { + throw new Error('Missing required parameter: "fileId"'); + } + + let path = '/storage/files/{fileId}/download'.replace(new RegExp('{fileId}', 'g'), fileId); + + let payload = {}; + + payload['project'] = config.project; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); + }, + + /** + * Get File Preview + * + * Get a file preview image. Currently, this method supports preview for image + * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, + * and spreadsheets, will return the file icon image. You can also pass query + * string arguments for cutting and resizing your preview image. + * + * @param {string} fileId + * @param {number} width + * @param {number} height + * @param {number} quality + * @param {string} background + * @param {string} output + * @throws {Error} + * @return {string} + */ + getFilePreview: function(fileId, width = 0, height = 0, quality = 100, background = '', output = '') { + if(fileId === undefined) { + throw new Error('Missing required parameter: "fileId"'); + } + + let path = '/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}', 'g'), fileId); + + let payload = {}; + + if(width) { + payload['width'] = width; + } + + if(height) { + payload['height'] = height; + } + + if(quality) { + payload['quality'] = quality; + } + + if(background) { + payload['background'] = background; + } + + if(output) { + payload['output'] = output; + } + + payload['project'] = config.project; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); + }, + + /** + * Get File for View + * + * Get file content by its unique ID. This endpoint is similar to the download + * method but returns with no 'Content-Disposition: attachment' header. + * + * @param {string} fileId + * @param {string} as + * @throws {Error} + * @return {string} + */ + getFileView: function(fileId, as = '') { + if(fileId === undefined) { + throw new Error('Missing required parameter: "fileId"'); + } + + let path = '/storage/files/{fileId}/view'.replace(new RegExp('{fileId}', 'g'), fileId); + + let payload = {}; + + if(as) { + payload['as'] = as; + } + + payload['project'] = config.project; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); + } + }; + + let teams = { + + /** + * List Teams + * + * Get a list of all the current user teams. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project teams. [Learn more about different API modes](/docs/admin). + * + * @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 = '/teams'; + + 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 Team + * + * Create a new team. The user who creates the team will automatically be + * assigned as the owner of the team. The team owner can invite new members, + * who will be able add new owners and update or delete the team from your + * project. + * + * @param {string} name + * @param {array} roles + * @throws {Error} + * @return {Promise} + */ + create: function(name, roles = ["owner"]) { + if(name === undefined) { + throw new Error('Missing required parameter: "name"'); + } + + let path = '/teams'; + + let payload = {}; + + if(name) { + payload['name'] = name; + } + + if(roles) { + payload['roles'] = roles; + } + + return http + .post(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Team + * + * Get team by its unique ID. All team members have read access for this + * resource. + * + * @param {string} teamId + * @throws {Error} + * @return {Promise} + */ + get: function(teamId) { + if(teamId === undefined) { + throw new Error('Missing required parameter: "teamId"'); + } + + let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Update Team + * + * Update team by its unique ID. Only team owners have write access for this + * resource. + * + * @param {string} teamId + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + update: function(teamId, name) { + if(teamId === undefined) { + throw new Error('Missing required parameter: "teamId"'); + } + + if(name === undefined) { + throw new Error('Missing required parameter: "name"'); + } + + let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); + + let payload = {}; + + if(name) { + payload['name'] = name; + } + + return http + .put(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Delete Team + * + * Delete team by its unique ID. Only team owners have write access for this + * resource. + * + * @param {string} teamId + * @throws {Error} + * @return {Promise} + */ + delete: function(teamId) { + if(teamId === undefined) { + throw new Error('Missing required parameter: "teamId"'); + } + + let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); + + let payload = {}; + + return http + .delete(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Team Memberships + * + * Get team members by the team unique ID. All team members have read access + * for this list of resources. + * + * @param {string} teamId + * @throws {Error} + * @return {Promise} + */ + getMemberships: function(teamId) { + if(teamId === undefined) { + throw new Error('Missing required parameter: "teamId"'); + } + + let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Create Team Membership + * + * Use this endpoint to invite a new member to join your team. An email with a + * link to join the team will be sent to the new member email address if the + * member doesn't exist in the project it will be created automatically. + * + * Use the 'URL' parameter to redirect the user from the invitation email back + * to your app. When the user is redirected, use the [Update Team Membership + * Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to + * accept the invitation to the team. + * + * Please note that in order to avoid a [Redirect + * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URL's are the once from domains you have set when + * added your platforms in the console interface. + * + * @param {string} teamId + * @param {string} email + * @param {array} roles + * @param {string} url + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + createMembership: function(teamId, email, roles, url, name = '') { + if(teamId === undefined) { + throw new Error('Missing required parameter: "teamId"'); + } + + if(email === undefined) { + throw new Error('Missing required parameter: "email"'); + } + + if(roles === undefined) { + throw new Error('Missing required parameter: "roles"'); + } + + if(url === undefined) { + throw new Error('Missing required parameter: "url"'); + } + + let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); + + let payload = {}; + + if(email) { + payload['email'] = email; + } + + if(name) { + payload['name'] = name; + } + + if(roles) { + payload['roles'] = roles; + } + + if(url) { + payload['url'] = url; + } + + return http + .post(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Delete Team Membership + * + * This endpoint allows a user to leave a team or for a team owner to delete + * the membership of any other team member. You can also use this endpoint to + * delete a user membership even if he didn't accept it. + * + * @param {string} teamId + * @param {string} inviteId + * @throws {Error} + * @return {Promise} + */ + deleteMembership: function(teamId, inviteId) { + if(teamId === undefined) { + throw new Error('Missing required parameter: "teamId"'); + } + + if(inviteId === undefined) { + throw new Error('Missing required parameter: "inviteId"'); + } + + let path = '/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); + + let payload = {}; + + return http + .delete(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Update Team Membership Status + * + * Use this endpoint to allow a user to accept an invitation to join a team + * after he is being redirected back to your app from the invitation email he + * was sent. + * + * @param {string} teamId + * @param {string} inviteId + * @param {string} userId + * @param {string} secret + * @throws {Error} + * @return {Promise} + */ + updateMembershipStatus: function(teamId, inviteId, userId, secret) { + if(teamId === undefined) { + throw new Error('Missing required parameter: "teamId"'); + } + + if(inviteId === undefined) { + throw new Error('Missing required parameter: "inviteId"'); + } + + if(userId === undefined) { + throw new Error('Missing required parameter: "userId"'); + } + + if(secret === undefined) { + throw new Error('Missing required parameter: "secret"'); + } + + let path = '/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); + + let payload = {}; + + if(userId) { + payload['userId'] = userId; + } + + if(secret) { + payload['secret'] = secret; + } + + 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, + locale: locale, + storage: storage, + teams: teams + }; + }; + + if(typeof module !== "undefined") { + module.exports = window.Appwrite; + } + +})((typeof window !== "undefined") ? window : {}); \ No newline at end of file diff --git a/app/sdks/javascript/src/sdk.min.js b/app/sdks/javascript/src/sdk.min.js new file mode 100644 index 0000000000..60e5d1a66b --- /dev/null +++ b/app/sdks/javascript/src/sdk.min.js @@ -0,0 +1,169 @@ +(function(window){'use strict';window.Appwrite=function(){let config={endpoint:'https://appwrite.io/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;index=request.status){let data=request.response;let contentType=this.getResponseHeader('content-type')||'';contentType=contentType.substring(0,contentType.indexOf(';'));switch(contentType){case 'application/json':data=JSON.parse(data);break} +resolve(data)}else{reject(new Error(request.statusText))}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,!1)} +request.onerror=function(){reject(new Error("Network Error"))};request.send(params)})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{})},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress)},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress)},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress)},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress)},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let iframe=function(method,url,params){let form=document.createElement('form');form.setAttribute('method',method);form.setAttribute('action',config.endpoint+url);for(let key in params){if(params.hasOwnProperty(key)){let hiddenField=document.createElement("input");hiddenField.setAttribute("type","hidden");hiddenField.setAttribute("name",key);hiddenField.setAttribute("value",params[key]);form.appendChild(hiddenField)}} +document.body.appendChild(form);return form.submit()};let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} +if(password===undefined){throw new Error('Missing required parameter: "password"')} +let path='/account';let payload={};if(email){payload.email=email} +if(password){payload.password=password} +if(name){payload.name=name} +return http.post(path,{'content-type':'application/json',},payload)},delete:function(){let path='/account';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateEmail:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"')} +if(password===undefined){throw new Error('Missing required parameter: "password"')} +let path='/account/email';let payload={};if(email){payload.email=email} +if(password){payload.password=password} +return http.patch(path,{'content-type':'application/json',},payload)},getLogs:function(){let path='/account/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateName:function(name){if(name===undefined){throw new Error('Missing required parameter: "name"')} +let path='/account/name';let payload={};if(name){payload.name=name} +return http.patch(path,{'content-type':'application/json',},payload)},updatePassword:function(password,oldPassword){if(password===undefined){throw new Error('Missing required parameter: "password"')} +if(oldPassword===undefined){throw new Error('Missing required parameter: "oldPassword"')} +let path='/account/password';let payload={};if(password){payload.password=password} +if(oldPassword){payload['old-password']=oldPassword} +return http.patch(path,{'content-type':'application/json',},payload)},getPrefs:function(){let path='/account/prefs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},updatePrefs:function(prefs){if(prefs===undefined){throw new Error('Missing required parameter: "prefs"')} +let path='/account/prefs';let payload={};if(prefs){payload.prefs=prefs} +return http.patch(path,{'content-type':'application/json',},payload)},createRecovery:function(email,url){if(email===undefined){throw new Error('Missing required parameter: "email"')} +if(url===undefined){throw new Error('Missing required parameter: "url"')} +let path='/account/recovery';let payload={};if(email){payload.email=email} +if(url){payload.url=url} +return http.post(path,{'content-type':'application/json',},payload)},updateRecovery:function(userId,secret,passwordA,passwordB){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} +if(secret===undefined){throw new Error('Missing required parameter: "secret"')} +if(passwordA===undefined){throw new Error('Missing required parameter: "passwordA"')} +if(passwordB===undefined){throw new Error('Missing required parameter: "passwordB"')} +let path='/account/recovery';let payload={};if(userId){payload.userId=userId} +if(secret){payload.secret=secret} +if(passwordA){payload['password-a']=passwordA} +if(passwordB){payload['password-b']=passwordB} +return http.put(path,{'content-type':'application/json',},payload)},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json',},payload)},createSession:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"')} +if(password===undefined){throw new Error('Missing required parameter: "password"')} +let path='/account/sessions';let payload={};if(email){payload.email=email} +if(password){payload.password=password} +return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success,failure){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} +if(success===undefined){throw new Error('Missing required parameter: "success"')} +if(failure===undefined){throw new Error('Missing required parameter: "failure"')} +let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success} +if(failure){payload.failure=failure} +payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},deleteSession:function(sessionId){if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')} +let path='/account/sessions/{sessionId}'.replace(new RegExp('{sessionId}','g'),sessionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createVerification:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')} +let path='/account/verification';let payload={};if(url){payload.url=url} +return http.post(path,{'content-type':'application/json',},payload)},updateVerification:function(userId,secret){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} +if(secret===undefined){throw new Error('Missing required parameter: "secret"')} +let path='/account/verification';let payload={};if(userId){payload.userId=userId} +if(secret){payload.secret=secret} +return http.put(path,{'content-type':'application/json',},payload)}};let avatars={getBrowser:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} +let path='/avatars/browsers/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} +if(height){payload.height=height} +if(quality){payload.quality=quality} +return http.get(path,{'content-type':'application/json',},payload)},getCreditCard:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} +let path='/avatars/credit-cards/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} +if(height){payload.height=height} +if(quality){payload.quality=quality} +return http.get(path,{'content-type':'application/json',},payload)},getFavicon:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')} +let path='/avatars/favicon';let payload={};if(url){payload.url=url} +return http.get(path,{'content-type':'application/json',},payload)},getFlag:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} +let path='/avatars/flags/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} +if(height){payload.height=height} +if(quality){payload.quality=quality} +return http.get(path,{'content-type':'application/json',},payload)},getImage:function(url,width=400,height=400){if(url===undefined){throw new Error('Missing required parameter: "url"')} +let path='/avatars/image';let payload={};if(url){payload.url=url} +if(width){payload.width=width} +if(height){payload.height=height} +return http.get(path,{'content-type':'application/json',},payload)},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} +if(download){payload.download=download} +return http.get(path,{'content-type':'application/json',},payload)}};let database={listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$uid',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} +let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(filters){payload.filters=filters} +if(offset){payload.offset=offset} +if(limit){payload.limit=limit} +if(orderField){payload['order-field']=orderField} +if(orderType){payload['order-type']=orderType} +if(orderCast){payload['order-cast']=orderCast} +if(search){payload.search=search} +if(first){payload.first=first} +if(last){payload.last=last} +return http.get(path,{'content-type':'application/json',},payload)},createDocument:function(collectionId,data,read,write,parentDocument='',parentProperty='',parentPropertyType='assign'){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} +if(data===undefined){throw new Error('Missing required parameter: "data"')} +if(read===undefined){throw new Error('Missing required parameter: "read"')} +if(write===undefined){throw new Error('Missing required parameter: "write"')} +let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(data){payload.data=data} +if(read){payload.read=read} +if(write){payload.write=write} +if(parentDocument){payload.parentDocument=parentDocument} +if(parentProperty){payload.parentProperty=parentProperty} +if(parentPropertyType){payload.parentPropertyType=parentPropertyType} +return http.post(path,{'content-type':'application/json',},payload)},getDocument: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.get(path,{'content-type':'application/json',},payload)},updateDocument:function(collectionId,documentId,data,read,write){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} +if(documentId===undefined){throw new Error('Missing required parameter: "documentId"')} +if(data===undefined){throw new Error('Missing required parameter: "data"')} +if(read===undefined){throw new Error('Missing required parameter: "read"')} +if(write===undefined){throw new Error('Missing required parameter: "write"')} +let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};if(data){payload.data=data} +if(read){payload.read=read} +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)}};let locale={get:function(){let path='/locale';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getContinents:function(){let path='/locale/continents';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountries:function(){let path='/locale/countries';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesEU:function(){let path='/locale/countries/eu';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesPhones:function(){let path='/locale/countries/phones';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCurrencies:function(){let path='/locale/currencies';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let storage={listFiles:function(search='',limit=25,offset=0,orderType='ASC'){let path='/storage/files';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)},createFile:function(file,read,write){if(file===undefined){throw new Error('Missing required parameter: "file"')} +if(read===undefined){throw new Error('Missing required parameter: "read"')} +if(write===undefined){throw new Error('Missing required parameter: "write"')} +let path='/storage/files';let payload={};if(file){payload.file=file} +if(read){payload.read=read} +if(write){payload.write=write} +return http.post(path,{'content-type':'multipart/form-data',},payload)},getFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} +let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateFile:function(fileId,read,write){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} +if(read===undefined){throw new Error('Missing required parameter: "read"')} +if(write===undefined){throw new Error('Missing required parameter: "write"')} +let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};if(read){payload.read=read} +if(write){payload.write=write} +return http.put(path,{'content-type':'application/json',},payload)},deleteFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} +let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getFileDownload:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} +let path='/storage/files/{fileId}/download'.replace(new RegExp('{fileId}','g'),fileId);let payload={};payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getFilePreview:function(fileId,width=0,height=0,quality=100,background='',output=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} +let path='/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}','g'),fileId);let payload={};if(width){payload.width=width} +if(height){payload.height=height} +if(quality){payload.quality=quality} +if(background){payload.background=background} +if(output){payload.output=output} +payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getFileView:function(fileId,as=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} +let path='/storage/files/{fileId}/view'.replace(new RegExp('{fileId}','g'),fileId);let payload={};if(as){payload.as=as} +payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')}};let teams={list:function(search='',limit=25,offset=0,orderType='ASC'){let path='/teams';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,roles=["owner"]){if(name===undefined){throw new Error('Missing required parameter: "name"')} +let path='/teams';let payload={};if(name){payload.name=name} +if(roles){payload.roles=roles} +return http.post(path,{'content-type':'application/json',},payload)},get:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} +let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},update:function(teamId,name){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} +if(name===undefined){throw new Error('Missing required parameter: "name"')} +let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(name){payload.name=name} +return http.put(path,{'content-type':'application/json',},payload)},delete:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} +let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getMemberships:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} +let path='/teams/{teamId}/memberships'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},createMembership:function(teamId,email,roles,url,name=''){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} +if(email===undefined){throw new Error('Missing required parameter: "email"')} +if(roles===undefined){throw new Error('Missing required parameter: "roles"')} +if(url===undefined){throw new Error('Missing required parameter: "url"')} +let path='/teams/{teamId}/memberships'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(email){payload.email=email} +if(name){payload.name=name} +if(roles){payload.roles=roles} +if(url){payload.url=url} +return http.post(path,{'content-type':'application/json',},payload)},deleteMembership:function(teamId,inviteId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} +if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"')} +let path='/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateMembershipStatus:function(teamId,inviteId,userId,secret){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} +if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"')} +if(userId===undefined){throw new Error('Missing required parameter: "userId"')} +if(secret===undefined){throw new Error('Missing required parameter: "secret"')} +let path='/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};if(userId){payload.userId=userId} +if(secret){payload.secret=secret} +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,locale:locale,storage:storage,teams:teams}};if(typeof module!=="undefined"){module.exports=window.Appwrite}})((typeof window!=="undefined")?window:{}) \ No newline at end of file diff --git a/app/sdks/js/docs/examples/account/get-security.md b/app/sdks/js/docs/examples/account/get-security.md deleted file mode 100644 index ab0671da8a..0000000000 --- a/app/sdks/js/docs/examples/account/get-security.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.account.getSecurity(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/account/update-prefs.md b/app/sdks/js/docs/examples/account/update-prefs.md deleted file mode 100644 index da37ceff8e..0000000000 --- a/app/sdks/js/docs/examples/account/update-prefs.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.account.updatePrefs('{}'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/confirm-resend.md b/app/sdks/js/docs/examples/auth/confirm-resend.md deleted file mode 100644 index 4c66e71d93..0000000000 --- a/app/sdks/js/docs/examples/auth/confirm-resend.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.auth.confirmResend('https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/confirm.md b/app/sdks/js/docs/examples/auth/confirm.md deleted file mode 100644 index 4313e94f23..0000000000 --- a/app/sdks/js/docs/examples/auth/confirm.md +++ /dev/null @@ -1,12 +0,0 @@ -let sdk = new Appwrite(); - -sdk -; - -let promise = sdk.auth.confirm('[USER_ID]', '[TOKEN]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/login.md b/app/sdks/js/docs/examples/auth/login.md deleted file mode 100644 index 99ffaa8df7..0000000000 --- a/app/sdks/js/docs/examples/auth/login.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.auth.login('email@example.com', 'password'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/logout-by-session.md b/app/sdks/js/docs/examples/auth/logout-by-session.md deleted file mode 100644 index ba03feff4a..0000000000 --- a/app/sdks/js/docs/examples/auth/logout-by-session.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.auth.logoutBySession('[ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/logout.md b/app/sdks/js/docs/examples/auth/logout.md deleted file mode 100644 index 90f5ff4b18..0000000000 --- a/app/sdks/js/docs/examples/auth/logout.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.auth.logout(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/oauth-callback.md b/app/sdks/js/docs/examples/auth/oauth-callback.md deleted file mode 100644 index f5412deea6..0000000000 --- a/app/sdks/js/docs/examples/auth/oauth-callback.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - setProject('') -; - -let promise = sdk.auth.oauthCallback('[PROJECT_ID]', 'bitbucket', '[CODE]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/oauth.md b/app/sdks/js/docs/examples/auth/oauth.md deleted file mode 100644 index eeffd40b57..0000000000 --- a/app/sdks/js/docs/examples/auth/oauth.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.auth.oauth('bitbucket', 'https://example.com', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/recovery-reset.md b/app/sdks/js/docs/examples/auth/recovery-reset.md deleted file mode 100644 index 7830eba1d6..0000000000 --- a/app/sdks/js/docs/examples/auth/recovery-reset.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.auth.recoveryReset('[USER_ID]', '[TOKEN]', 'password', 'password'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/recovery.md b/app/sdks/js/docs/examples/auth/recovery.md deleted file mode 100644 index a313e192f8..0000000000 --- a/app/sdks/js/docs/examples/auth/recovery.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.auth.recovery('email@example.com', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/auth/register.md b/app/sdks/js/docs/examples/auth/register.md deleted file mode 100644 index c5205f90cd..0000000000 --- a/app/sdks/js/docs/examples/auth/register.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.auth.register('email@example.com', 'password', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/create-collection.md b/app/sdks/js/docs/examples/database/create-collection.md deleted file mode 100644 index a93fe45778..0000000000 --- a/app/sdks/js/docs/examples/database/create-collection.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.database.createCollection('[NAME]', [], [], []); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/create-document.md b/app/sdks/js/docs/examples/database/create-document.md deleted file mode 100644 index aa251ae2b2..0000000000 --- a/app/sdks/js/docs/examples/database/create-document.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.database.createDocument('[COLLECTION_ID]', '{}', [], []); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/delete-collection.md b/app/sdks/js/docs/examples/database/delete-collection.md deleted file mode 100644 index 1a116c58b9..0000000000 --- a/app/sdks/js/docs/examples/database/delete-collection.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.database.deleteCollection('[COLLECTION_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/get-collection.md b/app/sdks/js/docs/examples/database/get-collection.md deleted file mode 100644 index abe8d482d4..0000000000 --- a/app/sdks/js/docs/examples/database/get-collection.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.database.getCollection('[COLLECTION_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/list-collections.md b/app/sdks/js/docs/examples/database/list-collections.md deleted file mode 100644 index 3160903309..0000000000 --- a/app/sdks/js/docs/examples/database/list-collections.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.database.listCollections(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/database/update-collection.md b/app/sdks/js/docs/examples/database/update-collection.md deleted file mode 100644 index 726c244c79..0000000000 --- a/app/sdks/js/docs/examples/database/update-collection.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.database.updateCollection('[COLLECTION_ID]', '[NAME]', [], []); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/locale/get-locale.md b/app/sdks/js/docs/examples/locale/get-locale.md deleted file mode 100644 index 4cc5a3f3b2..0000000000 --- a/app/sdks/js/docs/examples/locale/get-locale.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.locale.getLocale(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/create-key.md b/app/sdks/js/docs/examples/projects/create-key.md deleted file mode 100644 index 3c12c8a8c2..0000000000 --- a/app/sdks/js/docs/examples/projects/create-key.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.createKey('[PROJECT_ID]', '[NAME]', []); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/create-platform.md b/app/sdks/js/docs/examples/projects/create-platform.md deleted file mode 100644 index b67b84ba56..0000000000 --- a/app/sdks/js/docs/examples/projects/create-platform.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.createPlatform('[PROJECT_ID]', 'web', '[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/create-project.md b/app/sdks/js/docs/examples/projects/create-project.md deleted file mode 100644 index a1b6922fed..0000000000 --- a/app/sdks/js/docs/examples/projects/create-project.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.createProject('[NAME]', '[TEAM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/create-task.md b/app/sdks/js/docs/examples/projects/create-task.md deleted file mode 100644 index 3262b4d9fe..0000000000 --- a/app/sdks/js/docs/examples/projects/create-task.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.createTask('[PROJECT_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/create-webhook.md b/app/sdks/js/docs/examples/projects/create-webhook.md deleted file mode 100644 index 66a76c26c2..0000000000 --- a/app/sdks/js/docs/examples/projects/create-webhook.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 0); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/delete-key.md b/app/sdks/js/docs/examples/projects/delete-key.md deleted file mode 100644 index e5ae8e426c..0000000000 --- a/app/sdks/js/docs/examples/projects/delete-key.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.deleteKey('[PROJECT_ID]', '[KEY_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/delete-platform.md b/app/sdks/js/docs/examples/projects/delete-platform.md deleted file mode 100644 index 450f9cd0a6..0000000000 --- a/app/sdks/js/docs/examples/projects/delete-platform.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.deletePlatform('[PROJECT_ID]', '[PLATFORM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/delete-project.md b/app/sdks/js/docs/examples/projects/delete-project.md deleted file mode 100644 index b60d4de3c9..0000000000 --- a/app/sdks/js/docs/examples/projects/delete-project.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.deleteProject('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/delete-task.md b/app/sdks/js/docs/examples/projects/delete-task.md deleted file mode 100644 index 3208d38bf8..0000000000 --- a/app/sdks/js/docs/examples/projects/delete-task.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.deleteTask('[PROJECT_ID]', '[TASK_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/delete-webhook.md b/app/sdks/js/docs/examples/projects/delete-webhook.md deleted file mode 100644 index 030a3b77f1..0000000000 --- a/app/sdks/js/docs/examples/projects/delete-webhook.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.deleteWebhook('[PROJECT_ID]', '[WEBHOOK_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/get-key.md b/app/sdks/js/docs/examples/projects/get-key.md deleted file mode 100644 index 7207b33bf7..0000000000 --- a/app/sdks/js/docs/examples/projects/get-key.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.getKey('[PROJECT_ID]', '[KEY_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/get-platform.md b/app/sdks/js/docs/examples/projects/get-platform.md deleted file mode 100644 index 6f353f3aca..0000000000 --- a/app/sdks/js/docs/examples/projects/get-platform.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.getPlatform('[PROJECT_ID]', '[PLATFORM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/get-project-usage.md b/app/sdks/js/docs/examples/projects/get-project-usage.md deleted file mode 100644 index 87a2e3148a..0000000000 --- a/app/sdks/js/docs/examples/projects/get-project-usage.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.getProjectUsage('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/get-project.md b/app/sdks/js/docs/examples/projects/get-project.md deleted file mode 100644 index 084e48c253..0000000000 --- a/app/sdks/js/docs/examples/projects/get-project.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.getProject('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/get-task.md b/app/sdks/js/docs/examples/projects/get-task.md deleted file mode 100644 index e5195bce8c..0000000000 --- a/app/sdks/js/docs/examples/projects/get-task.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.getTask('[PROJECT_ID]', '[TASK_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/get-webhook.md b/app/sdks/js/docs/examples/projects/get-webhook.md deleted file mode 100644 index a2b6089c3e..0000000000 --- a/app/sdks/js/docs/examples/projects/get-webhook.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.getWebhook('[PROJECT_ID]', '[WEBHOOK_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/list-keys.md b/app/sdks/js/docs/examples/projects/list-keys.md deleted file mode 100644 index 14ef64fb6f..0000000000 --- a/app/sdks/js/docs/examples/projects/list-keys.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.listKeys('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/list-platforms.md b/app/sdks/js/docs/examples/projects/list-platforms.md deleted file mode 100644 index 7cfd9341a7..0000000000 --- a/app/sdks/js/docs/examples/projects/list-platforms.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.listPlatforms('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/list-projects.md b/app/sdks/js/docs/examples/projects/list-projects.md deleted file mode 100644 index 3ba3afc41e..0000000000 --- a/app/sdks/js/docs/examples/projects/list-projects.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.listProjects(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/list-tasks.md b/app/sdks/js/docs/examples/projects/list-tasks.md deleted file mode 100644 index fd8ab61ffa..0000000000 --- a/app/sdks/js/docs/examples/projects/list-tasks.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.listTasks('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/list-webhooks.md b/app/sdks/js/docs/examples/projects/list-webhooks.md deleted file mode 100644 index b19851c8b1..0000000000 --- a/app/sdks/js/docs/examples/projects/list-webhooks.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.listWebhooks('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/update-key.md b/app/sdks/js/docs/examples/projects/update-key.md deleted file mode 100644 index 063f4daea4..0000000000 --- a/app/sdks/js/docs/examples/projects/update-key.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.updateKey('[PROJECT_ID]', '[KEY_ID]', '[NAME]', []); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/update-platform.md b/app/sdks/js/docs/examples/projects/update-platform.md deleted file mode 100644 index e28846f050..0000000000 --- a/app/sdks/js/docs/examples/projects/update-platform.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.updatePlatform('[PROJECT_ID]', '[PLATFORM_ID]', '[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/update-project-o-auth.md b/app/sdks/js/docs/examples/projects/update-project-o-auth.md deleted file mode 100644 index 9ab78a4ea9..0000000000 --- a/app/sdks/js/docs/examples/projects/update-project-o-auth.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.updateProjectOAuth('[PROJECT_ID]', 'bitbucket'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/update-project.md b/app/sdks/js/docs/examples/projects/update-project.md deleted file mode 100644 index 6fcaa49f37..0000000000 --- a/app/sdks/js/docs/examples/projects/update-project.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.updateProject('[PROJECT_ID]', '[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/update-task.md b/app/sdks/js/docs/examples/projects/update-task.md deleted file mode 100644 index 54116a41d0..0000000000 --- a/app/sdks/js/docs/examples/projects/update-task.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/projects/update-webhook.md b/app/sdks/js/docs/examples/projects/update-webhook.md deleted file mode 100644 index ce876d5a64..0000000000 --- a/app/sdks/js/docs/examples/projects/update-webhook.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 0); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/storage/get-file-download.md b/app/sdks/js/docs/examples/storage/get-file-download.md deleted file mode 100644 index a53142184c..0000000000 --- a/app/sdks/js/docs/examples/storage/get-file-download.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.storage.getFileDownload('[FILE_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/storage/get-file-preview.md b/app/sdks/js/docs/examples/storage/get-file-preview.md deleted file mode 100644 index 1cce3acd24..0000000000 --- a/app/sdks/js/docs/examples/storage/get-file-preview.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.storage.getFilePreview('[FILE_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/storage/get-file-view.md b/app/sdks/js/docs/examples/storage/get-file-view.md deleted file mode 100644 index 4844b22ce3..0000000000 --- a/app/sdks/js/docs/examples/storage/get-file-view.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.storage.getFileView('[FILE_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/create-team-membership-resend.md b/app/sdks/js/docs/examples/teams/create-team-membership-resend.md deleted file mode 100644 index 03ac8240a9..0000000000 --- a/app/sdks/js/docs/examples/teams/create-team-membership-resend.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.createTeamMembershipResend('[TEAM_ID]', '[INVITE_ID]', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/create-team-membership.md b/app/sdks/js/docs/examples/teams/create-team-membership.md deleted file mode 100644 index 60f996c209..0000000000 --- a/app/sdks/js/docs/examples/teams/create-team-membership.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.createTeamMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/create-team.md b/app/sdks/js/docs/examples/teams/create-team.md deleted file mode 100644 index 2dafeac2ab..0000000000 --- a/app/sdks/js/docs/examples/teams/create-team.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.createTeam('[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/delete-team-membership.md b/app/sdks/js/docs/examples/teams/delete-team-membership.md deleted file mode 100644 index 551dfd7dbb..0000000000 --- a/app/sdks/js/docs/examples/teams/delete-team-membership.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.deleteTeamMembership('[TEAM_ID]', '[INVITE_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/delete-team.md b/app/sdks/js/docs/examples/teams/delete-team.md deleted file mode 100644 index 3f9cd8b6f5..0000000000 --- a/app/sdks/js/docs/examples/teams/delete-team.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.deleteTeam('[TEAM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/get-team-members.md b/app/sdks/js/docs/examples/teams/get-team-members.md deleted file mode 100644 index f1ba5d9f4a..0000000000 --- a/app/sdks/js/docs/examples/teams/get-team-members.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.getTeamMembers('[TEAM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/get-team.md b/app/sdks/js/docs/examples/teams/get-team.md deleted file mode 100644 index 7e1f8254fe..0000000000 --- a/app/sdks/js/docs/examples/teams/get-team.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.getTeam('[TEAM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/list-teams.md b/app/sdks/js/docs/examples/teams/list-teams.md deleted file mode 100644 index abd4fa420b..0000000000 --- a/app/sdks/js/docs/examples/teams/list-teams.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.listTeams(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/update-team-membership-status.md b/app/sdks/js/docs/examples/teams/update-team-membership-status.md deleted file mode 100644 index 15eb72524b..0000000000 --- a/app/sdks/js/docs/examples/teams/update-team-membership-status.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.updateTeamMembershipStatus('[TEAM_ID]', '[INVITE_ID]', '[USER_ID]', '[SECRET]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/teams/update-team.md b/app/sdks/js/docs/examples/teams/update-team.md deleted file mode 100644 index 2ec35ec906..0000000000 --- a/app/sdks/js/docs/examples/teams/update-team.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.teams.updateTeam('[TEAM_ID]', '[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/create-user.md b/app/sdks/js/docs/examples/users/create-user.md deleted file mode 100644 index 1242fe70c2..0000000000 --- a/app/sdks/js/docs/examples/users/create-user.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.createUser('email@example.com', 'password'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/delete-user-session.md b/app/sdks/js/docs/examples/users/delete-user-session.md deleted file mode 100644 index 4b5df53439..0000000000 --- a/app/sdks/js/docs/examples/users/delete-user-session.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.deleteUserSession('[USER_ID]', '[SESSION_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/delete-user-sessions.md b/app/sdks/js/docs/examples/users/delete-user-sessions.md deleted file mode 100644 index 1a6851ce15..0000000000 --- a/app/sdks/js/docs/examples/users/delete-user-sessions.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.deleteUserSessions('[USER_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/delete-users-session.md b/app/sdks/js/docs/examples/users/delete-users-session.md deleted file mode 100644 index 5eac7e2236..0000000000 --- a/app/sdks/js/docs/examples/users/delete-users-session.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.deleteUsersSession('[USER_ID]', '[SESSION_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/get-user-logs.md b/app/sdks/js/docs/examples/users/get-user-logs.md deleted file mode 100644 index 85175b0e1e..0000000000 --- a/app/sdks/js/docs/examples/users/get-user-logs.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.getUserLogs('[USER_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/get-user-prefs.md b/app/sdks/js/docs/examples/users/get-user-prefs.md deleted file mode 100644 index 0d9c8dbb22..0000000000 --- a/app/sdks/js/docs/examples/users/get-user-prefs.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.getUserPrefs('[USER_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/get-user-sessions.md b/app/sdks/js/docs/examples/users/get-user-sessions.md deleted file mode 100644 index 8cc7b1f85b..0000000000 --- a/app/sdks/js/docs/examples/users/get-user-sessions.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.getUserSessions('[USER_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/get-user.md b/app/sdks/js/docs/examples/users/get-user.md deleted file mode 100644 index feb40dff2d..0000000000 --- a/app/sdks/js/docs/examples/users/get-user.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.getUser('[USER_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/list-users.md b/app/sdks/js/docs/examples/users/list-users.md deleted file mode 100644 index 561826cbd1..0000000000 --- a/app/sdks/js/docs/examples/users/list-users.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.listUsers(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/update-user-prefs.md b/app/sdks/js/docs/examples/users/update-user-prefs.md deleted file mode 100644 index 54208f5f96..0000000000 --- a/app/sdks/js/docs/examples/users/update-user-prefs.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.updateUserPrefs('[USER_ID]', '{}'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/docs/examples/users/update-user-status.md b/app/sdks/js/docs/examples/users/update-user-status.md deleted file mode 100644 index 15b7376ca7..0000000000 --- a/app/sdks/js/docs/examples/users/update-user-status.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('') -; - -let promise = sdk.users.updateUserStatus('[USER_ID]', '1'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/js/src/sdk.min.js b/app/sdks/js/src/sdk.min.js deleted file mode 100644 index f921d5801a..0000000000 --- a/app/sdks/js/src/sdk.min.js +++ /dev/null @@ -1,361 +0,0 @@ -(function(window){'use strict';window.Appwrite=function(){let config={endpoint:'https://appwrite.io/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;index=request.status){let data=request.response;let contentType=this.getResponseHeader('content-type')||'';contentType=contentType.substring(0,contentType.indexOf(';'));switch(contentType){case 'application/json':data=JSON.parse(data);break} -resolve(data)}else{reject(new Error(request.statusText))}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,!1)} -request.onerror=function(){reject(new Error("Network Error"))};request.send(params)})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{})},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress)},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress)},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress)},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress)},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let iframe=function(method,url,params){let form=document.createElement('form');form.setAttribute('method',method);form.setAttribute('action',config.endpoint+url);for(let key in params){if(params.hasOwnProperty(key)){let hiddenField=document.createElement("input");hiddenField.setAttribute("type","hidden");hiddenField.setAttribute("name",key);hiddenField.setAttribute("value",params[key]);form.appendChild(hiddenField)}} -document.body.appendChild(form);return form.submit()};let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload)},delete:function(){let path='/account';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateEmail:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -let path='/account/email';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -return http.patch(path,{'content-type':'application/json',},payload)},updateName:function(name){if(name===undefined){throw new Error('Missing required parameter: "name"')} -let path='/account/name';let payload={};if(name){payload.name=name} -return http.patch(path,{'content-type':'application/json',},payload)},updatePassword:function(password,oldPassword){if(password===undefined){throw new Error('Missing required parameter: "password"')} -if(oldPassword===undefined){throw new Error('Missing required parameter: "oldPassword"')} -let path='/account/password';let payload={};if(password){payload.password=password} -if(oldPassword){payload['old-password']=oldPassword} -return http.patch(path,{'content-type':'application/json',},payload)},getPrefs:function(){let path='/account/prefs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},updatePrefs:function(prefs){if(prefs===undefined){throw new Error('Missing required parameter: "prefs"')} -let path='/account/prefs';let payload={};if(prefs){payload.prefs=prefs} -return http.patch(path,{'content-type':'application/json',},payload)},getSecurity:function(){let path='/account/security';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let auth={login:function(email,password,success='',failure=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -let path='/auth/login';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -if(success){payload.success=success} -if(failure){payload.failure=failure} -payload.project=config.project;return iframe('post',path,payload)},oauth:function(provider,success,failure){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} -if(success===undefined){throw new Error('Missing required parameter: "success"')} -if(failure===undefined){throw new Error('Missing required parameter: "failure"')} -let path='/auth/login/oauth/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success} -if(failure){payload.failure=failure} -payload.project=config.project;return iframe('get',path,payload)},logout:function(){let path='/auth/logout';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},logoutBySession:function(id){if(id===undefined){throw new Error('Missing required parameter: "id"')} -let path='/auth/logout/{id}'.replace(new RegExp('{id}','g'),id);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},recovery:function(email,reset){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(reset===undefined){throw new Error('Missing required parameter: "reset"')} -let path='/auth/recovery';let payload={};if(email){payload.email=email} -if(reset){payload.reset=reset} -return http.post(path,{'content-type':'application/json',},payload)},recoveryReset:function(userId,token,passwordA,passwordB){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -if(token===undefined){throw new Error('Missing required parameter: "token"')} -if(passwordA===undefined){throw new Error('Missing required parameter: "passwordA"')} -if(passwordB===undefined){throw new Error('Missing required parameter: "passwordB"')} -let path='/auth/recovery/reset';let payload={};if(userId){payload.userId=userId} -if(token){payload.token=token} -if(passwordA){payload['password-a']=passwordA} -if(passwordB){payload['password-b']=passwordB} -return http.put(path,{'content-type':'application/json',},payload)},register:function(email,password,confirm,success='',failure='',name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -if(confirm===undefined){throw new Error('Missing required parameter: "confirm"')} -let path='/auth/register';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -if(confirm){payload.confirm=confirm} -if(success){payload.success=success} -if(failure){payload.failure=failure} -if(name){payload.name=name} -payload.project=config.project;return iframe('post',path,payload)},confirm:function(userId,token){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -if(token===undefined){throw new Error('Missing required parameter: "token"')} -let path='/auth/register/confirm';let payload={};if(userId){payload.userId=userId} -if(token){payload.token=token} -return http.post(path,{'content-type':'application/json',},payload)},confirmResend:function(confirm){if(confirm===undefined){throw new Error('Missing required parameter: "confirm"')} -let path='/auth/register/confirm/resend';let payload={};if(confirm){payload.confirm=confirm} -return http.post(path,{'content-type':'application/json',},payload)}};let avatars={getBrowser:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} -let path='/avatars/browsers/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} -if(height){payload.height=height} -if(quality){payload.quality=quality} -return http.get(path,{'content-type':'application/json',},payload)},getCreditCard:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} -let path='/avatars/credit-cards/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} -if(height){payload.height=height} -if(quality){payload.quality=quality} -return http.get(path,{'content-type':'application/json',},payload)},getFavicon:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')} -let path='/avatars/favicon';let payload={};if(url){payload.url=url} -return http.get(path,{'content-type':'application/json',},payload)},getFlag:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} -let path='/avatars/flags/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} -if(height){payload.height=height} -if(quality){payload.quality=quality} -return http.get(path,{'content-type':'application/json',},payload)},getImage:function(url,width=400,height=400){if(url===undefined){throw new Error('Missing required parameter: "url"')} -let path='/avatars/image';let payload={};if(url){payload.url=url} -if(width){payload.width=width} -if(height){payload.height=height} -return http.get(path,{'content-type':'application/json',},payload)},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} -if(download){payload.download=download} -return http.get(path,{'content-type':'application/json',},payload)}};let database={listCollections:function(search='',limit=25,offset=0,orderType='ASC'){let path='/database';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)},createCollection:function(name,read,write,rules){if(name===undefined){throw new Error('Missing required parameter: "name"')} -if(read===undefined){throw new Error('Missing required parameter: "read"')} -if(write===undefined){throw new Error('Missing required parameter: "write"')} -if(rules===undefined){throw new Error('Missing required parameter: "rules"')} -let path='/database';let payload={};if(name){payload.name=name} -if(read){payload.read=read} -if(write){payload.write=write} -if(rules){payload.rules=rules} -return http.post(path,{'content-type':'application/json',},payload)},getCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} -let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateCollection:function(collectionId,name,read,write,rules=[]){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -if(read===undefined){throw new Error('Missing required parameter: "read"')} -if(write===undefined){throw new Error('Missing required parameter: "write"')} -let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(name){payload.name=name} -if(read){payload.read=read} -if(write){payload.write=write} -if(rules){payload.rules=rules} -return http.put(path,{'content-type':'application/json',},payload)},deleteCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} -let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$uid',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} -let path='/database/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(filters){payload.filters=filters} -if(offset){payload.offset=offset} -if(limit){payload.limit=limit} -if(orderField){payload['order-field']=orderField} -if(orderType){payload['order-type']=orderType} -if(orderCast){payload['order-cast']=orderCast} -if(search){payload.search=search} -if(first){payload.first=first} -if(last){payload.last=last} -return http.get(path,{'content-type':'application/json',},payload)},createDocument:function(collectionId,data,read,write,parentDocument='',parentProperty='',parentPropertyType='assign'){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} -if(data===undefined){throw new Error('Missing required parameter: "data"')} -if(read===undefined){throw new Error('Missing required parameter: "read"')} -if(write===undefined){throw new Error('Missing required parameter: "write"')} -let path='/database/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(data){payload.data=data} -if(read){payload.read=read} -if(write){payload.write=write} -if(parentDocument){payload.parentDocument=parentDocument} -if(parentProperty){payload.parentProperty=parentProperty} -if(parentPropertyType){payload.parentPropertyType=parentPropertyType} -return http.post(path,{'content-type':'application/json',},payload)},getDocument: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/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateDocument:function(collectionId,documentId,data,read,write){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} -if(documentId===undefined){throw new Error('Missing required parameter: "documentId"')} -if(data===undefined){throw new Error('Missing required parameter: "data"')} -if(read===undefined){throw new Error('Missing required parameter: "read"')} -if(write===undefined){throw new Error('Missing required parameter: "write"')} -let path='/database/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};if(data){payload.data=data} -if(read){payload.read=read} -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/{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)}};let locale={getLocale:function(){let path='/locale';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getContinents:function(){let path='/locale/continents';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountries:function(){let path='/locale/countries';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesEU:function(){let path='/locale/countries/eu';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesPhones:function(){let path='/locale/countries/phones';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCurrencies:function(){let path='/locale/currencies';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let projects={listProjects:function(){let path='/projects';let payload={};return http.get(path,{'content-type':'application/json',},payload)},createProject: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} -if(description){payload.description=description} -if(logo){payload.logo=logo} -if(url){payload.url=url} -if(legalName){payload.legalName=legalName} -if(legalCountry){payload.legalCountry=legalCountry} -if(legalState){payload.legalState=legalState} -if(legalCity){payload.legalCity=legalCity} -if(legalAddress){payload.legalAddress=legalAddress} -if(legalTaxId){payload.legalTaxId=legalTaxId} -return http.post(path,{'content-type':'application/json',},payload)},getProject:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -let path='/projects/{projectId}'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateProject:function(projectId,name,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -let path='/projects/{projectId}'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload.name=name} -if(description){payload.description=description} -if(logo){payload.logo=logo} -if(url){payload.url=url} -if(legalName){payload.legalName=legalName} -if(legalCountry){payload.legalCountry=legalCountry} -if(legalState){payload.legalState=legalState} -if(legalCity){payload.legalCity=legalCity} -if(legalAddress){payload.legalAddress=legalAddress} -if(legalTaxId){payload.legalTaxId=legalTaxId} -return http.patch(path,{'content-type':'application/json',},payload)},deleteProject:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -let path='/projects/{projectId}'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},listKeys:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -let path='/projects/{projectId}/keys'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},createKey:function(projectId,name,scopes){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -if(scopes===undefined){throw new Error('Missing required parameter: "scopes"')} -let path='/projects/{projectId}/keys'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload.name=name} -if(scopes){payload.scopes=scopes} -return http.post(path,{'content-type':'application/json',},payload)},getKey:function(projectId,keyId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(keyId===undefined){throw new Error('Missing required parameter: "keyId"')} -let path='/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{keyId}','g'),keyId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateKey:function(projectId,keyId,name,scopes){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(keyId===undefined){throw new Error('Missing required parameter: "keyId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -if(scopes===undefined){throw new Error('Missing required parameter: "scopes"')} -let path='/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{keyId}','g'),keyId);let payload={};if(name){payload.name=name} -if(scopes){payload.scopes=scopes} -return http.put(path,{'content-type':'application/json',},payload)},deleteKey:function(projectId,keyId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(keyId===undefined){throw new Error('Missing required parameter: "keyId"')} -let path='/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{keyId}','g'),keyId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateProjectOAuth:function(projectId,provider,appId='',secret=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(provider===undefined){throw new Error('Missing required parameter: "provider"')} -let path='/projects/{projectId}/oauth'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(provider){payload.provider=provider} -if(appId){payload.appId=appId} -if(secret){payload.secret=secret} -return http.patch(path,{'content-type':'application/json',},payload)},listPlatforms:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -let path='/projects/{projectId}/platforms'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},createPlatform:function(projectId,type,name,key='',store='',url=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(type===undefined){throw new Error('Missing required parameter: "type"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -let path='/projects/{projectId}/platforms'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(type){payload.type=type} -if(name){payload.name=name} -if(key){payload.key=key} -if(store){payload.store=store} -if(url){payload.url=url} -return http.post(path,{'content-type':'application/json',},payload)},getPlatform:function(projectId,platformId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(platformId===undefined){throw new Error('Missing required parameter: "platformId"')} -let path='/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{platformId}','g'),platformId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updatePlatform:function(projectId,platformId,name,key='',store='',url=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(platformId===undefined){throw new Error('Missing required parameter: "platformId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -let path='/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{platformId}','g'),platformId);let payload={};if(name){payload.name=name} -if(key){payload.key=key} -if(store){payload.store=store} -if(url){payload.url=url} -return http.put(path,{'content-type':'application/json',},payload)},deletePlatform:function(projectId,platformId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(platformId===undefined){throw new Error('Missing required parameter: "platformId"')} -let path='/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{platformId}','g'),platformId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},listTasks:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -let path='/projects/{projectId}/tasks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},createTask:function(projectId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -if(status===undefined){throw new Error('Missing required parameter: "status"')} -if(schedule===undefined){throw new Error('Missing required parameter: "schedule"')} -if(security===undefined){throw new Error('Missing required parameter: "security"')} -if(httpMethod===undefined){throw new Error('Missing required parameter: "httpMethod"')} -if(httpUrl===undefined){throw new Error('Missing required parameter: "httpUrl"')} -let path='/projects/{projectId}/tasks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload.name=name} -if(status){payload.status=status} -if(schedule){payload.schedule=schedule} -if(security){payload.security=security} -if(httpMethod){payload.httpMethod=httpMethod} -if(httpUrl){payload.httpUrl=httpUrl} -if(httpHeaders){payload.httpHeaders=httpHeaders} -if(httpUser){payload.httpUser=httpUser} -if(httpPass){payload.httpPass=httpPass} -return http.post(path,{'content-type':'application/json',},payload)},getTask:function(projectId,taskId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(taskId===undefined){throw new Error('Missing required parameter: "taskId"')} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateTask:function(projectId,taskId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(taskId===undefined){throw new Error('Missing required parameter: "taskId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -if(status===undefined){throw new Error('Missing required parameter: "status"')} -if(schedule===undefined){throw new Error('Missing required parameter: "schedule"')} -if(security===undefined){throw new Error('Missing required parameter: "security"')} -if(httpMethod===undefined){throw new Error('Missing required parameter: "httpMethod"')} -if(httpUrl===undefined){throw new Error('Missing required parameter: "httpUrl"')} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};if(name){payload.name=name} -if(status){payload.status=status} -if(schedule){payload.schedule=schedule} -if(security){payload.security=security} -if(httpMethod){payload.httpMethod=httpMethod} -if(httpUrl){payload.httpUrl=httpUrl} -if(httpHeaders){payload.httpHeaders=httpHeaders} -if(httpUser){payload.httpUser=httpUser} -if(httpPass){payload.httpPass=httpPass} -return http.put(path,{'content-type':'application/json',},payload)},deleteTask:function(projectId,taskId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(taskId===undefined){throw new Error('Missing required parameter: "taskId"')} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getProjectUsage:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -let path='/projects/{projectId}/usage'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},listWebhooks:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -let path='/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},createWebhook:function(projectId,name,events,url,security,httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -if(events===undefined){throw new Error('Missing required parameter: "events"')} -if(url===undefined){throw new Error('Missing required parameter: "url"')} -if(security===undefined){throw new Error('Missing required parameter: "security"')} -let path='/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload.name=name} -if(events){payload.events=events} -if(url){payload.url=url} -if(security){payload.security=security} -if(httpUser){payload.httpUser=httpUser} -if(httpPass){payload.httpPass=httpPass} -return http.post(path,{'content-type':'application/json',},payload)},getWebhook:function(projectId,webhookId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"')} -let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateWebhook:function(projectId,webhookId,name,events,url,security,httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -if(events===undefined){throw new Error('Missing required parameter: "events"')} -if(url===undefined){throw new Error('Missing required parameter: "url"')} -if(security===undefined){throw new Error('Missing required parameter: "security"')} -let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);let payload={};if(name){payload.name=name} -if(events){payload.events=events} -if(url){payload.url=url} -if(security){payload.security=security} -if(httpUser){payload.httpUser=httpUser} -if(httpPass){payload.httpPass=httpPass} -return http.put(path,{'content-type':'application/json',},payload)},deleteWebhook:function(projectId,webhookId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"')} -let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)}};let storage={listFiles:function(search='',limit=25,offset=0,orderType='ASC'){let path='/storage/files';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)},createFile:function(files,read,write){if(files===undefined){throw new Error('Missing required parameter: "files"')} -if(read===undefined){throw new Error('Missing required parameter: "read"')} -if(write===undefined){throw new Error('Missing required parameter: "write"')} -let path='/storage/files';let payload={};if(files){payload.files=files} -if(read){payload.read=read} -if(write){payload.write=write} -return http.post(path,{'content-type':'multipart/form-data',},payload)},getFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} -let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateFile:function(fileId,read,write){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} -if(read===undefined){throw new Error('Missing required parameter: "read"')} -if(write===undefined){throw new Error('Missing required parameter: "write"')} -let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};if(read){payload.read=read} -if(write){payload.write=write} -return http.put(path,{'content-type':'application/json',},payload)},deleteFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} -let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getFileDownload:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} -let path='/storage/files/{fileId}/download'.replace(new RegExp('{fileId}','g'),fileId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},getFilePreview:function(fileId,width=0,height=0,quality=100,background='',output=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} -let path='/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}','g'),fileId);let payload={};if(width){payload.width=width} -if(height){payload.height=height} -if(quality){payload.quality=quality} -if(background){payload.background=background} -if(output){payload.output=output} -return http.get(path,{'content-type':'application/json',},payload)},getFileView:function(fileId,as=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')} -let path='/storage/files/{fileId}/view'.replace(new RegExp('{fileId}','g'),fileId);let payload={};if(as){payload.as=as} -return http.get(path,{'content-type':'application/json',},payload)}};let teams={listTeams:function(search='',limit=25,offset=0,orderType='ASC'){let path='/teams';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)},createTeam:function(name,roles=["owner"]){if(name===undefined){throw new Error('Missing required parameter: "name"')} -let path='/teams';let payload={};if(name){payload.name=name} -if(roles){payload.roles=roles} -return http.post(path,{'content-type':'application/json',},payload)},getTeam:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} -let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateTeam:function(teamId,name){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} -if(name===undefined){throw new Error('Missing required parameter: "name"')} -let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(name){payload.name=name} -return http.put(path,{'content-type':'application/json',},payload)},deleteTeam:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} -let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getTeamMembers:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} -let path='/teams/{teamId}/members'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},createTeamMembership:function(teamId,email,roles,redirect,name=''){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} -if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(roles===undefined){throw new Error('Missing required parameter: "roles"')} -if(redirect===undefined){throw new Error('Missing required parameter: "redirect"')} -let path='/teams/{teamId}/memberships'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(email){payload.email=email} -if(name){payload.name=name} -if(roles){payload.roles=roles} -if(redirect){payload.redirect=redirect} -return http.post(path,{'content-type':'application/json',},payload)},deleteTeamMembership:function(teamId,inviteId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} -if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"')} -let path='/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createTeamMembershipResend:function(teamId,inviteId,redirect){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} -if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"')} -if(redirect===undefined){throw new Error('Missing required parameter: "redirect"')} -let path='/teams/{teamId}/memberships/{inviteId}/resend'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};if(redirect){payload.redirect=redirect} -return http.post(path,{'content-type':'application/json',},payload)},updateTeamMembershipStatus:function(teamId,inviteId,userId,secret,success='',failure=''){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} -if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"')} -if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -if(secret===undefined){throw new Error('Missing required parameter: "secret"')} -let path='/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};if(userId){payload.userId=userId} -if(secret){payload.secret=secret} -if(success){payload.success=success} -if(failure){payload.failure=failure} -payload.project=config.project;return iframe('patch',path,payload)}};let users={listUsers:function(search='',limit=25,offset=0,orderType='ASC'){let path='/users';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)},createUser:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -let path='/users';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -if(name){payload.name=name} -return http.post(path,{'content-type':'application/json',},payload)},getUser:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -let path='/users/{userId}'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},getUserLogs:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -let path='/users/{userId}/logs'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},getUserPrefs:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -let path='/users/{userId}/prefs'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateUserPrefs:function(userId,prefs){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -if(prefs===undefined){throw new Error('Missing required parameter: "prefs"')} -let path='/users/{userId}/prefs'.replace(new RegExp('{userId}','g'),userId);let payload={};if(prefs){payload.prefs=prefs} -return http.patch(path,{'content-type':'application/json',},payload)},getUserSessions:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -let path='/users/{userId}/sessions'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},deleteUserSessions:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -let path='/users/{userId}/sessions'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},deleteUserSession:function(userId,sessionId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')} -let path='/users/{userId}/sessions/:session'.replace(new RegExp('{userId}','g'),userId);let payload={};if(sessionId){payload.sessionId=sessionId} -return http.delete(path,{'content-type':'application/json',},payload)},updateUserStatus: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,auth:auth,avatars:avatars,database:database,locale:locale,projects:projects,storage:storage,teams:teams,users:users}};if(typeof module!=="undefined"){module.exports=window.Appwrite}})((typeof window!=="undefined")?window:{}) \ No newline at end of file diff --git a/app/sdks/node/docs/examples/account/delete.md b/app/sdks/node/docs/examples/account/delete.md deleted file mode 100644 index 0710fd6dfc..0000000000 --- a/app/sdks/node/docs/examples/account/delete.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let account = new sdk.Account(client); - -client - .setProject('') - .setKey('') -; - -let promise = account.delete(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/account/get-prefs.md b/app/sdks/node/docs/examples/account/get-prefs.md deleted file mode 100644 index bdff57e923..0000000000 --- a/app/sdks/node/docs/examples/account/get-prefs.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let account = new sdk.Account(client); - -client - .setProject('') - .setKey('') -; - -let promise = account.getPrefs(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/account/get-security.md b/app/sdks/node/docs/examples/account/get-security.md deleted file mode 100644 index 03a6561fff..0000000000 --- a/app/sdks/node/docs/examples/account/get-security.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let account = new sdk.Account(client); - -client - .setProject('') - .setKey('') -; - -let promise = account.getSecurity(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/account/get-sessions.md b/app/sdks/node/docs/examples/account/get-sessions.md deleted file mode 100644 index 02b464a497..0000000000 --- a/app/sdks/node/docs/examples/account/get-sessions.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let account = new sdk.Account(client); - -client - .setProject('') - .setKey('') -; - -let promise = account.getSessions(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/account/get.md b/app/sdks/node/docs/examples/account/get.md deleted file mode 100644 index b2e078d061..0000000000 --- a/app/sdks/node/docs/examples/account/get.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let account = new sdk.Account(client); - -client - .setProject('') - .setKey('') -; - -let promise = account.get(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/account/update-email.md b/app/sdks/node/docs/examples/account/update-email.md deleted file mode 100644 index 29b50314f2..0000000000 --- a/app/sdks/node/docs/examples/account/update-email.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let account = new sdk.Account(client); - -client - .setProject('') - .setKey('') -; - -let promise = account.updateEmail('email@example.com', 'password'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/account/update-name.md b/app/sdks/node/docs/examples/account/update-name.md deleted file mode 100644 index d8b4734cbb..0000000000 --- a/app/sdks/node/docs/examples/account/update-name.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let account = new sdk.Account(client); - -client - .setProject('') - .setKey('') -; - -let promise = account.updateName('[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/account/update-password.md b/app/sdks/node/docs/examples/account/update-password.md deleted file mode 100644 index 5aa6622ffa..0000000000 --- a/app/sdks/node/docs/examples/account/update-password.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let account = new sdk.Account(client); - -client - .setProject('') - .setKey('') -; - -let promise = account.updatePassword('password', 'password'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/account/update-prefs.md b/app/sdks/node/docs/examples/account/update-prefs.md deleted file mode 100644 index c76e735e18..0000000000 --- a/app/sdks/node/docs/examples/account/update-prefs.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let account = new sdk.Account(client); - -client - .setProject('') - .setKey('') -; - -let promise = account.updatePrefs('{}'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/confirm-resend.md b/app/sdks/node/docs/examples/auth/confirm-resend.md deleted file mode 100644 index 443870394b..0000000000 --- a/app/sdks/node/docs/examples/auth/confirm-resend.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let auth = new sdk.Auth(client); - -client - .setProject('') - .setKey('') -; - -let promise = auth.confirmResend('https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/confirm.md b/app/sdks/node/docs/examples/auth/confirm.md deleted file mode 100644 index 527df2d6ff..0000000000 --- a/app/sdks/node/docs/examples/auth/confirm.md +++ /dev/null @@ -1,17 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let auth = new sdk.Auth(client); - -client -; - -let promise = auth.confirm('[USER_ID]', '[TOKEN]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/login.md b/app/sdks/node/docs/examples/auth/login.md deleted file mode 100644 index 1033b6f30f..0000000000 --- a/app/sdks/node/docs/examples/auth/login.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let auth = new sdk.Auth(client); - -client - .setProject('') - .setKey('') -; - -let promise = auth.login('email@example.com', 'password'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/logout-by-session.md b/app/sdks/node/docs/examples/auth/logout-by-session.md deleted file mode 100644 index df964c0caf..0000000000 --- a/app/sdks/node/docs/examples/auth/logout-by-session.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let auth = new sdk.Auth(client); - -client - .setProject('') - .setKey('') -; - -let promise = auth.logoutBySession('[ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/logout.md b/app/sdks/node/docs/examples/auth/logout.md deleted file mode 100644 index d34102cbd7..0000000000 --- a/app/sdks/node/docs/examples/auth/logout.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let auth = new sdk.Auth(client); - -client - .setProject('') - .setKey('') -; - -let promise = auth.logout(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/oauth-callback.md b/app/sdks/node/docs/examples/auth/oauth-callback.md deleted file mode 100644 index 2588802fed..0000000000 --- a/app/sdks/node/docs/examples/auth/oauth-callback.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new Auth.Client(); - -let auth = new sdk.Auth(client); - -client - setProject('') - setKey('') -; - -let promise = auth.oauthCallback('[PROJECT_ID]', 'bitbucket', '[CODE]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/oauth.md b/app/sdks/node/docs/examples/auth/oauth.md deleted file mode 100644 index 4a2230c686..0000000000 --- a/app/sdks/node/docs/examples/auth/oauth.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let auth = new sdk.Auth(client); - -client - .setProject('') - .setKey('') -; - -let promise = auth.oauth('bitbucket', 'https://example.com', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/recovery-reset.md b/app/sdks/node/docs/examples/auth/recovery-reset.md deleted file mode 100644 index f43a8b3305..0000000000 --- a/app/sdks/node/docs/examples/auth/recovery-reset.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let auth = new sdk.Auth(client); - -client - .setProject('') - .setKey('') -; - -let promise = auth.recoveryReset('[USER_ID]', '[TOKEN]', 'password', 'password'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/recovery.md b/app/sdks/node/docs/examples/auth/recovery.md deleted file mode 100644 index 9e340a7f32..0000000000 --- a/app/sdks/node/docs/examples/auth/recovery.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let auth = new sdk.Auth(client); - -client - .setProject('') - .setKey('') -; - -let promise = auth.recovery('email@example.com', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/auth/register.md b/app/sdks/node/docs/examples/auth/register.md deleted file mode 100644 index 708719a56f..0000000000 --- a/app/sdks/node/docs/examples/auth/register.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let auth = new sdk.Auth(client); - -client - .setProject('') - .setKey('') -; - -let promise = auth.register('email@example.com', 'password', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/locale/get-locale.md b/app/sdks/node/docs/examples/locale/get-locale.md deleted file mode 100644 index 57e5d69e78..0000000000 --- a/app/sdks/node/docs/examples/locale/get-locale.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let locale = new sdk.Locale(client); - -client - .setProject('') - .setKey('') -; - -let promise = locale.getLocale(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/create-key.md b/app/sdks/node/docs/examples/projects/create-key.md deleted file mode 100644 index 227e8fc5ba..0000000000 --- a/app/sdks/node/docs/examples/projects/create-key.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.createKey('[PROJECT_ID]', '[NAME]', []); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/create-platform.md b/app/sdks/node/docs/examples/projects/create-platform.md deleted file mode 100644 index ce9c7e01e1..0000000000 --- a/app/sdks/node/docs/examples/projects/create-platform.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.createPlatform('[PROJECT_ID]', 'web', '[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/create-project.md b/app/sdks/node/docs/examples/projects/create-project.md deleted file mode 100644 index 8f0d8b47ef..0000000000 --- a/app/sdks/node/docs/examples/projects/create-project.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.createProject('[NAME]', '[TEAM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/create-task.md b/app/sdks/node/docs/examples/projects/create-task.md deleted file mode 100644 index 8923742294..0000000000 --- a/app/sdks/node/docs/examples/projects/create-task.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.createTask('[PROJECT_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/create-webhook.md b/app/sdks/node/docs/examples/projects/create-webhook.md deleted file mode 100644 index 8135e8d66e..0000000000 --- a/app/sdks/node/docs/examples/projects/create-webhook.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 0); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/delete-key.md b/app/sdks/node/docs/examples/projects/delete-key.md deleted file mode 100644 index 3ca5caba8a..0000000000 --- a/app/sdks/node/docs/examples/projects/delete-key.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.deleteKey('[PROJECT_ID]', '[KEY_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/delete-platform.md b/app/sdks/node/docs/examples/projects/delete-platform.md deleted file mode 100644 index 8c01703dd0..0000000000 --- a/app/sdks/node/docs/examples/projects/delete-platform.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.deletePlatform('[PROJECT_ID]', '[PLATFORM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/delete-project.md b/app/sdks/node/docs/examples/projects/delete-project.md deleted file mode 100644 index 7755f35c1f..0000000000 --- a/app/sdks/node/docs/examples/projects/delete-project.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.deleteProject('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/delete-task.md b/app/sdks/node/docs/examples/projects/delete-task.md deleted file mode 100644 index a3b985b784..0000000000 --- a/app/sdks/node/docs/examples/projects/delete-task.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.deleteTask('[PROJECT_ID]', '[TASK_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/delete-webhook.md b/app/sdks/node/docs/examples/projects/delete-webhook.md deleted file mode 100644 index 3b41b8c433..0000000000 --- a/app/sdks/node/docs/examples/projects/delete-webhook.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.deleteWebhook('[PROJECT_ID]', '[WEBHOOK_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/get-key.md b/app/sdks/node/docs/examples/projects/get-key.md deleted file mode 100644 index e0b2a85856..0000000000 --- a/app/sdks/node/docs/examples/projects/get-key.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.getKey('[PROJECT_ID]', '[KEY_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/get-platform.md b/app/sdks/node/docs/examples/projects/get-platform.md deleted file mode 100644 index c035141e0c..0000000000 --- a/app/sdks/node/docs/examples/projects/get-platform.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.getPlatform('[PROJECT_ID]', '[PLATFORM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/get-project-usage.md b/app/sdks/node/docs/examples/projects/get-project-usage.md deleted file mode 100644 index 32c13c13a3..0000000000 --- a/app/sdks/node/docs/examples/projects/get-project-usage.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.getProjectUsage('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/get-project.md b/app/sdks/node/docs/examples/projects/get-project.md deleted file mode 100644 index 15b685a554..0000000000 --- a/app/sdks/node/docs/examples/projects/get-project.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.getProject('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/get-task.md b/app/sdks/node/docs/examples/projects/get-task.md deleted file mode 100644 index 83040a39f1..0000000000 --- a/app/sdks/node/docs/examples/projects/get-task.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.getTask('[PROJECT_ID]', '[TASK_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/get-webhook.md b/app/sdks/node/docs/examples/projects/get-webhook.md deleted file mode 100644 index cb98367d6f..0000000000 --- a/app/sdks/node/docs/examples/projects/get-webhook.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.getWebhook('[PROJECT_ID]', '[WEBHOOK_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/list-keys.md b/app/sdks/node/docs/examples/projects/list-keys.md deleted file mode 100644 index a0a894a68e..0000000000 --- a/app/sdks/node/docs/examples/projects/list-keys.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.listKeys('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/list-platforms.md b/app/sdks/node/docs/examples/projects/list-platforms.md deleted file mode 100644 index bb7f1370cb..0000000000 --- a/app/sdks/node/docs/examples/projects/list-platforms.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.listPlatforms('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/list-projects.md b/app/sdks/node/docs/examples/projects/list-projects.md deleted file mode 100644 index e4651ef686..0000000000 --- a/app/sdks/node/docs/examples/projects/list-projects.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.listProjects(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/list-tasks.md b/app/sdks/node/docs/examples/projects/list-tasks.md deleted file mode 100644 index 98e381116f..0000000000 --- a/app/sdks/node/docs/examples/projects/list-tasks.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.listTasks('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/list-webhooks.md b/app/sdks/node/docs/examples/projects/list-webhooks.md deleted file mode 100644 index 35da55721b..0000000000 --- a/app/sdks/node/docs/examples/projects/list-webhooks.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.listWebhooks('[PROJECT_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/update-key.md b/app/sdks/node/docs/examples/projects/update-key.md deleted file mode 100644 index cd445aef25..0000000000 --- a/app/sdks/node/docs/examples/projects/update-key.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.updateKey('[PROJECT_ID]', '[KEY_ID]', '[NAME]', []); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/update-platform.md b/app/sdks/node/docs/examples/projects/update-platform.md deleted file mode 100644 index 6adcad9ed9..0000000000 --- a/app/sdks/node/docs/examples/projects/update-platform.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.updatePlatform('[PROJECT_ID]', '[PLATFORM_ID]', '[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/update-project-o-auth.md b/app/sdks/node/docs/examples/projects/update-project-o-auth.md deleted file mode 100644 index 229f7e9c3b..0000000000 --- a/app/sdks/node/docs/examples/projects/update-project-o-auth.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.updateProjectOAuth('[PROJECT_ID]', 'bitbucket'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/update-project.md b/app/sdks/node/docs/examples/projects/update-project.md deleted file mode 100644 index 486cef2a4d..0000000000 --- a/app/sdks/node/docs/examples/projects/update-project.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.updateProject('[PROJECT_ID]', '[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/update-task.md b/app/sdks/node/docs/examples/projects/update-task.md deleted file mode 100644 index 06f0dd21e4..0000000000 --- a/app/sdks/node/docs/examples/projects/update-task.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/projects/update-webhook.md b/app/sdks/node/docs/examples/projects/update-webhook.md deleted file mode 100644 index 4a74848fca..0000000000 --- a/app/sdks/node/docs/examples/projects/update-webhook.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let projects = new sdk.Projects(client); - -client - .setProject('') - .setKey('') -; - -let promise = projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 0); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/teams/delete-team.md b/app/sdks/node/docs/examples/teams/delete-team.md deleted file mode 100644 index 0204d40c98..0000000000 --- a/app/sdks/node/docs/examples/teams/delete-team.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let teams = new sdk.Teams(client); - -client - .setProject('') - .setKey('') -; - -let promise = teams.deleteTeam('[TEAM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/teams/get-team-members.md b/app/sdks/node/docs/examples/teams/get-team-members.md deleted file mode 100644 index 35fd3062fe..0000000000 --- a/app/sdks/node/docs/examples/teams/get-team-members.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let teams = new sdk.Teams(client); - -client - .setProject('') - .setKey('') -; - -let promise = teams.getTeamMembers('[TEAM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/teams/get-team.md b/app/sdks/node/docs/examples/teams/get-team.md deleted file mode 100644 index b716b7ea01..0000000000 --- a/app/sdks/node/docs/examples/teams/get-team.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let teams = new sdk.Teams(client); - -client - .setProject('') - .setKey('') -; - -let promise = teams.getTeam('[TEAM_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/teams/list-teams.md b/app/sdks/node/docs/examples/teams/list-teams.md deleted file mode 100644 index 609c708753..0000000000 --- a/app/sdks/node/docs/examples/teams/list-teams.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let teams = new sdk.Teams(client); - -client - .setProject('') - .setKey('') -; - -let promise = teams.listTeams(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/teams/update-team-membership-status.md b/app/sdks/node/docs/examples/teams/update-team-membership-status.md deleted file mode 100644 index 8d65bf33b0..0000000000 --- a/app/sdks/node/docs/examples/teams/update-team-membership-status.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let teams = new sdk.Teams(client); - -client - .setProject('') - .setKey('') -; - -let promise = teams.updateTeamMembershipStatus('[TEAM_ID]', '[INVITE_ID]', '[USER_ID]', '[SECRET]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/teams/update-team.md b/app/sdks/node/docs/examples/teams/update-team.md deleted file mode 100644 index 6afb377091..0000000000 --- a/app/sdks/node/docs/examples/teams/update-team.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let teams = new sdk.Teams(client); - -client - .setProject('') - .setKey('') -; - -let promise = teams.updateTeam('[TEAM_ID]', '[NAME]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/users/get-user-logs.md b/app/sdks/node/docs/examples/users/get-user-logs.md deleted file mode 100644 index 85d0a125a0..0000000000 --- a/app/sdks/node/docs/examples/users/get-user-logs.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let users = new sdk.Users(client); - -client - .setProject('') - .setKey('') -; - -let promise = users.getUserLogs('[USER_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/users/get-user-prefs.md b/app/sdks/node/docs/examples/users/get-user-prefs.md deleted file mode 100644 index 46d959e1cb..0000000000 --- a/app/sdks/node/docs/examples/users/get-user-prefs.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let users = new sdk.Users(client); - -client - .setProject('') - .setKey('') -; - -let promise = users.getUserPrefs('[USER_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/users/get-user-sessions.md b/app/sdks/node/docs/examples/users/get-user-sessions.md deleted file mode 100644 index b3dfe28405..0000000000 --- a/app/sdks/node/docs/examples/users/get-user-sessions.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let users = new sdk.Users(client); - -client - .setProject('') - .setKey('') -; - -let promise = users.getUserSessions('[USER_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/users/get-user.md b/app/sdks/node/docs/examples/users/get-user.md deleted file mode 100644 index 96676c0196..0000000000 --- a/app/sdks/node/docs/examples/users/get-user.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let users = new sdk.Users(client); - -client - .setProject('') - .setKey('') -; - -let promise = users.getUser('[USER_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/users/list-users.md b/app/sdks/node/docs/examples/users/list-users.md deleted file mode 100644 index 455e42db4d..0000000000 --- a/app/sdks/node/docs/examples/users/list-users.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let users = new sdk.Users(client); - -client - .setProject('') - .setKey('') -; - -let promise = users.listUsers(); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/users/update-user-prefs.md b/app/sdks/node/docs/examples/users/update-user-prefs.md deleted file mode 100644 index beacba0b0a..0000000000 --- a/app/sdks/node/docs/examples/users/update-user-prefs.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let users = new sdk.Users(client); - -client - .setProject('') - .setKey('') -; - -let promise = users.updateUserPrefs('[USER_ID]', '{}'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/users/update-user-status.md b/app/sdks/node/docs/examples/users/update-user-status.md deleted file mode 100644 index 858833a50c..0000000000 --- a/app/sdks/node/docs/examples/users/update-user-status.md +++ /dev/null @@ -1,19 +0,0 @@ -const sdk = require('node-appwrite'); - -// Init SDK -let client = new sdk.Client(); - -let users = new sdk.Users(client); - -client - .setProject('') - .setKey('') -; - -let promise = users.updateUserStatus('[USER_ID]', '1'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/node/lib/services/account.js b/app/sdks/node/lib/services/account.js deleted file mode 100644 index 327c1c80fd..0000000000 --- a/app/sdks/node/lib/services/account.js +++ /dev/null @@ -1,191 +0,0 @@ -const Service = require('../service.js'); - -class Account extends Service { - - /** - * Get Account - * - * Get currently logged in user data as JSON object. - * - * @throws Exception - * @return {} - */ - async get() { - let path = '/account'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @throws Exception - * @return {} - */ - async delete() { - let path = '/account'; - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Account Email - * - * Update currently logged in user account email address. After changing user - * address, user confirmation status is being reset and a new confirmation - * mail is sent. For security measures, user password is required to complete - * this request. - * - * @param string email - * @param string password - * @throws Exception - * @return {} - */ - async updateEmail(email, password) { - let path = '/account/email'; - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'email': email, - 'password': password - }); - } - - /** - * Update Account Name - * - * Update currently logged in user account name. - * - * @param string name - * @throws Exception - * @return {} - */ - async updateName(name) { - let path = '/account/name'; - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'name': name - }); - } - - /** - * Update Account Password - * - * Update currently logged in user password. For validation, user is required - * to pass the password twice. - * - * @param string password - * @param string oldPassword - * @throws Exception - * @return {} - */ - async updatePassword(password, oldPassword) { - let path = '/account/password'; - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'password': password, - 'old-password': oldPassword - }); - } - - /** - * Get Account Preferences - * - * Get currently logged in user preferences key-value object. - * - * @throws Exception - * @return {} - */ - async getPrefs() { - let path = '/account/prefs'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Account Prefs - * - * Update currently logged in user account preferences. You can pass only the - * specific settings you wish to update. - * - * @param string prefs - * @throws Exception - * @return {} - */ - async updatePrefs(prefs) { - let path = '/account/prefs'; - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'prefs': prefs - }); - } - - /** - * Get Account Security Log - * - * Get currently logged in user list of latest security activity logs. Each - * log returns user IP address, location and date and time of log. - * - * @throws Exception - * @return {} - */ - async getSecurity() { - let path = '/account/security'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Account Active Sessions - * - * Get currently logged in user list of active sessions across different - * devices. - * - * @throws Exception - * @return {} - */ - async getSessions() { - let path = '/account/sessions'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } -} - -module.exports = Account; \ No newline at end of file diff --git a/app/sdks/node/lib/services/auth.js b/app/sdks/node/lib/services/auth.js deleted file mode 100644 index c88bb9bdf5..0000000000 --- a/app/sdks/node/lib/services/auth.js +++ /dev/null @@ -1,274 +0,0 @@ -const Service = require('../service.js'); - -class Auth extends Service { - - /** - * Login - * - * Allow the user to login into his account by providing a valid email and - * password combination. Use the success and failure arguments to provide a - * redirect URL\'s back to your app when login is completed. - * - * Please notice that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * - * When accessing this route using Javascript from the browser, success and - * failure parameter URLs are required. Appwrite server will respond with a - * 301 redirect status code and will set the user session cookie. This - * behavior is enforced because modern browsers are limiting 3rd party cookies - * in XHR of fetch requests to protect user privacy. - * - * @param string email - * @param string password - * @param string success - * @param string failure - * @throws Exception - * @return {} - */ - async login(email, password, success = '', failure = '') { - let path = '/auth/login'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'email': email, - 'password': password, - 'success': success, - 'failure': failure - }); - } - - /** - * Login with OAuth - * - * Allow the user to login to his account using the OAuth provider of his - * choice. Each OAuth provider should be enabled from the Appwrite console - * first. Use the success and failure arguments to provide a redirect URL's - * back to your app when login is completed. - * - * @param string provider - * @param string success - * @param string failure - * @throws Exception - * @return {} - */ - async oauth(provider, success, failure) { - let path = '/auth/login/oauth/{provider}'.replace(new RegExp('{provider}', 'g'), provider); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'success': success, - 'failure': failure - }); - } - - /** - * Logout Current Session - * - * Use this endpoint to log out the currently logged in user from his account. - * When successful this endpoint will delete the user session and remove the - * session secret cookie from the user client. - * - * @throws Exception - * @return {} - */ - async logout() { - let path = '/auth/logout'; - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Logout Specific Session - * - * Use this endpoint to log out the currently logged in user from all his - * account sessions across all his different devices. When using the option id - * argument, only the session unique ID provider will be deleted. - * - * @param string id - * @throws Exception - * @return {} - */ - async logoutBySession(id) { - let path = '/auth/logout/{id}'.replace(new RegExp('{id}', 'g'), id); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Password Recovery - * - * Sends the user an email with a temporary secret token for password reset. - * When the user clicks the confirmation link he is redirected back to your - * app password reset redirect URL with a secret token and email address - * values attached to the URL query string. Use the query string params to - * submit a request to the /auth/password/reset endpoint to complete the - * process. - * - * @param string email - * @param string reset - * @throws Exception - * @return {} - */ - async recovery(email, reset) { - let path = '/auth/recovery'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'email': email, - 'reset': reset - }); - } - - /** - * Password Reset - * - * Use this endpoint to complete the user account password reset. Both the - * **userId** and **token** arguments will be passed as query parameters to - * the redirect URL you have provided when sending your request to the - * /auth/recovery endpoint. - * - * Please notice that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * - * @param string userId - * @param string token - * @param string passwordA - * @param string passwordB - * @throws Exception - * @return {} - */ - async recoveryReset(userId, token, passwordA, passwordB) { - let path = '/auth/recovery/reset'; - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'userId': userId, - 'token': token, - 'password-a': passwordA, - 'password-b': passwordB - }); - } - - /** - * Register - * - * Use this endpoint to allow a new user to register an account in your - * project. Use the success and failure URLs to redirect users back to your - * application after signup completes. - * - * If registration completes successfully user will be sent with a - * confirmation email in order to confirm he is the owner of the account email - * address. Use the confirmation parameter to redirect the user from the - * confirmation email back to your app. When the user is redirected, use the - * /auth/confirm endpoint to complete the account confirmation. - * - * Please notice that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * - * When accessing this route using Javascript from the browser, success and - * failure parameter URLs are required. Appwrite server will respond with a - * 301 redirect status code and will set the user session cookie. This - * behavior is enforced because modern browsers are limiting 3rd party cookies - * in XHR of fetch requests to protect user privacy. - * - * @param string email - * @param string password - * @param string confirm - * @param string success - * @param string failure - * @param string name - * @throws Exception - * @return {} - */ - async register(email, password, confirm, success = '', failure = '', name = '') { - let path = '/auth/register'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'email': email, - 'password': password, - 'confirm': confirm, - 'success': success, - 'failure': failure, - 'name': name - }); - } - - /** - * Confirmation - * - * Use this endpoint to complete the confirmation of the user account email - * address. Both the **userId** and **token** arguments will be passed as - * query parameters to the redirect URL you have provided when sending your - * request to the /auth/register endpoint. - * - * @param string userId - * @param string token - * @throws Exception - * @return {} - */ - async confirm(userId, token) { - let path = '/auth/register/confirm'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'userId': userId, - 'token': token - }); - } - - /** - * Resend Confirmation - * - * This endpoint allows the user to request your app to resend him his email - * confirmation message. The redirect arguments act the same way as in - * /auth/register endpoint. - * - * Please notice that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * - * @param string confirm - * @throws Exception - * @return {} - */ - async confirmResend(confirm) { - let path = '/auth/register/confirm/resend'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'confirm': confirm - }); - } -} - -module.exports = Auth; \ No newline at end of file diff --git a/app/sdks/node/lib/services/projects.js b/app/sdks/node/lib/services/projects.js deleted file mode 100644 index 58a03980a2..0000000000 --- a/app/sdks/node/lib/services/projects.js +++ /dev/null @@ -1,609 +0,0 @@ -const Service = require('../service.js'); - -class Projects extends Service { - - /** - * List Projects - * - * @throws Exception - * @return {} - */ - async listProjects() { - let path = '/projects'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Create Project - * - * @param string name - * @param string teamId - * @param string description - * @param string logo - * @param string url - * @param string legalName - * @param string legalCountry - * @param string legalState - * @param string legalCity - * @param string legalAddress - * @param string legalTaxId - * @throws Exception - * @return {} - */ - async createProject(name, teamId, description = '', logo = '', url = '', legalName = '', legalCountry = '', legalState = '', legalCity = '', legalAddress = '', legalTaxId = '') { - let path = '/projects'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'teamId': teamId, - 'description': description, - 'logo': logo, - 'url': url, - 'legalName': legalName, - 'legalCountry': legalCountry, - 'legalState': legalState, - 'legalCity': legalCity, - 'legalAddress': legalAddress, - 'legalTaxId': legalTaxId - }); - } - - /** - * Get Project - * - * @param string projectId - * @throws Exception - * @return {} - */ - async getProject(projectId) { - let path = '/projects/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Project - * - * @param string projectId - * @param string name - * @param string description - * @param string logo - * @param string url - * @param string legalName - * @param string legalCountry - * @param string legalState - * @param string legalCity - * @param string legalAddress - * @param string legalTaxId - * @throws Exception - * @return {} - */ - async updateProject(projectId, name, description = '', logo = '', url = '', legalName = '', legalCountry = '', legalState = '', legalCity = '', legalAddress = '', legalTaxId = '') { - let path = '/projects/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'description': description, - 'logo': logo, - 'url': url, - 'legalName': legalName, - 'legalCountry': legalCountry, - 'legalState': legalState, - 'legalCity': legalCity, - 'legalAddress': legalAddress, - 'legalTaxId': legalTaxId - }); - } - - /** - * Delete Project - * - * @param string projectId - * @throws Exception - * @return {} - */ - async deleteProject(projectId) { - let path = '/projects/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Keys - * - * @param string projectId - * @throws Exception - * @return {} - */ - async listKeys(projectId) { - let path = '/projects/{projectId}/keys'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Create Key - * - * @param string projectId - * @param string name - * @param array scopes - * @throws Exception - * @return {} - */ - async createKey(projectId, name, scopes) { - let path = '/projects/{projectId}/keys'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'scopes': scopes - }); - } - - /** - * Get Key - * - * @param string projectId - * @param string keyId - * @throws Exception - * @return {} - */ - async getKey(projectId, keyId) { - let path = '/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{keyId}', 'g'), keyId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Key - * - * @param string projectId - * @param string keyId - * @param string name - * @param array scopes - * @throws Exception - * @return {} - */ - async updateKey(projectId, keyId, name, scopes) { - let path = '/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{keyId}', 'g'), keyId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'scopes': scopes - }); - } - - /** - * Delete Key - * - * @param string projectId - * @param string keyId - * @throws Exception - * @return {} - */ - async deleteKey(projectId, keyId) { - let path = '/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{keyId}', 'g'), keyId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Project OAuth - * - * @param string projectId - * @param string provider - * @param string appId - * @param string secret - * @throws Exception - * @return {} - */ - async updateProjectOAuth(projectId, provider, appId = '', secret = '') { - let path = '/projects/{projectId}/oauth'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'provider': provider, - 'appId': appId, - 'secret': secret - }); - } - - /** - * List Platforms - * - * @param string projectId - * @throws Exception - * @return {} - */ - async listPlatforms(projectId) { - let path = '/projects/{projectId}/platforms'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Create Platform - * - * @param string projectId - * @param string type - * @param string name - * @param string key - * @param string store - * @param string url - * @throws Exception - * @return {} - */ - async createPlatform(projectId, type, name, key = '', store = '', url = '') { - let path = '/projects/{projectId}/platforms'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'type': type, - 'name': name, - 'key': key, - 'store': store, - 'url': url - }); - } - - /** - * Get Platform - * - * @param string projectId - * @param string platformId - * @throws Exception - * @return {} - */ - async getPlatform(projectId, platformId) { - let path = '/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{platformId}', 'g'), platformId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Platform - * - * @param string projectId - * @param string platformId - * @param string name - * @param string key - * @param string store - * @param string url - * @throws Exception - * @return {} - */ - async updatePlatform(projectId, platformId, name, key = '', store = '', url = '') { - let path = '/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{platformId}', 'g'), platformId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'key': key, - 'store': store, - 'url': url - }); - } - - /** - * Delete Platform - * - * @param string projectId - * @param string platformId - * @throws Exception - * @return {} - */ - async deletePlatform(projectId, platformId) { - let path = '/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{platformId}', 'g'), platformId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Tasks - * - * @param string projectId - * @throws Exception - * @return {} - */ - async listTasks(projectId) { - let path = '/projects/{projectId}/tasks'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Create Task - * - * @param string projectId - * @param string name - * @param string status - * @param string schedule - * @param number security - * @param string httpMethod - * @param string httpUrl - * @param array httpHeaders - * @param string httpUser - * @param string httpPass - * @throws Exception - * @return {} - */ - async createTask(projectId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = [], httpUser = '', httpPass = '') { - let path = '/projects/{projectId}/tasks'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'status': status, - 'schedule': schedule, - 'security': security, - 'httpMethod': httpMethod, - 'httpUrl': httpUrl, - 'httpHeaders': httpHeaders, - 'httpUser': httpUser, - 'httpPass': httpPass - }); - } - - /** - * Get Task - * - * @param string projectId - * @param string taskId - * @throws Exception - * @return {} - */ - async getTask(projectId, taskId) { - let path = '/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{taskId}', 'g'), taskId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Task - * - * @param string projectId - * @param string taskId - * @param string name - * @param string status - * @param string schedule - * @param number security - * @param string httpMethod - * @param string httpUrl - * @param array httpHeaders - * @param string httpUser - * @param string httpPass - * @throws Exception - * @return {} - */ - async updateTask(projectId, taskId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = [], httpUser = '', httpPass = '') { - let path = '/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{taskId}', 'g'), taskId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'status': status, - 'schedule': schedule, - 'security': security, - 'httpMethod': httpMethod, - 'httpUrl': httpUrl, - 'httpHeaders': httpHeaders, - 'httpUser': httpUser, - 'httpPass': httpPass - }); - } - - /** - * Delete Task - * - * @param string projectId - * @param string taskId - * @throws Exception - * @return {} - */ - async deleteTask(projectId, taskId) { - let path = '/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{taskId}', 'g'), taskId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Project - * - * @param string projectId - * @throws Exception - * @return {} - */ - async getProjectUsage(projectId) { - let path = '/projects/{projectId}/usage'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Webhooks - * - * @param string projectId - * @throws Exception - * @return {} - */ - async listWebhooks(projectId) { - let path = '/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Create Webhook - * - * @param string projectId - * @param string name - * @param array events - * @param string url - * @param number security - * @param string httpUser - * @param string httpPass - * @throws Exception - * @return {} - */ - async createWebhook(projectId, name, events, url, security, httpUser = '', httpPass = '') { - let path = '/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}', 'g'), projectId); - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'events': events, - 'url': url, - 'security': security, - 'httpUser': httpUser, - 'httpPass': httpPass - }); - } - - /** - * Get Webhook - * - * @param string projectId - * @param string webhookId - * @throws Exception - * @return {} - */ - async getWebhook(projectId, webhookId) { - let path = '/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{webhookId}', 'g'), webhookId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Webhook - * - * @param string projectId - * @param string webhookId - * @param string name - * @param array events - * @param string url - * @param number security - * @param string httpUser - * @param string httpPass - * @throws Exception - * @return {} - */ - async updateWebhook(projectId, webhookId, name, events, url, security, httpUser = '', httpPass = '') { - let path = '/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{webhookId}', 'g'), webhookId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'events': events, - 'url': url, - 'security': security, - 'httpUser': httpUser, - 'httpPass': httpPass - }); - } - - /** - * Delete Webhook - * - * @param string projectId - * @param string webhookId - * @throws Exception - * @return {} - */ - async deleteWebhook(projectId, webhookId) { - let path = '/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{webhookId}', 'g'), webhookId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } -} - -module.exports = Projects; \ No newline at end of file diff --git a/app/sdks/node/LICENSE b/app/sdks/nodejs/LICENSE similarity index 100% rename from app/sdks/node/LICENSE rename to app/sdks/nodejs/LICENSE diff --git a/app/sdks/node/README.md b/app/sdks/nodejs/README.md similarity index 80% rename from app/sdks/node/README.md rename to app/sdks/nodejs/README.md index 51a4ba0454..3e0b06818b 100644 --- a/app/sdks/node/README.md +++ b/app/sdks/nodejs/README.md @@ -1,9 +1,7 @@ # Appwrite SDK for NodeJS ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1) - -**This SDK is compatible with Appwrite server version 0.4.0. For older versions, please check previous releases.** +![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1) Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/node/docs/examples/avatars/get-browser.md b/app/sdks/nodejs/docs/examples/avatars/get-browser.md similarity index 69% rename from app/sdks/node/docs/examples/avatars/get-browser.md rename to app/sdks/nodejs/docs/examples/avatars/get-browser.md index 50d3fefcf1..662526f015 100644 --- a/app/sdks/node/docs/examples/avatars/get-browser.md +++ b/app/sdks/nodejs/docs/examples/avatars/get-browser.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let avatars = new sdk.Avatars(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = avatars.getBrowser('aa'); diff --git a/app/sdks/node/docs/examples/avatars/get-credit-card.md b/app/sdks/nodejs/docs/examples/avatars/get-credit-card.md similarity index 70% rename from app/sdks/node/docs/examples/avatars/get-credit-card.md rename to app/sdks/nodejs/docs/examples/avatars/get-credit-card.md index f64488cc12..98165f3d3e 100644 --- a/app/sdks/node/docs/examples/avatars/get-credit-card.md +++ b/app/sdks/nodejs/docs/examples/avatars/get-credit-card.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let avatars = new sdk.Avatars(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = avatars.getCreditCard('amex'); diff --git a/app/sdks/node/docs/examples/avatars/get-favicon.md b/app/sdks/nodejs/docs/examples/avatars/get-favicon.md similarity index 70% rename from app/sdks/node/docs/examples/avatars/get-favicon.md rename to app/sdks/nodejs/docs/examples/avatars/get-favicon.md index ac449e9f1a..2b0c9c60f7 100644 --- a/app/sdks/node/docs/examples/avatars/get-favicon.md +++ b/app/sdks/nodejs/docs/examples/avatars/get-favicon.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let avatars = new sdk.Avatars(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = avatars.getFavicon('https://example.com'); diff --git a/app/sdks/node/docs/examples/avatars/get-flag.md b/app/sdks/nodejs/docs/examples/avatars/get-flag.md similarity index 69% rename from app/sdks/node/docs/examples/avatars/get-flag.md rename to app/sdks/nodejs/docs/examples/avatars/get-flag.md index d53f2aa555..79d6869b4c 100644 --- a/app/sdks/node/docs/examples/avatars/get-flag.md +++ b/app/sdks/nodejs/docs/examples/avatars/get-flag.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let avatars = new sdk.Avatars(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = avatars.getFlag('af'); diff --git a/app/sdks/node/docs/examples/avatars/get-image.md b/app/sdks/nodejs/docs/examples/avatars/get-image.md similarity index 70% rename from app/sdks/node/docs/examples/avatars/get-image.md rename to app/sdks/nodejs/docs/examples/avatars/get-image.md index e541b90e61..6652964694 100644 --- a/app/sdks/node/docs/examples/avatars/get-image.md +++ b/app/sdks/nodejs/docs/examples/avatars/get-image.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let avatars = new sdk.Avatars(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = avatars.getImage('https://example.com'); diff --git a/app/sdks/node/docs/examples/avatars/get-q-r.md b/app/sdks/nodejs/docs/examples/avatars/get-q-r.md similarity index 69% rename from app/sdks/node/docs/examples/avatars/get-q-r.md rename to app/sdks/nodejs/docs/examples/avatars/get-q-r.md index 9611a617ef..d827ee2179 100644 --- a/app/sdks/node/docs/examples/avatars/get-q-r.md +++ b/app/sdks/nodejs/docs/examples/avatars/get-q-r.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let avatars = new sdk.Avatars(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = avatars.getQR('[TEXT]'); diff --git a/app/sdks/node/docs/examples/database/create-collection.md b/app/sdks/nodejs/docs/examples/database/create-collection.md similarity index 71% rename from app/sdks/node/docs/examples/database/create-collection.md rename to app/sdks/nodejs/docs/examples/database/create-collection.md index c7ea8d43e1..3e0f8b4270 100644 --- a/app/sdks/node/docs/examples/database/create-collection.md +++ b/app/sdks/nodejs/docs/examples/database/create-collection.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = database.createCollection('[NAME]', [], [], []); diff --git a/app/sdks/node/docs/examples/database/create-document.md b/app/sdks/nodejs/docs/examples/database/create-document.md similarity index 56% rename from app/sdks/node/docs/examples/database/create-document.md rename to app/sdks/nodejs/docs/examples/database/create-document.md index 9a15f133d5..9375820357 100644 --- a/app/sdks/node/docs/examples/database/create-document.md +++ b/app/sdks/nodejs/docs/examples/database/create-document.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = database.createDocument('[COLLECTION_ID]', '{}', [], []); +let promise = database.createDocument('[COLLECTION_ID]', {}, [], []); promise.then(function (response) { console.log(response); diff --git a/app/sdks/node/docs/examples/database/delete-collection.md b/app/sdks/nodejs/docs/examples/database/delete-collection.md similarity index 71% rename from app/sdks/node/docs/examples/database/delete-collection.md rename to app/sdks/nodejs/docs/examples/database/delete-collection.md index 7be40b41bf..f8c0bf99f8 100644 --- a/app/sdks/node/docs/examples/database/delete-collection.md +++ b/app/sdks/nodejs/docs/examples/database/delete-collection.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = database.deleteCollection('[COLLECTION_ID]'); diff --git a/app/sdks/node/docs/examples/database/delete-document.md b/app/sdks/nodejs/docs/examples/database/delete-document.md similarity index 72% rename from app/sdks/node/docs/examples/database/delete-document.md rename to app/sdks/nodejs/docs/examples/database/delete-document.md index d74f2dd16c..d0faf7a519 100644 --- a/app/sdks/node/docs/examples/database/delete-document.md +++ b/app/sdks/nodejs/docs/examples/database/delete-document.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = database.deleteDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); diff --git a/app/sdks/node/docs/examples/database/get-collection.md b/app/sdks/nodejs/docs/examples/database/get-collection.md similarity index 71% rename from app/sdks/node/docs/examples/database/get-collection.md rename to app/sdks/nodejs/docs/examples/database/get-collection.md index 69a39382bf..e789936066 100644 --- a/app/sdks/node/docs/examples/database/get-collection.md +++ b/app/sdks/nodejs/docs/examples/database/get-collection.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = database.getCollection('[COLLECTION_ID]'); diff --git a/app/sdks/node/docs/examples/database/get-document.md b/app/sdks/nodejs/docs/examples/database/get-document.md similarity index 72% rename from app/sdks/node/docs/examples/database/get-document.md rename to app/sdks/nodejs/docs/examples/database/get-document.md index 5a676580bd..1f19c6d4e4 100644 --- a/app/sdks/node/docs/examples/database/get-document.md +++ b/app/sdks/nodejs/docs/examples/database/get-document.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = database.getDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); diff --git a/app/sdks/node/docs/examples/database/list-collections.md b/app/sdks/nodejs/docs/examples/database/list-collections.md similarity index 69% rename from app/sdks/node/docs/examples/database/list-collections.md rename to app/sdks/nodejs/docs/examples/database/list-collections.md index 2f746de896..787201b8c8 100644 --- a/app/sdks/node/docs/examples/database/list-collections.md +++ b/app/sdks/nodejs/docs/examples/database/list-collections.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = database.listCollections(); diff --git a/app/sdks/node/docs/examples/database/list-documents.md b/app/sdks/nodejs/docs/examples/database/list-documents.md similarity index 71% rename from app/sdks/node/docs/examples/database/list-documents.md rename to app/sdks/nodejs/docs/examples/database/list-documents.md index 641a572420..a5f68f9adf 100644 --- a/app/sdks/node/docs/examples/database/list-documents.md +++ b/app/sdks/nodejs/docs/examples/database/list-documents.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = database.listDocuments('[COLLECTION_ID]'); diff --git a/app/sdks/node/docs/examples/database/update-collection.md b/app/sdks/nodejs/docs/examples/database/update-collection.md similarity index 72% rename from app/sdks/node/docs/examples/database/update-collection.md rename to app/sdks/nodejs/docs/examples/database/update-collection.md index d393606e8f..03c5276066 100644 --- a/app/sdks/node/docs/examples/database/update-collection.md +++ b/app/sdks/nodejs/docs/examples/database/update-collection.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = database.updateCollection('[COLLECTION_ID]', '[NAME]', [], []); diff --git a/app/sdks/node/docs/examples/database/update-document.md b/app/sdks/nodejs/docs/examples/database/update-document.md similarity index 67% rename from app/sdks/node/docs/examples/database/update-document.md rename to app/sdks/nodejs/docs/examples/database/update-document.md index b281187da4..aa595eb5d4 100644 --- a/app/sdks/node/docs/examples/database/update-document.md +++ b/app/sdks/nodejs/docs/examples/database/update-document.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let database = new sdk.Database(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', '{}', [], []); +let promise = database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {}, [], []); promise.then(function (response) { console.log(response); diff --git a/app/sdks/node/docs/examples/locale/get-continents.md b/app/sdks/nodejs/docs/examples/locale/get-continents.md similarity index 69% rename from app/sdks/node/docs/examples/locale/get-continents.md rename to app/sdks/nodejs/docs/examples/locale/get-continents.md index 3c2143cf06..437672de14 100644 --- a/app/sdks/node/docs/examples/locale/get-continents.md +++ b/app/sdks/nodejs/docs/examples/locale/get-continents.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let locale = new sdk.Locale(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = locale.getContinents(); diff --git a/app/sdks/node/docs/examples/locale/get-countries-e-u.md b/app/sdks/nodejs/docs/examples/locale/get-countries-e-u.md similarity index 69% rename from app/sdks/node/docs/examples/locale/get-countries-e-u.md rename to app/sdks/nodejs/docs/examples/locale/get-countries-e-u.md index 3aabf5713b..023f079bee 100644 --- a/app/sdks/node/docs/examples/locale/get-countries-e-u.md +++ b/app/sdks/nodejs/docs/examples/locale/get-countries-e-u.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let locale = new sdk.Locale(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = locale.getCountriesEU(); diff --git a/app/sdks/node/docs/examples/locale/get-countries-phones.md b/app/sdks/nodejs/docs/examples/locale/get-countries-phones.md similarity index 69% rename from app/sdks/node/docs/examples/locale/get-countries-phones.md rename to app/sdks/nodejs/docs/examples/locale/get-countries-phones.md index 79cc6f5b6b..9ecf5289dc 100644 --- a/app/sdks/node/docs/examples/locale/get-countries-phones.md +++ b/app/sdks/nodejs/docs/examples/locale/get-countries-phones.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let locale = new sdk.Locale(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = locale.getCountriesPhones(); diff --git a/app/sdks/node/docs/examples/locale/get-countries.md b/app/sdks/nodejs/docs/examples/locale/get-countries.md similarity index 69% rename from app/sdks/node/docs/examples/locale/get-countries.md rename to app/sdks/nodejs/docs/examples/locale/get-countries.md index a4e878bc6a..54acdfd12f 100644 --- a/app/sdks/node/docs/examples/locale/get-countries.md +++ b/app/sdks/nodejs/docs/examples/locale/get-countries.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let locale = new sdk.Locale(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = locale.getCountries(); diff --git a/app/sdks/node/docs/examples/locale/get-currencies.md b/app/sdks/nodejs/docs/examples/locale/get-currencies.md similarity index 69% rename from app/sdks/node/docs/examples/locale/get-currencies.md rename to app/sdks/nodejs/docs/examples/locale/get-currencies.md index 59d8137dee..b947708adb 100644 --- a/app/sdks/node/docs/examples/locale/get-currencies.md +++ b/app/sdks/nodejs/docs/examples/locale/get-currencies.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let locale = new sdk.Locale(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = locale.getCurrencies(); diff --git a/app/sdks/nodejs/docs/examples/locale/get.md b/app/sdks/nodejs/docs/examples/locale/get.md new file mode 100644 index 0000000000..293612f9d4 --- /dev/null +++ b/app/sdks/nodejs/docs/examples/locale/get.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let locale = new sdk.Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = locale.get(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/storage/create-file.md b/app/sdks/nodejs/docs/examples/storage/create-file.md similarity index 50% rename from app/sdks/node/docs/examples/storage/create-file.md rename to app/sdks/nodejs/docs/examples/storage/create-file.md index f0c9d4c5a8..9a24cac516 100644 --- a/app/sdks/node/docs/examples/storage/create-file.md +++ b/app/sdks/nodejs/docs/examples/storage/create-file.md @@ -1,4 +1,5 @@ const sdk = require('node-appwrite'); +const fs = require('fs'); // Init SDK let client = new sdk.Client(); @@ -6,11 +7,11 @@ let client = new sdk.Client(); let storage = new sdk.Storage(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = storage.createFile(document.getElementById('uploader').files[0], [], []); +let promise = storage.createFile(fs.createReadStream(__dirname + '/file.png')), [], []); promise.then(function (response) { console.log(response); diff --git a/app/sdks/node/docs/examples/storage/delete-file.md b/app/sdks/nodejs/docs/examples/storage/delete-file.md similarity index 70% rename from app/sdks/node/docs/examples/storage/delete-file.md rename to app/sdks/nodejs/docs/examples/storage/delete-file.md index 9e8d13880f..7c7e22f335 100644 --- a/app/sdks/node/docs/examples/storage/delete-file.md +++ b/app/sdks/nodejs/docs/examples/storage/delete-file.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let storage = new sdk.Storage(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = storage.deleteFile('[FILE_ID]'); diff --git a/app/sdks/node/docs/examples/storage/get-file-download.md b/app/sdks/nodejs/docs/examples/storage/get-file-download.md similarity index 70% rename from app/sdks/node/docs/examples/storage/get-file-download.md rename to app/sdks/nodejs/docs/examples/storage/get-file-download.md index 2967170695..63a8da4e3f 100644 --- a/app/sdks/node/docs/examples/storage/get-file-download.md +++ b/app/sdks/nodejs/docs/examples/storage/get-file-download.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let storage = new sdk.Storage(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = storage.getFileDownload('[FILE_ID]'); diff --git a/app/sdks/node/docs/examples/storage/get-file-preview.md b/app/sdks/nodejs/docs/examples/storage/get-file-preview.md similarity index 70% rename from app/sdks/node/docs/examples/storage/get-file-preview.md rename to app/sdks/nodejs/docs/examples/storage/get-file-preview.md index 0c09e8ca8d..c4339db0c2 100644 --- a/app/sdks/node/docs/examples/storage/get-file-preview.md +++ b/app/sdks/nodejs/docs/examples/storage/get-file-preview.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let storage = new sdk.Storage(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = storage.getFilePreview('[FILE_ID]'); diff --git a/app/sdks/node/docs/examples/storage/get-file-view.md b/app/sdks/nodejs/docs/examples/storage/get-file-view.md similarity index 70% rename from app/sdks/node/docs/examples/storage/get-file-view.md rename to app/sdks/nodejs/docs/examples/storage/get-file-view.md index a3074fbed1..3fa784e548 100644 --- a/app/sdks/node/docs/examples/storage/get-file-view.md +++ b/app/sdks/nodejs/docs/examples/storage/get-file-view.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let storage = new sdk.Storage(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = storage.getFileView('[FILE_ID]'); diff --git a/app/sdks/node/docs/examples/storage/get-file.md b/app/sdks/nodejs/docs/examples/storage/get-file.md similarity index 69% rename from app/sdks/node/docs/examples/storage/get-file.md rename to app/sdks/nodejs/docs/examples/storage/get-file.md index a1a3baf009..91cce65d90 100644 --- a/app/sdks/node/docs/examples/storage/get-file.md +++ b/app/sdks/nodejs/docs/examples/storage/get-file.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let storage = new sdk.Storage(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = storage.getFile('[FILE_ID]'); diff --git a/app/sdks/node/docs/examples/storage/list-files.md b/app/sdks/nodejs/docs/examples/storage/list-files.md similarity index 69% rename from app/sdks/node/docs/examples/storage/list-files.md rename to app/sdks/nodejs/docs/examples/storage/list-files.md index 59a331a2b5..349433700c 100644 --- a/app/sdks/node/docs/examples/storage/list-files.md +++ b/app/sdks/nodejs/docs/examples/storage/list-files.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let storage = new sdk.Storage(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = storage.listFiles(); diff --git a/app/sdks/node/docs/examples/storage/update-file.md b/app/sdks/nodejs/docs/examples/storage/update-file.md similarity index 70% rename from app/sdks/node/docs/examples/storage/update-file.md rename to app/sdks/nodejs/docs/examples/storage/update-file.md index 3741785996..a424a8e576 100644 --- a/app/sdks/node/docs/examples/storage/update-file.md +++ b/app/sdks/nodejs/docs/examples/storage/update-file.md @@ -6,8 +6,8 @@ let client = new sdk.Client(); let storage = new sdk.Storage(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = storage.updateFile('[FILE_ID]', [], []); diff --git a/app/sdks/nodejs/docs/examples/teams/create-membership.md b/app/sdks/nodejs/docs/examples/teams/create-membership.md new file mode 100644 index 0000000000..03d569beee --- /dev/null +++ b/app/sdks/nodejs/docs/examples/teams/create-membership.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.createMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/teams/create-team-membership.md b/app/sdks/nodejs/docs/examples/teams/create.md similarity index 59% rename from app/sdks/node/docs/examples/teams/create-team-membership.md rename to app/sdks/nodejs/docs/examples/teams/create.md index 7a2c9be298..2a581f6bf4 100644 --- a/app/sdks/node/docs/examples/teams/create-team-membership.md +++ b/app/sdks/nodejs/docs/examples/teams/create.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let teams = new sdk.Teams(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = teams.createTeamMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com'); +let promise = teams.create('[NAME]'); promise.then(function (response) { console.log(response); diff --git a/app/sdks/nodejs/docs/examples/teams/delete-membership.md b/app/sdks/nodejs/docs/examples/teams/delete-membership.md new file mode 100644 index 0000000000..d6c1807e19 --- /dev/null +++ b/app/sdks/nodejs/docs/examples/teams/delete-membership.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.deleteMembership('[TEAM_ID]', '[INVITE_ID]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/teams/create-team.md b/app/sdks/nodejs/docs/examples/teams/delete.md similarity index 59% rename from app/sdks/node/docs/examples/teams/create-team.md rename to app/sdks/nodejs/docs/examples/teams/delete.md index 73dd77ecc5..9801610fc4 100644 --- a/app/sdks/node/docs/examples/teams/create-team.md +++ b/app/sdks/nodejs/docs/examples/teams/delete.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let teams = new sdk.Teams(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = teams.createTeam('[NAME]'); +let promise = teams.delete('[TEAM_ID]'); promise.then(function (response) { console.log(response); diff --git a/app/sdks/nodejs/docs/examples/teams/get-memberships.md b/app/sdks/nodejs/docs/examples/teams/get-memberships.md new file mode 100644 index 0000000000..9e3690ffdd --- /dev/null +++ b/app/sdks/nodejs/docs/examples/teams/get-memberships.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.getMemberships('[TEAM_ID]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/teams/delete-team-membership.md b/app/sdks/nodejs/docs/examples/teams/get.md similarity index 59% rename from app/sdks/node/docs/examples/teams/delete-team-membership.md rename to app/sdks/nodejs/docs/examples/teams/get.md index 435a65026f..5d14c3163d 100644 --- a/app/sdks/node/docs/examples/teams/delete-team-membership.md +++ b/app/sdks/nodejs/docs/examples/teams/get.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let teams = new sdk.Teams(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = teams.deleteTeamMembership('[TEAM_ID]', '[INVITE_ID]'); +let promise = teams.get('[TEAM_ID]'); promise.then(function (response) { console.log(response); diff --git a/app/sdks/node/docs/examples/teams/create-team-membership-resend.md b/app/sdks/nodejs/docs/examples/teams/list.md similarity index 61% rename from app/sdks/node/docs/examples/teams/create-team-membership-resend.md rename to app/sdks/nodejs/docs/examples/teams/list.md index 1f387d0b3b..237925fee2 100644 --- a/app/sdks/node/docs/examples/teams/create-team-membership-resend.md +++ b/app/sdks/nodejs/docs/examples/teams/list.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let teams = new sdk.Teams(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = teams.createTeamMembershipResend('[TEAM_ID]', '[INVITE_ID]', 'https://example.com'); +let promise = teams.list(); promise.then(function (response) { console.log(response); diff --git a/app/sdks/nodejs/docs/examples/teams/update.md b/app/sdks/nodejs/docs/examples/teams/update.md new file mode 100644 index 0000000000..6f5bd1b51b --- /dev/null +++ b/app/sdks/nodejs/docs/examples/teams/update.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.update('[TEAM_ID]', '[NAME]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/nodejs/docs/examples/users/create.md b/app/sdks/nodejs/docs/examples/users/create.md new file mode 100644 index 0000000000..692e221008 --- /dev/null +++ b/app/sdks/nodejs/docs/examples/users/create.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.create('email@example.com', 'password'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/nodejs/docs/examples/users/delete-session.md b/app/sdks/nodejs/docs/examples/users/delete-session.md new file mode 100644 index 0000000000..9715f20bd1 --- /dev/null +++ b/app/sdks/nodejs/docs/examples/users/delete-session.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.deleteSession('[USER_ID]', '[SESSION_ID]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/nodejs/docs/examples/users/delete-sessions.md b/app/sdks/nodejs/docs/examples/users/delete-sessions.md new file mode 100644 index 0000000000..3c25045433 --- /dev/null +++ b/app/sdks/nodejs/docs/examples/users/delete-sessions.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.deleteSessions('[USER_ID]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/users/delete-user-session.md b/app/sdks/nodejs/docs/examples/users/get-logs.md similarity index 59% rename from app/sdks/node/docs/examples/users/delete-user-session.md rename to app/sdks/nodejs/docs/examples/users/get-logs.md index dab704e2d4..70ba499a97 100644 --- a/app/sdks/node/docs/examples/users/delete-user-session.md +++ b/app/sdks/nodejs/docs/examples/users/get-logs.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let users = new sdk.Users(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = users.deleteUserSession('[USER_ID]', '[SESSION_ID]'); +let promise = users.getLogs('[USER_ID]'); promise.then(function (response) { console.log(response); diff --git a/app/sdks/node/docs/examples/users/delete-user-sessions.md b/app/sdks/nodejs/docs/examples/users/get-prefs.md similarity index 59% rename from app/sdks/node/docs/examples/users/delete-user-sessions.md rename to app/sdks/nodejs/docs/examples/users/get-prefs.md index 33f803298d..4824700394 100644 --- a/app/sdks/node/docs/examples/users/delete-user-sessions.md +++ b/app/sdks/nodejs/docs/examples/users/get-prefs.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let users = new sdk.Users(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = users.deleteUserSessions('[USER_ID]'); +let promise = users.getPrefs('[USER_ID]'); promise.then(function (response) { console.log(response); diff --git a/app/sdks/nodejs/docs/examples/users/get-sessions.md b/app/sdks/nodejs/docs/examples/users/get-sessions.md new file mode 100644 index 0000000000..cf14125b43 --- /dev/null +++ b/app/sdks/nodejs/docs/examples/users/get-sessions.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.getSessions('[USER_ID]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/node/docs/examples/users/delete-users-session.md b/app/sdks/nodejs/docs/examples/users/get.md similarity index 59% rename from app/sdks/node/docs/examples/users/delete-users-session.md rename to app/sdks/nodejs/docs/examples/users/get.md index 530503da4b..1f69cfcf9e 100644 --- a/app/sdks/node/docs/examples/users/delete-users-session.md +++ b/app/sdks/nodejs/docs/examples/users/get.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let users = new sdk.Users(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = users.deleteUsersSession('[USER_ID]', '[SESSION_ID]'); +let promise = users.get('[USER_ID]'); promise.then(function (response) { console.log(response); diff --git a/app/sdks/node/docs/examples/users/create-user.md b/app/sdks/nodejs/docs/examples/users/list.md similarity index 61% rename from app/sdks/node/docs/examples/users/create-user.md rename to app/sdks/nodejs/docs/examples/users/list.md index d07ab1eabf..0d8c4e8b94 100644 --- a/app/sdks/node/docs/examples/users/create-user.md +++ b/app/sdks/nodejs/docs/examples/users/list.md @@ -6,11 +6,11 @@ let client = new sdk.Client(); let users = new sdk.Users(client); client - .setProject('') - .setKey('') + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = users.createUser('email@example.com', 'password'); +let promise = users.list(); promise.then(function (response) { console.log(response); diff --git a/app/sdks/nodejs/docs/examples/users/update-prefs.md b/app/sdks/nodejs/docs/examples/users/update-prefs.md new file mode 100644 index 0000000000..f06a5c0a0e --- /dev/null +++ b/app/sdks/nodejs/docs/examples/users/update-prefs.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.updatePrefs('[USER_ID]', {}); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/nodejs/docs/examples/users/update-status.md b/app/sdks/nodejs/docs/examples/users/update-status.md new file mode 100644 index 0000000000..0849c0805a --- /dev/null +++ b/app/sdks/nodejs/docs/examples/users/update-status.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.updateStatus('[USER_ID]', '1'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/node/index.js b/app/sdks/nodejs/index.js similarity index 70% rename from app/sdks/node/index.js rename to app/sdks/nodejs/index.js index f4b28948ae..d9e8b5a391 100644 --- a/app/sdks/node/index.js +++ b/app/sdks/nodejs/index.js @@ -1,22 +1,16 @@ const Client = require('./lib/client.js'); -const Account = require('./lib/services/account.js'); -const Auth = require('./lib/services/auth.js'); const Avatars = require('./lib/services/avatars.js'); const Database = require('./lib/services/database.js'); const Locale = require('./lib/services/locale.js'); -const Projects = require('./lib/services/projects.js'); const Storage = require('./lib/services/storage.js'); const Teams = require('./lib/services/teams.js'); const Users = require('./lib/services/users.js'); module.exports = { Client, - Account, - Auth, Avatars, Database, Locale, - Projects, Storage, Teams, Users, diff --git a/app/sdks/node/lib/client.js b/app/sdks/nodejs/lib/client.js similarity index 64% rename from app/sdks/node/lib/client.js rename to app/sdks/nodejs/lib/client.js index 253bf95f02..71ee27b07f 100644 --- a/app/sdks/node/lib/client.js +++ b/app/sdks/nodejs/lib/client.js @@ -15,7 +15,7 @@ class Client { /** * Set Project * - * Your Appwrite project ID + * Your project ID * * @param string value * @@ -30,7 +30,7 @@ class Client { /** * Set Key * - * Your Appwrite project secret key + * Your secret API key * * @param string value * @@ -99,23 +99,49 @@ class Client { return this; } - call(method, path = '', headers = {}, params = {}) { + async call(method, path = '', headers = {}, params = {}) { if(this.selfSigned) { // Allow self signed requests process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; } headers = Object.assign(this.headers, headers); - + + let contentType = headers['content-type'].toLowerCase(); let options = { method: method.toUpperCase(), uri: this.endpoint + path, qs: (method.toUpperCase() === 'GET') ? params : {}, headers: headers, - body: (method.toUpperCase() === 'GET') ? '' : params, - json: (headers['content-type'].toLowerCase().startsWith('application/json')), + body: (method.toUpperCase() === 'GET' || contentType.startsWith('multipart/form-data')) ? null : params, + json: (contentType.startsWith('application/json')), + formData: (contentType.startsWith('multipart/form-data')) ? this.flatten(params) : null, }; - return request(options); + let response = await request(options); + + if(contentType.startsWith('multipart/form-data')) { + response = JSON.parse(response); + } + + return response; + } + + flatten(data, prefix = '') { + let output = {}; + + for (const key in data) { + let value = data[key]; + let finalKey = prefix ? prefix + '[' + key +']' : key; + + if (Array.isArray(value)) { + output = Object.assign(output, this.flatten(value, finalKey)); // @todo: handle name collision here if needed + } + else { + output[finalKey] = value; + } + } + + return output; } } diff --git a/app/sdks/node/lib/service.js b/app/sdks/nodejs/lib/service.js similarity index 100% rename from app/sdks/node/lib/service.js rename to app/sdks/nodejs/lib/service.js diff --git a/app/sdks/node/lib/services/avatars.js b/app/sdks/nodejs/lib/services/avatars.js similarity index 100% rename from app/sdks/node/lib/services/avatars.js rename to app/sdks/nodejs/lib/services/avatars.js diff --git a/app/sdks/node/lib/services/database.js b/app/sdks/nodejs/lib/services/database.js similarity index 84% rename from app/sdks/node/lib/services/database.js rename to app/sdks/nodejs/lib/services/database.js index 4287484038..547753a4cd 100644 --- a/app/sdks/node/lib/services/database.js +++ b/app/sdks/nodejs/lib/services/database.js @@ -18,7 +18,7 @@ class Database extends Service { * @return {} */ async listCollections(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/database'; + let path = '/database/collections'; return await this.client.call('get', path, { 'content-type': 'application/json', @@ -44,7 +44,7 @@ class Database extends Service { * @return {} */ async createCollection(name, read, write, rules) { - let path = '/database'; + let path = '/database/collections'; return await this.client.call('post', path, { 'content-type': 'application/json', @@ -68,7 +68,7 @@ class Database extends Service { * @return {} */ async getCollection(collectionId) { - let path = '/database/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); + let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); return await this.client.call('get', path, { 'content-type': 'application/json', @@ -91,7 +91,7 @@ class Database extends Service { * @return {} */ async updateCollection(collectionId, name, read, write, rules = []) { - let path = '/database/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); + let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); return await this.client.call('put', path, { 'content-type': 'application/json', @@ -115,7 +115,7 @@ class Database extends Service { * @return {} */ async deleteCollection(collectionId) { - let path = '/database/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); + let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); return await this.client.call('delete', path, { 'content-type': 'application/json', @@ -146,7 +146,7 @@ class Database extends Service { * @return {} */ async listDocuments(collectionId, filters = [], offset = 0, limit = 50, orderField = '$uid', orderType = 'ASC', orderCast = 'string', search = '', first = 0, last = 0) { - let path = '/database/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); + let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); return await this.client.call('get', path, { 'content-type': 'application/json', @@ -170,7 +170,7 @@ class Database extends Service { * Create a new Document. * * @param string collectionId - * @param string data + * @param object data * @param array read * @param array write * @param string parentDocument @@ -180,7 +180,7 @@ class Database extends Service { * @return {} */ async createDocument(collectionId, data, read, write, parentDocument = '', parentProperty = '', parentPropertyType = 'assign') { - let path = '/database/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); + let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); return await this.client.call('post', path, { 'content-type': 'application/json', @@ -207,7 +207,7 @@ class Database extends Service { * @return {} */ async getDocument(collectionId, documentId) { - let path = '/database/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); return await this.client.call('get', path, { 'content-type': 'application/json', @@ -221,14 +221,14 @@ class Database extends Service { * * @param string collectionId * @param string documentId - * @param string data + * @param object data * @param array read * @param array write * @throws Exception * @return {} */ async updateDocument(collectionId, documentId, data, read, write) { - let path = '/database/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); return await this.client.call('patch', path, { 'content-type': 'application/json', @@ -253,7 +253,7 @@ class Database extends Service { * @return {} */ async deleteDocument(collectionId, documentId) { - let path = '/database/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); return await this.client.call('delete', path, { 'content-type': 'application/json', diff --git a/app/sdks/node/lib/services/locale.js b/app/sdks/nodejs/lib/services/locale.js similarity index 94% rename from app/sdks/node/lib/services/locale.js rename to app/sdks/nodejs/lib/services/locale.js index 8233259394..1a89ba7dd9 100644 --- a/app/sdks/node/lib/services/locale.js +++ b/app/sdks/nodejs/lib/services/locale.js @@ -9,11 +9,13 @@ class Locale extends Service { * country code, country name, continent name, continent code, ip address and * suggested currency. You can use the locale header to get the data in a * supported language. + * + * ([IP Geolocation by DB-IP](https://db-ip.com)) * * @throws Exception * @return {} */ - async getLocale() { + async get() { let path = '/locale'; return await this.client.call('get', path, { @@ -65,8 +67,7 @@ class Locale extends Service { * List EU Countries * * List of all countries that are currently members of the EU. You can use the - * locale header to get the data in a supported language. UK brexit date is - * currently set to 2019-10-31 and will be updated if and when needed. + * locale header to get the data in a supported language. * * @throws Exception * @return {} diff --git a/app/sdks/node/lib/services/storage.js b/app/sdks/nodejs/lib/services/storage.js similarity index 95% rename from app/sdks/node/lib/services/storage.js rename to app/sdks/nodejs/lib/services/storage.js index fb9f8632c9..7237ccfc6f 100644 --- a/app/sdks/node/lib/services/storage.js +++ b/app/sdks/nodejs/lib/services/storage.js @@ -37,20 +37,20 @@ class Storage extends Service { * assigned to read and write access unless he has passed custom values for * read and write arguments. * - * @param File files + * @param File file * @param array read * @param array write * @throws Exception * @return {} */ - async createFile(files, read, write) { + async createFile(file, read, write) { let path = '/storage/files'; return await this.client.call('post', path, { 'content-type': 'multipart/form-data', }, { - 'files': files, + 'file': file, 'read': read, 'write': write }); @@ -144,9 +144,9 @@ class Storage extends Service { /** * Get File Preview * - * Get file preview image. Currently, this method supports preview for image + * Get a file preview image. Currently, this method supports preview for image * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets will return file icon image. You can also pass query + * and spreadsheets, will return the file icon image. You can also pass query * string arguments for cutting and resizing your preview image. * * @param string fileId diff --git a/app/sdks/node/lib/services/teams.js b/app/sdks/nodejs/lib/services/teams.js similarity index 56% rename from app/sdks/node/lib/services/teams.js rename to app/sdks/nodejs/lib/services/teams.js index 9ed1def550..ed9924bbee 100644 --- a/app/sdks/node/lib/services/teams.js +++ b/app/sdks/nodejs/lib/services/teams.js @@ -16,7 +16,7 @@ class Teams extends Service { * @throws Exception * @return {} */ - async listTeams(search = '', limit = 25, offset = 0, orderType = 'ASC') { + async list(search = '', limit = 25, offset = 0, orderType = 'ASC') { let path = '/teams'; return await this.client.call('get', path, { @@ -43,7 +43,7 @@ class Teams extends Service { * @throws Exception * @return {} */ - async createTeam(name, roles = ["owner"]) { + async create(name, roles = ["owner"]) { let path = '/teams'; return await this.client.call('post', path, { @@ -65,7 +65,7 @@ class Teams extends Service { * @throws Exception * @return {} */ - async getTeam(teamId) { + async get(teamId) { let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); return await this.client.call('get', path, { @@ -86,7 +86,7 @@ class Teams extends Service { * @throws Exception * @return {} */ - async updateTeam(teamId, name) { + async update(teamId, name) { let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); return await this.client.call('put', path, { @@ -107,7 +107,7 @@ class Teams extends Service { * @throws Exception * @return {} */ - async deleteTeam(teamId) { + async delete(teamId) { let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); return await this.client.call('delete', path, { @@ -118,7 +118,7 @@ class Teams extends Service { } /** - * Get Team Members + * Get Team Memberships * * Get team members by the team unique ID. All team members have read access * for this list of resources. @@ -127,8 +127,8 @@ class Teams extends Service { * @throws Exception * @return {} */ - async getTeamMembers(teamId) { - let path = '/teams/{teamId}/members'.replace(new RegExp('{teamId}', 'g'), teamId); + async getMemberships(teamId) { + let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); return await this.client.call('get', path, { 'content-type': 'application/json', @@ -140,16 +140,16 @@ class Teams extends Service { /** * Create Team Membership * - * Use this endpoint to invite a new member to your team. An email with a link - * to join the team will be sent to the new member email address. If member - * doesn't exists in the project it will be automatically created. + * Use this endpoint to invite a new member to join your team. An email with a + * link to join the team will be sent to the new member email address if the + * member doesn't exist in the project it will be created automatically. * - * Use the redirect parameter to redirect the user from the invitation email - * back to your app. When the user is redirected, use the - * /teams/{teamId}/memberships/{inviteId}/status endpoint to finally join the - * user to the team. + * Use the 'URL' parameter to redirect the user from the invitation email back + * to your app. When the user is redirected, use the [Update Team Membership + * Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to + * accept the invitation to the team. * - * Please notice that in order to avoid a [Redirect + * Please note that in order to avoid a [Redirect * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) * the only valid redirect URL's are the once from domains you have set when * added your platforms in the console interface. @@ -157,12 +157,12 @@ class Teams extends Service { * @param string teamId * @param string email * @param array roles - * @param string redirect + * @param string url * @param string name * @throws Exception * @return {} */ - async createTeamMembership(teamId, email, roles, redirect, name = '') { + async createMembership(teamId, email, roles, url, name = '') { let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); return await this.client.call('post', path, { @@ -172,7 +172,7 @@ class Teams extends Service { 'email': email, 'name': name, 'roles': roles, - 'redirect': redirect + 'url': url }); } @@ -180,14 +180,15 @@ class Teams extends Service { * Delete Team Membership * * This endpoint allows a user to leave a team or for a team owner to delete - * the membership of any other team member. + * the membership of any other team member. You can also use this endpoint to + * delete a user membership even if he didn't accept it. * * @param string teamId * @param string inviteId * @throws Exception * @return {} */ - async deleteTeamMembership(teamId, inviteId) { + async deleteMembership(teamId, inviteId) { let path = '/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); return await this.client.call('delete', path, { @@ -196,71 +197,6 @@ class Teams extends Service { { }); } - - /** - * Create Team Membership (Resend) - * - * Use this endpoint to resend your invitation email for a user to join a - * team. - * - * @param string teamId - * @param string inviteId - * @param string redirect - * @throws Exception - * @return {} - */ - async createTeamMembershipResend(teamId, inviteId, redirect) { - let path = '/teams/{teamId}/memberships/{inviteId}/resend'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'redirect': redirect - }); - } - - /** - * Update Team Membership Status - * - * Use this endpoint to let user accept an invitation to join a team after he - * is being redirect back to your app from the invitation email. Use the - * success and failure URL's to redirect users back to your application after - * the request completes. - * - * Please notice that in order to avoid a [Redirect - * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URL's are the once from domains you have set when - * added your platforms in the console interface. - * - * When not using the success or failure redirect arguments this endpoint will - * result with a 200 status code on success and with 401 status error on - * failure. This behavior was applied to help the web clients deal with - * browsers who don't allow to set 3rd party HTTP cookies needed for saving - * the account session token. - * - * @param string teamId - * @param string inviteId - * @param string userId - * @param string secret - * @param string success - * @param string failure - * @throws Exception - * @return {} - */ - async updateTeamMembershipStatus(teamId, inviteId, userId, secret, success = '', failure = '') { - let path = '/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'userId': userId, - 'secret': secret, - 'success': success, - 'failure': failure - }); - } } module.exports = Teams; \ No newline at end of file diff --git a/app/sdks/node/lib/services/users.js b/app/sdks/nodejs/lib/services/users.js similarity index 90% rename from app/sdks/node/lib/services/users.js rename to app/sdks/nodejs/lib/services/users.js index 85da0ae9b8..abcdd4ed9f 100644 --- a/app/sdks/node/lib/services/users.js +++ b/app/sdks/nodejs/lib/services/users.js @@ -15,7 +15,7 @@ class Users extends Service { * @throws Exception * @return {} */ - async listUsers(search = '', limit = 25, offset = 0, orderType = 'ASC') { + async list(search = '', limit = 25, offset = 0, orderType = 'ASC') { let path = '/users'; return await this.client.call('get', path, { @@ -40,7 +40,7 @@ class Users extends Service { * @throws Exception * @return {} */ - async createUser(email, password, name = '') { + async create(email, password, name = '') { let path = '/users'; return await this.client.call('post', path, { @@ -62,7 +62,7 @@ class Users extends Service { * @throws Exception * @return {} */ - async getUser(userId) { + async get(userId) { let path = '/users/{userId}'.replace(new RegExp('{userId}', 'g'), userId); return await this.client.call('get', path, { @@ -81,7 +81,7 @@ class Users extends Service { * @throws Exception * @return {} */ - async getUserLogs(userId) { + async getLogs(userId) { let path = '/users/{userId}/logs'.replace(new RegExp('{userId}', 'g'), userId); return await this.client.call('get', path, { @@ -92,7 +92,7 @@ class Users extends Service { } /** - * Get User Prefs + * Get User Preferences * * Get user preferences by its unique ID. * @@ -100,7 +100,7 @@ class Users extends Service { * @throws Exception * @return {} */ - async getUserPrefs(userId) { + async getPrefs(userId) { let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); return await this.client.call('get', path, { @@ -111,17 +111,17 @@ class Users extends Service { } /** - * Update User Prefs + * Update User Preferences * * Update user preferences by its unique ID. You can pass only the specific * settings you wish to update. * * @param string userId - * @param string prefs + * @param object prefs * @throws Exception * @return {} */ - async updateUserPrefs(userId, prefs) { + async updatePrefs(userId, prefs) { let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); return await this.client.call('patch', path, { @@ -141,7 +141,7 @@ class Users extends Service { * @throws Exception * @return {} */ - async getUserSessions(userId) { + async getSessions(userId) { let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); return await this.client.call('get', path, { @@ -160,7 +160,7 @@ class Users extends Service { * @throws Exception * @return {} */ - async deleteUserSessions(userId) { + async deleteSessions(userId) { let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); return await this.client.call('delete', path, { @@ -180,7 +180,7 @@ class Users extends Service { * @throws Exception * @return {} */ - async deleteUserSession(userId, sessionId) { + async deleteSession(userId, sessionId) { let path = '/users/{userId}/sessions/:session'.replace(new RegExp('{userId}', 'g'), userId); return await this.client.call('delete', path, { @@ -201,7 +201,7 @@ class Users extends Service { * @throws Exception * @return {} */ - async updateUserStatus(userId, status) { + async updateStatus(userId, status) { let path = '/users/{userId}/status'.replace(new RegExp('{userId}', 'g'), userId); return await this.client.call('patch', path, { diff --git a/app/sdks/node/package.json b/app/sdks/nodejs/package.json similarity index 91% rename from app/sdks/node/package.json rename to app/sdks/nodejs/package.json index 88159d963a..b10f63562a 100644 --- a/app/sdks/node/package.json +++ b/app/sdks/nodejs/package.json @@ -7,7 +7,7 @@ "main": "index.js", "repository": { "type": "git", - "url": "https://github.com/appwrite/sdk-for-node.git" + "url": "https://github.com/appwrite/sdk-for-node" }, "devDependencies": {}, "dependencies": { diff --git a/app/sdks/php/README.md b/app/sdks/php/README.md index 8244a4d953..b0a8bc90bd 100644 --- a/app/sdks/php/README.md +++ b/app/sdks/php/README.md @@ -1,9 +1,7 @@ # Appwrite SDK for PHP ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1) - -**This SDK is compatible with Appwrite server version 0.4.0. For older versions, please check previous releases.** +![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1) Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/php/docs/account.md b/app/sdks/php/docs/account.md deleted file mode 100644 index 7d4455ffef..0000000000 --- a/app/sdks/php/docs/account.md +++ /dev/null @@ -1,100 +0,0 @@ -# Account Service - -## Get Account - -```http request -GET https://appwrite.io/v1/account -``` - -** Get currently logged in user data as JSON object. ** - -## Delete Account - -```http request -DELETE https://appwrite.io/v1/account -``` - -** Delete a currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. This is done to avoid deleted accounts being overtaken by new users with the same email address. Any user-related resources like documents or storage files should be deleted separately. ** - -## Update Account Email - -```http request -PATCH https://appwrite.io/v1/account/email -``` - -** Update currently logged in user account email address. After changing user address, user confirmation status is being reset and a new confirmation mail is sent. For security measures, user password is required to complete this request. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| email | string | Email Address | | -| password | string | User Password | | - -## Update Account Name - -```http request -PATCH https://appwrite.io/v1/account/name -``` - -** Update currently logged in user account name. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| name | string | User name | | - -## Update Account Password - -```http request -PATCH https://appwrite.io/v1/account/password -``` - -** Update currently logged in user password. For validation, user is required to pass the password twice. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| password | string | New password | | -| old-password | string | Old password | | - -## Get Account Preferences - -```http request -GET https://appwrite.io/v1/account/prefs -``` - -** Get currently logged in user preferences key-value object. ** - -## Update Account Prefs - -```http request -PATCH https://appwrite.io/v1/account/prefs -``` - -** Update currently logged in user account preferences. You can pass only the specific settings you wish to update. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| prefs | string | Prefs key-value JSON object string. | | - -## Get Account Security Log - -```http request -GET https://appwrite.io/v1/account/security -``` - -** Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log. ** - -## Get Account Active Sessions - -```http request -GET https://appwrite.io/v1/account/sessions -``` - -** Get currently logged in user list of active sessions across different devices. ** - diff --git a/app/sdks/php/docs/auth.md b/app/sdks/php/docs/auth.md deleted file mode 100644 index 2af37f5239..0000000000 --- a/app/sdks/php/docs/auth.md +++ /dev/null @@ -1,151 +0,0 @@ -# Auth Service - -## Login - -```http request -POST https://appwrite.io/v1/auth/login -``` - -** Allow the user to login into his account by providing a valid email and password combination. Use the success and failure arguments to provide a redirect URL\'s back to your app when login is completed. - -Please notice that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - -When accessing this route using Javascript from the browser, success and failure parameter URLs are required. Appwrite server will respond with a 301 redirect status code and will set the user session cookie. This behavior is enforced because modern browsers are limiting 3rd party cookies in XHR of fetch requests to protect user privacy. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| email | string | User account email address | | -| password | string | User account password | | -| success | string | URL to redirect back to your app after a successful login attempt. | | -| failure | string | URL to redirect back to your app after a failed login attempt. | | - -## Login with OAuth - -```http request -GET https://appwrite.io/v1/auth/login/oauth/{provider} -``` - -** Allow the user to login to his account using the OAuth provider of his choice. Each OAuth provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| provider | string | **Required** OAuth Provider. Currently, supported providers are: bitbucket, facebook, github, gitlab, google, microsoft, linkedin, slack, dropbox, amazon, vk | | -| success | string | **Required** URL to redirect back to your app after a successful login attempt. | | -| failure | string | **Required** URL to redirect back to your app after a failed login attempt. | | - -## Logout Current Session - -```http request -DELETE https://appwrite.io/v1/auth/logout -``` - -** Use this endpoint to log out the currently logged in user from his account. When successful this endpoint will delete the user session and remove the session secret cookie from the user client. ** - -## Logout Specific Session - -```http request -DELETE https://appwrite.io/v1/auth/logout/{id} -``` - -** Use this endpoint to log out the currently logged in user from all his account sessions across all his different devices. When using the option id argument, only the session unique ID provider will be deleted. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| id | string | **Required** User specific session unique ID number. if 0 delete all sessions. | | - -## Password Recovery - -```http request -POST https://appwrite.io/v1/auth/recovery -``` - -** Sends the user an email with a temporary secret token for password reset. When the user clicks the confirmation link he is redirected back to your app password reset redirect URL with a secret token and email address values attached to the URL query string. Use the query string params to submit a request to the /auth/password/reset endpoint to complete the process. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| email | string | User account email address. | | -| reset | string | Reset URL in your app to redirect the user after the reset token has been sent to the user email. | | - -## Password Reset - -```http request -PUT https://appwrite.io/v1/auth/recovery/reset -``` - -** Use this endpoint to complete the user account password reset. Both the **userId** and **token** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the /auth/recovery endpoint. - -Please notice that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | User account email address. | | -| token | string | Valid reset token. | | -| password-a | string | New password. | | -| password-b | string | New password again. | | - -## Register - -```http request -POST https://appwrite.io/v1/auth/register -``` - -** Use this endpoint to allow a new user to register an account in your project. Use the success and failure URLs to redirect users back to your application after signup completes. - -If registration completes successfully user will be sent with a confirmation email in order to confirm he is the owner of the account email address. Use the confirmation parameter to redirect the user from the confirmation email back to your app. When the user is redirected, use the /auth/confirm endpoint to complete the account confirmation. - -Please notice that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - -When accessing this route using Javascript from the browser, success and failure parameter URLs are required. Appwrite server will respond with a 301 redirect status code and will set the user session cookie. This behavior is enforced because modern browsers are limiting 3rd party cookies in XHR of fetch requests to protect user privacy. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| email | string | Account email | | -| password | string | User password | | -| confirm | string | Confirmation URL to redirect user after confirm token has been sent to user email | | -| success | string | Redirect when registration succeed | | -| failure | string | Redirect when registration failed | | -| name | string | User name | | - -## Confirmation - -```http request -POST https://appwrite.io/v1/auth/register/confirm -``` - -** Use this endpoint to complete the confirmation of the user account email address. Both the **userId** and **token** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the /auth/register endpoint. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | User unique ID | | -| token | string | Confirmation secret token | | - -## Resend Confirmation - -```http request -POST https://appwrite.io/v1/auth/register/confirm/resend -``` - -** This endpoint allows the user to request your app to resend him his email confirmation message. The redirect arguments act the same way as in /auth/register endpoint. - -Please notice that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| confirm | string | Confirmation URL to redirect user to your app after confirm token has been sent to user email. | | - diff --git a/app/sdks/php/docs/avatars.md b/app/sdks/php/docs/avatars.md index 7f5796d07a..cf506e0db1 100644 --- a/app/sdks/php/docs/avatars.md +++ b/app/sdks/php/docs/avatars.md @@ -13,9 +13,9 @@ GET https://appwrite.io/v1/avatars/browsers/{code} | Field Name | Type | Description | Default | | --- | --- | --- | --- | | code | string | **Required** Browser Code. | | -| width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100 | 100 | -| height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100 | 100 | -| quality | integer | Image quality. Pass an integer between 0 to 100. Defaults to 100 | 100 | +| width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100. | 100 | +| height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100. | 100 | +| quality | integer | Image quality. Pass an integer between 0 to 100. Defaults to 100. | 100 | ## Get Credit Card Icon @@ -30,9 +30,9 @@ GET https://appwrite.io/v1/avatars/credit-cards/{code} | Field Name | Type | Description | Default | | --- | --- | --- | --- | | code | string | **Required** Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa. | | -| width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100 | 100 | -| height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100 | 100 | -| quality | integer | Image quality. Pass an integer between 0 to 100. Defaults to 100 | 100 | +| width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100. | 100 | +| height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100. | 100 | +| quality | integer | Image quality. Pass an integer between 0 to 100. Defaults to 100. | 100 | ## Get Favicon @@ -61,9 +61,9 @@ GET https://appwrite.io/v1/avatars/flags/{code} | Field Name | Type | Description | Default | | --- | --- | --- | --- | | code | string | **Required** Country Code. ISO Alpha-2 country code format. | | -| width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100 | 100 | -| height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100 | 100 | -| quality | integer | Image quality. Pass an integer between 0 to 100. Defaults to 100 | 100 | +| width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100. | 100 | +| height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100. | 100 | +| quality | integer | Image quality. Pass an integer between 0 to 100. Defaults to 100. | 100 | ## Get Image from URL @@ -78,8 +78,8 @@ GET https://appwrite.io/v1/avatars/image | Field Name | Type | Description | Default | | --- | --- | --- | --- | | url | string | **Required** Image URL which you want to crop. | | -| width | integer | Resize preview image width, Pass an integer between 0 to 4000 | 400 | -| height | integer | Resize preview image height, Pass an integer between 0 to 4000 | 400 | +| width | integer | Resize preview image width, Pass an integer between 0 to 2000. | 400 | +| height | integer | Resize preview image height, Pass an integer between 0 to 2000. | 400 | ## Get QR Code @@ -93,7 +93,7 @@ GET https://appwrite.io/v1/avatars/qr | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| text | string | **Required** Plain text to be converted to QR code image | | +| text | string | **Required** Plain text to be converted to QR code image. | | | size | integer | QR code size. Pass an integer between 0 to 1000. Defaults to 400. | 400 | | margin | integer | Margin From Edge. Pass an integer between 0 to 10. Defaults to 1. | 1 | | download | integer | Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0. | 0 | diff --git a/app/sdks/php/docs/database.md b/app/sdks/php/docs/database.md index 86a8b20933..421a1139cb 100644 --- a/app/sdks/php/docs/database.md +++ b/app/sdks/php/docs/database.md @@ -3,7 +3,7 @@ ## List Collections ```http request -GET https://appwrite.io/v1/database +GET https://appwrite.io/v1/database/collections ``` ** Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project collections. [Learn more about different API modes](/docs/admin). ** @@ -20,7 +20,7 @@ GET https://appwrite.io/v1/database ## Create Collection ```http request -POST https://appwrite.io/v1/database +POST https://appwrite.io/v1/database/collections ``` ** Create a new Collection. ** @@ -32,12 +32,12 @@ POST https://appwrite.io/v1/database | name | string | Collection name. | | | read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | | write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| rules | array | Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation | | +| rules | array | Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation. | | ## Get Collection ```http request -GET https://appwrite.io/v1/database/{collectionId} +GET https://appwrite.io/v1/database/collections/{collectionId} ``` ** Get collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. ** @@ -51,7 +51,7 @@ GET https://appwrite.io/v1/database/{collectionId} ## Update Collection ```http request -PUT https://appwrite.io/v1/database/{collectionId} +PUT https://appwrite.io/v1/database/collections/{collectionId} ``` ** Update collection by its unique ID. ** @@ -64,12 +64,12 @@ PUT https://appwrite.io/v1/database/{collectionId} | name | string | Collection name. | | | read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions(/docs/permissions) and get a full list of available permissions. | | | write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| rules | array | Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation | [] | +| rules | array | Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation. | [] | ## Delete Collection ```http request -DELETE https://appwrite.io/v1/database/{collectionId} +DELETE https://appwrite.io/v1/database/collections/{collectionId} ``` ** Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. ** @@ -83,7 +83,7 @@ DELETE https://appwrite.io/v1/database/{collectionId} ## List Documents ```http request -GET https://appwrite.io/v1/database/{collectionId}/documents +GET https://appwrite.io/v1/database/collections/{collectionId}/documents ``` ** Get a list of all the user documents. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project documents. [Learn more about different API modes](/docs/admin). ** @@ -92,8 +92,8 @@ GET https://appwrite.io/v1/database/{collectionId}/documents | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection unique ID. | | -| filters | array | Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: 'name=John Doe' or 'category.$uid>=5bed2d152c362' | [] | +| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection). | | +| filters | array | Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: 'name=John Doe' or 'category.$uid>=5bed2d152c362'. | [] | | offset | integer | Offset value. Use this value to manage pagination. | 0 | | limit | integer | Maximum number of documents to return in response. Use this value to manage pagination. | 50 | | order-field | string | Document field that results will be sorted by. | $uid | @@ -106,7 +106,7 @@ GET https://appwrite.io/v1/database/{collectionId}/documents ## Create Document ```http request -POST https://appwrite.io/v1/database/{collectionId}/documents +POST https://appwrite.io/v1/database/collections/{collectionId}/documents ``` ** Create a new Document. ** @@ -115,8 +115,8 @@ POST https://appwrite.io/v1/database/{collectionId}/documents | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection unique ID. | | -| data | string | Document data as JSON string. | | +| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection). | | +| data | object | Document data as JSON string. | | | read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | | write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | | parentDocument | string | Parent document unique ID. Use when you want your new document to be a child of a parent document. | | @@ -126,7 +126,7 @@ POST https://appwrite.io/v1/database/{collectionId}/documents ## Get Document ```http request -GET https://appwrite.io/v1/database/{collectionId}/documents/{documentId} +GET https://appwrite.io/v1/database/collections/{collectionId}/documents/{documentId} ``` ** Get document by its unique ID. This endpoint response returns a JSON object with the document data. ** @@ -135,29 +135,29 @@ GET https://appwrite.io/v1/database/{collectionId}/documents/{documentId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection unique ID | | -| documentId | string | **Required** Document unique ID | | +| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection). | | +| documentId | string | **Required** Document unique ID. | | ## Update Document ```http request -PATCH https://appwrite.io/v1/database/{collectionId}/documents/{documentId} +PATCH https://appwrite.io/v1/database/collections/{collectionId}/documents/{documentId} ``` ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection unique ID | | -| documentId | string | **Required** Document unique ID | | -| data | string | Document data as JSON string | | +| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection). | | +| documentId | string | **Required** Document unique ID. | | +| data | object | Document data as JSON string. | | | read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | | write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | ## Delete Document ```http request -DELETE https://appwrite.io/v1/database/{collectionId}/documents/{documentId} +DELETE https://appwrite.io/v1/database/collections/{collectionId}/documents/{documentId} ``` ** Delete document by its unique ID. This endpoint deletes only the parent documents, his attributes and relations to other documents. Child documents **will not** be deleted. ** @@ -166,6 +166,6 @@ DELETE https://appwrite.io/v1/database/{collectionId}/documents/{documentId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection unique ID | | -| documentId | string | **Required** Document unique ID | | +| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection). | | +| documentId | string | **Required** Document unique ID. | | diff --git a/app/sdks/php/docs/examples/account/delete.md b/app/sdks/php/docs/examples/account/delete.md deleted file mode 100644 index 4aeb1f0096..0000000000 --- a/app/sdks/php/docs/examples/account/delete.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$account = new Account($client); - -$result = $account->delete(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/account/get-prefs.md b/app/sdks/php/docs/examples/account/get-prefs.md deleted file mode 100644 index f3f6d72519..0000000000 --- a/app/sdks/php/docs/examples/account/get-prefs.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$account = new Account($client); - -$result = $account->getPrefs(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/account/get-security.md b/app/sdks/php/docs/examples/account/get-security.md deleted file mode 100644 index 381d0bd755..0000000000 --- a/app/sdks/php/docs/examples/account/get-security.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$account = new Account($client); - -$result = $account->getSecurity(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/account/get-sessions.md b/app/sdks/php/docs/examples/account/get-sessions.md deleted file mode 100644 index 8af7a7cd82..0000000000 --- a/app/sdks/php/docs/examples/account/get-sessions.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$account = new Account($client); - -$result = $account->getSessions(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/account/get.md b/app/sdks/php/docs/examples/account/get.md deleted file mode 100644 index c7241e576f..0000000000 --- a/app/sdks/php/docs/examples/account/get.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$account = new Account($client); - -$result = $account->get(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/account/update-email.md b/app/sdks/php/docs/examples/account/update-email.md deleted file mode 100644 index 66cb6dff4a..0000000000 --- a/app/sdks/php/docs/examples/account/update-email.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$account = new Account($client); - -$result = $account->updateEmail('email@example.com', 'password'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/account/update-name.md b/app/sdks/php/docs/examples/account/update-name.md deleted file mode 100644 index 068f824863..0000000000 --- a/app/sdks/php/docs/examples/account/update-name.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$account = new Account($client); - -$result = $account->updateName('[NAME]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/account/update-password.md b/app/sdks/php/docs/examples/account/update-password.md deleted file mode 100644 index 124bc26dab..0000000000 --- a/app/sdks/php/docs/examples/account/update-password.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$account = new Account($client); - -$result = $account->updatePassword('password', 'password'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/account/update-prefs.md b/app/sdks/php/docs/examples/account/update-prefs.md deleted file mode 100644 index df73bac861..0000000000 --- a/app/sdks/php/docs/examples/account/update-prefs.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$account = new Account($client); - -$result = $account->updatePrefs('{}'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/confirm-resend.md b/app/sdks/php/docs/examples/auth/confirm-resend.md deleted file mode 100644 index 643e600d2f..0000000000 --- a/app/sdks/php/docs/examples/auth/confirm-resend.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$auth = new Auth($client); - -$result = $auth->confirmResend('https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/confirm.md b/app/sdks/php/docs/examples/auth/confirm.md deleted file mode 100644 index c60b7fb01d..0000000000 --- a/app/sdks/php/docs/examples/auth/confirm.md +++ /dev/null @@ -1,13 +0,0 @@ -confirm('[USER_ID]', '[TOKEN]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/login.md b/app/sdks/php/docs/examples/auth/login.md deleted file mode 100644 index f282a88e64..0000000000 --- a/app/sdks/php/docs/examples/auth/login.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$auth = new Auth($client); - -$result = $auth->login('email@example.com', 'password'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/logout-by-session.md b/app/sdks/php/docs/examples/auth/logout-by-session.md deleted file mode 100644 index 90a1f23fd6..0000000000 --- a/app/sdks/php/docs/examples/auth/logout-by-session.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$auth = new Auth($client); - -$result = $auth->logoutBySession('[ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/logout.md b/app/sdks/php/docs/examples/auth/logout.md deleted file mode 100644 index 78bd0275cc..0000000000 --- a/app/sdks/php/docs/examples/auth/logout.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$auth = new Auth($client); - -$result = $auth->logout(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/oauth-callback.md b/app/sdks/php/docs/examples/auth/oauth-callback.md deleted file mode 100644 index 437a7c427f..0000000000 --- a/app/sdks/php/docs/examples/auth/oauth-callback.md +++ /dev/null @@ -1,15 +0,0 @@ -oauthCallback('[PROJECT_ID]', 'bitbucket', '[CODE]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/oauth.md b/app/sdks/php/docs/examples/auth/oauth.md deleted file mode 100644 index 25b8d17613..0000000000 --- a/app/sdks/php/docs/examples/auth/oauth.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$auth = new Auth($client); - -$result = $auth->oauth('bitbucket', 'https://example.com', 'https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/recovery-reset.md b/app/sdks/php/docs/examples/auth/recovery-reset.md deleted file mode 100644 index 19a4d83cfc..0000000000 --- a/app/sdks/php/docs/examples/auth/recovery-reset.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$auth = new Auth($client); - -$result = $auth->recoveryReset('[USER_ID]', '[TOKEN]', 'password', 'password'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/recovery.md b/app/sdks/php/docs/examples/auth/recovery.md deleted file mode 100644 index b52ddcb6ed..0000000000 --- a/app/sdks/php/docs/examples/auth/recovery.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$auth = new Auth($client); - -$result = $auth->recovery('email@example.com', 'https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/auth/register.md b/app/sdks/php/docs/examples/auth/register.md deleted file mode 100644 index c34b859808..0000000000 --- a/app/sdks/php/docs/examples/auth/register.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$auth = new Auth($client); - -$result = $auth->register('email@example.com', 'password', 'https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/avatars/get-browser.md b/app/sdks/php/docs/examples/avatars/get-browser.md index c9a6a6b6c0..e1d578d09f 100644 --- a/app/sdks/php/docs/examples/avatars/get-browser.md +++ b/app/sdks/php/docs/examples/avatars/get-browser.md @@ -6,8 +6,8 @@ use Appwrite\Services\Avatars; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $avatars = new Avatars($client); diff --git a/app/sdks/php/docs/examples/avatars/get-credit-card.md b/app/sdks/php/docs/examples/avatars/get-credit-card.md index 206b0cc8c8..24f2e75bfc 100644 --- a/app/sdks/php/docs/examples/avatars/get-credit-card.md +++ b/app/sdks/php/docs/examples/avatars/get-credit-card.md @@ -6,8 +6,8 @@ use Appwrite\Services\Avatars; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $avatars = new Avatars($client); diff --git a/app/sdks/php/docs/examples/avatars/get-favicon.md b/app/sdks/php/docs/examples/avatars/get-favicon.md index 01f28add89..b0c33ccb3e 100644 --- a/app/sdks/php/docs/examples/avatars/get-favicon.md +++ b/app/sdks/php/docs/examples/avatars/get-favicon.md @@ -6,8 +6,8 @@ use Appwrite\Services\Avatars; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $avatars = new Avatars($client); diff --git a/app/sdks/php/docs/examples/avatars/get-flag.md b/app/sdks/php/docs/examples/avatars/get-flag.md index 26740446cd..83eebce6d8 100644 --- a/app/sdks/php/docs/examples/avatars/get-flag.md +++ b/app/sdks/php/docs/examples/avatars/get-flag.md @@ -6,8 +6,8 @@ use Appwrite\Services\Avatars; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $avatars = new Avatars($client); diff --git a/app/sdks/php/docs/examples/avatars/get-image.md b/app/sdks/php/docs/examples/avatars/get-image.md index bbbe68d2d0..a452e07ee7 100644 --- a/app/sdks/php/docs/examples/avatars/get-image.md +++ b/app/sdks/php/docs/examples/avatars/get-image.md @@ -6,8 +6,8 @@ use Appwrite\Services\Avatars; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $avatars = new Avatars($client); diff --git a/app/sdks/php/docs/examples/avatars/get-q-r.md b/app/sdks/php/docs/examples/avatars/get-q-r.md index e10ec33d59..bc457a7e21 100644 --- a/app/sdks/php/docs/examples/avatars/get-q-r.md +++ b/app/sdks/php/docs/examples/avatars/get-q-r.md @@ -6,8 +6,8 @@ use Appwrite\Services\Avatars; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $avatars = new Avatars($client); diff --git a/app/sdks/php/docs/examples/database/create-collection.md b/app/sdks/php/docs/examples/database/create-collection.md index 183d906905..b5f3ed4955 100644 --- a/app/sdks/php/docs/examples/database/create-collection.md +++ b/app/sdks/php/docs/examples/database/create-collection.md @@ -6,8 +6,8 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); diff --git a/app/sdks/php/docs/examples/database/create-document.md b/app/sdks/php/docs/examples/database/create-document.md index 84c4d7fd06..318b66a2f1 100644 --- a/app/sdks/php/docs/examples/database/create-document.md +++ b/app/sdks/php/docs/examples/database/create-document.md @@ -6,10 +6,10 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); -$result = $database->createDocument('[COLLECTION_ID]', '{}', [], []); \ No newline at end of file +$result = $database->createDocument('[COLLECTION_ID]', [], [], []); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/database/delete-collection.md b/app/sdks/php/docs/examples/database/delete-collection.md index 2319d52c57..d35e7ef7e4 100644 --- a/app/sdks/php/docs/examples/database/delete-collection.md +++ b/app/sdks/php/docs/examples/database/delete-collection.md @@ -6,8 +6,8 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); diff --git a/app/sdks/php/docs/examples/database/delete-document.md b/app/sdks/php/docs/examples/database/delete-document.md index b364e0bcd5..d69bc27dc1 100644 --- a/app/sdks/php/docs/examples/database/delete-document.md +++ b/app/sdks/php/docs/examples/database/delete-document.md @@ -6,8 +6,8 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); diff --git a/app/sdks/php/docs/examples/database/get-collection.md b/app/sdks/php/docs/examples/database/get-collection.md index 9daa61ddfc..3f274b10ae 100644 --- a/app/sdks/php/docs/examples/database/get-collection.md +++ b/app/sdks/php/docs/examples/database/get-collection.md @@ -6,8 +6,8 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); diff --git a/app/sdks/php/docs/examples/database/get-document.md b/app/sdks/php/docs/examples/database/get-document.md index da72bd8f1b..06ad41708b 100644 --- a/app/sdks/php/docs/examples/database/get-document.md +++ b/app/sdks/php/docs/examples/database/get-document.md @@ -6,8 +6,8 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); diff --git a/app/sdks/php/docs/examples/database/list-collections.md b/app/sdks/php/docs/examples/database/list-collections.md index c46daa2cda..f3fcc58540 100644 --- a/app/sdks/php/docs/examples/database/list-collections.md +++ b/app/sdks/php/docs/examples/database/list-collections.md @@ -6,8 +6,8 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); diff --git a/app/sdks/php/docs/examples/database/list-documents.md b/app/sdks/php/docs/examples/database/list-documents.md index 973f9c477e..8c6e1b3f94 100644 --- a/app/sdks/php/docs/examples/database/list-documents.md +++ b/app/sdks/php/docs/examples/database/list-documents.md @@ -6,8 +6,8 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); diff --git a/app/sdks/php/docs/examples/database/update-collection.md b/app/sdks/php/docs/examples/database/update-collection.md index 2576449e5c..3384d0056d 100644 --- a/app/sdks/php/docs/examples/database/update-collection.md +++ b/app/sdks/php/docs/examples/database/update-collection.md @@ -6,8 +6,8 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); diff --git a/app/sdks/php/docs/examples/database/update-document.md b/app/sdks/php/docs/examples/database/update-document.md index 2051d09772..c5768a07cb 100644 --- a/app/sdks/php/docs/examples/database/update-document.md +++ b/app/sdks/php/docs/examples/database/update-document.md @@ -6,10 +6,10 @@ use Appwrite\Services\Database; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $database = new Database($client); -$result = $database->updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', '{}', [], []); \ No newline at end of file +$result = $database->updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', [], [], []); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/locale/get-continents.md b/app/sdks/php/docs/examples/locale/get-continents.md index 22b1528c0a..c642fa1414 100644 --- a/app/sdks/php/docs/examples/locale/get-continents.md +++ b/app/sdks/php/docs/examples/locale/get-continents.md @@ -6,8 +6,8 @@ use Appwrite\Services\Locale; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $locale = new Locale($client); diff --git a/app/sdks/php/docs/examples/locale/get-countries-e-u.md b/app/sdks/php/docs/examples/locale/get-countries-e-u.md index 9f0f1973cc..47bcaa417a 100644 --- a/app/sdks/php/docs/examples/locale/get-countries-e-u.md +++ b/app/sdks/php/docs/examples/locale/get-countries-e-u.md @@ -6,8 +6,8 @@ use Appwrite\Services\Locale; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $locale = new Locale($client); diff --git a/app/sdks/php/docs/examples/locale/get-countries-phones.md b/app/sdks/php/docs/examples/locale/get-countries-phones.md index 2478c7c730..4e0bcfba94 100644 --- a/app/sdks/php/docs/examples/locale/get-countries-phones.md +++ b/app/sdks/php/docs/examples/locale/get-countries-phones.md @@ -6,8 +6,8 @@ use Appwrite\Services\Locale; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $locale = new Locale($client); diff --git a/app/sdks/php/docs/examples/locale/get-countries.md b/app/sdks/php/docs/examples/locale/get-countries.md index 111dc52777..08557f8808 100644 --- a/app/sdks/php/docs/examples/locale/get-countries.md +++ b/app/sdks/php/docs/examples/locale/get-countries.md @@ -6,8 +6,8 @@ use Appwrite\Services\Locale; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $locale = new Locale($client); diff --git a/app/sdks/php/docs/examples/locale/get-currencies.md b/app/sdks/php/docs/examples/locale/get-currencies.md index e01d5fd623..efbeb932de 100644 --- a/app/sdks/php/docs/examples/locale/get-currencies.md +++ b/app/sdks/php/docs/examples/locale/get-currencies.md @@ -6,8 +6,8 @@ use Appwrite\Services\Locale; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $locale = new Locale($client); diff --git a/app/sdks/php/docs/examples/locale/get-locale.md b/app/sdks/php/docs/examples/locale/get-locale.md deleted file mode 100644 index ac56f068de..0000000000 --- a/app/sdks/php/docs/examples/locale/get-locale.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$locale = new Locale($client); - -$result = $locale->getLocale(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/locale/get.md b/app/sdks/php/docs/examples/locale/get.md new file mode 100644 index 0000000000..023d3227b0 --- /dev/null +++ b/app/sdks/php/docs/examples/locale/get.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$locale = new Locale($client); + +$result = $locale->get(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/create-key.md b/app/sdks/php/docs/examples/projects/create-key.md deleted file mode 100644 index b732c540ab..0000000000 --- a/app/sdks/php/docs/examples/projects/create-key.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->createKey('[PROJECT_ID]', '[NAME]', []); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/create-platform.md b/app/sdks/php/docs/examples/projects/create-platform.md deleted file mode 100644 index 4f5f6a3355..0000000000 --- a/app/sdks/php/docs/examples/projects/create-platform.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->createPlatform('[PROJECT_ID]', 'web', '[NAME]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/create-project.md b/app/sdks/php/docs/examples/projects/create-project.md deleted file mode 100644 index c7a36650af..0000000000 --- a/app/sdks/php/docs/examples/projects/create-project.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->createProject('[NAME]', '[TEAM_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/create-task.md b/app/sdks/php/docs/examples/projects/create-task.md deleted file mode 100644 index fab9e27653..0000000000 --- a/app/sdks/php/docs/examples/projects/create-task.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->createTask('[PROJECT_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/create-webhook.md b/app/sdks/php/docs/examples/projects/create-webhook.md deleted file mode 100644 index 6eacda1fc0..0000000000 --- a/app/sdks/php/docs/examples/projects/create-webhook.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 0); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/delete-key.md b/app/sdks/php/docs/examples/projects/delete-key.md deleted file mode 100644 index 4af28f9929..0000000000 --- a/app/sdks/php/docs/examples/projects/delete-key.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->deleteKey('[PROJECT_ID]', '[KEY_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/delete-platform.md b/app/sdks/php/docs/examples/projects/delete-platform.md deleted file mode 100644 index cab8785a49..0000000000 --- a/app/sdks/php/docs/examples/projects/delete-platform.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->deletePlatform('[PROJECT_ID]', '[PLATFORM_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/delete-project.md b/app/sdks/php/docs/examples/projects/delete-project.md deleted file mode 100644 index d02ceb6e2b..0000000000 --- a/app/sdks/php/docs/examples/projects/delete-project.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->deleteProject('[PROJECT_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/delete-task.md b/app/sdks/php/docs/examples/projects/delete-task.md deleted file mode 100644 index 0e8632cf3f..0000000000 --- a/app/sdks/php/docs/examples/projects/delete-task.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->deleteTask('[PROJECT_ID]', '[TASK_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/delete-webhook.md b/app/sdks/php/docs/examples/projects/delete-webhook.md deleted file mode 100644 index fff5956e0c..0000000000 --- a/app/sdks/php/docs/examples/projects/delete-webhook.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->deleteWebhook('[PROJECT_ID]', '[WEBHOOK_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/get-key.md b/app/sdks/php/docs/examples/projects/get-key.md deleted file mode 100644 index 4863bc23d4..0000000000 --- a/app/sdks/php/docs/examples/projects/get-key.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->getKey('[PROJECT_ID]', '[KEY_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/get-platform.md b/app/sdks/php/docs/examples/projects/get-platform.md deleted file mode 100644 index 94f23656f5..0000000000 --- a/app/sdks/php/docs/examples/projects/get-platform.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->getPlatform('[PROJECT_ID]', '[PLATFORM_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/get-project-usage.md b/app/sdks/php/docs/examples/projects/get-project-usage.md deleted file mode 100644 index 495ba2fe9f..0000000000 --- a/app/sdks/php/docs/examples/projects/get-project-usage.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->getProjectUsage('[PROJECT_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/get-project.md b/app/sdks/php/docs/examples/projects/get-project.md deleted file mode 100644 index b64f8a0e26..0000000000 --- a/app/sdks/php/docs/examples/projects/get-project.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->getProject('[PROJECT_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/get-task.md b/app/sdks/php/docs/examples/projects/get-task.md deleted file mode 100644 index 598bba69e5..0000000000 --- a/app/sdks/php/docs/examples/projects/get-task.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->getTask('[PROJECT_ID]', '[TASK_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/get-webhook.md b/app/sdks/php/docs/examples/projects/get-webhook.md deleted file mode 100644 index c765dfb108..0000000000 --- a/app/sdks/php/docs/examples/projects/get-webhook.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->getWebhook('[PROJECT_ID]', '[WEBHOOK_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/list-keys.md b/app/sdks/php/docs/examples/projects/list-keys.md deleted file mode 100644 index 69db3fda45..0000000000 --- a/app/sdks/php/docs/examples/projects/list-keys.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->listKeys('[PROJECT_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/list-platforms.md b/app/sdks/php/docs/examples/projects/list-platforms.md deleted file mode 100644 index ae0155379e..0000000000 --- a/app/sdks/php/docs/examples/projects/list-platforms.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->listPlatforms('[PROJECT_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/list-projects.md b/app/sdks/php/docs/examples/projects/list-projects.md deleted file mode 100644 index 5e39729bc2..0000000000 --- a/app/sdks/php/docs/examples/projects/list-projects.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->listProjects(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/list-tasks.md b/app/sdks/php/docs/examples/projects/list-tasks.md deleted file mode 100644 index 7f0bc62a5b..0000000000 --- a/app/sdks/php/docs/examples/projects/list-tasks.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->listTasks('[PROJECT_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/list-webhooks.md b/app/sdks/php/docs/examples/projects/list-webhooks.md deleted file mode 100644 index 121698a240..0000000000 --- a/app/sdks/php/docs/examples/projects/list-webhooks.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->listWebhooks('[PROJECT_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/update-key.md b/app/sdks/php/docs/examples/projects/update-key.md deleted file mode 100644 index 09aa0d2517..0000000000 --- a/app/sdks/php/docs/examples/projects/update-key.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->updateKey('[PROJECT_ID]', '[KEY_ID]', '[NAME]', []); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/update-platform.md b/app/sdks/php/docs/examples/projects/update-platform.md deleted file mode 100644 index e7c35dd232..0000000000 --- a/app/sdks/php/docs/examples/projects/update-platform.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->updatePlatform('[PROJECT_ID]', '[PLATFORM_ID]', '[NAME]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/update-project-o-auth.md b/app/sdks/php/docs/examples/projects/update-project-o-auth.md deleted file mode 100644 index cd0ef51f3a..0000000000 --- a/app/sdks/php/docs/examples/projects/update-project-o-auth.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->updateProjectOAuth('[PROJECT_ID]', 'bitbucket'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/update-project.md b/app/sdks/php/docs/examples/projects/update-project.md deleted file mode 100644 index 0d7997c16d..0000000000 --- a/app/sdks/php/docs/examples/projects/update-project.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->updateProject('[PROJECT_ID]', '[NAME]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/update-task.md b/app/sdks/php/docs/examples/projects/update-task.md deleted file mode 100644 index 59308c5d6d..0000000000 --- a/app/sdks/php/docs/examples/projects/update-task.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/update-webhook.md b/app/sdks/php/docs/examples/projects/update-webhook.md deleted file mode 100644 index a7e42dcce2..0000000000 --- a/app/sdks/php/docs/examples/projects/update-webhook.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$projects = new Projects($client); - -$result = $projects->updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 0); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/storage/create-file.md b/app/sdks/php/docs/examples/storage/create-file.md index 225b9e2bec..da6fa4d755 100644 --- a/app/sdks/php/docs/examples/storage/create-file.md +++ b/app/sdks/php/docs/examples/storage/create-file.md @@ -6,8 +6,8 @@ use Appwrite\Services\Storage; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $storage = new Storage($client); diff --git a/app/sdks/php/docs/examples/storage/delete-file.md b/app/sdks/php/docs/examples/storage/delete-file.md index 74448e5a7c..84707c25cd 100644 --- a/app/sdks/php/docs/examples/storage/delete-file.md +++ b/app/sdks/php/docs/examples/storage/delete-file.md @@ -6,8 +6,8 @@ use Appwrite\Services\Storage; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $storage = new Storage($client); diff --git a/app/sdks/php/docs/examples/storage/get-file-download.md b/app/sdks/php/docs/examples/storage/get-file-download.md index 3a6db00081..680c5637b4 100644 --- a/app/sdks/php/docs/examples/storage/get-file-download.md +++ b/app/sdks/php/docs/examples/storage/get-file-download.md @@ -6,8 +6,8 @@ use Appwrite\Services\Storage; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $storage = new Storage($client); diff --git a/app/sdks/php/docs/examples/storage/get-file-preview.md b/app/sdks/php/docs/examples/storage/get-file-preview.md index 8b02bdd2a9..913628839c 100644 --- a/app/sdks/php/docs/examples/storage/get-file-preview.md +++ b/app/sdks/php/docs/examples/storage/get-file-preview.md @@ -6,8 +6,8 @@ use Appwrite\Services\Storage; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $storage = new Storage($client); diff --git a/app/sdks/php/docs/examples/storage/get-file-view.md b/app/sdks/php/docs/examples/storage/get-file-view.md index 59cc25bc74..88a71a1523 100644 --- a/app/sdks/php/docs/examples/storage/get-file-view.md +++ b/app/sdks/php/docs/examples/storage/get-file-view.md @@ -6,8 +6,8 @@ use Appwrite\Services\Storage; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $storage = new Storage($client); diff --git a/app/sdks/php/docs/examples/storage/get-file.md b/app/sdks/php/docs/examples/storage/get-file.md index 63fa59b40a..4b4554ece1 100644 --- a/app/sdks/php/docs/examples/storage/get-file.md +++ b/app/sdks/php/docs/examples/storage/get-file.md @@ -6,8 +6,8 @@ use Appwrite\Services\Storage; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $storage = new Storage($client); diff --git a/app/sdks/php/docs/examples/storage/list-files.md b/app/sdks/php/docs/examples/storage/list-files.md index 434e1fe70d..497bada42e 100644 --- a/app/sdks/php/docs/examples/storage/list-files.md +++ b/app/sdks/php/docs/examples/storage/list-files.md @@ -6,8 +6,8 @@ use Appwrite\Services\Storage; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $storage = new Storage($client); diff --git a/app/sdks/php/docs/examples/storage/update-file.md b/app/sdks/php/docs/examples/storage/update-file.md index 637870a7a6..f7f3503f4c 100644 --- a/app/sdks/php/docs/examples/storage/update-file.md +++ b/app/sdks/php/docs/examples/storage/update-file.md @@ -6,8 +6,8 @@ use Appwrite\Services\Storage; $client = new Client(); $client - ->setProject('') - ->setKey('') + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $storage = new Storage($client); diff --git a/app/sdks/php/docs/examples/teams/create-membership.md b/app/sdks/php/docs/examples/teams/create-membership.md new file mode 100644 index 0000000000..8864d1f418 --- /dev/null +++ b/app/sdks/php/docs/examples/teams/create-membership.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$teams = new Teams($client); + +$result = $teams->createMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/create-team-membership-resend.md b/app/sdks/php/docs/examples/teams/create-team-membership-resend.md deleted file mode 100644 index 0789412121..0000000000 --- a/app/sdks/php/docs/examples/teams/create-team-membership-resend.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->createTeamMembershipResend('[TEAM_ID]', '[INVITE_ID]', 'https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/create-team-membership.md b/app/sdks/php/docs/examples/teams/create-team-membership.md deleted file mode 100644 index 12a47b6f15..0000000000 --- a/app/sdks/php/docs/examples/teams/create-team-membership.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->createTeamMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/create-team.md b/app/sdks/php/docs/examples/teams/create-team.md deleted file mode 100644 index 11928b37cc..0000000000 --- a/app/sdks/php/docs/examples/teams/create-team.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->createTeam('[NAME]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/create.md b/app/sdks/php/docs/examples/teams/create.md new file mode 100644 index 0000000000..45646098cb --- /dev/null +++ b/app/sdks/php/docs/examples/teams/create.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$teams = new Teams($client); + +$result = $teams->create('[NAME]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/delete-membership.md b/app/sdks/php/docs/examples/teams/delete-membership.md new file mode 100644 index 0000000000..0bf19be778 --- /dev/null +++ b/app/sdks/php/docs/examples/teams/delete-membership.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$teams = new Teams($client); + +$result = $teams->deleteMembership('[TEAM_ID]', '[INVITE_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/delete-team-membership.md b/app/sdks/php/docs/examples/teams/delete-team-membership.md deleted file mode 100644 index d53e1ed7ce..0000000000 --- a/app/sdks/php/docs/examples/teams/delete-team-membership.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->deleteTeamMembership('[TEAM_ID]', '[INVITE_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/delete-team.md b/app/sdks/php/docs/examples/teams/delete-team.md deleted file mode 100644 index 7fb04015be..0000000000 --- a/app/sdks/php/docs/examples/teams/delete-team.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->deleteTeam('[TEAM_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/delete.md b/app/sdks/php/docs/examples/teams/delete.md new file mode 100644 index 0000000000..4d1bcee7b8 --- /dev/null +++ b/app/sdks/php/docs/examples/teams/delete.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$teams = new Teams($client); + +$result = $teams->delete('[TEAM_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/get-memberships.md b/app/sdks/php/docs/examples/teams/get-memberships.md new file mode 100644 index 0000000000..bd71709838 --- /dev/null +++ b/app/sdks/php/docs/examples/teams/get-memberships.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$teams = new Teams($client); + +$result = $teams->getMemberships('[TEAM_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/get-team-members.md b/app/sdks/php/docs/examples/teams/get-team-members.md deleted file mode 100644 index 7f7b4c88bf..0000000000 --- a/app/sdks/php/docs/examples/teams/get-team-members.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->getTeamMembers('[TEAM_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/get-team.md b/app/sdks/php/docs/examples/teams/get-team.md deleted file mode 100644 index e58a9d0dc2..0000000000 --- a/app/sdks/php/docs/examples/teams/get-team.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->getTeam('[TEAM_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/get.md b/app/sdks/php/docs/examples/teams/get.md new file mode 100644 index 0000000000..d9b3ba11dd --- /dev/null +++ b/app/sdks/php/docs/examples/teams/get.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$teams = new Teams($client); + +$result = $teams->get('[TEAM_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/list-teams.md b/app/sdks/php/docs/examples/teams/list-teams.md deleted file mode 100644 index 9b753c6d16..0000000000 --- a/app/sdks/php/docs/examples/teams/list-teams.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->listTeams(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/list.md b/app/sdks/php/docs/examples/teams/list.md new file mode 100644 index 0000000000..a127a3d1eb --- /dev/null +++ b/app/sdks/php/docs/examples/teams/list.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$teams = new Teams($client); + +$result = $teams->list(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/update-team-membership-status.md b/app/sdks/php/docs/examples/teams/update-team-membership-status.md deleted file mode 100644 index 19f14550e4..0000000000 --- a/app/sdks/php/docs/examples/teams/update-team-membership-status.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->updateTeamMembershipStatus('[TEAM_ID]', '[INVITE_ID]', '[USER_ID]', '[SECRET]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/update-team.md b/app/sdks/php/docs/examples/teams/update-team.md deleted file mode 100644 index a76fce3a83..0000000000 --- a/app/sdks/php/docs/examples/teams/update-team.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$teams = new Teams($client); - -$result = $teams->updateTeam('[TEAM_ID]', '[NAME]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/teams/update.md b/app/sdks/php/docs/examples/teams/update.md new file mode 100644 index 0000000000..6318ca5bad --- /dev/null +++ b/app/sdks/php/docs/examples/teams/update.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$teams = new Teams($client); + +$result = $teams->update('[TEAM_ID]', '[NAME]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/create-user.md b/app/sdks/php/docs/examples/users/create-user.md deleted file mode 100644 index b25a479c89..0000000000 --- a/app/sdks/php/docs/examples/users/create-user.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->createUser('email@example.com', 'password'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/create.md b/app/sdks/php/docs/examples/users/create.md new file mode 100644 index 0000000000..bc52ac6836 --- /dev/null +++ b/app/sdks/php/docs/examples/users/create.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->create('email@example.com', 'password'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/delete-session.md b/app/sdks/php/docs/examples/users/delete-session.md new file mode 100644 index 0000000000..02acfeddd2 --- /dev/null +++ b/app/sdks/php/docs/examples/users/delete-session.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->deleteSession('[USER_ID]', '[SESSION_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/delete-sessions.md b/app/sdks/php/docs/examples/users/delete-sessions.md new file mode 100644 index 0000000000..461c4e1df5 --- /dev/null +++ b/app/sdks/php/docs/examples/users/delete-sessions.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->deleteSessions('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/delete-user-session.md b/app/sdks/php/docs/examples/users/delete-user-session.md deleted file mode 100644 index 28ad6dd165..0000000000 --- a/app/sdks/php/docs/examples/users/delete-user-session.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->deleteUserSession('[USER_ID]', '[SESSION_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/delete-user-sessions.md b/app/sdks/php/docs/examples/users/delete-user-sessions.md deleted file mode 100644 index a83c648f69..0000000000 --- a/app/sdks/php/docs/examples/users/delete-user-sessions.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->deleteUserSessions('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/delete-users-session.md b/app/sdks/php/docs/examples/users/delete-users-session.md deleted file mode 100644 index f5a9c6fa1b..0000000000 --- a/app/sdks/php/docs/examples/users/delete-users-session.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->deleteUsersSession('[USER_ID]', '[SESSION_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/get-logs.md b/app/sdks/php/docs/examples/users/get-logs.md new file mode 100644 index 0000000000..9164405788 --- /dev/null +++ b/app/sdks/php/docs/examples/users/get-logs.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->getLogs('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/get-prefs.md b/app/sdks/php/docs/examples/users/get-prefs.md new file mode 100644 index 0000000000..0874dbc508 --- /dev/null +++ b/app/sdks/php/docs/examples/users/get-prefs.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->getPrefs('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/get-sessions.md b/app/sdks/php/docs/examples/users/get-sessions.md new file mode 100644 index 0000000000..06a6a026ac --- /dev/null +++ b/app/sdks/php/docs/examples/users/get-sessions.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->getSessions('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/get-user-logs.md b/app/sdks/php/docs/examples/users/get-user-logs.md deleted file mode 100644 index bb9a70e975..0000000000 --- a/app/sdks/php/docs/examples/users/get-user-logs.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->getUserLogs('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/get-user-prefs.md b/app/sdks/php/docs/examples/users/get-user-prefs.md deleted file mode 100644 index 949d206065..0000000000 --- a/app/sdks/php/docs/examples/users/get-user-prefs.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->getUserPrefs('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/get-user-sessions.md b/app/sdks/php/docs/examples/users/get-user-sessions.md deleted file mode 100644 index 9f29697960..0000000000 --- a/app/sdks/php/docs/examples/users/get-user-sessions.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->getUserSessions('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/get-user.md b/app/sdks/php/docs/examples/users/get-user.md deleted file mode 100644 index bc776d4313..0000000000 --- a/app/sdks/php/docs/examples/users/get-user.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->getUser('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/get.md b/app/sdks/php/docs/examples/users/get.md new file mode 100644 index 0000000000..4f4d3c937d --- /dev/null +++ b/app/sdks/php/docs/examples/users/get.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->get('[USER_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/list-users.md b/app/sdks/php/docs/examples/users/list-users.md deleted file mode 100644 index d3824540fc..0000000000 --- a/app/sdks/php/docs/examples/users/list-users.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->listUsers(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/list.md b/app/sdks/php/docs/examples/users/list.md new file mode 100644 index 0000000000..ea5983f101 --- /dev/null +++ b/app/sdks/php/docs/examples/users/list.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->list(); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/update-prefs.md b/app/sdks/php/docs/examples/users/update-prefs.md new file mode 100644 index 0000000000..e21a056151 --- /dev/null +++ b/app/sdks/php/docs/examples/users/update-prefs.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->updatePrefs('[USER_ID]', []); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/update-status.md b/app/sdks/php/docs/examples/users/update-status.md new file mode 100644 index 0000000000..cee1486385 --- /dev/null +++ b/app/sdks/php/docs/examples/users/update-status.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->updateStatus('[USER_ID]', '1'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/update-user-prefs.md b/app/sdks/php/docs/examples/users/update-user-prefs.md deleted file mode 100644 index 073df70bd3..0000000000 --- a/app/sdks/php/docs/examples/users/update-user-prefs.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->updateUserPrefs('[USER_ID]', '{}'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/users/update-user-status.md b/app/sdks/php/docs/examples/users/update-user-status.md deleted file mode 100644 index 918d827962..0000000000 --- a/app/sdks/php/docs/examples/users/update-user-status.md +++ /dev/null @@ -1,15 +0,0 @@ -setProject('') - ->setKey('') -; - -$users = new Users($client); - -$result = $users->updateUserStatus('[USER_ID]', '1'); \ No newline at end of file diff --git a/app/sdks/php/docs/locale.md b/app/sdks/php/docs/locale.md index 81190fa96c..604d4f37fb 100644 --- a/app/sdks/php/docs/locale.md +++ b/app/sdks/php/docs/locale.md @@ -6,7 +6,9 @@ GET https://appwrite.io/v1/locale ``` -** Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. ** +** Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. + +([IP Geolocation by DB-IP](https://db-ip.com)) ** ## List Countries @@ -30,7 +32,7 @@ GET https://appwrite.io/v1/locale/countries GET https://appwrite.io/v1/locale/countries/eu ``` -** List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. UK brexit date is currently set to 2019-10-31 and will be updated if and when needed. ** +** List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. ** ## List Countries Phone Codes diff --git a/app/sdks/php/docs/projects.md b/app/sdks/php/docs/projects.md deleted file mode 100644 index bc4026970d..0000000000 --- a/app/sdks/php/docs/projects.md +++ /dev/null @@ -1,398 +0,0 @@ -# Projects Service - -## List Projects - -```http request -GET https://appwrite.io/v1/projects -``` - -## Create Project - -```http request -POST https://appwrite.io/v1/projects -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| name | string | Project name | | -| teamId | string | Team unique ID. | | -| description | string | Project description | | -| logo | string | Project logo | | -| url | string | Project URL | | -| legalName | string | Project Legal Name | | -| legalCountry | string | Project Legal Country | | -| legalState | string | Project Legal State | | -| legalCity | string | Project Legal City | | -| legalAddress | string | Project Legal Address | | -| legalTaxId | string | Project Legal Tax ID | | - -## Get Project - -```http request -GET https://appwrite.io/v1/projects/{projectId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | - -## Update Project - -```http request -PATCH https://appwrite.io/v1/projects/{projectId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| name | string | Project name | | -| description | string | Project description | | -| logo | string | Project logo | | -| url | string | Project URL | | -| legalName | string | Project Legal Name | | -| legalCountry | string | Project Legal Country | | -| legalState | string | Project Legal State | | -| legalCity | string | Project Legal City | | -| legalAddress | string | Project Legal Address | | -| legalTaxId | string | Project Legal Tax ID | | - -## Delete Project - -```http request -DELETE https://appwrite.io/v1/projects/{projectId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | - -## List Keys - -```http request -GET https://appwrite.io/v1/projects/{projectId}/keys -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | - -## Create Key - -```http request -POST https://appwrite.io/v1/projects/{projectId}/keys -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| name | string | Key name | | -| scopes | array | Key scopes list | | - -## Get Key - -```http request -GET https://appwrite.io/v1/projects/{projectId}/keys/{keyId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| keyId | string | **Required** Key unique ID. | | - -## Update Key - -```http request -PUT https://appwrite.io/v1/projects/{projectId}/keys/{keyId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| keyId | string | **Required** Key unique ID. | | -| name | string | Key name | | -| scopes | array | Key scopes list | | - -## Delete Key - -```http request -DELETE https://appwrite.io/v1/projects/{projectId}/keys/{keyId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| keyId | string | **Required** Key unique ID. | | - -## Update Project OAuth - -```http request -PATCH https://appwrite.io/v1/projects/{projectId}/oauth -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| provider | string | Provider Name | | -| appId | string | Provider App ID | | -| secret | string | Provider Secret Key | | - -## List Platforms - -```http request -GET https://appwrite.io/v1/projects/{projectId}/platforms -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | - -## Create Platform - -```http request -POST https://appwrite.io/v1/projects/{projectId}/platforms -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| type | string | Platform name | | -| name | string | Platform name | | -| key | string | Package name for android or bundle ID for iOS | | -| store | string | App store or Google Play store ID | | -| url | string | Platform client URL | | - -## Get Platform - -```http request -GET https://appwrite.io/v1/projects/{projectId}/platforms/{platformId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| platformId | string | **Required** Platform unique ID. | | - -## Update Platform - -```http request -PUT https://appwrite.io/v1/projects/{projectId}/platforms/{platformId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| platformId | string | **Required** Platform unique ID. | | -| name | string | Platform name | | -| key | string | Package name for android or bundle ID for iOS | | -| store | string | App store or Google Play store ID | | -| url | string | Platform client URL | | - -## Delete Platform - -```http request -DELETE https://appwrite.io/v1/projects/{projectId}/platforms/{platformId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| platformId | string | **Required** Platform unique ID. | | - -## List Tasks - -```http request -GET https://appwrite.io/v1/projects/{projectId}/tasks -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | - -## Create Task - -```http request -POST https://appwrite.io/v1/projects/{projectId}/tasks -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| name | string | Task name | | -| status | string | Task status | | -| schedule | string | Task schedule syntax | | -| security | integer | Certificate verification, 0 for disabled or 1 for enabled | | -| httpMethod | string | Task HTTP method | | -| httpUrl | string | Task HTTP URL | | -| httpHeaders | array | Task HTTP headers list | | -| httpUser | string | Task HTTP user | | -| httpPass | string | Task HTTP password | | - -## Get Task - -```http request -GET https://appwrite.io/v1/projects/{projectId}/tasks/{taskId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| taskId | string | **Required** Task unique ID. | | - -## Update Task - -```http request -PUT https://appwrite.io/v1/projects/{projectId}/tasks/{taskId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| taskId | string | **Required** Task unique ID. | | -| name | string | Task name | | -| status | string | Task status | | -| schedule | string | Task schedule syntax | | -| security | integer | Certificate verification, 0 for disabled or 1 for enabled | | -| httpMethod | string | Task HTTP method | | -| httpUrl | string | Task HTTP URL | | -| httpHeaders | array | Task HTTP headers list | | -| httpUser | string | Task HTTP user | | -| httpPass | string | Task HTTP password | | - -## Delete Task - -```http request -DELETE https://appwrite.io/v1/projects/{projectId}/tasks/{taskId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| taskId | string | **Required** Task unique ID. | | - -## Get Project - -```http request -GET https://appwrite.io/v1/projects/{projectId}/usage -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | - -## List Webhooks - -```http request -GET https://appwrite.io/v1/projects/{projectId}/webhooks -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | - -## Create Webhook - -```http request -POST https://appwrite.io/v1/projects/{projectId}/webhooks -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| name | string | Webhook name | | -| events | array | Webhook events list | | -| url | string | Webhook URL | | -| security | integer | Certificate verification, 0 for disabled or 1 for enabled | | -| httpUser | string | Webhook HTTP user | | -| httpPass | string | Webhook HTTP password | | - -## Get Webhook - -```http request -GET https://appwrite.io/v1/projects/{projectId}/webhooks/{webhookId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| webhookId | string | **Required** Webhook unique ID. | | - -## Update Webhook - -```http request -PUT https://appwrite.io/v1/projects/{projectId}/webhooks/{webhookId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| webhookId | string | **Required** Webhook unique ID. | | -| name | string | Webhook name | | -| events | array | Webhook events list | | -| url | string | Webhook URL | | -| security | integer | Certificate verification, 0 for disabled or 1 for enabled | | -| httpUser | string | Webhook HTTP user | | -| httpPass | string | Webhook HTTP password | | - -## Delete Webhook - -```http request -DELETE https://appwrite.io/v1/projects/{projectId}/webhooks/{webhookId} -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| projectId | string | **Required** Project unique ID. | | -| webhookId | string | **Required** Webhook unique ID. | | - diff --git a/app/sdks/php/docs/storage.md b/app/sdks/php/docs/storage.md index f7eca89305..2138f901a8 100644 --- a/app/sdks/php/docs/storage.md +++ b/app/sdks/php/docs/storage.md @@ -29,7 +29,7 @@ POST https://appwrite.io/v1/storage/files | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| files | file | Binary Files. | | +| file | file | Binary File. | | | read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | | write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | @@ -97,18 +97,18 @@ GET https://appwrite.io/v1/storage/files/{fileId}/download GET https://appwrite.io/v1/storage/files/{fileId}/preview ``` -** Get file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets will return file icon image. You can also pass query string arguments for cutting and resizing your preview image. ** +** Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. ** ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | | fileId | string | **Required** File unique ID | | -| width | integer | Resize preview image width, Pass an integer between 0 to 4000 | 0 | -| height | integer | Resize preview image height, Pass an integer between 0 to 4000 | 0 | -| quality | integer | Preview image quality. Pass an integer between 0 to 100. Defaults to 100 | 100 | +| width | integer | Resize preview image width, Pass an integer between 0 to 4000. | 0 | +| height | integer | Resize preview image height, Pass an integer between 0 to 4000. | 0 | +| quality | integer | Preview image quality. Pass an integer between 0 to 100. Defaults to 100. | 100 | | background | string | Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. | | -| output | string | Output format type (jpeg, jpg, png, gif and webp) | | +| output | string | Output format type (jpeg, jpg, png, gif and webp). | | ## Get File for View diff --git a/app/sdks/php/docs/teams.md b/app/sdks/php/docs/teams.md index 109c1e7280..7b2646c0ce 100644 --- a/app/sdks/php/docs/teams.md +++ b/app/sdks/php/docs/teams.md @@ -30,7 +30,7 @@ POST https://appwrite.io/v1/teams | Field Name | Type | Description | Default | | --- | --- | --- | --- | | name | string | Team name. | | -| roles | array | User roles array. Use this param to set the roles in the team for the user who created the team. The default role is **owner**, a role can be any string. | ["owner"] | +| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). | ["owner"] | ## Get Team @@ -75,10 +75,10 @@ DELETE https://appwrite.io/v1/teams/{teamId} | --- | --- | --- | --- | | teamId | string | **Required** Team unique ID. | | -## Get Team Members +## Get Team Memberships ```http request -GET https://appwrite.io/v1/teams/{teamId}/members +GET https://appwrite.io/v1/teams/{teamId}/memberships ``` ** Get team members by the team unique ID. All team members have read access for this list of resources. ** @@ -95,21 +95,21 @@ GET https://appwrite.io/v1/teams/{teamId}/members POST https://appwrite.io/v1/teams/{teamId}/memberships ``` -** Use this endpoint to invite a new member to your team. An email with a link to join the team will be sent to the new member email address. If member doesn't exists in the project it will be automatically created. +** Use this endpoint to invite a new member to join your team. An email with a link to join the team will be sent to the new member email address if the member doesn't exist in the project it will be created automatically. -Use the redirect parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the /teams/{teamId}/memberships/{inviteId}/status endpoint to finally join the user to the team. +Use the 'URL' parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the [Update Team Membership Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. -Please notice that in order to avoid a [Redirect Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URL's are the once from domains you have set when added your platforms in the console interface. ** +Please note that in order to avoid a [Redirect Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URL's are the once from domains you have set when added your platforms in the console interface. ** ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | | teamId | string | **Required** Team unique ID. | | -| email | string | New team member email address. | | +| email | string | New team member email. | | | name | string | New team member name. | | -| roles | array | Invite roles array. Learn more about [roles and permissions](/docs/permissions). | | -| redirect | string | Reset page to redirect user back to your app from the invitation email. | | +| roles | array | Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). | | +| url | string | URL to redirect the user back to your app from the invitation email. | | ## Delete Team Membership @@ -117,22 +117,7 @@ Please notice that in order to avoid a [Redirect Attacks](https://github.com/OWA DELETE https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId} ``` -** This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| teamId | string | **Required** Team unique ID. | | -| inviteId | string | **Required** Invite unique ID | | - -## Create Team Membership (Resend) - -```http request -POST https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId}/resend -``` - -** Use this endpoint to resend your invitation email for a user to join a team. ** +** This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if he didn't accept it. ** ### Parameters @@ -140,28 +125,4 @@ POST https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId}/resend | --- | --- | --- | --- | | teamId | string | **Required** Team unique ID. | | | inviteId | string | **Required** Invite unique ID. | | -| redirect | string | Reset page to redirect user back to your app from the invitation email. | | - -## Update Team Membership Status - -```http request -PATCH https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId}/status -``` - -** Use this endpoint to let user accept an invitation to join a team after he is being redirect back to your app from the invitation email. Use the success and failure URL's to redirect users back to your application after the request completes. - -Please notice that in order to avoid a [Redirect Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URL's are the once from domains you have set when added your platforms in the console interface. - -When not using the success or failure redirect arguments this endpoint will result with a 200 status code on success and with 401 status error on failure. This behavior was applied to help the web clients deal with browsers who don't allow to set 3rd party HTTP cookies needed for saving the account session token. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| teamId | string | **Required** Team unique ID. | | -| inviteId | string | **Required** Invite unique ID | | -| userId | string | User unique ID | | -| secret | string | Secret Key | | -| success | string | Redirect when registration succeed | | -| failure | string | Redirect when registration failed | | diff --git a/app/sdks/php/docs/users.md b/app/sdks/php/docs/users.md index fedcd71d54..fe68614cab 100644 --- a/app/sdks/php/docs/users.md +++ b/app/sdks/php/docs/users.md @@ -29,9 +29,9 @@ POST https://appwrite.io/v1/users | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| email | string | User account email. | | -| password | string | User account password. | | -| name | string | User account name. | | +| email | string | User email. | | +| password | string | User password. | | +| name | string | User name. | | ## Get User @@ -61,7 +61,7 @@ GET https://appwrite.io/v1/users/{userId}/logs | --- | --- | --- | --- | | userId | string | **Required** User unique ID. | | -## Get User Prefs +## Get User Preferences ```http request GET https://appwrite.io/v1/users/{userId}/prefs @@ -75,7 +75,7 @@ GET https://appwrite.io/v1/users/{userId}/prefs | --- | --- | --- | --- | | userId | string | **Required** User unique ID. | | -## Update User Prefs +## Update User Preferences ```http request PATCH https://appwrite.io/v1/users/{userId}/prefs @@ -88,7 +88,7 @@ PATCH https://appwrite.io/v1/users/{userId}/prefs | Field Name | Type | Description | Default | | --- | --- | --- | --- | | userId | string | **Required** User unique ID. | | -| prefs | string | Prefs key-value JSON object string. | | +| prefs | object | Prefs key-value JSON object. | | ## Get User Sessions diff --git a/app/sdks/php/src/Appwrite/Client.php b/app/sdks/php/src/Appwrite/Client.php index 360a6d614f..4d97c8f946 100644 --- a/app/sdks/php/src/Appwrite/Client.php +++ b/app/sdks/php/src/Appwrite/Client.php @@ -50,7 +50,7 @@ class Client /** * Set Project * - * Your Appwrite project ID + * Your project ID * * @param string $value * @@ -66,7 +66,7 @@ class Client /** * Set Key * - * Your Appwrite project secret key + * Your secret API key * * @param string $value * @@ -185,6 +185,7 @@ class Client curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, php_uname('s') . '-' . php_uname('r') . ':php-' . phpversion()); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$responseHeaders) { $len = strlen($header); $header = explode(':', strtolower($header), 2); diff --git a/app/sdks/php/src/Appwrite/Services/Account.php b/app/sdks/php/src/Appwrite/Services/Account.php deleted file mode 100644 index d56ea4c941..0000000000 --- a/app/sdks/php/src/Appwrite/Services/Account.php +++ /dev/null @@ -1,205 +0,0 @@ -client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @throws Exception - * @return array - */ - public function delete():array - { - $path = str_replace([], [], '/account'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Account Email - * - * Update currently logged in user account email address. After changing user - * address, user confirmation status is being reset and a new confirmation - * mail is sent. For security measures, user password is required to complete - * this request. - * - * @param string $email - * @param string $password - * @throws Exception - * @return array - */ - public function updateEmail(string $email, string $password):array - { - $path = str_replace([], [], '/account/email'); - $params = []; - - $params['email'] = $email; - $params['password'] = $password; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Account Name - * - * Update currently logged in user account name. - * - * @param string $name - * @throws Exception - * @return array - */ - public function updateName(string $name):array - { - $path = str_replace([], [], '/account/name'); - $params = []; - - $params['name'] = $name; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Account Password - * - * Update currently logged in user password. For validation, user is required - * to pass the password twice. - * - * @param string $password - * @param string $oldPassword - * @throws Exception - * @return array - */ - public function updatePassword(string $password, string $oldPassword):array - { - $path = str_replace([], [], '/account/password'); - $params = []; - - $params['password'] = $password; - $params['old-password'] = $oldPassword; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Account Preferences - * - * Get currently logged in user preferences key-value object. - * - * @throws Exception - * @return array - */ - public function getPrefs():array - { - $path = str_replace([], [], '/account/prefs'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Account Prefs - * - * Update currently logged in user account preferences. You can pass only the - * specific settings you wish to update. - * - * @param string $prefs - * @throws Exception - * @return array - */ - public function updatePrefs(string $prefs):array - { - $path = str_replace([], [], '/account/prefs'); - $params = []; - - $params['prefs'] = $prefs; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Account Security Log - * - * Get currently logged in user list of latest security activity logs. Each - * log returns user IP address, location and date and time of log. - * - * @throws Exception - * @return array - */ - public function getSecurity():array - { - $path = str_replace([], [], '/account/security'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Account Active Sessions - * - * Get currently logged in user list of active sessions across different - * devices. - * - * @throws Exception - * @return array - */ - public function getSessions():array - { - $path = str_replace([], [], '/account/sessions'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/php/src/Appwrite/Services/Auth.php b/app/sdks/php/src/Appwrite/Services/Auth.php deleted file mode 100644 index 31a48ebebd..0000000000 --- a/app/sdks/php/src/Appwrite/Services/Auth.php +++ /dev/null @@ -1,288 +0,0 @@ -client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Login with OAuth - * - * Allow the user to login to his account using the OAuth provider of his - * choice. Each OAuth provider should be enabled from the Appwrite console - * first. Use the success and failure arguments to provide a redirect URL's - * back to your app when login is completed. - * - * @param string $provider - * @param string $success - * @param string $failure - * @throws Exception - * @return array - */ - public function oauth(string $provider, string $success, string $failure):array - { - $path = str_replace(['{provider}'], [$provider], '/auth/login/oauth/{provider}'); - $params = []; - - $params['success'] = $success; - $params['failure'] = $failure; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Logout Current Session - * - * Use this endpoint to log out the currently logged in user from his account. - * When successful this endpoint will delete the user session and remove the - * session secret cookie from the user client. - * - * @throws Exception - * @return array - */ - public function logout():array - { - $path = str_replace([], [], '/auth/logout'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Logout Specific Session - * - * Use this endpoint to log out the currently logged in user from all his - * account sessions across all his different devices. When using the option id - * argument, only the session unique ID provider will be deleted. - * - * @param string $id - * @throws Exception - * @return array - */ - public function logoutBySession(string $id):array - { - $path = str_replace(['{id}'], [$id], '/auth/logout/{id}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Password Recovery - * - * Sends the user an email with a temporary secret token for password reset. - * When the user clicks the confirmation link he is redirected back to your - * app password reset redirect URL with a secret token and email address - * values attached to the URL query string. Use the query string params to - * submit a request to the /auth/password/reset endpoint to complete the - * process. - * - * @param string $email - * @param string $reset - * @throws Exception - * @return array - */ - public function recovery(string $email, string $reset):array - { - $path = str_replace([], [], '/auth/recovery'); - $params = []; - - $params['email'] = $email; - $params['reset'] = $reset; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Password Reset - * - * Use this endpoint to complete the user account password reset. Both the - * **userId** and **token** arguments will be passed as query parameters to - * the redirect URL you have provided when sending your request to the - * /auth/recovery endpoint. - * - * Please notice that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * - * @param string $userId - * @param string $token - * @param string $passwordA - * @param string $passwordB - * @throws Exception - * @return array - */ - public function recoveryReset(string $userId, string $token, string $passwordA, string $passwordB):array - { - $path = str_replace([], [], '/auth/recovery/reset'); - $params = []; - - $params['userId'] = $userId; - $params['token'] = $token; - $params['password-a'] = $passwordA; - $params['password-b'] = $passwordB; - - return $this->client->call(Client::METHOD_PUT, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Register - * - * Use this endpoint to allow a new user to register an account in your - * project. Use the success and failure URLs to redirect users back to your - * application after signup completes. - * - * If registration completes successfully user will be sent with a - * confirmation email in order to confirm he is the owner of the account email - * address. Use the confirmation parameter to redirect the user from the - * confirmation email back to your app. When the user is redirected, use the - * /auth/confirm endpoint to complete the account confirmation. - * - * Please notice that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * - * When accessing this route using Javascript from the browser, success and - * failure parameter URLs are required. Appwrite server will respond with a - * 301 redirect status code and will set the user session cookie. This - * behavior is enforced because modern browsers are limiting 3rd party cookies - * in XHR of fetch requests to protect user privacy. - * - * @param string $email - * @param string $password - * @param string $confirm - * @param string $success - * @param string $failure - * @param string $name - * @throws Exception - * @return array - */ - public function register(string $email, string $password, string $confirm, string $success = '', string $failure = '', string $name = ''):array - { - $path = str_replace([], [], '/auth/register'); - $params = []; - - $params['email'] = $email; - $params['password'] = $password; - $params['confirm'] = $confirm; - $params['success'] = $success; - $params['failure'] = $failure; - $params['name'] = $name; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Confirmation - * - * Use this endpoint to complete the confirmation of the user account email - * address. Both the **userId** and **token** arguments will be passed as - * query parameters to the redirect URL you have provided when sending your - * request to the /auth/register endpoint. - * - * @param string $userId - * @param string $token - * @throws Exception - * @return array - */ - public function confirm(string $userId, string $token):array - { - $path = str_replace([], [], '/auth/register/confirm'); - $params = []; - - $params['userId'] = $userId; - $params['token'] = $token; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Resend Confirmation - * - * This endpoint allows the user to request your app to resend him his email - * confirmation message. The redirect arguments act the same way as in - * /auth/register endpoint. - * - * Please notice that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * - * @param string $confirm - * @throws Exception - * @return array - */ - public function confirmResend(string $confirm):array - { - $path = str_replace([], [], '/auth/register/confirm/resend'); - $params = []; - - $params['confirm'] = $confirm; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/php/src/Appwrite/Services/Database.php b/app/sdks/php/src/Appwrite/Services/Database.php index 3621a5c4b2..9cec81bc33 100644 --- a/app/sdks/php/src/Appwrite/Services/Database.php +++ b/app/sdks/php/src/Appwrite/Services/Database.php @@ -25,7 +25,7 @@ class Database extends Service */ public function listCollections(string $search = '', int $limit = 25, int $offset = 0, string $orderType = 'ASC'):array { - $path = str_replace([], [], '/database'); + $path = str_replace([], [], '/database/collections'); $params = []; $params['search'] = $search; @@ -52,7 +52,7 @@ class Database extends Service */ public function createCollection(string $name, array $read, array $write, array $rules):array { - $path = str_replace([], [], '/database'); + $path = str_replace([], [], '/database/collections'); $params = []; $params['name'] = $name; @@ -77,7 +77,7 @@ class Database extends Service */ public function getCollection(string $collectionId):array { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/{collectionId}'); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}'); $params = []; @@ -101,7 +101,7 @@ class Database extends Service */ public function updateCollection(string $collectionId, string $name, array $read, array $write, array $rules = []):array { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/{collectionId}'); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}'); $params = []; $params['name'] = $name; @@ -126,7 +126,7 @@ class Database extends Service */ public function deleteCollection(string $collectionId):array { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/{collectionId}'); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}'); $params = []; @@ -158,7 +158,7 @@ class Database extends Service */ public function listDocuments(string $collectionId, array $filters = [], int $offset = 0, int $limit = 50, string $orderField = '$uid', string $orderType = 'ASC', string $orderCast = 'string', string $search = '', int $first = 0, int $last = 0):array { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/{collectionId}/documents'); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/documents'); $params = []; $params['filters'] = $filters; @@ -182,7 +182,7 @@ class Database extends Service * Create a new Document. * * @param string $collectionId - * @param string $data + * @param array $data * @param array $read * @param array $write * @param string $parentDocument @@ -191,9 +191,9 @@ class Database extends Service * @throws Exception * @return array */ - public function createDocument(string $collectionId, string $data, array $read, array $write, string $parentDocument = '', string $parentProperty = '', string $parentPropertyType = 'assign'):array + public function createDocument(string $collectionId, array $data, array $read, array $write, string $parentDocument = '', string $parentProperty = '', string $parentPropertyType = 'assign'):array { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/{collectionId}/documents'); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/documents'); $params = []; $params['data'] = $data; @@ -221,7 +221,7 @@ class Database extends Service */ public function getDocument(string $collectionId, string $documentId):array { - $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/{collectionId}/documents/{documentId}'); + $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/collections/{collectionId}/documents/{documentId}'); $params = []; @@ -235,15 +235,15 @@ class Database extends Service * * @param string $collectionId * @param string $documentId - * @param string $data + * @param array $data * @param array $read * @param array $write * @throws Exception * @return array */ - public function updateDocument(string $collectionId, string $documentId, string $data, array $read, array $write):array + public function updateDocument(string $collectionId, string $documentId, array $data, array $read, array $write):array { - $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/{collectionId}/documents/{documentId}'); + $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/collections/{collectionId}/documents/{documentId}'); $params = []; $params['data'] = $data; @@ -269,7 +269,7 @@ class Database extends Service */ public function deleteDocument(string $collectionId, string $documentId):array { - $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/{collectionId}/documents/{documentId}'); + $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/collections/{collectionId}/documents/{documentId}'); $params = []; diff --git a/app/sdks/php/src/Appwrite/Services/Locale.php b/app/sdks/php/src/Appwrite/Services/Locale.php index fafeabc7fd..4cb95fa97a 100644 --- a/app/sdks/php/src/Appwrite/Services/Locale.php +++ b/app/sdks/php/src/Appwrite/Services/Locale.php @@ -15,11 +15,13 @@ class Locale extends Service * country code, country name, continent name, continent code, ip address and * suggested currency. You can use the locale header to get the data in a * supported language. + * + * ([IP Geolocation by DB-IP](https://db-ip.com)) * * @throws Exception * @return array */ - public function getLocale():array + public function get():array { $path = str_replace([], [], '/locale'); $params = []; @@ -74,8 +76,7 @@ class Locale extends Service * List EU Countries * * List of all countries that are currently members of the EU. You can use the - * locale header to get the data in a supported language. UK brexit date is - * currently set to 2019-10-31 and will be updated if and when needed. + * locale header to get the data in a supported language. * * @throws Exception * @return array diff --git a/app/sdks/php/src/Appwrite/Services/Projects.php b/app/sdks/php/src/Appwrite/Services/Projects.php deleted file mode 100644 index 701c3cc523..0000000000 --- a/app/sdks/php/src/Appwrite/Services/Projects.php +++ /dev/null @@ -1,641 +0,0 @@ -client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Create Project - * - * @param string $name - * @param string $teamId - * @param string $description - * @param string $logo - * @param string $url - * @param string $legalName - * @param string $legalCountry - * @param string $legalState - * @param string $legalCity - * @param string $legalAddress - * @param string $legalTaxId - * @throws Exception - * @return array - */ - public function createProject(string $name, string $teamId, string $description = '', string $logo = '', string $url = '', string $legalName = '', string $legalCountry = '', string $legalState = '', string $legalCity = '', string $legalAddress = '', string $legalTaxId = ''):array - { - $path = str_replace([], [], '/projects'); - $params = []; - - $params['name'] = $name; - $params['teamId'] = $teamId; - $params['description'] = $description; - $params['logo'] = $logo; - $params['url'] = $url; - $params['legalName'] = $legalName; - $params['legalCountry'] = $legalCountry; - $params['legalState'] = $legalState; - $params['legalCity'] = $legalCity; - $params['legalAddress'] = $legalAddress; - $params['legalTaxId'] = $legalTaxId; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Project - * - * @param string $projectId - * @throws Exception - * @return array - */ - public function getProject(string $projectId):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Project - * - * @param string $projectId - * @param string $name - * @param string $description - * @param string $logo - * @param string $url - * @param string $legalName - * @param string $legalCountry - * @param string $legalState - * @param string $legalCity - * @param string $legalAddress - * @param string $legalTaxId - * @throws Exception - * @return array - */ - public function updateProject(string $projectId, string $name, string $description = '', string $logo = '', string $url = '', string $legalName = '', string $legalCountry = '', string $legalState = '', string $legalCity = '', string $legalAddress = '', string $legalTaxId = ''):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}'); - $params = []; - - $params['name'] = $name; - $params['description'] = $description; - $params['logo'] = $logo; - $params['url'] = $url; - $params['legalName'] = $legalName; - $params['legalCountry'] = $legalCountry; - $params['legalState'] = $legalState; - $params['legalCity'] = $legalCity; - $params['legalAddress'] = $legalAddress; - $params['legalTaxId'] = $legalTaxId; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Delete Project - * - * @param string $projectId - * @throws Exception - * @return array - */ - public function deleteProject(string $projectId):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * List Keys - * - * @param string $projectId - * @throws Exception - * @return array - */ - public function listKeys(string $projectId):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/keys'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Create Key - * - * @param string $projectId - * @param string $name - * @param array $scopes - * @throws Exception - * @return array - */ - public function createKey(string $projectId, string $name, array $scopes):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/keys'); - $params = []; - - $params['name'] = $name; - $params['scopes'] = $scopes; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Key - * - * @param string $projectId - * @param string $keyId - * @throws Exception - * @return array - */ - public function getKey(string $projectId, string $keyId):array - { - $path = str_replace(['{projectId}', '{keyId}'], [$projectId, $keyId], '/projects/{projectId}/keys/{keyId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Key - * - * @param string $projectId - * @param string $keyId - * @param string $name - * @param array $scopes - * @throws Exception - * @return array - */ - public function updateKey(string $projectId, string $keyId, string $name, array $scopes):array - { - $path = str_replace(['{projectId}', '{keyId}'], [$projectId, $keyId], '/projects/{projectId}/keys/{keyId}'); - $params = []; - - $params['name'] = $name; - $params['scopes'] = $scopes; - - return $this->client->call(Client::METHOD_PUT, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Delete Key - * - * @param string $projectId - * @param string $keyId - * @throws Exception - * @return array - */ - public function deleteKey(string $projectId, string $keyId):array - { - $path = str_replace(['{projectId}', '{keyId}'], [$projectId, $keyId], '/projects/{projectId}/keys/{keyId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Project OAuth - * - * @param string $projectId - * @param string $provider - * @param string $appId - * @param string $secret - * @throws Exception - * @return array - */ - public function updateProjectOAuth(string $projectId, string $provider, string $appId = '', string $secret = ''):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/oauth'); - $params = []; - - $params['provider'] = $provider; - $params['appId'] = $appId; - $params['secret'] = $secret; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * List Platforms - * - * @param string $projectId - * @throws Exception - * @return array - */ - public function listPlatforms(string $projectId):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/platforms'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Create Platform - * - * @param string $projectId - * @param string $type - * @param string $name - * @param string $key - * @param string $store - * @param string $url - * @throws Exception - * @return array - */ - public function createPlatform(string $projectId, string $type, string $name, string $key = '', string $store = '', string $url = ''):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/platforms'); - $params = []; - - $params['type'] = $type; - $params['name'] = $name; - $params['key'] = $key; - $params['store'] = $store; - $params['url'] = $url; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Platform - * - * @param string $projectId - * @param string $platformId - * @throws Exception - * @return array - */ - public function getPlatform(string $projectId, string $platformId):array - { - $path = str_replace(['{projectId}', '{platformId}'], [$projectId, $platformId], '/projects/{projectId}/platforms/{platformId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Platform - * - * @param string $projectId - * @param string $platformId - * @param string $name - * @param string $key - * @param string $store - * @param string $url - * @throws Exception - * @return array - */ - public function updatePlatform(string $projectId, string $platformId, string $name, string $key = '', string $store = '', string $url = ''):array - { - $path = str_replace(['{projectId}', '{platformId}'], [$projectId, $platformId], '/projects/{projectId}/platforms/{platformId}'); - $params = []; - - $params['name'] = $name; - $params['key'] = $key; - $params['store'] = $store; - $params['url'] = $url; - - return $this->client->call(Client::METHOD_PUT, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Delete Platform - * - * @param string $projectId - * @param string $platformId - * @throws Exception - * @return array - */ - public function deletePlatform(string $projectId, string $platformId):array - { - $path = str_replace(['{projectId}', '{platformId}'], [$projectId, $platformId], '/projects/{projectId}/platforms/{platformId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * List Tasks - * - * @param string $projectId - * @throws Exception - * @return array - */ - public function listTasks(string $projectId):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/tasks'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Create Task - * - * @param string $projectId - * @param string $name - * @param string $status - * @param string $schedule - * @param int $security - * @param string $httpMethod - * @param string $httpUrl - * @param array $httpHeaders - * @param string $httpUser - * @param string $httpPass - * @throws Exception - * @return array - */ - public function createTask(string $projectId, string $name, string $status, string $schedule, int $security, string $httpMethod, string $httpUrl, array $httpHeaders = [], string $httpUser = '', string $httpPass = ''):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/tasks'); - $params = []; - - $params['name'] = $name; - $params['status'] = $status; - $params['schedule'] = $schedule; - $params['security'] = $security; - $params['httpMethod'] = $httpMethod; - $params['httpUrl'] = $httpUrl; - $params['httpHeaders'] = $httpHeaders; - $params['httpUser'] = $httpUser; - $params['httpPass'] = $httpPass; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Task - * - * @param string $projectId - * @param string $taskId - * @throws Exception - * @return array - */ - public function getTask(string $projectId, string $taskId):array - { - $path = str_replace(['{projectId}', '{taskId}'], [$projectId, $taskId], '/projects/{projectId}/tasks/{taskId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Task - * - * @param string $projectId - * @param string $taskId - * @param string $name - * @param string $status - * @param string $schedule - * @param int $security - * @param string $httpMethod - * @param string $httpUrl - * @param array $httpHeaders - * @param string $httpUser - * @param string $httpPass - * @throws Exception - * @return array - */ - public function updateTask(string $projectId, string $taskId, string $name, string $status, string $schedule, int $security, string $httpMethod, string $httpUrl, array $httpHeaders = [], string $httpUser = '', string $httpPass = ''):array - { - $path = str_replace(['{projectId}', '{taskId}'], [$projectId, $taskId], '/projects/{projectId}/tasks/{taskId}'); - $params = []; - - $params['name'] = $name; - $params['status'] = $status; - $params['schedule'] = $schedule; - $params['security'] = $security; - $params['httpMethod'] = $httpMethod; - $params['httpUrl'] = $httpUrl; - $params['httpHeaders'] = $httpHeaders; - $params['httpUser'] = $httpUser; - $params['httpPass'] = $httpPass; - - return $this->client->call(Client::METHOD_PUT, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Delete Task - * - * @param string $projectId - * @param string $taskId - * @throws Exception - * @return array - */ - public function deleteTask(string $projectId, string $taskId):array - { - $path = str_replace(['{projectId}', '{taskId}'], [$projectId, $taskId], '/projects/{projectId}/tasks/{taskId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Project - * - * @param string $projectId - * @throws Exception - * @return array - */ - public function getProjectUsage(string $projectId):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/usage'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * List Webhooks - * - * @param string $projectId - * @throws Exception - * @return array - */ - public function listWebhooks(string $projectId):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/webhooks'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Create Webhook - * - * @param string $projectId - * @param string $name - * @param array $events - * @param string $url - * @param int $security - * @param string $httpUser - * @param string $httpPass - * @throws Exception - * @return array - */ - public function createWebhook(string $projectId, string $name, array $events, string $url, int $security, string $httpUser = '', string $httpPass = ''):array - { - $path = str_replace(['{projectId}'], [$projectId], '/projects/{projectId}/webhooks'); - $params = []; - - $params['name'] = $name; - $params['events'] = $events; - $params['url'] = $url; - $params['security'] = $security; - $params['httpUser'] = $httpUser; - $params['httpPass'] = $httpPass; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Webhook - * - * @param string $projectId - * @param string $webhookId - * @throws Exception - * @return array - */ - public function getWebhook(string $projectId, string $webhookId):array - { - $path = str_replace(['{projectId}', '{webhookId}'], [$projectId, $webhookId], '/projects/{projectId}/webhooks/{webhookId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Webhook - * - * @param string $projectId - * @param string $webhookId - * @param string $name - * @param array $events - * @param string $url - * @param int $security - * @param string $httpUser - * @param string $httpPass - * @throws Exception - * @return array - */ - public function updateWebhook(string $projectId, string $webhookId, string $name, array $events, string $url, int $security, string $httpUser = '', string $httpPass = ''):array - { - $path = str_replace(['{projectId}', '{webhookId}'], [$projectId, $webhookId], '/projects/{projectId}/webhooks/{webhookId}'); - $params = []; - - $params['name'] = $name; - $params['events'] = $events; - $params['url'] = $url; - $params['security'] = $security; - $params['httpUser'] = $httpUser; - $params['httpPass'] = $httpPass; - - return $this->client->call(Client::METHOD_PUT, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Delete Webhook - * - * @param string $projectId - * @param string $webhookId - * @throws Exception - * @return array - */ - public function deleteWebhook(string $projectId, string $webhookId):array - { - $path = str_replace(['{projectId}', '{webhookId}'], [$projectId, $webhookId], '/projects/{projectId}/webhooks/{webhookId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/php/src/Appwrite/Services/Storage.php b/app/sdks/php/src/Appwrite/Services/Storage.php index 37b0117d60..09b74fbf8f 100644 --- a/app/sdks/php/src/Appwrite/Services/Storage.php +++ b/app/sdks/php/src/Appwrite/Services/Storage.php @@ -44,18 +44,18 @@ class Storage extends Service * assigned to read and write access unless he has passed custom values for * read and write arguments. * - * @param \CurlFile $files + * @param \CurlFile $file * @param array $read * @param array $write * @throws Exception * @return array */ - public function createFile(\CurlFile $files, array $read, array $write):array + public function createFile(\CurlFile $file, array $read, array $write):array { $path = str_replace([], [], '/storage/files'); $params = []; - $params['files'] = $files; + $params['file'] = $file; $params['read'] = $read; $params['write'] = $write; @@ -156,9 +156,9 @@ class Storage extends Service /** * Get File Preview * - * Get file preview image. Currently, this method supports preview for image + * Get a file preview image. Currently, this method supports preview for image * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets will return file icon image. You can also pass query + * and spreadsheets, will return the file icon image. You can also pass query * string arguments for cutting and resizing your preview image. * * @param string $fileId diff --git a/app/sdks/php/src/Appwrite/Services/Teams.php b/app/sdks/php/src/Appwrite/Services/Teams.php index 4109aef893..7ef2240ab7 100644 --- a/app/sdks/php/src/Appwrite/Services/Teams.php +++ b/app/sdks/php/src/Appwrite/Services/Teams.php @@ -22,7 +22,7 @@ class Teams extends Service * @throws Exception * @return array */ - public function listTeams(string $search = '', int $limit = 25, int $offset = 0, string $orderType = 'ASC'):array + public function list(string $search = '', int $limit = 25, int $offset = 0, string $orderType = 'ASC'):array { $path = str_replace([], [], '/teams'); $params = []; @@ -50,7 +50,7 @@ class Teams extends Service * @throws Exception * @return array */ - public function createTeam(string $name, array $roles = ["owner"]):array + public function create(string $name, array $roles = ["owner"]):array { $path = str_replace([], [], '/teams'); $params = []; @@ -73,7 +73,7 @@ class Teams extends Service * @throws Exception * @return array */ - public function getTeam(string $teamId):array + public function get(string $teamId):array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); $params = []; @@ -95,7 +95,7 @@ class Teams extends Service * @throws Exception * @return array */ - public function updateTeam(string $teamId, string $name):array + public function update(string $teamId, string $name):array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); $params = []; @@ -117,7 +117,7 @@ class Teams extends Service * @throws Exception * @return array */ - public function deleteTeam(string $teamId):array + public function delete(string $teamId):array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); $params = []; @@ -129,7 +129,7 @@ class Teams extends Service } /** - * Get Team Members + * Get Team Memberships * * Get team members by the team unique ID. All team members have read access * for this list of resources. @@ -138,9 +138,9 @@ class Teams extends Service * @throws Exception * @return array */ - public function getTeamMembers(string $teamId):array + public function getMemberships(string $teamId):array { - $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/members'); + $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); $params = []; @@ -152,16 +152,16 @@ class Teams extends Service /** * Create Team Membership * - * Use this endpoint to invite a new member to your team. An email with a link - * to join the team will be sent to the new member email address. If member - * doesn't exists in the project it will be automatically created. + * Use this endpoint to invite a new member to join your team. An email with a + * link to join the team will be sent to the new member email address if the + * member doesn't exist in the project it will be created automatically. * - * Use the redirect parameter to redirect the user from the invitation email - * back to your app. When the user is redirected, use the - * /teams/{teamId}/memberships/{inviteId}/status endpoint to finally join the - * user to the team. + * Use the 'URL' parameter to redirect the user from the invitation email back + * to your app. When the user is redirected, use the [Update Team Membership + * Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to + * accept the invitation to the team. * - * Please notice that in order to avoid a [Redirect + * Please note that in order to avoid a [Redirect * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) * the only valid redirect URL's are the once from domains you have set when * added your platforms in the console interface. @@ -169,12 +169,12 @@ class Teams extends Service * @param string $teamId * @param string $email * @param array $roles - * @param string $redirect + * @param string $url * @param string $name * @throws Exception * @return array */ - public function createTeamMembership(string $teamId, string $email, array $roles, string $redirect, string $name = ''):array + public function createMembership(string $teamId, string $email, array $roles, string $url, string $name = ''):array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); $params = []; @@ -182,7 +182,7 @@ class Teams extends Service $params['email'] = $email; $params['name'] = $name; $params['roles'] = $roles; - $params['redirect'] = $redirect; + $params['url'] = $url; return $this->client->call(Client::METHOD_POST, $path, [ 'content-type' => 'application/json', @@ -193,14 +193,15 @@ class Teams extends Service * Delete Team Membership * * This endpoint allows a user to leave a team or for a team owner to delete - * the membership of any other team member. + * the membership of any other team member. You can also use this endpoint to + * delete a user membership even if he didn't accept it. * * @param string $teamId * @param string $inviteId * @throws Exception * @return array */ - public function deleteTeamMembership(string $teamId, string $inviteId):array + public function deleteMembership(string $teamId, string $inviteId):array { $path = str_replace(['{teamId}', '{inviteId}'], [$teamId, $inviteId], '/teams/{teamId}/memberships/{inviteId}'); $params = []; @@ -211,71 +212,4 @@ class Teams extends Service ], $params); } - /** - * Create Team Membership (Resend) - * - * Use this endpoint to resend your invitation email for a user to join a - * team. - * - * @param string $teamId - * @param string $inviteId - * @param string $redirect - * @throws Exception - * @return array - */ - public function createTeamMembershipResend(string $teamId, string $inviteId, string $redirect):array - { - $path = str_replace(['{teamId}', '{inviteId}'], [$teamId, $inviteId], '/teams/{teamId}/memberships/{inviteId}/resend'); - $params = []; - - $params['redirect'] = $redirect; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Team Membership Status - * - * Use this endpoint to let user accept an invitation to join a team after he - * is being redirect back to your app from the invitation email. Use the - * success and failure URL's to redirect users back to your application after - * the request completes. - * - * Please notice that in order to avoid a [Redirect - * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URL's are the once from domains you have set when - * added your platforms in the console interface. - * - * When not using the success or failure redirect arguments this endpoint will - * result with a 200 status code on success and with 401 status error on - * failure. This behavior was applied to help the web clients deal with - * browsers who don't allow to set 3rd party HTTP cookies needed for saving - * the account session token. - * - * @param string $teamId - * @param string $inviteId - * @param string $userId - * @param string $secret - * @param string $success - * @param string $failure - * @throws Exception - * @return array - */ - public function updateTeamMembershipStatus(string $teamId, string $inviteId, string $userId, string $secret, string $success = '', string $failure = ''):array - { - $path = str_replace(['{teamId}', '{inviteId}'], [$teamId, $inviteId], '/teams/{teamId}/memberships/{inviteId}/status'); - $params = []; - - $params['userId'] = $userId; - $params['secret'] = $secret; - $params['success'] = $success; - $params['failure'] = $failure; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - } \ No newline at end of file diff --git a/app/sdks/php/src/Appwrite/Services/Users.php b/app/sdks/php/src/Appwrite/Services/Users.php index aca2a1edb1..89189b0d63 100644 --- a/app/sdks/php/src/Appwrite/Services/Users.php +++ b/app/sdks/php/src/Appwrite/Services/Users.php @@ -21,7 +21,7 @@ class Users extends Service * @throws Exception * @return array */ - public function listUsers(string $search = '', int $limit = 25, int $offset = 0, string $orderType = 'ASC'):array + public function list(string $search = '', int $limit = 25, int $offset = 0, string $orderType = 'ASC'):array { $path = str_replace([], [], '/users'); $params = []; @@ -47,7 +47,7 @@ class Users extends Service * @throws Exception * @return array */ - public function createUser(string $email, string $password, string $name = ''):array + public function create(string $email, string $password, string $name = ''):array { $path = str_replace([], [], '/users'); $params = []; @@ -70,7 +70,7 @@ class Users extends Service * @throws Exception * @return array */ - public function getUser(string $userId):array + public function get(string $userId):array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}'); $params = []; @@ -90,7 +90,7 @@ class Users extends Service * @throws Exception * @return array */ - public function getUserLogs(string $userId):array + public function getLogs(string $userId):array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/logs'); $params = []; @@ -102,7 +102,7 @@ class Users extends Service } /** - * Get User Prefs + * Get User Preferences * * Get user preferences by its unique ID. * @@ -110,7 +110,7 @@ class Users extends Service * @throws Exception * @return array */ - public function getUserPrefs(string $userId):array + public function getPrefs(string $userId):array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); $params = []; @@ -122,17 +122,17 @@ class Users extends Service } /** - * Update User Prefs + * Update User Preferences * * Update user preferences by its unique ID. You can pass only the specific * settings you wish to update. * * @param string $userId - * @param string $prefs + * @param array $prefs * @throws Exception * @return array */ - public function updateUserPrefs(string $userId, string $prefs):array + public function updatePrefs(string $userId, array $prefs):array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); $params = []; @@ -153,7 +153,7 @@ class Users extends Service * @throws Exception * @return array */ - public function getUserSessions(string $userId):array + public function getSessions(string $userId):array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); $params = []; @@ -173,7 +173,7 @@ class Users extends Service * @throws Exception * @return array */ - public function deleteUserSessions(string $userId):array + public function deleteSessions(string $userId):array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); $params = []; @@ -194,7 +194,7 @@ class Users extends Service * @throws Exception * @return array */ - public function deleteUserSession(string $userId, string $sessionId):array + public function deleteSession(string $userId, string $sessionId):array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions/:session'); $params = []; @@ -216,7 +216,7 @@ class Users extends Service * @throws Exception * @return array */ - public function updateUserStatus(string $userId, string $status):array + public function updateStatus(string $userId, string $status):array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/status'); $params = []; diff --git a/app/sdks/python/README.md b/app/sdks/python/README.md index 0d388a4486..84ad580d4d 100644 --- a/app/sdks/python/README.md +++ b/app/sdks/python/README.md @@ -1,9 +1,9 @@ # Appwrite SDK for Python ![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1) -**WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).** +**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.** Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/python/appwrite/client.py b/app/sdks/python/appwrite/client.py index 7fbadfaff4..083adf1564 100644 --- a/app/sdks/python/appwrite/client.py +++ b/app/sdks/python/appwrite/client.py @@ -23,13 +23,13 @@ class Client: return self def set_project(self, value): - """Your Appwrite project ID""" + """Your project ID""" self._global_headers['x-appwrite-project'] = value.lower() return self def set_key(self, value): - """Your Appwrite project secret key""" + """Your secret API key""" self._global_headers['x-appwrite-key'] = value.lower() return self @@ -73,5 +73,11 @@ class Client: ) response.raise_for_status() - - return response.json() + + content_type = response.headers['Content-Type'] + + if content_type.startswith('application/json'): + return response.json() + + return response._content + diff --git a/app/sdks/python/appwrite/services/account.py b/app/sdks/python/appwrite/services/account.py deleted file mode 100644 index 4b38e4a824..0000000000 --- a/app/sdks/python/appwrite/services/account.py +++ /dev/null @@ -1,103 +0,0 @@ -from ..service import Service - - -class Account(Service): - - def __init__(self, client): - super(Account, self).__init__(client) - - def get(self): - """Get Account""" - - params = {} - path = '/account' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def delete(self): - """Delete Account""" - - params = {} - path = '/account' - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def update_email(self, email, password): - """Update Account Email""" - - params = {} - path = '/account/email' - params['email'] = email - params['password'] = password - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - - def update_name(self, name): - """Update Account Name""" - - params = {} - path = '/account/name' - params['name'] = name - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - - def update_password(self, password, old_password): - """Update Account Password""" - - params = {} - path = '/account/password' - params['password'] = password - params['old-password'] = old_password - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - - def get_prefs(self): - """Get Account Preferences""" - - params = {} - path = '/account/prefs' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_prefs(self, prefs): - """Update Account Prefs""" - - params = {} - path = '/account/prefs' - params['prefs'] = prefs - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - - def get_security(self): - """Get Account Security Log""" - - params = {} - path = '/account/security' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_sessions(self): - """Get Account Active Sessions""" - - params = {} - path = '/account/sessions' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/python/appwrite/services/auth.py b/app/sdks/python/appwrite/services/auth.py deleted file mode 100644 index ff0a894428..0000000000 --- a/app/sdks/python/appwrite/services/auth.py +++ /dev/null @@ -1,120 +0,0 @@ -from ..service import Service - - -class Auth(Service): - - def __init__(self, client): - super(Auth, self).__init__(client) - - def login(self, email, password, success='', failure=''): - """Login""" - - params = {} - path = '/auth/login' - params['email'] = email - params['password'] = password - params['success'] = success - params['failure'] = failure - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def oauth(self, provider, success, failure): - """Login with OAuth""" - - params = {} - path = '/auth/login/oauth/{provider}' - path = path.replace('{provider}', provider) - params['success'] = success - params['failure'] = failure - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def logout(self): - """Logout Current Session""" - - params = {} - path = '/auth/logout' - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def logout_by_session(self, id): - """Logout Specific Session""" - - params = {} - path = '/auth/logout/{id}' - path = path.replace('{id}', id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def recovery(self, email, reset): - """Password Recovery""" - - params = {} - path = '/auth/recovery' - params['email'] = email - params['reset'] = reset - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def recovery_reset(self, user_id, token, password_a, password_b): - """Password Reset""" - - params = {} - path = '/auth/recovery/reset' - params['userId'] = user_id - params['token'] = token - params['password-a'] = password_a - params['password-b'] = password_b - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def register(self, email, password, confirm, success='', failure='', name=''): - """Register""" - - params = {} - path = '/auth/register' - params['email'] = email - params['password'] = password - params['confirm'] = confirm - params['success'] = success - params['failure'] = failure - params['name'] = name - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def confirm(self, user_id, token): - """Confirmation""" - - params = {} - path = '/auth/register/confirm' - params['userId'] = user_id - params['token'] = token - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def confirm_resend(self, confirm): - """Resend Confirmation""" - - params = {} - path = '/auth/register/confirm/resend' - params['confirm'] = confirm - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/python/appwrite/services/database.py b/app/sdks/python/appwrite/services/database.py index 486f5c3299..36d3b68111 100644 --- a/app/sdks/python/appwrite/services/database.py +++ b/app/sdks/python/appwrite/services/database.py @@ -10,7 +10,7 @@ class Database(Service): """List Collections""" params = {} - path = '/database' + path = '/database/collections' params['search'] = search params['limit'] = limit params['offset'] = offset @@ -24,7 +24,7 @@ class Database(Service): """Create Collection""" params = {} - path = '/database' + path = '/database/collections' params['name'] = name params['read'] = read params['write'] = write @@ -38,7 +38,7 @@ class Database(Service): """Get Collection""" params = {} - path = '/database/{collectionId}' + path = '/database/collections/{collectionId}' path = path.replace('{collectionId}', collection_id) return self.client.call('get', path, { @@ -49,7 +49,7 @@ class Database(Service): """Update Collection""" params = {} - path = '/database/{collectionId}' + path = '/database/collections/{collectionId}' path = path.replace('{collectionId}', collection_id) params['name'] = name params['read'] = read @@ -64,7 +64,7 @@ class Database(Service): """Delete Collection""" params = {} - path = '/database/{collectionId}' + path = '/database/collections/{collectionId}' path = path.replace('{collectionId}', collection_id) return self.client.call('delete', path, { @@ -75,7 +75,7 @@ class Database(Service): """List Documents""" params = {} - path = '/database/{collectionId}/documents' + path = '/database/collections/{collectionId}/documents' path = path.replace('{collectionId}', collection_id) params['filters'] = filters params['offset'] = offset @@ -95,7 +95,7 @@ class Database(Service): """Create Document""" params = {} - path = '/database/{collectionId}/documents' + path = '/database/collections/{collectionId}/documents' path = path.replace('{collectionId}', collection_id) params['data'] = data params['read'] = read @@ -112,7 +112,7 @@ class Database(Service): """Get Document""" params = {} - path = '/database/{collectionId}/documents/{documentId}' + path = '/database/collections/{collectionId}/documents/{documentId}' path = path.replace('{collectionId}', collection_id) path = path.replace('{documentId}', document_id) @@ -124,7 +124,7 @@ class Database(Service): """Update Document""" params = {} - path = '/database/{collectionId}/documents/{documentId}' + path = '/database/collections/{collectionId}/documents/{documentId}' path = path.replace('{collectionId}', collection_id) path = path.replace('{documentId}', document_id) params['data'] = data @@ -139,7 +139,7 @@ class Database(Service): """Delete Document""" params = {} - path = '/database/{collectionId}/documents/{documentId}' + path = '/database/collections/{collectionId}/documents/{documentId}' path = path.replace('{collectionId}', collection_id) path = path.replace('{documentId}', document_id) diff --git a/app/sdks/python/appwrite/services/locale.py b/app/sdks/python/appwrite/services/locale.py index 4982618c9b..1c5ad69832 100644 --- a/app/sdks/python/appwrite/services/locale.py +++ b/app/sdks/python/appwrite/services/locale.py @@ -6,7 +6,7 @@ class Locale(Service): def __init__(self, client): super(Locale, self).__init__(client) - def get_locale(self): + def get(self): """Get User Locale""" params = {} diff --git a/app/sdks/python/appwrite/services/projects.py b/app/sdks/python/appwrite/services/projects.py deleted file mode 100644 index 3dea4fbd9b..0000000000 --- a/app/sdks/python/appwrite/services/projects.py +++ /dev/null @@ -1,381 +0,0 @@ -from ..service import Service - - -class Projects(Service): - - def __init__(self, client): - super(Projects, self).__init__(client) - - def list_projects(self): - """List Projects""" - - params = {} - path = '/projects' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_project(self, name, team_id, description='', logo='', url='', legal_name='', legal_country='', legal_state='', legal_city='', legal_address='', legal_tax_id=''): - """Create Project""" - - params = {} - path = '/projects' - params['name'] = name - params['teamId'] = team_id - params['description'] = description - params['logo'] = logo - params['url'] = url - params['legalName'] = legal_name - params['legalCountry'] = legal_country - params['legalState'] = legal_state - params['legalCity'] = legal_city - params['legalAddress'] = legal_address - params['legalTaxId'] = legal_tax_id - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_project(self, project_id): - """Get Project""" - - params = {} - path = '/projects/{projectId}' - path = path.replace('{projectId}', project_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_project(self, project_id, name, description='', logo='', url='', legal_name='', legal_country='', legal_state='', legal_city='', legal_address='', legal_tax_id=''): - """Update Project""" - - params = {} - path = '/projects/{projectId}' - path = path.replace('{projectId}', project_id) - params['name'] = name - params['description'] = description - params['logo'] = logo - params['url'] = url - params['legalName'] = legal_name - params['legalCountry'] = legal_country - params['legalState'] = legal_state - params['legalCity'] = legal_city - params['legalAddress'] = legal_address - params['legalTaxId'] = legal_tax_id - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - - def delete_project(self, project_id): - """Delete Project""" - - params = {} - path = '/projects/{projectId}' - path = path.replace('{projectId}', project_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def list_keys(self, project_id): - """List Keys""" - - params = {} - path = '/projects/{projectId}/keys' - path = path.replace('{projectId}', project_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_key(self, project_id, name, scopes): - """Create Key""" - - params = {} - path = '/projects/{projectId}/keys' - path = path.replace('{projectId}', project_id) - params['name'] = name - params['scopes'] = scopes - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_key(self, project_id, key_id): - """Get Key""" - - params = {} - path = '/projects/{projectId}/keys/{keyId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{keyId}', key_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_key(self, project_id, key_id, name, scopes): - """Update Key""" - - params = {} - path = '/projects/{projectId}/keys/{keyId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{keyId}', key_id) - params['name'] = name - params['scopes'] = scopes - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def delete_key(self, project_id, key_id): - """Delete Key""" - - params = {} - path = '/projects/{projectId}/keys/{keyId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{keyId}', key_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def update_project_o_auth(self, project_id, provider, app_id='', secret=''): - """Update Project OAuth""" - - params = {} - path = '/projects/{projectId}/oauth' - path = path.replace('{projectId}', project_id) - params['provider'] = provider - params['appId'] = app_id - params['secret'] = secret - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - - def list_platforms(self, project_id): - """List Platforms""" - - params = {} - path = '/projects/{projectId}/platforms' - path = path.replace('{projectId}', project_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_platform(self, project_id, type, name, key='', store='', url=''): - """Create Platform""" - - params = {} - path = '/projects/{projectId}/platforms' - path = path.replace('{projectId}', project_id) - params['type'] = type - params['name'] = name - params['key'] = key - params['store'] = store - params['url'] = url - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_platform(self, project_id, platform_id): - """Get Platform""" - - params = {} - path = '/projects/{projectId}/platforms/{platformId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{platformId}', platform_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_platform(self, project_id, platform_id, name, key='', store='', url=''): - """Update Platform""" - - params = {} - path = '/projects/{projectId}/platforms/{platformId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{platformId}', platform_id) - params['name'] = name - params['key'] = key - params['store'] = store - params['url'] = url - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def delete_platform(self, project_id, platform_id): - """Delete Platform""" - - params = {} - path = '/projects/{projectId}/platforms/{platformId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{platformId}', platform_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def list_tasks(self, project_id): - """List Tasks""" - - params = {} - path = '/projects/{projectId}/tasks' - path = path.replace('{projectId}', project_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_task(self, project_id, name, status, schedule, security, http_method, http_url, http_headers={}, http_user='', http_pass=''): - """Create Task""" - - params = {} - path = '/projects/{projectId}/tasks' - path = path.replace('{projectId}', project_id) - params['name'] = name - params['status'] = status - params['schedule'] = schedule - params['security'] = security - params['httpMethod'] = http_method - params['httpUrl'] = http_url - params['httpHeaders'] = http_headers - params['httpUser'] = http_user - params['httpPass'] = http_pass - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_task(self, project_id, task_id): - """Get Task""" - - params = {} - path = '/projects/{projectId}/tasks/{taskId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{taskId}', task_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_task(self, project_id, task_id, name, status, schedule, security, http_method, http_url, http_headers={}, http_user='', http_pass=''): - """Update Task""" - - params = {} - path = '/projects/{projectId}/tasks/{taskId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{taskId}', task_id) - params['name'] = name - params['status'] = status - params['schedule'] = schedule - params['security'] = security - params['httpMethod'] = http_method - params['httpUrl'] = http_url - params['httpHeaders'] = http_headers - params['httpUser'] = http_user - params['httpPass'] = http_pass - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def delete_task(self, project_id, task_id): - """Delete Task""" - - params = {} - path = '/projects/{projectId}/tasks/{taskId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{taskId}', task_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def get_project_usage(self, project_id): - """Get Project""" - - params = {} - path = '/projects/{projectId}/usage' - path = path.replace('{projectId}', project_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def list_webhooks(self, project_id): - """List Webhooks""" - - params = {} - path = '/projects/{projectId}/webhooks' - path = path.replace('{projectId}', project_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_webhook(self, project_id, name, events, url, security, http_user='', http_pass=''): - """Create Webhook""" - - params = {} - path = '/projects/{projectId}/webhooks' - path = path.replace('{projectId}', project_id) - params['name'] = name - params['events'] = events - params['url'] = url - params['security'] = security - params['httpUser'] = http_user - params['httpPass'] = http_pass - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_webhook(self, project_id, webhook_id): - """Get Webhook""" - - params = {} - path = '/projects/{projectId}/webhooks/{webhookId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{webhookId}', webhook_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_webhook(self, project_id, webhook_id, name, events, url, security, http_user='', http_pass=''): - """Update Webhook""" - - params = {} - path = '/projects/{projectId}/webhooks/{webhookId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{webhookId}', webhook_id) - params['name'] = name - params['events'] = events - params['url'] = url - params['security'] = security - params['httpUser'] = http_user - params['httpPass'] = http_pass - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def delete_webhook(self, project_id, webhook_id): - """Delete Webhook""" - - params = {} - path = '/projects/{projectId}/webhooks/{webhookId}' - path = path.replace('{projectId}', project_id) - path = path.replace('{webhookId}', webhook_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/python/appwrite/services/storage.py b/app/sdks/python/appwrite/services/storage.py index 7b8fa23581..7e2a986f6e 100644 --- a/app/sdks/python/appwrite/services/storage.py +++ b/app/sdks/python/appwrite/services/storage.py @@ -20,12 +20,12 @@ class Storage(Service): 'content-type': 'application/json', }, params) - def create_file(self, files, read, write): + def create_file(self, file, read, write): """Create File""" params = {} path = '/storage/files' - params['files'] = files + params['file'] = file params['read'] = read params['write'] = write diff --git a/app/sdks/python/appwrite/services/teams.py b/app/sdks/python/appwrite/services/teams.py index c69424d8ba..cdc3780ad9 100644 --- a/app/sdks/python/appwrite/services/teams.py +++ b/app/sdks/python/appwrite/services/teams.py @@ -6,7 +6,7 @@ class Teams(Service): def __init__(self, client): super(Teams, self).__init__(client) - def list_teams(self, search='', limit=25, offset=0, order_type='ASC'): + def list(self, search='', limit=25, offset=0, order_type='ASC'): """List Teams""" params = {} @@ -20,7 +20,7 @@ class Teams(Service): 'content-type': 'application/json', }, params) - def create_team(self, name, roles=[]): + def create(self, name, roles=[]): """Create Team""" params = {} @@ -32,7 +32,7 @@ class Teams(Service): 'content-type': 'application/json', }, params) - def get_team(self, team_id): + def get(self, team_id): """Get Team""" params = {} @@ -43,7 +43,7 @@ class Teams(Service): 'content-type': 'application/json', }, params) - def update_team(self, team_id, name): + def update(self, team_id, name): """Update Team""" params = {} @@ -55,7 +55,7 @@ class Teams(Service): 'content-type': 'application/json', }, params) - def delete_team(self, team_id): + def delete(self, team_id): """Delete Team""" params = {} @@ -66,18 +66,18 @@ class Teams(Service): 'content-type': 'application/json', }, params) - def get_team_members(self, team_id): - """Get Team Members""" + def get_memberships(self, team_id): + """Get Team Memberships""" params = {} - path = '/teams/{teamId}/members' + path = '/teams/{teamId}/memberships' path = path.replace('{teamId}', team_id) return self.client.call('get', path, { 'content-type': 'application/json', }, params) - def create_team_membership(self, team_id, email, roles, redirect, name=''): + def create_membership(self, team_id, email, roles, url, name=''): """Create Team Membership""" params = {} @@ -86,13 +86,13 @@ class Teams(Service): params['email'] = email params['name'] = name params['roles'] = roles - params['redirect'] = redirect + params['url'] = url return self.client.call('post', path, { 'content-type': 'application/json', }, params) - def delete_team_membership(self, team_id, invite_id): + def delete_membership(self, team_id, invite_id): """Delete Team Membership""" params = {} @@ -103,32 +103,3 @@ class Teams(Service): return self.client.call('delete', path, { 'content-type': 'application/json', }, params) - - def create_team_membership_resend(self, team_id, invite_id, redirect): - """Create Team Membership (Resend)""" - - params = {} - path = '/teams/{teamId}/memberships/{inviteId}/resend' - path = path.replace('{teamId}', team_id) - path = path.replace('{inviteId}', invite_id) - params['redirect'] = redirect - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def update_team_membership_status(self, team_id, invite_id, user_id, secret, success='', failure=''): - """Update Team Membership Status""" - - params = {} - path = '/teams/{teamId}/memberships/{inviteId}/status' - path = path.replace('{teamId}', team_id) - path = path.replace('{inviteId}', invite_id) - params['userId'] = user_id - params['secret'] = secret - params['success'] = success - params['failure'] = failure - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/python/appwrite/services/users.py b/app/sdks/python/appwrite/services/users.py index e97a961901..be9b2da8de 100644 --- a/app/sdks/python/appwrite/services/users.py +++ b/app/sdks/python/appwrite/services/users.py @@ -6,7 +6,7 @@ class Users(Service): def __init__(self, client): super(Users, self).__init__(client) - def list_users(self, search='', limit=25, offset=0, order_type='ASC'): + def list(self, search='', limit=25, offset=0, order_type='ASC'): """List Users""" params = {} @@ -20,7 +20,7 @@ class Users(Service): 'content-type': 'application/json', }, params) - def create_user(self, email, password, name=''): + def create(self, email, password, name=''): """Create User""" params = {} @@ -33,7 +33,7 @@ class Users(Service): 'content-type': 'application/json', }, params) - def get_user(self, user_id): + def get(self, user_id): """Get User""" params = {} @@ -44,7 +44,7 @@ class Users(Service): 'content-type': 'application/json', }, params) - def get_user_logs(self, user_id): + def get_logs(self, user_id): """Get User Logs""" params = {} @@ -55,8 +55,8 @@ class Users(Service): 'content-type': 'application/json', }, params) - def get_user_prefs(self, user_id): - """Get User Prefs""" + def get_prefs(self, user_id): + """Get User Preferences""" params = {} path = '/users/{userId}/prefs' @@ -66,8 +66,8 @@ class Users(Service): 'content-type': 'application/json', }, params) - def update_user_prefs(self, user_id, prefs): - """Update User Prefs""" + def update_prefs(self, user_id, prefs): + """Update User Preferences""" params = {} path = '/users/{userId}/prefs' @@ -78,7 +78,7 @@ class Users(Service): 'content-type': 'application/json', }, params) - def get_user_sessions(self, user_id): + def get_sessions(self, user_id): """Get User Sessions""" params = {} @@ -89,7 +89,7 @@ class Users(Service): 'content-type': 'application/json', }, params) - def delete_user_sessions(self, user_id): + def delete_sessions(self, user_id): """Delete User Sessions""" params = {} @@ -100,7 +100,7 @@ class Users(Service): 'content-type': 'application/json', }, params) - def delete_user_session(self, user_id, session_id): + def delete_session(self, user_id, session_id): """Delete User Session""" params = {} @@ -112,7 +112,7 @@ class Users(Service): 'content-type': 'application/json', }, params) - def update_user_status(self, user_id, status): + def update_status(self, user_id, status): """Update User Status""" params = {} diff --git a/app/sdks/python/docs/examples/avatars/get-browser.md b/app/sdks/python/docs/examples/avatars/get-browser.md new file mode 100644 index 0000000000..34cd9d9502 --- /dev/null +++ b/app/sdks/python/docs/examples/avatars/get-browser.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.avatars import Avatars + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +avatars = Avatars(client) + +result = avatars.get_browser('aa') diff --git a/app/sdks/python/docs/examples/avatars/get-credit-card.md b/app/sdks/python/docs/examples/avatars/get-credit-card.md new file mode 100644 index 0000000000..a4e05600c3 --- /dev/null +++ b/app/sdks/python/docs/examples/avatars/get-credit-card.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.avatars import Avatars + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +avatars = Avatars(client) + +result = avatars.get_credit_card('amex') diff --git a/app/sdks/python/docs/examples/avatars/get-favicon.md b/app/sdks/python/docs/examples/avatars/get-favicon.md new file mode 100644 index 0000000000..0d9d1f2cc1 --- /dev/null +++ b/app/sdks/python/docs/examples/avatars/get-favicon.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.avatars import Avatars + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +avatars = Avatars(client) + +result = avatars.get_favicon('https://example.com') diff --git a/app/sdks/python/docs/examples/avatars/get-flag.md b/app/sdks/python/docs/examples/avatars/get-flag.md new file mode 100644 index 0000000000..f1ebc9b0fa --- /dev/null +++ b/app/sdks/python/docs/examples/avatars/get-flag.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.avatars import Avatars + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +avatars = Avatars(client) + +result = avatars.get_flag('af') diff --git a/app/sdks/python/docs/examples/avatars/get-image.md b/app/sdks/python/docs/examples/avatars/get-image.md new file mode 100644 index 0000000000..43c59994e0 --- /dev/null +++ b/app/sdks/python/docs/examples/avatars/get-image.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.avatars import Avatars + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +avatars = Avatars(client) + +result = avatars.get_image('https://example.com') diff --git a/app/sdks/python/docs/examples/avatars/get-q-r.md b/app/sdks/python/docs/examples/avatars/get-q-r.md new file mode 100644 index 0000000000..0fb4d95e3a --- /dev/null +++ b/app/sdks/python/docs/examples/avatars/get-q-r.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.avatars import Avatars + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +avatars = Avatars(client) + +result = avatars.get_q_r('[TEXT]') diff --git a/app/sdks/python/docs/examples/database/create-collection.md b/app/sdks/python/docs/examples/database/create-collection.md new file mode 100644 index 0000000000..5fd4823de5 --- /dev/null +++ b/app/sdks/python/docs/examples/database/create-collection.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.create_collection('[NAME]', {}, {}, {}) diff --git a/app/sdks/python/docs/examples/database/create-document.md b/app/sdks/python/docs/examples/database/create-document.md new file mode 100644 index 0000000000..ff146a7d17 --- /dev/null +++ b/app/sdks/python/docs/examples/database/create-document.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.create_document('[COLLECTION_ID]', {}, {}, {}) diff --git a/app/sdks/python/docs/examples/database/delete-collection.md b/app/sdks/python/docs/examples/database/delete-collection.md new file mode 100644 index 0000000000..433d45d3d6 --- /dev/null +++ b/app/sdks/python/docs/examples/database/delete-collection.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.delete_collection('[COLLECTION_ID]') diff --git a/app/sdks/python/docs/examples/database/delete-document.md b/app/sdks/python/docs/examples/database/delete-document.md new file mode 100644 index 0000000000..81d9d2aab9 --- /dev/null +++ b/app/sdks/python/docs/examples/database/delete-document.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.delete_document('[COLLECTION_ID]', '[DOCUMENT_ID]') diff --git a/app/sdks/python/docs/examples/database/get-collection.md b/app/sdks/python/docs/examples/database/get-collection.md new file mode 100644 index 0000000000..7e00030f1a --- /dev/null +++ b/app/sdks/python/docs/examples/database/get-collection.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.get_collection('[COLLECTION_ID]') diff --git a/app/sdks/python/docs/examples/database/get-document.md b/app/sdks/python/docs/examples/database/get-document.md new file mode 100644 index 0000000000..ec7f36957b --- /dev/null +++ b/app/sdks/python/docs/examples/database/get-document.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.get_document('[COLLECTION_ID]', '[DOCUMENT_ID]') diff --git a/app/sdks/python/docs/examples/database/list-collections.md b/app/sdks/python/docs/examples/database/list-collections.md new file mode 100644 index 0000000000..1615e075e5 --- /dev/null +++ b/app/sdks/python/docs/examples/database/list-collections.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.list_collections() diff --git a/app/sdks/python/docs/examples/database/list-documents.md b/app/sdks/python/docs/examples/database/list-documents.md new file mode 100644 index 0000000000..9a30f08ff7 --- /dev/null +++ b/app/sdks/python/docs/examples/database/list-documents.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.list_documents('[COLLECTION_ID]') diff --git a/app/sdks/python/docs/examples/database/update-collection.md b/app/sdks/python/docs/examples/database/update-collection.md new file mode 100644 index 0000000000..4a67d1fb6c --- /dev/null +++ b/app/sdks/python/docs/examples/database/update-collection.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.update_collection('[COLLECTION_ID]', '[NAME]', {}, {}) diff --git a/app/sdks/python/docs/examples/database/update-document.md b/app/sdks/python/docs/examples/database/update-document.md new file mode 100644 index 0000000000..1e27a77b9f --- /dev/null +++ b/app/sdks/python/docs/examples/database/update-document.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.update_document('[COLLECTION_ID]', '[DOCUMENT_ID]', {}, {}, {}) diff --git a/app/sdks/python/docs/examples/locale/get-continents.md b/app/sdks/python/docs/examples/locale/get-continents.md new file mode 100644 index 0000000000..6b84bd7bb6 --- /dev/null +++ b/app/sdks/python/docs/examples/locale/get-continents.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.get_continents() diff --git a/app/sdks/python/docs/examples/locale/get-countries-e-u.md b/app/sdks/python/docs/examples/locale/get-countries-e-u.md new file mode 100644 index 0000000000..100a0d56a4 --- /dev/null +++ b/app/sdks/python/docs/examples/locale/get-countries-e-u.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.get_countries_e_u() diff --git a/app/sdks/python/docs/examples/locale/get-countries-phones.md b/app/sdks/python/docs/examples/locale/get-countries-phones.md new file mode 100644 index 0000000000..dbac81e356 --- /dev/null +++ b/app/sdks/python/docs/examples/locale/get-countries-phones.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.get_countries_phones() diff --git a/app/sdks/python/docs/examples/locale/get-countries.md b/app/sdks/python/docs/examples/locale/get-countries.md new file mode 100644 index 0000000000..ee994e73c9 --- /dev/null +++ b/app/sdks/python/docs/examples/locale/get-countries.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.get_countries() diff --git a/app/sdks/python/docs/examples/locale/get-currencies.md b/app/sdks/python/docs/examples/locale/get-currencies.md new file mode 100644 index 0000000000..7a4e50fe56 --- /dev/null +++ b/app/sdks/python/docs/examples/locale/get-currencies.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.get_currencies() diff --git a/app/sdks/python/docs/examples/locale/get.md b/app/sdks/python/docs/examples/locale/get.md new file mode 100644 index 0000000000..f86fa446e7 --- /dev/null +++ b/app/sdks/python/docs/examples/locale/get.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.get() diff --git a/app/sdks/python/docs/examples/storage/create-file.md b/app/sdks/python/docs/examples/storage/create-file.md new file mode 100644 index 0000000000..7ef7cba970 --- /dev/null +++ b/app/sdks/python/docs/examples/storage/create-file.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +storage = Storage(client) + +result = storage.create_file(document.getElementById('uploader').files[0], {}, {}) diff --git a/app/sdks/python/docs/examples/storage/delete-file.md b/app/sdks/python/docs/examples/storage/delete-file.md new file mode 100644 index 0000000000..1fda179766 --- /dev/null +++ b/app/sdks/python/docs/examples/storage/delete-file.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +storage = Storage(client) + +result = storage.delete_file('[FILE_ID]') diff --git a/app/sdks/python/docs/examples/storage/get-file-download.md b/app/sdks/python/docs/examples/storage/get-file-download.md new file mode 100644 index 0000000000..02ea23459c --- /dev/null +++ b/app/sdks/python/docs/examples/storage/get-file-download.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +storage = Storage(client) + +result = storage.get_file_download('[FILE_ID]') diff --git a/app/sdks/python/docs/examples/storage/get-file-preview.md b/app/sdks/python/docs/examples/storage/get-file-preview.md new file mode 100644 index 0000000000..f1778b3b81 --- /dev/null +++ b/app/sdks/python/docs/examples/storage/get-file-preview.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +storage = Storage(client) + +result = storage.get_file_preview('[FILE_ID]') diff --git a/app/sdks/python/docs/examples/storage/get-file-view.md b/app/sdks/python/docs/examples/storage/get-file-view.md new file mode 100644 index 0000000000..52d69787a2 --- /dev/null +++ b/app/sdks/python/docs/examples/storage/get-file-view.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +storage = Storage(client) + +result = storage.get_file_view('[FILE_ID]') diff --git a/app/sdks/python/docs/examples/storage/get-file.md b/app/sdks/python/docs/examples/storage/get-file.md new file mode 100644 index 0000000000..61b48ce7c5 --- /dev/null +++ b/app/sdks/python/docs/examples/storage/get-file.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +storage = Storage(client) + +result = storage.get_file('[FILE_ID]') diff --git a/app/sdks/python/docs/examples/storage/list-files.md b/app/sdks/python/docs/examples/storage/list-files.md new file mode 100644 index 0000000000..2de28ac6ff --- /dev/null +++ b/app/sdks/python/docs/examples/storage/list-files.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +storage = Storage(client) + +result = storage.list_files() diff --git a/app/sdks/python/docs/examples/storage/update-file.md b/app/sdks/python/docs/examples/storage/update-file.md new file mode 100644 index 0000000000..ec6890240f --- /dev/null +++ b/app/sdks/python/docs/examples/storage/update-file.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +storage = Storage(client) + +result = storage.update_file('[FILE_ID]', {}, {}) diff --git a/app/sdks/python/docs/examples/teams/create-membership.md b/app/sdks/python/docs/examples/teams/create-membership.md new file mode 100644 index 0000000000..fa32e5fc32 --- /dev/null +++ b/app/sdks/python/docs/examples/teams/create-membership.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +teams = Teams(client) + +result = teams.create_membership('[TEAM_ID]', 'email@example.com', {}, 'https://example.com') diff --git a/app/sdks/python/docs/examples/teams/create.md b/app/sdks/python/docs/examples/teams/create.md new file mode 100644 index 0000000000..3511082e01 --- /dev/null +++ b/app/sdks/python/docs/examples/teams/create.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +teams = Teams(client) + +result = teams.create('[NAME]') diff --git a/app/sdks/python/docs/examples/teams/delete-membership.md b/app/sdks/python/docs/examples/teams/delete-membership.md new file mode 100644 index 0000000000..e8e103b783 --- /dev/null +++ b/app/sdks/python/docs/examples/teams/delete-membership.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +teams = Teams(client) + +result = teams.delete_membership('[TEAM_ID]', '[INVITE_ID]') diff --git a/app/sdks/python/docs/examples/teams/delete.md b/app/sdks/python/docs/examples/teams/delete.md new file mode 100644 index 0000000000..9ec3d76e8a --- /dev/null +++ b/app/sdks/python/docs/examples/teams/delete.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +teams = Teams(client) + +result = teams.delete('[TEAM_ID]') diff --git a/app/sdks/python/docs/examples/teams/get-memberships.md b/app/sdks/python/docs/examples/teams/get-memberships.md new file mode 100644 index 0000000000..aed5537ac1 --- /dev/null +++ b/app/sdks/python/docs/examples/teams/get-memberships.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +teams = Teams(client) + +result = teams.get_memberships('[TEAM_ID]') diff --git a/app/sdks/python/docs/examples/teams/get.md b/app/sdks/python/docs/examples/teams/get.md new file mode 100644 index 0000000000..694bb9b996 --- /dev/null +++ b/app/sdks/python/docs/examples/teams/get.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +teams = Teams(client) + +result = teams.get('[TEAM_ID]') diff --git a/app/sdks/python/docs/examples/teams/list.md b/app/sdks/python/docs/examples/teams/list.md new file mode 100644 index 0000000000..08aea8927d --- /dev/null +++ b/app/sdks/python/docs/examples/teams/list.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +teams = Teams(client) + +result = teams.list() diff --git a/app/sdks/python/docs/examples/teams/update.md b/app/sdks/python/docs/examples/teams/update.md new file mode 100644 index 0000000000..ceed295c52 --- /dev/null +++ b/app/sdks/python/docs/examples/teams/update.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +teams = Teams(client) + +result = teams.update('[TEAM_ID]', '[NAME]') diff --git a/app/sdks/python/docs/examples/users/create.md b/app/sdks/python/docs/examples/users/create.md new file mode 100644 index 0000000000..84973214d5 --- /dev/null +++ b/app/sdks/python/docs/examples/users/create.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.create('email@example.com', 'password') diff --git a/app/sdks/python/docs/examples/users/delete-session.md b/app/sdks/python/docs/examples/users/delete-session.md new file mode 100644 index 0000000000..6d006d6734 --- /dev/null +++ b/app/sdks/python/docs/examples/users/delete-session.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.delete_session('[USER_ID]', '[SESSION_ID]') diff --git a/app/sdks/python/docs/examples/users/delete-sessions.md b/app/sdks/python/docs/examples/users/delete-sessions.md new file mode 100644 index 0000000000..b27fbb4f4f --- /dev/null +++ b/app/sdks/python/docs/examples/users/delete-sessions.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.delete_sessions('[USER_ID]') diff --git a/app/sdks/python/docs/examples/users/get-logs.md b/app/sdks/python/docs/examples/users/get-logs.md new file mode 100644 index 0000000000..8ccea842df --- /dev/null +++ b/app/sdks/python/docs/examples/users/get-logs.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.get_logs('[USER_ID]') diff --git a/app/sdks/python/docs/examples/users/get-prefs.md b/app/sdks/python/docs/examples/users/get-prefs.md new file mode 100644 index 0000000000..ce566bd732 --- /dev/null +++ b/app/sdks/python/docs/examples/users/get-prefs.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.get_prefs('[USER_ID]') diff --git a/app/sdks/python/docs/examples/users/get-sessions.md b/app/sdks/python/docs/examples/users/get-sessions.md new file mode 100644 index 0000000000..58e7e4b507 --- /dev/null +++ b/app/sdks/python/docs/examples/users/get-sessions.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.get_sessions('[USER_ID]') diff --git a/app/sdks/python/docs/examples/users/get.md b/app/sdks/python/docs/examples/users/get.md new file mode 100644 index 0000000000..67d8c8d690 --- /dev/null +++ b/app/sdks/python/docs/examples/users/get.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.get('[USER_ID]') diff --git a/app/sdks/python/docs/examples/users/list.md b/app/sdks/python/docs/examples/users/list.md new file mode 100644 index 0000000000..ed8e7651ae --- /dev/null +++ b/app/sdks/python/docs/examples/users/list.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.list() diff --git a/app/sdks/python/docs/examples/users/update-prefs.md b/app/sdks/python/docs/examples/users/update-prefs.md new file mode 100644 index 0000000000..cc11f989ce --- /dev/null +++ b/app/sdks/python/docs/examples/users/update-prefs.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.update_prefs('[USER_ID]', {}) diff --git a/app/sdks/python/docs/examples/users/update-status.md b/app/sdks/python/docs/examples/users/update-status.md new file mode 100644 index 0000000000..268715af54 --- /dev/null +++ b/app/sdks/python/docs/examples/users/update-status.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.update_status('[USER_ID]', '1') diff --git a/app/sdks/ruby/README.md b/app/sdks/ruby/README.md index af0c396288..67e7a0fb24 100644 --- a/app/sdks/ruby/README.md +++ b/app/sdks/ruby/README.md @@ -1,9 +1,9 @@ # Appwrite SDK for Ruby ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1) -**WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).** +**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.** Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/ruby/lib/appwrite.rb b/app/sdks/ruby/lib/appwrite.rb index 7f12c9aedf..0d0dcd156e 100644 --- a/app/sdks/ruby/lib/appwrite.rb +++ b/app/sdks/ruby/lib/appwrite.rb @@ -3,12 +3,9 @@ require 'uri' require 'json' require_relative 'appwrite/client' require_relative 'appwrite/service' -require_relative 'appwrite/services/account' -require_relative 'appwrite/services/auth' require_relative 'appwrite/services/avatars' require_relative 'appwrite/services/database' require_relative 'appwrite/services/locale' -require_relative 'appwrite/services/projects' require_relative 'appwrite/services/storage' require_relative 'appwrite/services/teams' require_relative 'appwrite/services/users' diff --git a/app/sdks/ruby/lib/appwrite/client.rb b/app/sdks/ruby/lib/appwrite/client.rb index 43dd47a235..86bef71f02 100644 --- a/app/sdks/ruby/lib/appwrite/client.rb +++ b/app/sdks/ruby/lib/appwrite/client.rb @@ -62,7 +62,17 @@ module Appwrite end def call(method, path = '', headers = {}, params = {}) - uri = URI.parse(@endpoint + path + ((method == METHOD_GET) ? '?' + encode(params) : '')) + uri = URI.parse(@endpoint + path + ((method == METHOD_GET && params.length) ? '?' + encode(params) : '')) + return fetch(method, uri, headers, params) + end + + protected + + private + + def fetch(method, uri, headers, params, limit = 5) + raise ArgumentError, 'Too Many HTTP Redirects' if limit == 0 + http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = (uri.scheme == 'https') payload = '' @@ -83,14 +93,18 @@ module Appwrite rescue => error raise 'Request Failed: ' + error.message end + + # Handle Redirects + if (response.class == Net::HTTPRedirection || response.class == Net::HTTPMovedPermanently) + location = response['location'] + uri = URI.parse(uri.scheme + "://" + uri.host + "" + location) + + return fetch(method, uri, headers, {}, limit - 1) + end return JSON.parse(response.body); end - protected - - private - def encode(value, key = nil) case value when Hash then value.map { |k,v| encode(v, append_key(key,k)) }.join('&') diff --git a/app/sdks/ruby/lib/appwrite/services/account.rb b/app/sdks/ruby/lib/appwrite/services/account.rb deleted file mode 100644 index 8f2a8b3e2a..0000000000 --- a/app/sdks/ruby/lib/appwrite/services/account.rb +++ /dev/null @@ -1,114 +0,0 @@ -module Appwrite - class Account < Service - - def get() - path = '/account' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete() - path = '/account' - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_email(email:, password:) - path = '/account/email' - - params = { - 'email': email, - 'password': password - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_name(name:) - path = '/account/name' - - params = { - 'name': name - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_password(password:, old_password:) - path = '/account/password' - - params = { - 'password': password, - 'old-password': old_password - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_prefs() - path = '/account/prefs' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_prefs(prefs:) - path = '/account/prefs' - - params = { - 'prefs': prefs - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_security() - path = '/account/security' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_sessions() - path = '/account/sessions' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/ruby/lib/appwrite/services/auth.rb b/app/sdks/ruby/lib/appwrite/services/auth.rb deleted file mode 100644 index bcf5e8906b..0000000000 --- a/app/sdks/ruby/lib/appwrite/services/auth.rb +++ /dev/null @@ -1,131 +0,0 @@ -module Appwrite - class Auth < Service - - def login(email:, password:, success: '', failure: '') - path = '/auth/login' - - params = { - 'email': email, - 'password': password, - 'success': success, - 'failure': failure - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def oauth(provider:, success:, failure:) - path = '/auth/login/oauth/{provider}' - .gsub('{provider}', provider) - - params = { - 'success': success, - 'failure': failure - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def logout() - path = '/auth/logout' - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def logout_by_session(id:) - path = '/auth/logout/{id}' - .gsub('{id}', id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def recovery(email:, reset:) - path = '/auth/recovery' - - params = { - 'email': email, - 'reset': reset - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def recovery_reset(user_id:, token:, password_a:, password_b:) - path = '/auth/recovery/reset' - - params = { - 'userId': user_id, - 'token': token, - 'password-a': password_a, - 'password-b': password_b - } - - return @client.call('put', path, { - 'content-type' => 'application/json', - }, params); - end - - def register(email:, password:, confirm:, success: '', failure: '', name: '') - path = '/auth/register' - - params = { - 'email': email, - 'password': password, - 'confirm': confirm, - 'success': success, - 'failure': failure, - 'name': name - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def confirm(user_id:, token:) - path = '/auth/register/confirm' - - params = { - 'userId': user_id, - 'token': token - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def confirm_resend(confirm:) - path = '/auth/register/confirm/resend' - - params = { - 'confirm': confirm - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/ruby/lib/appwrite/services/database.rb b/app/sdks/ruby/lib/appwrite/services/database.rb index cf1171248d..52404c3b56 100644 --- a/app/sdks/ruby/lib/appwrite/services/database.rb +++ b/app/sdks/ruby/lib/appwrite/services/database.rb @@ -2,7 +2,7 @@ module Appwrite class Database < Service def list_collections(search: '', limit: 25, offset: 0, order_type: 'ASC') - path = '/database' + path = '/database/collections' params = { 'search': search, @@ -17,7 +17,7 @@ module Appwrite end def create_collection(name:, read:, write:, rules:) - path = '/database' + path = '/database/collections' params = { 'name': name, @@ -32,7 +32,7 @@ module Appwrite end def get_collection(collection_id:) - path = '/database/{collectionId}' + path = '/database/collections/{collectionId}' .gsub('{collection_id}', collection_id) params = { @@ -44,7 +44,7 @@ module Appwrite end def update_collection(collection_id:, name:, read:, write:, rules: []) - path = '/database/{collectionId}' + path = '/database/collections/{collectionId}' .gsub('{collection_id}', collection_id) params = { @@ -60,7 +60,7 @@ module Appwrite end def delete_collection(collection_id:) - path = '/database/{collectionId}' + path = '/database/collections/{collectionId}' .gsub('{collection_id}', collection_id) params = { @@ -72,7 +72,7 @@ module Appwrite end def list_documents(collection_id:, filters: [], offset: 0, limit: 50, order_field: '$uid', order_type: 'ASC', order_cast: 'string', search: '', first: 0, last: 0) - path = '/database/{collectionId}/documents' + path = '/database/collections/{collectionId}/documents' .gsub('{collection_id}', collection_id) params = { @@ -93,7 +93,7 @@ module Appwrite end def create_document(collection_id:, data:, read:, write:, parent_document: '', parent_property: '', parent_property_type: 'assign') - path = '/database/{collectionId}/documents' + path = '/database/collections/{collectionId}/documents' .gsub('{collection_id}', collection_id) params = { @@ -111,7 +111,7 @@ module Appwrite end def get_document(collection_id:, document_id:) - path = '/database/{collectionId}/documents/{documentId}' + path = '/database/collections/{collectionId}/documents/{documentId}' .gsub('{collection_id}', collection_id) .gsub('{document_id}', document_id) @@ -124,7 +124,7 @@ module Appwrite end def update_document(collection_id:, document_id:, data:, read:, write:) - path = '/database/{collectionId}/documents/{documentId}' + path = '/database/collections/{collectionId}/documents/{documentId}' .gsub('{collection_id}', collection_id) .gsub('{document_id}', document_id) @@ -140,7 +140,7 @@ module Appwrite end def delete_document(collection_id:, document_id:) - path = '/database/{collectionId}/documents/{documentId}' + path = '/database/collections/{collectionId}/documents/{documentId}' .gsub('{collection_id}', collection_id) .gsub('{document_id}', document_id) diff --git a/app/sdks/ruby/lib/appwrite/services/locale.rb b/app/sdks/ruby/lib/appwrite/services/locale.rb index a5c708c764..707c8b2f4a 100644 --- a/app/sdks/ruby/lib/appwrite/services/locale.rb +++ b/app/sdks/ruby/lib/appwrite/services/locale.rb @@ -1,7 +1,7 @@ module Appwrite class Locale < Service - def get_locale() + def get() path = '/locale' params = { diff --git a/app/sdks/ruby/lib/appwrite/services/projects.rb b/app/sdks/ruby/lib/appwrite/services/projects.rb deleted file mode 100644 index 9988708e92..0000000000 --- a/app/sdks/ruby/lib/appwrite/services/projects.rb +++ /dev/null @@ -1,410 +0,0 @@ -module Appwrite - class Projects < Service - - def list_projects() - path = '/projects' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create_project(name:, team_id:, description: '', logo: '', url: '', legal_name: '', legal_country: '', legal_state: '', legal_city: '', legal_address: '', legal_tax_id: '') - path = '/projects' - - params = { - 'name': name, - 'teamId': team_id, - 'description': description, - 'logo': logo, - 'url': url, - 'legalName': legal_name, - 'legalCountry': legal_country, - 'legalState': legal_state, - 'legalCity': legal_city, - 'legalAddress': legal_address, - 'legalTaxId': legal_tax_id - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_project(project_id:) - path = '/projects/{projectId}' - .gsub('{project_id}', project_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_project(project_id:, name:, description: '', logo: '', url: '', legal_name: '', legal_country: '', legal_state: '', legal_city: '', legal_address: '', legal_tax_id: '') - path = '/projects/{projectId}' - .gsub('{project_id}', project_id) - - params = { - 'name': name, - 'description': description, - 'logo': logo, - 'url': url, - 'legalName': legal_name, - 'legalCountry': legal_country, - 'legalState': legal_state, - 'legalCity': legal_city, - 'legalAddress': legal_address, - 'legalTaxId': legal_tax_id - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_project(project_id:) - path = '/projects/{projectId}' - .gsub('{project_id}', project_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def list_keys(project_id:) - path = '/projects/{projectId}/keys' - .gsub('{project_id}', project_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create_key(project_id:, name:, scopes:) - path = '/projects/{projectId}/keys' - .gsub('{project_id}', project_id) - - params = { - 'name': name, - 'scopes': scopes - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_key(project_id:, key_id:) - path = '/projects/{projectId}/keys/{keyId}' - .gsub('{project_id}', project_id) - .gsub('{key_id}', key_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_key(project_id:, key_id:, name:, scopes:) - path = '/projects/{projectId}/keys/{keyId}' - .gsub('{project_id}', project_id) - .gsub('{key_id}', key_id) - - params = { - 'name': name, - 'scopes': scopes - } - - return @client.call('put', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_key(project_id:, key_id:) - path = '/projects/{projectId}/keys/{keyId}' - .gsub('{project_id}', project_id) - .gsub('{key_id}', key_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_project_o_auth(project_id:, provider:, app_id: '', secret: '') - path = '/projects/{projectId}/oauth' - .gsub('{project_id}', project_id) - - params = { - 'provider': provider, - 'appId': app_id, - 'secret': secret - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - - def list_platforms(project_id:) - path = '/projects/{projectId}/platforms' - .gsub('{project_id}', project_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create_platform(project_id:, type:, name:, key: '', store: '', url: '') - path = '/projects/{projectId}/platforms' - .gsub('{project_id}', project_id) - - params = { - 'type': type, - 'name': name, - 'key': key, - 'store': store, - 'url': url - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_platform(project_id:, platform_id:) - path = '/projects/{projectId}/platforms/{platformId}' - .gsub('{project_id}', project_id) - .gsub('{platform_id}', platform_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_platform(project_id:, platform_id:, name:, key: '', store: '', url: '') - path = '/projects/{projectId}/platforms/{platformId}' - .gsub('{project_id}', project_id) - .gsub('{platform_id}', platform_id) - - params = { - 'name': name, - 'key': key, - 'store': store, - 'url': url - } - - return @client.call('put', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_platform(project_id:, platform_id:) - path = '/projects/{projectId}/platforms/{platformId}' - .gsub('{project_id}', project_id) - .gsub('{platform_id}', platform_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def list_tasks(project_id:) - path = '/projects/{projectId}/tasks' - .gsub('{project_id}', project_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create_task(project_id:, name:, status:, schedule:, security:, http_method:, http_url:, http_headers: [], http_user: '', http_pass: '') - path = '/projects/{projectId}/tasks' - .gsub('{project_id}', project_id) - - params = { - 'name': name, - 'status': status, - 'schedule': schedule, - 'security': security, - 'httpMethod': http_method, - 'httpUrl': http_url, - 'httpHeaders': http_headers, - 'httpUser': http_user, - 'httpPass': http_pass - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_task(project_id:, task_id:) - path = '/projects/{projectId}/tasks/{taskId}' - .gsub('{project_id}', project_id) - .gsub('{task_id}', task_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_task(project_id:, task_id:, name:, status:, schedule:, security:, http_method:, http_url:, http_headers: [], http_user: '', http_pass: '') - path = '/projects/{projectId}/tasks/{taskId}' - .gsub('{project_id}', project_id) - .gsub('{task_id}', task_id) - - params = { - 'name': name, - 'status': status, - 'schedule': schedule, - 'security': security, - 'httpMethod': http_method, - 'httpUrl': http_url, - 'httpHeaders': http_headers, - 'httpUser': http_user, - 'httpPass': http_pass - } - - return @client.call('put', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_task(project_id:, task_id:) - path = '/projects/{projectId}/tasks/{taskId}' - .gsub('{project_id}', project_id) - .gsub('{task_id}', task_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_project_usage(project_id:) - path = '/projects/{projectId}/usage' - .gsub('{project_id}', project_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def list_webhooks(project_id:) - path = '/projects/{projectId}/webhooks' - .gsub('{project_id}', project_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create_webhook(project_id:, name:, events:, url:, security:, http_user: '', http_pass: '') - path = '/projects/{projectId}/webhooks' - .gsub('{project_id}', project_id) - - params = { - 'name': name, - 'events': events, - 'url': url, - 'security': security, - 'httpUser': http_user, - 'httpPass': http_pass - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_webhook(project_id:, webhook_id:) - path = '/projects/{projectId}/webhooks/{webhookId}' - .gsub('{project_id}', project_id) - .gsub('{webhook_id}', webhook_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_webhook(project_id:, webhook_id:, name:, events:, url:, security:, http_user: '', http_pass: '') - path = '/projects/{projectId}/webhooks/{webhookId}' - .gsub('{project_id}', project_id) - .gsub('{webhook_id}', webhook_id) - - params = { - 'name': name, - 'events': events, - 'url': url, - 'security': security, - 'httpUser': http_user, - 'httpPass': http_pass - } - - return @client.call('put', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_webhook(project_id:, webhook_id:) - path = '/projects/{projectId}/webhooks/{webhookId}' - .gsub('{project_id}', project_id) - .gsub('{webhook_id}', webhook_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/ruby/lib/appwrite/services/storage.rb b/app/sdks/ruby/lib/appwrite/services/storage.rb index 6e854b1f6d..2fe1a5762f 100644 --- a/app/sdks/ruby/lib/appwrite/services/storage.rb +++ b/app/sdks/ruby/lib/appwrite/services/storage.rb @@ -16,11 +16,11 @@ module Appwrite }, params); end - def create_file(files:, read:, write:) + def create_file(file:, read:, write:) path = '/storage/files' params = { - 'files': files, + 'file': file, 'read': read, 'write': write } diff --git a/app/sdks/ruby/lib/appwrite/services/teams.rb b/app/sdks/ruby/lib/appwrite/services/teams.rb index 109786e542..de6079b6f8 100644 --- a/app/sdks/ruby/lib/appwrite/services/teams.rb +++ b/app/sdks/ruby/lib/appwrite/services/teams.rb @@ -1,7 +1,7 @@ module Appwrite class Teams < Service - def list_teams(search: '', limit: 25, offset: 0, order_type: 'ASC') + def list(search: '', limit: 25, offset: 0, order_type: 'ASC') path = '/teams' params = { @@ -16,7 +16,7 @@ module Appwrite }, params); end - def create_team(name:, roles: ["owner"]) + def create(name:, roles: ["owner"]) path = '/teams' params = { @@ -29,7 +29,7 @@ module Appwrite }, params); end - def get_team(team_id:) + def get(team_id:) path = '/teams/{teamId}' .gsub('{team_id}', team_id) @@ -41,7 +41,7 @@ module Appwrite }, params); end - def update_team(team_id:, name:) + def update(team_id:, name:) path = '/teams/{teamId}' .gsub('{team_id}', team_id) @@ -54,7 +54,7 @@ module Appwrite }, params); end - def delete_team(team_id:) + def delete(team_id:) path = '/teams/{teamId}' .gsub('{team_id}', team_id) @@ -66,8 +66,8 @@ module Appwrite }, params); end - def get_team_members(team_id:) - path = '/teams/{teamId}/members' + def get_memberships(team_id:) + path = '/teams/{teamId}/memberships' .gsub('{team_id}', team_id) params = { @@ -78,7 +78,7 @@ module Appwrite }, params); end - def create_team_membership(team_id:, email:, roles:, redirect:, name: '') + def create_membership(team_id:, email:, roles:, url:, name: '') path = '/teams/{teamId}/memberships' .gsub('{team_id}', team_id) @@ -86,7 +86,7 @@ module Appwrite 'email': email, 'name': name, 'roles': roles, - 'redirect': redirect + 'url': url } return @client.call('post', path, { @@ -94,7 +94,7 @@ module Appwrite }, params); end - def delete_team_membership(team_id:, invite_id:) + def delete_membership(team_id:, invite_id:) path = '/teams/{teamId}/memberships/{inviteId}' .gsub('{team_id}', team_id) .gsub('{invite_id}', invite_id) @@ -107,37 +107,6 @@ module Appwrite }, params); end - def create_team_membership_resend(team_id:, invite_id:, redirect:) - path = '/teams/{teamId}/memberships/{inviteId}/resend' - .gsub('{team_id}', team_id) - .gsub('{invite_id}', invite_id) - - params = { - 'redirect': redirect - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_team_membership_status(team_id:, invite_id:, user_id:, secret:, success: '', failure: '') - path = '/teams/{teamId}/memberships/{inviteId}/status' - .gsub('{team_id}', team_id) - .gsub('{invite_id}', invite_id) - - params = { - 'userId': user_id, - 'secret': secret, - 'success': success, - 'failure': failure - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - protected diff --git a/app/sdks/ruby/lib/appwrite/services/users.rb b/app/sdks/ruby/lib/appwrite/services/users.rb index 99927523f0..75b1701f2d 100644 --- a/app/sdks/ruby/lib/appwrite/services/users.rb +++ b/app/sdks/ruby/lib/appwrite/services/users.rb @@ -1,7 +1,7 @@ module Appwrite class Users < Service - def list_users(search: '', limit: 25, offset: 0, order_type: 'ASC') + def list(search: '', limit: 25, offset: 0, order_type: 'ASC') path = '/users' params = { @@ -16,7 +16,7 @@ module Appwrite }, params); end - def create_user(email:, password:, name: '') + def create(email:, password:, name: '') path = '/users' params = { @@ -30,7 +30,7 @@ module Appwrite }, params); end - def get_user(user_id:) + def get(user_id:) path = '/users/{userId}' .gsub('{user_id}', user_id) @@ -42,7 +42,7 @@ module Appwrite }, params); end - def get_user_logs(user_id:) + def get_logs(user_id:) path = '/users/{userId}/logs' .gsub('{user_id}', user_id) @@ -54,7 +54,7 @@ module Appwrite }, params); end - def get_user_prefs(user_id:) + def get_prefs(user_id:) path = '/users/{userId}/prefs' .gsub('{user_id}', user_id) @@ -66,7 +66,7 @@ module Appwrite }, params); end - def update_user_prefs(user_id:, prefs:) + def update_prefs(user_id:, prefs:) path = '/users/{userId}/prefs' .gsub('{user_id}', user_id) @@ -79,7 +79,7 @@ module Appwrite }, params); end - def get_user_sessions(user_id:) + def get_sessions(user_id:) path = '/users/{userId}/sessions' .gsub('{user_id}', user_id) @@ -91,7 +91,7 @@ module Appwrite }, params); end - def delete_user_sessions(user_id:) + def delete_sessions(user_id:) path = '/users/{userId}/sessions' .gsub('{user_id}', user_id) @@ -103,7 +103,7 @@ module Appwrite }, params); end - def delete_user_session(user_id:, session_id:) + def delete_session(user_id:, session_id:) path = '/users/{userId}/sessions/:session' .gsub('{user_id}', user_id) @@ -116,7 +116,7 @@ module Appwrite }, params); end - def update_user_status(user_id:, status:) + def update_status(user_id:, status:) path = '/users/{userId}/status' .gsub('{user_id}', user_id) diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index ef830044fd..8a21d26f96 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -2,6 +2,7 @@ [ - 'version' => '1.0.16', - 'result' => __DIR__.'/../sdks/php/', - 'gitURL' => 'https://github.com/appwrite/sdk-for-php.git', - 'gitRepo' => 'git@github.com:appwrite/sdk-for-php.git', - 'gitRepoName' => 'sdk-for-php', - 'gitUserName' => 'appwrite', - 'warning' => $warning, - 'readme' => false, - 'platform' => 'server', - ], - 'js' => [ - 'version' => '1.0.28', - 'result' => __DIR__.'/../sdks/js/', - 'gitURL' => 'https://github.com/appwrite/sdk-for-js.git', - 'gitRepo' => 'git@github.com:appwrite/sdk-for-js.git', - 'gitRepoName' => 'sdk-for-js', - 'gitUserName' => 'appwrite', - 'warning' => $warning, - 'readme' => realpath(__DIR__ . '/../../docs/sdks/js.md'), - 'platform' => 'client', - ], - 'node' => [ - 'version' => '1.0.31', - 'result' => __DIR__.'/../sdks/node/', - 'gitURL' => 'https://github.com/appwrite/sdk-for-node.git', - 'gitRepo' => 'git@github.com:appwrite/sdk-for-node.git', - 'gitRepoName' => 'sdk-for-node', - 'gitUserName' => 'appwrite', - 'warning' => $warning, - 'readme' => false, - 'platform' => 'server', - ], - 'python' => [ - 'version' => '0.0.3', - 'result' => __DIR__.'/../sdks/python/', - 'gitURL' => 'https://github.com/appwrite/sdk-for-python.git', - 'gitRepo' => 'git@github.com:appwrite/sdk-for-python.git', - 'gitRepoName' => 'sdk-for-python', - 'gitUserName' => 'appwrite', - 'warning' => '**WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).**', - 'readme' => false, - 'platform' => 'server', - ], - 'ruby' => [ - 'version' => '1.0.8', - 'result' => __DIR__.'/../sdks/ruby/', - 'gitURL' => 'https://github.com/appwrite/sdk-for-ruby.git', - 'gitRepo' => 'git@github.com:appwrite/sdk-for-ruby.git', - 'gitRepoName' => 'sdk-for-ruby', - 'gitUserName' => 'appwrite', - 'warning' => '**WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).**', - 'readme' => false, - 'platform' => 'server', - ], - 'dart' => [ - 'version' => '0.0.6', - 'result' => __DIR__.'/../sdks/dart/', - 'gitURL' => 'https://github.com/appwrite/sdk-for-dart', - 'gitRepo' => 'git@github.com:appwrite/sdk-for-dart.git', - 'gitRepoName' => 'sdk-for-dart', - 'gitUserName' => 'appwrite', - 'warning' => '**WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).**', - 'readme' => false, - 'platform' => 'client', - ], - 'go' => [ - 'version' => '0.0.5', - 'result' => __DIR__.'/../sdks/go/', - 'gitURL' => 'https://github.com/appwrite/sdk-for-go', - 'gitRepo' => 'git@github.com:appwrite/sdk-for-go.git', - 'gitRepoName' => 'sdk-for-go', - 'gitUserName' => 'appwrite', - 'warning' => '**WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).**', - 'readme' => false, - 'platform' => 'server', - ], - ]; + $platforms = include __DIR__ . '/../config/platforms.php'; + $message = Console::confirm('Please enter your commit message:'); - - foreach ($clients as $name => $client) { + foreach($platforms as $platform) { + foreach($platform['languages'] as $language) { + if(!$language['enabled']) { + Console::warning($language['name'].' for '.$platform['name'] . ' is disabled'); + continue; + } - Console::info('Fetching API Spec for '.$name.' ('.$client['platform'].')'); - - $spec = getSSLPage('https://localhost/v1/open-api-2.json?extensions=1&platform='.$client['platform']); - $spec = getSSLPage('https://appwrite.io/v1/open-api-2.json?extensions=1&platform='.$client['platform']); - - $license = 'BSD-3-Clause'; + Console::info('Fetching API Spec for '.$language['name'].' for '.$platform['name']); + + $spec = getSSLPage('http://localhost/v1/open-api-2.json?extensions=1&platform='.$language['family']); - switch ($name) { - case 'php': - $language = new PHP(); - $language - ->setComposerVendor('appwrite') - ->setComposerPackage('appwrite') - ; - break; - case 'js': - $language = new JS(); - $language - ->setNPMPackage('appwrite') - ->setBowerPackage('appwrite') - ; - break; - case 'node': - $language = new Node(); - $language - ->setNPMPackage('node-appwrite') - ->setBowerPackage('appwrite') - ; - break; - case 'python': - $language = new Python(); - $language - ->setPipPackage('appwrite') - ; - $license = 'BSD License'; // license edited due to classifiers in pypi - break; - case 'ruby': - $language = new Ruby(); - $language - ->setGemPackage('appwrite') - ; - break; - case 'dart': - $language = new Dart(); - $language - ->setPackageName('appwrite') - ; - break; - break; - case 'go': - $language = new Go(); - break; - default: - throw new Exception('Language not supported'); - break; - } - - $target = __DIR__.'/../sdks/git/'.$name; - - Console::success("Generating {$name} SDK"); - - $sdk = new SDK($language, new Swagger2($spec)); - - $sdk - ->setLicense($license) - ->setLicenseContent('Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors. + $result = realpath(__DIR__.'/..').'/sdks/'.$language['key']; + $target = realpath(__DIR__.'/..').'/sdks/git/'.$language['key'].'/'; + $readme = realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'.md'); + $readme = ($readme) ? file_get_contents($readme) : ''; + $warning = ($language['beta']) ? '**This SDK is compatible with Appwrite server version ' . $version . '. For older versions, please check previous releases.**' : ''; + $license = 'BSD-3-Clause'; + $licenseContent = 'Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -196,48 +69,112 @@ Redistribution and use in source and binary forms, with or without modification, 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.') - ->setVersion($client['version']) - ->setGitRepo($client['gitRepo']) - ->setGitURL($client['gitURL']) - ->setGitRepoName($client['gitRepoName']) - ->setGitUserName($client['gitUserName']) - ->setLogo('https://appwrite.io/images/github.png') - ->setURL('https://appwrite.io') - ->setShareText('Appwrite is a backend as a service for building web or mobile apps') - ->setShareURL('http://appwrite.io') - ->setShareTags('JS,javascript,reactjs,angular,ios,android') - ->setShareVia('appwrite_io') - ->setWarning($client['warning']) - ->setReadme(($client['readme'] && file_exists($client['readme'])) ? file_get_contents($client['readme']) : ''); +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.'; - try { - $sdk->generate($client['result']); - } catch (Exception $exception) { - Console::error($exception->getMessage()); - } catch (Throwable $exception) { - Console::error($exception->getMessage()); + switch ($language['key']) { + case 'php': + $config = new PHP(); + $config + ->setComposerVendor('appwrite') + ->setComposerPackage('appwrite') + ; + break; + case 'javascript': + $config = new JS(); + $config + ->setNPMPackage('appwrite') + ->setBowerPackage('appwrite') + ; + break; + case 'nodejs': + $config = new Node(); + $config + ->setNPMPackage('node-appwrite') + ->setBowerPackage('appwrite') + ; + break; + case 'python': + $config = new Python(); + $config + ->setPipPackage('appwrite') + ; + $license = 'BSD License'; // license edited due to classifiers in pypi + break; + case 'ruby': + $config = new Ruby(); + $config + ->setGemPackage('appwrite') + ; + break; + case 'dart': + $config = new Dart(); + $config + ->setPackageName('appwrite') + ; + break; + case 'go': + $config = new Go(); + break; + default: + throw new Exception('Language "'.$language['key'].'" not supported'); + break; + } + + Console::info("Generating {$language['name']} SDK..."); + + $sdk = new SDK($config, new Swagger2($spec)); + + $sdk + ->setLicense($license) + ->setLicenseContent($licenseContent) + ->setVersion($language['version']) + ->setGitURL($language['url']) + ->setGitRepo($language['gitUrl']) + ->setGitRepoName($language['gitRepoName']) + ->setGitUserName($language['gitUserName']) + ->setLogo('https://appwrite.io/images/github.png') + ->setURL('https://appwrite.io') + ->setShareText('Appwrite is a backend as a service for building web or mobile apps') + ->setShareURL('http://appwrite.io') + ->setShareTags('JS,javascript,reactjs,angular,ios,android,serverless') + ->setShareVia('appwrite_io') + ->setWarning($warning) + ->setReadme($readme) + ; + + try { + $sdk->generate($result); + } catch (Exception $exception) { + Console::error($exception->getMessage()); + } catch (Throwable $exception) { + Console::error($exception->getMessage()); + } + + $gitUrl = $language['gitUrl']; + $gitUrl = 'git@github.com:aw-tests/'.$language['gitRepoName'].'.git'; + + exec('rm -rf '.$target.' && \ + mkdir -p '.$target.' && \ + cd '.$target.' && \ + git init && \ + git remote add origin '.$gitUrl.' && \ + git fetch && \ + git pull '.$gitUrl.' && \ + rm -rf '.$target.'/* && \ + cp -r '.$result.'/ '.$target.'/ && \ + git add . && \ + git commit -m "'.$message.'" && \ + git push -u origin master'); + + Console::success("Pushed {$language['name']} SDK to {$gitUrl}"); + + exec('rm -rf '.$target); + + Console::success("Remove temp directory '{$target}' for {$language['name']} SDK"); } - - exec('rm -rf '.$target.' && \ - mkdir -p '.$target.' && \ - cd '.$target.' && \ - git init && \ - git remote add origin '.$client['gitRepo'].' && \ - git fetch && \ - git pull '.$client['gitRepo'].' && \ - rm -rf '.$target.'/* && \ - cp -r '.$client['result'].' '.$target.' && \ - git add . && \ - git commit -m "Initial commit" && \ - git push -u origin master'); - - Console::success("Pushing {$name} SDK to {$client['gitRepo']}"); - - exec('rm -rf '.$target); - - Console::success("Remove temp directory '{$target}' for {$name} SDK"); } + + exit(); }); $cli->run(); diff --git a/app/tasks/upgrade.php b/app/tasks/upgrade.php index 7962069854..57f9aa1888 100644 --- a/app/tasks/upgrade.php +++ b/app/tasks/upgrade.php @@ -3,8 +3,11 @@ require_once __DIR__.'/../init.php'; -global $register; +global $register, $projectDB, $console, $providers; +use Database\Database; +use Database\Document; +use Database\Validator\Authorization; use Utopia\CLI\CLI; use Utopia\CLI\Console; @@ -12,59 +15,190 @@ $cli = new CLI(); $db = $register->get('db'); $callbacks = [ - '1.0.1' => function() { + '0.4.0' => function() { Console::log('I got nothing to do.'); }, - '1.0.2' => function($tables) use ($db) { + '0.5.0' => function($project) use ($db, $projectDB) { - foreach($tables as $node) { - $table = $node['table']; - $project = $node['project']; - $namespace = $node['namespace']; - $name = $node['name']; + Console::info('Upgrading project: '.$project->getId()); + + // Update all documents $uid -> $id + + $limit = 30; + $sum = 30; + $offset = 0; + + while ($sum >= 30) { + $all = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderField' => '$uid', + 'orderType' => 'DESC', + 'orderCast' => 'string', + ]); + + $sum = count($all); - if (($namespace !== 'audit') || ($name !== 'audit')) { - continue; - } - - Console::info('Altering table: '.$table); - - try { - $statement = $db->prepare(" - ALTER TABLE `appwrite`.`{$project}.audit.audit` DROP COLUMN IF EXISTS `userType`; - ALTER TABLE `appwrite`.`{$project}.audit.audit` DROP INDEX IF EXISTS `index_1`; - ALTER TABLE `appwrite`.`{$project}.audit.audit` ADD INDEX IF NOT EXISTS `index_1` (`userId` ASC); - "); - - $statement->execute(); - } - catch (\Exception $e) { - Console::error($e->getMessage().'/'); - } + Console::success('Fetched '.$sum.' (offset: '.$offset.' / limit: '.$limit.') documents from a total of '.$projectDB->getSum()); + foreach($all as $document) { + if(empty($document->getAttribute('$uid', null))) { + Console::info('Skipped document'); + continue; + } + + $document = fixDocument($document); + + if(empty($document->getId())) { + throw new Exception('Missing ID'); + } + + try { + $new = $projectDB->overwriteDocument($document->getArrayCopy()); + Console::success('Updated document succefully'); + } catch (\Throwable $th) { + Console::error('Failed to update document: '.$th->getMessage()); + continue; + } + + if($new->getId() !== $document->getId()) { + throw new Exception('Duplication Error'); + } + } + + $offset = $offset + $limit; + } + + try { + $statement = $db->prepare(" + ALTER TABLE `appwrite`.`app_{$project->getId()}.audit.audit` DROP COLUMN IF EXISTS `userType`; + ALTER TABLE `appwrite`.`app_{$project->getId()}.audit.audit` DROP INDEX IF EXISTS `index_1`; + ALTER TABLE `appwrite`.`app_{$project->getId()}.audit.audit` ADD INDEX IF NOT EXISTS `index_1` (`userId` ASC); + "); + + $statement->closeCursor(); + + $statement->execute(); + } + catch (\Exception $e) { + Console::error('Failed to alter table for project: '.$project->getId().' with message: '.$e->getMessage().'/'); } }, ]; +function fixDocument(Document $document) { + global $providers; + + if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_PROJECTS){ + foreach($providers as $key => $provider) { + if(!empty($document->getAttribute('usersOauth'.ucfirst($key).'Appid'))) { + $document + ->setAttribute('usersOauth2'.ucfirst($key).'Appid', $document->getAttribute('usersOauth'.ucfirst($key).'Appid', '')) + ->removeAttribute('usersOauth'.ucfirst($key).'Appid') + ; + } + + if(!empty($document->getAttribute('usersOauth'.ucfirst($key).'Secret'))) { + $document + ->setAttribute('usersOauth2'.ucfirst($key).'Secret', $document->getAttribute('usersOauth'.ucfirst($key).'Secret', '')) + ->removeAttribute('usersOauth'.ucfirst($key).'Secret') + ; + } + } + } + + if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_USERS) { + foreach($providers as $key => $provider) { + if(!empty($document->getAttribute('oauth'.ucfirst($key)))) { + $document + ->setAttribute('oauth2'.ucfirst($key), $document->getAttribute('oauth'.ucfirst($key), '')) + ->removeAttribute('oauth'.ucfirst($key)) + ; + } + + if(!empty($document->getAttribute('oauth'.ucfirst($key).'AccessToken'))) { + $document + ->setAttribute('oauth2'.ucfirst($key).'AccessToken', $document->getAttribute('oauth'.ucfirst($key).'AccessToken', '')) + ->removeAttribute('oauth'.ucfirst($key).'AccessToken') + ; + } + } + + if($document->getAttribute('confirm', null) !== null) { + $document + ->setAttribute('emailVerification', $document->getAttribute('confirm', $document->getAttribute('emailVerification', false))) + ->removeAttribute('confirm') + ; + } + } + + if(empty($document->getAttribute('$uid', null))) { + return $document; + } + + $document + ->setAttribute('$id', $document->getAttribute('$uid', null)) + ->removeAttribute('$uid') + ; + + foreach($document as &$attr) { + if($attr instanceof Document) { + $attr = fixDocument($attr); + } + + if(is_array($attr)) { + foreach($attr as &$child) { + if($child instanceof Document) { + $child = fixDocument($child); + } + } + } + } + + return $document; +} + $cli ->task('run') - ->action(function () use ($db, $callbacks) { + ->action(function () use ($console, $projectDB, $consoleDB, $callbacks) { Console::success('Starting Upgrade'); - - $statment = $db->query('SELECT table_name FROM information_schema.tables WHERE table_schema = "appwrite";'); - - $tables = array_map(function($node) { - $name = explode('.', $node['table_name']); - return [ - 'table' => implode('.', $name), - 'project' => array_shift($name), - 'namespace' => array_shift($name), - 'name' => array_shift($name), - ]; - }, $statment->fetchAll()); - - $callbacks['1.0.2']($tables); + Authorization::disable(); + + $limit = 30; + $sum = 30; + $offset = 0; + $projects = [$console]; + + while ($sum >= 30) { + foreach($projects as $project) { + $projectDB->setNamespace('app_'.$project->getId()); + + try { + $callbacks['0.5.0']($project); + } catch (\Throwable $th) { + Console::error('Failed to update project ("'.$project->getId().'") version with error: '.$th->getMessage()); + $projectDB->setNamespace('app_console'); + $projectDB->deleteDocument($project->getId()); + } + } + + $projects = $consoleDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderField' => 'name', + 'orderType' => 'ASC', + 'orderCast' => 'string', + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_PROJECTS, + ], + ]); + + $sum = count($projects); + $offset = $offset + $limit; + + Console::success('Fetched '.$sum.' projects...'); + } }); $cli->run(); diff --git a/app/views/console/account/index.phtml b/app/views/console/account/index.phtml index c27c0b343d..99cbe7f3f2 100644 --- a/app/views/console/account/index.phtml +++ b/app/views/console/account/index.phtml @@ -13,7 +13,7 @@ data-name="account" data-event="load" data-failure="trigger" - data-failure-param-trigger-events="logout"> + data-failure-param-trigger-events="account.deleteSession">

Overview

@@ -21,6 +21,9 @@
Update Password + +
@@ -147,15 +161,18 @@

By deleting your account you will lose access to any of your teams and shared data.

-

PLEASE NOTICE: Account deletion is irreversible.

+

PLEASE NOTE: Account deletion is irreversible.

@@ -176,24 +193,27 @@ data-service="account.getSessions" data-scope="console" data-name="sessions" - data-event="load,session-delete"> + data-event="load,account.deleteRemoteSession">
  • - + @@ -201,17 +221,20 @@
    - +
    @@ -233,11 +256,14 @@
Activity
diff --git a/app/views/console/comps/footer.phtml b/app/views/console/comps/footer.phtml index 44636f5c64..bea05ab8b3 100644 --- a/app/views/console/comps/footer.phtml +++ b/app/views/console/comps/footer.phtml @@ -5,13 +5,25 @@ $version = $this->getParam('version', '');
+
+
+ Appwrite Light Logo + Appwrite Dark Logo +
+