mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge branch '0.7.x' of https://github.com/appwrite/appwrite into feat-na-response-filters
This commit is contained in:
@@ -27,4 +27,8 @@ _APP_SMTP_PASSWORD=
|
||||
_APP_STORAGE_LIMIT=10000000
|
||||
_APP_FUNCTIONS_TIMEOUT=900
|
||||
_APP_FUNCTIONS_CONTAINERS=10
|
||||
_APP_SYSTEM_RESPONSE_FORMAT=0.6
|
||||
_APP_FUNCTIONS_CPUS=1
|
||||
_APP_FUNCTIONS_MEMORY=128
|
||||
_APP_FUNCTIONS_MEMORY_SWAP=128
|
||||
_APP_MAINTENANCE_INTERVAL=86400
|
||||
_APP_SYSTEM_RESPONSE_FORMAT=0.6
|
||||
+3
-3
@@ -37,6 +37,6 @@ install:
|
||||
script:
|
||||
- docker ps
|
||||
- docker-compose logs appwrite
|
||||
- docker exec appwrite doctor
|
||||
- docker exec appwrite vars
|
||||
- docker exec appwrite test
|
||||
- docker-compose exec appwrite doctor
|
||||
- docker-compose exec appwrite vars
|
||||
- docker-compose exec appwrite test
|
||||
|
||||
+7
-13
@@ -2,9 +2,8 @@
|
||||
|
||||
## Features
|
||||
|
||||
- New route in Locale API to fetch a list of languages (@TorstenDittmann)
|
||||
- Improved Webhooks and New System Events - [Learn more]()
|
||||
- Added Google Fonts to Appwrite for offline availability
|
||||
- New QR code generator library (@PedroCisnerosSantana - [#475](https://github.com/appwrite/appwrite/issues/475))
|
||||
- Added response to /locale/languages API with a list of languages (@TorstenDittmann ,[#351](https://github.com/appwrite/appwrite/issues/351))
|
||||
- Added API response payload structure info and examples to the docs site ([#381](https://github.com/appwrite/appwrite/issues/381))
|
||||
- Added Google Fonts to Appwrite for offline availability
|
||||
@@ -13,14 +12,9 @@
|
||||
- Added option to view team members from the console ([#378](https://github.com/appwrite/appwrite/issues/378))
|
||||
- Add option to assign new team members to a team from the console and the API ([#379](https://github.com/appwrite/appwrite/issues/379))
|
||||
- Added support for Brotli compression (@PedroCisnerosSantana, @Rohitub222, [#310](https://github.com/appwrite/appwrite/issues/310))
|
||||
- Added a new route in the Avatars API to get user initials avatar
|
||||
- Added option to delete team from the console
|
||||
- Added Select All Checkbox for on Console API key Scopes Screen ([#477](https://github.com/appwrite/appwrite/issues/477))
|
||||
- Added pagination and search for team memberships route ([#387](https://github.com/appwrite/appwrite/issues/387))
|
||||
- UI performance & accessibility improvements ([#406](https://github.com/appwrite/appwrite/pull/406))
|
||||
- Added option to view team members from the console
|
||||
- Added option to join a user to any team from the console
|
||||
- Added option to delete user from the API (@TorstenDittmann - #378)
|
||||
- Added option to delete user from the console (@PineappleIOnic - #538)
|
||||
- Created lazy deletion of data worker ([#521](https://github.com/appwrite/appwrite/issues/521))
|
||||
- All emails are now sent asynchronously for improved performance (@TorstenDittmann ,[#402](https://github.com/appwrite/appwrite/pull/402))
|
||||
@@ -28,11 +22,7 @@
|
||||
- Upgraded Redis Resque queue library to version 1.3.6 ([#319](https://github.com/appwrite/appwrite/issues/319))
|
||||
- Moved all Appwrite container logs to STDOUT & STDERR ([#389](https://github.com/appwrite/appwrite/issues/389))
|
||||
- New UI micro-interactions and CSS fixes (@AnatoleLucet)
|
||||
- UI performance & accessibility improvements (#406)
|
||||
- New Doctor CLI to debug the Appwrite server ([#415](https://github.com/appwrite/appwrite/issues/415))
|
||||
- All emails are now sent asynchronously for improved performance (@TorstenDittmann)
|
||||
- Updated grid for OAuth2 providers list in the console
|
||||
- Upgraded Redis Resque queue library to version 1.3.6
|
||||
- Added container names to docker-compose.yml (@drandell)
|
||||
- Upgraded ClamAV container image to version 1.0.11 ([#412](https://github.com/appwrite/appwrite/issues/412))
|
||||
- Optimised function execution by using fully-qualified function calls
|
||||
@@ -40,14 +30,17 @@
|
||||
- Added pagination for projects list on the console home page.
|
||||
- Updated storage calculation to match IEC standards
|
||||
- Now using Alpine as base Docker image
|
||||
- User name max length is now 128 chars and not 100 for better API consistency
|
||||
- Team name max length is now 128 chars and not 100 for better API consistency
|
||||
- Upgraded device detctor to version 3.12.6
|
||||
- Upgraded MariaDB to version 10.5.5
|
||||
- Switch standard ports to 95xx prefix ([#780](https://github.com/appwrite/appwrite/pull/780))
|
||||
- User & Team name max length is now 128 chars and not 100 for better API consistency
|
||||
- Collection name max length is now 128 chars and not 256 for better API consistency
|
||||
- Project name max length is now 128 chars and not 100 for better API consistency
|
||||
- Webhook name max length is now 128 chars and not 256 for better API consistency
|
||||
- API Key name max length is now 128 chars and not 256 for better API consistency
|
||||
- Task name max length is now 128 chars and not 256 for better API consistency
|
||||
- Platform name max length is now 128 chars and not 256 for better API consistency
|
||||
- Webhooks payloads are now exactly the same as any of the API response objects
|
||||
- Added new locale: Marathi -mr (@spielers)
|
||||
- New and consistent response format for all API object + new response examples in the docs
|
||||
- Removed user roles attribute from user object (can be fetched from /v1/teams/memberships) **
|
||||
@@ -69,6 +62,7 @@
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Fixed a bug that caused blocked users to be able to create sessions ([#777](https://github.com/appwrite/appwrite/pull/781))
|
||||
- Fixed an issue where Special characters in _APP_OPENSSL_KEY_V1_ env caused an error ([#732](https://github.com/appwrite/appwrite/issues/732))
|
||||
- Fixed an issue where Account webhook doesn't trigger through the console ([#493](https://github.com/appwrite/appwrite/issues/493))
|
||||
- Fixed case sensitive country flag code ([#526](https://github.com/appwrite/appwrite/issues/526))
|
||||
|
||||
+12
-1
@@ -145,6 +145,10 @@ Each container in Appwrite is a microservice on its own. Each service is an inde
|
||||
|
||||
Currently, all of the Appwrite microservices are intended to communicate using the TCP protocol over a private network. You should be aware to not expose any of the services to the public-facing network, besides the public port 80 and 443, who, by default, are used to expose the Appwrite HTTP API.
|
||||
|
||||
## Ports
|
||||
|
||||
Appwrite dev version uses ports 80 and 443 as an entry point to the Appwrite API and console. We also expose multiple ports in the range of 9500-9504 for debugging some of the Appwrite containers on dev mode. If you have any conflicts with the ports running on your system, you can easily replace them by editing Appwrite's docker-compose.yml file and executing `docker-compose up -d` command.
|
||||
|
||||
## Technology Stack
|
||||
|
||||
To start helping us to improve the Appwrite server by submitting code, prior knowledge of Appwrite's technology stack can help you with getting started.
|
||||
@@ -224,11 +228,18 @@ bash ./build.sh X.X.X
|
||||
|
||||
Before running the command, make sure you have proper write permissions to the Appwrite docker hub team.
|
||||
|
||||
**Build for multicore**
|
||||
**Build for Multicore**
|
||||
|
||||
```bash
|
||||
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x -t appwrite/appwrite:dev --push .
|
||||
```
|
||||
**Build Functions Envs**
|
||||
|
||||
Build envs for all supported cloud functions (multicore builds)
|
||||
|
||||
```bash
|
||||
bash ./docker/environments/build.sh
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
|
||||
+7
-1
@@ -92,9 +92,14 @@ ENV _APP_SERVER=swoole \
|
||||
_APP_SMTP_PORT=25 \
|
||||
_APP_FUNCTIONS_TIMEOUT=900 \
|
||||
_APP_FUNCTIONS_CONTAINERS=10 \
|
||||
_APP_FUNCTIONS_CPUS=1 \
|
||||
_APP_FUNCTIONS_MEMORY=128 \
|
||||
_APP_FUNCTIONS_MEMORY_SWAP=128 \
|
||||
_APP_SETUP=self-hosted \
|
||||
_APP_VERSION=$VERSION \
|
||||
_APP_SYSTEM_RESPONSE_FORMAT=0.6
|
||||
_APP_SYSTEM_RESPONSE_FORMAT=0.6 \
|
||||
# 1 Day = 86400 s
|
||||
_APP_MAINTENANCE_INTERVAL=86400
|
||||
#ENV _APP_SMTP_SECURE ''
|
||||
#ENV _APP_SMTP_USERNAME ''
|
||||
#ENV _APP_SMTP_PASSWORD ''
|
||||
@@ -156,6 +161,7 @@ RUN mkdir -p /storage/uploads && \
|
||||
|
||||
# Executables
|
||||
RUN chmod +x /usr/local/bin/doctor && \
|
||||
chmod +x /usr/local/bin/maintenance && \
|
||||
chmod +x /usr/local/bin/install && \
|
||||
chmod +x /usr/local/bin/migrate && \
|
||||
chmod +x /usr/local/bin/schedule && \
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<!--[](CONTRIBUTING.md)-->
|
||||
[](https://appwrite.io/discord)
|
||||
[](https://hub.docker.com/r/appwrite/appwrite)
|
||||
[](https://travis-ci.com/appwrite/appwrite)
|
||||
[](https://travis-ci.com/appwrite/appwrite)
|
||||
[](https://twitter.com/appwrite_io)
|
||||
[](https://stackshare.io/appwrite)
|
||||
|
||||
@@ -18,10 +18,10 @@ Appwrite is an end-to-end backend server for Web, Mobile, Native, or Backend app
|
||||
|
||||
Using Appwrite, you can easily integrate your app with user authentication & multiple sign-in methods, a database for storing and querying users and team data, storage and file management, image manipulation, schedule CRON tasks, and [more services](https://appwrite.io/docs).
|
||||
|
||||
Find out more at: [https://appwrite.io](https://appwrite.io)
|
||||
|
||||

|
||||
|
||||
Find out more at: [https://appwrite.io](https://appwrite.io)
|
||||
|
||||
Table of Contents:
|
||||
|
||||
- [Installation](#installation)
|
||||
|
||||
@@ -9,6 +9,7 @@ use Utopia\CLI\Console;
|
||||
$cli = new CLI();
|
||||
|
||||
include 'tasks/doctor.php';
|
||||
include 'tasks/maintenance.php';
|
||||
include 'tasks/install.php';
|
||||
include 'tasks/migrate.php';
|
||||
include 'tasks/sdks.php';
|
||||
|
||||
@@ -5,35 +5,49 @@ return [
|
||||
'name' => 'Node.js',
|
||||
'version' => '14.5',
|
||||
'base' => 'node:14.5-alpine',
|
||||
'image' => 'appwrite/env-node:14.5',
|
||||
'image' => 'appwrite/env-node-14.5:1.0.0',
|
||||
'logo' => 'node.png',
|
||||
],
|
||||
'php-7.4' => [
|
||||
'name' => 'PHP',
|
||||
'version' => '7.4',
|
||||
'base' => 'php:7.4-cli-alpine',
|
||||
'image' => 'appwrite/env-php:7.4',
|
||||
'image' => 'appwrite/env-php-7.4:1.0.0',
|
||||
'logo' => 'php.png',
|
||||
],
|
||||
'php-8.0' => [
|
||||
'name' => 'PHP',
|
||||
'version' => '8.0',
|
||||
'base' => 'php:8.0-cli-alpine',
|
||||
'image' => 'appwrite/env-php-8.0:1.0.0',
|
||||
'logo' => 'php.png',
|
||||
],
|
||||
'ruby-2.7' => [
|
||||
'name' => 'Ruby',
|
||||
'version' => '2.7',
|
||||
'base' => 'ruby:2.7-alpine',
|
||||
'image' => 'appwrite/env-ruby:2.7',
|
||||
'image' => 'appwrite/env-ruby-2.7:1.0.2',
|
||||
'logo' => 'ruby.png',
|
||||
],
|
||||
'python-3.8' => [
|
||||
'name' => 'Python',
|
||||
'version' => '3.8',
|
||||
'base' => 'python:3.8-alpine',
|
||||
'image' => 'appwrite/env-python:3.8',
|
||||
'image' => 'appwrite/env-python-3.8:1.0.0',
|
||||
'logo' => 'python.png',
|
||||
],
|
||||
'deno-1.2' => [
|
||||
'name' => 'Deno',
|
||||
'version' => '1.2',
|
||||
'base' => 'hayd/deno:alpine-1.2.0',
|
||||
'image' => 'appwrite/env-deno:1.2',
|
||||
'image' => 'appwrite/env-deno-1.2:1.0.0',
|
||||
'logo' => 'deno.png',
|
||||
],
|
||||
'deno-1.5' => [
|
||||
'name' => 'Deno',
|
||||
'version' => '1.5',
|
||||
'base' => 'hayd/deno:alpine-1.5.0',
|
||||
'image' => 'appwrite/env-deno-1.5:1.0.0',
|
||||
'logo' => 'deno.png',
|
||||
],
|
||||
// 'dart-2.8' => [
|
||||
|
||||
@@ -15,7 +15,7 @@ return [
|
||||
[
|
||||
'key' => 'web',
|
||||
'name' => 'Web',
|
||||
'version' => '1.1.0',
|
||||
'version' => '1.2.0',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-js',
|
||||
'package' => 'https://www.npmjs.com/package/appwrite',
|
||||
'enabled' => true,
|
||||
@@ -44,22 +44,6 @@ return [
|
||||
'gitRepoName' => 'sdk-for-flutter',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
[
|
||||
'key' => 'flutter-dev',
|
||||
'name' => 'Flutter (Dev Channel)',
|
||||
'version' => '0.3.2',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-flutter-dev',
|
||||
'package' => '',
|
||||
'enabled' => true,
|
||||
'beta' => true,
|
||||
'dev' => true,
|
||||
'family' => APP_PLATFORM_CLIENT,
|
||||
'prism' => 'dart',
|
||||
'source' => realpath(__DIR__ . '/../sdks/client-flutter-dev'),
|
||||
'gitUrl' => 'git@github.com:appwrite/sdk-for-flutter-dev.git',
|
||||
'gitRepoName' => 'sdk-for-flutter-dev',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
[
|
||||
'key' => 'swift',
|
||||
'name' => 'Swift',
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -151,4 +151,28 @@ return [
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
],
|
||||
[
|
||||
'name' => '_APP_FUNCTIONS_CPUS',
|
||||
'default' => '1',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
],
|
||||
[
|
||||
'name' => '_APP_FUNCTIONS_MEMORY',
|
||||
'default' => '128',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
],
|
||||
[
|
||||
'name' => '_APP_FUNCTIONS_MEMORY_SWAP',
|
||||
'default' => '128',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
],
|
||||
[
|
||||
'name' => '_APP_MAINTENANCE_INTERVAL',
|
||||
'default' => '86400',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
],
|
||||
];
|
||||
+129
-25
@@ -44,6 +44,11 @@ App::post('/v1/account')
|
||||
->param('email', '', new Email(), 'User email.')
|
||||
->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.')
|
||||
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($email, $password, $name, $request, $response, $project, $projectDB, $audits) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -123,7 +128,7 @@ App::post('/v1/account')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($user, Response::MODEL_USER)
|
||||
;
|
||||
}, ['request', 'response', 'project', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::post('/v1/account/sessions')
|
||||
->desc('Create Account Session')
|
||||
@@ -141,6 +146,12 @@ App::post('/v1/account/sessions')
|
||||
->label('abuse-key', 'url:{url},email:{param-email}')
|
||||
->param('email', '', new Email(), 'User email.')
|
||||
->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.')
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('locale')
|
||||
->inject('geodb')
|
||||
->inject('audits')
|
||||
->action(function ($email, $password, $request, $response, $projectDB, $locale, $geodb, $audits) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -168,6 +179,10 @@ App::post('/v1/account/sessions')
|
||||
throw new Exception('Invalid credentials', 401); // Wrong password or username
|
||||
}
|
||||
|
||||
if (Auth::USER_STATUS_BLOCKED == $profile->getAttribute('status')) { // Account is blocked
|
||||
throw new Exception('Invalid credentials. User is blocked', 401); // User is in status blocked
|
||||
}
|
||||
|
||||
$dd = new DeviceDetector($request->getUserAgent('UNKNOWN'));
|
||||
|
||||
$dd->parse();
|
||||
@@ -262,7 +277,7 @@ App::post('/v1/account/sessions')
|
||||
;
|
||||
|
||||
$response->dynamic($session, Response::MODEL_SESSION);
|
||||
}, ['request', 'response', 'projectDB', 'locale', 'geodb', 'audits']);
|
||||
});
|
||||
|
||||
App::get('/v1/account/sessions/oauth2/:provider')
|
||||
->desc('Create Account Session with OAuth2')
|
||||
@@ -282,6 +297,9 @@ App::get('/v1/account/sessions/oauth2/:provider')
|
||||
->param('success', $oauthDefaultSuccess, function ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', true, ['clients'])
|
||||
->param('failure', $oauthDefaultFailure, function ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', true, ['clients'])
|
||||
->param('scopes', [], new ArrayList(new Text(128)), 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.', true)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->action(function ($provider, $success, $failure, $scopes, $request, $response, $project) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -292,8 +310,6 @@ App::get('/v1/account/sessions/oauth2/:provider')
|
||||
$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 = App::getEnv('_APP_OPENSSL_KEY_V'.$appSecret['version']);
|
||||
$appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag']));
|
||||
@@ -315,7 +331,7 @@ App::get('/v1/account/sessions/oauth2/:provider')
|
||||
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
|
||||
->addHeader('Pragma', 'no-cache')
|
||||
->redirect($oauth2->getLoginURL());
|
||||
}, ['request', 'response', 'project']);
|
||||
});
|
||||
|
||||
App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
|
||||
->desc('OAuth2 Callback')
|
||||
@@ -327,6 +343,8 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
|
||||
->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 provider.')
|
||||
->param('code', '', new Text(1024), 'OAuth2 code.')
|
||||
->param('state', '', new Text(2048), 'Login state params.', true)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->action(function ($projectId, $provider, $code, $state, $request, $response) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -339,7 +357,7 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
|
||||
->addHeader('Pragma', 'no-cache')
|
||||
->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?'
|
||||
.\http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state]));
|
||||
}, ['request', 'response']);
|
||||
});
|
||||
|
||||
App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
|
||||
->desc('OAuth2 Callback')
|
||||
@@ -352,6 +370,8 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
|
||||
->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 provider.')
|
||||
->param('code', '', new Text(1024), 'OAuth2 code.')
|
||||
->param('state', '', new Text(2048), 'Login state params.', true)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->action(function ($projectId, $provider, $code, $state, $request, $response) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -364,7 +384,7 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId')
|
||||
->addHeader('Pragma', 'no-cache')
|
||||
->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?'
|
||||
.\http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state]));
|
||||
}, ['request', 'response']);
|
||||
});
|
||||
|
||||
App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||
->desc('OAuth2 Redirect')
|
||||
@@ -378,6 +398,13 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||
->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 provider.')
|
||||
->param('code', '', new Text(1024), 'OAuth2 code.')
|
||||
->param('state', '', new Text(2048), 'OAuth2 state params.', true)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('geodb')
|
||||
->inject('audits')
|
||||
->action(function ($provider, $code, $state, $request, $response, $project, $user, $projectDB, $geodb, $audits) use ($oauthDefaultSuccess) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -395,8 +422,6 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||
$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 = App::getEnv('_APP_OPENSSL_KEY_V'.$appSecret['version']);
|
||||
$appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag']));
|
||||
@@ -503,6 +528,10 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||
}
|
||||
}
|
||||
|
||||
if (Auth::USER_STATUS_BLOCKED == $user->getAttribute('status')) { // Account is blocked
|
||||
throw new Exception('Invalid credentials. User is blocked', 401); // User is in status blocked
|
||||
}
|
||||
|
||||
// Create session token, verify user account and update OAuth2 ID and Access Token
|
||||
|
||||
$dd = new DeviceDetector($request->getUserAgent('UNKNOWN'));
|
||||
@@ -606,7 +635,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||
->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite'))
|
||||
->redirect($state['success'])
|
||||
;
|
||||
}, ['request', 'response', 'project', 'user', 'projectDB', 'geodb', 'audits']);
|
||||
});
|
||||
|
||||
App::get('/v1/account')
|
||||
->desc('Get Account')
|
||||
@@ -619,12 +648,14 @@ App::get('/v1/account')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_USER)
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->action(function ($response, $user) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
|
||||
$response->dynamic($user, Response::MODEL_USER);
|
||||
}, ['response', 'user']);
|
||||
});
|
||||
|
||||
App::get('/v1/account/prefs')
|
||||
->desc('Get Account Preferences')
|
||||
@@ -637,6 +668,8 @@ App::get('/v1/account/prefs')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_ANY)
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->action(function ($response, $user) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -644,7 +677,7 @@ App::get('/v1/account/prefs')
|
||||
$prefs = $user->getAttribute('prefs', new \stdClass);
|
||||
|
||||
$response->dynamic(new Document($prefs), Response::MODEL_ANY);
|
||||
}, ['response', 'user']);
|
||||
});
|
||||
|
||||
App::get('/v1/account/sessions')
|
||||
->desc('Get Account Sessions')
|
||||
@@ -657,6 +690,9 @@ App::get('/v1/account/sessions')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_SESSION_LIST)
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('locale')
|
||||
->action(function ($response, $user, $locale) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -684,7 +720,7 @@ App::get('/v1/account/sessions')
|
||||
'sum' => count($sessions),
|
||||
'sessions' => $sessions
|
||||
]), Response::MODEL_SESSION_LIST);
|
||||
}, ['response', 'user', 'locale']);
|
||||
});
|
||||
|
||||
App::get('/v1/account/logs')
|
||||
->desc('Get Account Logs')
|
||||
@@ -697,6 +733,12 @@ App::get('/v1/account/logs')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_LOG_LIST)
|
||||
->inject('response')
|
||||
->inject('register')
|
||||
->inject('project')
|
||||
->inject('user')
|
||||
->inject('locale')
|
||||
->inject('geodb')
|
||||
->action(function ($response, $register, $project, $user, $locale, $geodb) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
@@ -784,7 +826,7 @@ App::get('/v1/account/logs')
|
||||
}
|
||||
|
||||
$response->dynamic(new Document(['logs' => $output]), Response::MODEL_LOG_LIST);
|
||||
}, ['response', 'register', 'project', 'user', 'locale', 'geodb']);
|
||||
});
|
||||
|
||||
App::patch('/v1/account/name')
|
||||
->desc('Update Account Name')
|
||||
@@ -799,6 +841,10 @@ App::patch('/v1/account/name')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_USER)
|
||||
->param('name', '', new Text(128), 'User name. Max length: 128 chars.')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($name, $response, $user, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -820,7 +866,7 @@ App::patch('/v1/account/name')
|
||||
;
|
||||
|
||||
$response->dynamic($user, Response::MODEL_USER);
|
||||
}, ['response', 'user', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::patch('/v1/account/password')
|
||||
->desc('Update Account Password')
|
||||
@@ -836,6 +882,10 @@ App::patch('/v1/account/password')
|
||||
->label('sdk.response.model', Response::MODEL_USER)
|
||||
->param('password', '', new Password(), 'New user password. Must be between 6 to 32 chars.')
|
||||
->param('oldPassword', '', new Password(), 'Old user password. Must be between 6 to 32 chars.')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($password, $oldPassword, $response, $user, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -861,7 +911,7 @@ App::patch('/v1/account/password')
|
||||
;
|
||||
|
||||
$response->dynamic($user, Response::MODEL_USER);
|
||||
}, ['response', 'user', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::patch('/v1/account/email')
|
||||
->desc('Update Account Email')
|
||||
@@ -877,6 +927,10 @@ App::patch('/v1/account/email')
|
||||
->label('sdk.response.model', Response::MODEL_USER)
|
||||
->param('email', '', new Email(), 'User email.')
|
||||
->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($email, $password, $response, $user, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -917,7 +971,7 @@ App::patch('/v1/account/email')
|
||||
;
|
||||
|
||||
$response->dynamic($user, Response::MODEL_USER);
|
||||
}, ['response', 'user', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::patch('/v1/account/prefs')
|
||||
->desc('Update Account Preferences')
|
||||
@@ -932,6 +986,10 @@ App::patch('/v1/account/prefs')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_ANY)
|
||||
->param('prefs', [], new Assoc(), 'Prefs key-value JSON object.')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($prefs, $response, $user, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -952,7 +1010,7 @@ App::patch('/v1/account/prefs')
|
||||
;
|
||||
|
||||
$response->dynamic($user, Response::MODEL_USER);
|
||||
}, ['response', 'user', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::delete('/v1/account')
|
||||
->desc('Delete Account')
|
||||
@@ -966,6 +1024,12 @@ App::delete('/v1/account')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->inject('events')
|
||||
->action(function ($request, $response, $user, $projectDB, $audits, $events) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -1013,7 +1077,7 @@ App::delete('/v1/account')
|
||||
->addCookie(Auth::$cookieName, '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite'))
|
||||
->noContent()
|
||||
;
|
||||
}, ['request', 'response', 'user', 'projectDB', 'audits', 'events']);
|
||||
});
|
||||
|
||||
App::delete('/v1/account/sessions/:sessionId')
|
||||
->desc('Delete Account Session')
|
||||
@@ -1029,6 +1093,12 @@ App::delete('/v1/account/sessions/:sessionId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->label('abuse-limit', 100)
|
||||
->param('sessionId', null, new UID(), 'Session unique ID. Use the string \'current\' to delete the current device session.')
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->inject('events')
|
||||
->action(function ($sessionId, $request, $response, $user, $projectDB, $audits, $events) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -1082,7 +1152,7 @@ App::delete('/v1/account/sessions/:sessionId')
|
||||
}
|
||||
|
||||
throw new Exception('Session not found', 404);
|
||||
}, ['request', 'response', 'user', 'projectDB', 'audits', 'events']);
|
||||
});
|
||||
|
||||
App::delete('/v1/account/sessions')
|
||||
->desc('Delete All Account Sessions')
|
||||
@@ -1097,6 +1167,12 @@ App::delete('/v1/account/sessions')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->label('abuse-limit', 100)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->inject('events')
|
||||
->action(function ($request, $response, $user, $projectDB, $audits, $events) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -1144,7 +1220,7 @@ App::delete('/v1/account/sessions')
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
}, ['request', 'response', 'user', 'projectDB', 'audits', 'events']);
|
||||
});
|
||||
|
||||
App::post('/v1/account/recovery')
|
||||
->desc('Create Password Recovery')
|
||||
@@ -1162,6 +1238,14 @@ App::post('/v1/account/recovery')
|
||||
->label('abuse-key', 'url:{url},email:{param-email}')
|
||||
->param('email', '', new Email(), 'User email.')
|
||||
->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients'])
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('project')
|
||||
->inject('locale')
|
||||
->inject('mails')
|
||||
->inject('audits')
|
||||
->inject('events')
|
||||
->action(function ($email, $url, $request, $response, $projectDB, $project, $locale, $mails, $audits, $events) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -1187,6 +1271,10 @@ App::post('/v1/account/recovery')
|
||||
throw new Exception('User not found', 404); // TODO maybe hide this
|
||||
}
|
||||
|
||||
if (Auth::USER_STATUS_BLOCKED == $profile->getAttribute('status')) { // Account is blocked
|
||||
throw new Exception('Invalid credentials. User is blocked', 401); // User is in status blocked
|
||||
}
|
||||
|
||||
$secret = Auth::tokenGenerator();
|
||||
$recovery = new Document([
|
||||
'$collection' => Database::SYSTEM_COLLECTION_TOKENS,
|
||||
@@ -1270,7 +1358,7 @@ App::post('/v1/account/recovery')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($recovery, Response::MODEL_TOKEN)
|
||||
;
|
||||
}, ['request', 'response', 'projectDB', 'project', 'locale', 'mails', 'audits', 'events']);
|
||||
});
|
||||
|
||||
App::put('/v1/account/recovery')
|
||||
->desc('Complete Password Recovery')
|
||||
@@ -1290,6 +1378,9 @@ App::put('/v1/account/recovery')
|
||||
->param('secret', '', new Text(256), 'Valid reset token.')
|
||||
->param('password', '', new Password(), 'New password. Must be between 6 to 32 chars.')
|
||||
->param('passwordAgain', '', new Password(), 'New password again. Must be between 6 to 32 chars.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($userId, $secret, $password, $passwordAgain, $response, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -1346,7 +1437,7 @@ App::put('/v1/account/recovery')
|
||||
$recovery = $profile->search('$id', $recovery, $profile->getAttribute('tokens', []));
|
||||
|
||||
$response->dynamic($recovery, Response::MODEL_TOKEN);
|
||||
}, ['response', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::post('/v1/account/verification')
|
||||
->desc('Create Email Verification')
|
||||
@@ -1363,6 +1454,15 @@ App::post('/v1/account/verification')
|
||||
->label('abuse-limit', 10)
|
||||
->label('abuse-key', 'url:{url},email:{param-email}')
|
||||
->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) // TODO add built-in confirm page
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('locale')
|
||||
->inject('audits')
|
||||
->inject('events')
|
||||
->inject('mails')
|
||||
->action(function ($url, $request, $response, $project, $user, $projectDB, $locale, $audits, $events, $mails) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -1461,7 +1561,7 @@ App::post('/v1/account/verification')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($verification, Response::MODEL_TOKEN)
|
||||
;
|
||||
}, ['request', 'response', 'project', 'user', 'projectDB', 'locale', 'audits', 'events', 'mails']);
|
||||
});
|
||||
|
||||
App::put('/v1/account/verification')
|
||||
->desc('Complete Email Verification')
|
||||
@@ -1479,6 +1579,10 @@ App::put('/v1/account/verification')
|
||||
->label('abuse-key', 'url:{url},userId:{param-userId}')
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->param('secret', '', new Text(256), 'Valid verification token.')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($userId, $secret, $response, $user, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -1530,4 +1634,4 @@ App::put('/v1/account/verification')
|
||||
$verification = $profile->search('$id', $verification, $profile->getAttribute('tokens', []));
|
||||
|
||||
$response->dynamic($verification, Response::MODEL_TOKEN);
|
||||
}, ['response', 'user', 'projectDB', 'audits']);
|
||||
});
|
||||
@@ -95,9 +95,10 @@ App::get('/v1/avatars/credit-cards/:code')
|
||||
->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true)
|
||||
->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
|
||||
->param('quality', 100, new Range(0, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
|
||||
->inject('response')
|
||||
->action(function ($code, $width, $height, $quality, $response) use ($avatarCallback) {
|
||||
return $avatarCallback('credit-cards', $code, $width, $height, $quality, $response);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/avatars/browsers/:code')
|
||||
->desc('Get Browser Icon')
|
||||
@@ -114,9 +115,10 @@ App::get('/v1/avatars/browsers/:code')
|
||||
->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true)
|
||||
->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
|
||||
->param('quality', 100, new Range(0, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
|
||||
->inject('response')
|
||||
->action(function ($code, $width, $height, $quality, $response) use ($avatarCallback) {
|
||||
return $avatarCallback('browsers', $code, $width, $height, $quality, $response);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/avatars/flags/:code')
|
||||
->desc('Get Country Flag')
|
||||
@@ -133,9 +135,10 @@ App::get('/v1/avatars/flags/:code')
|
||||
->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true)
|
||||
->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
|
||||
->param('quality', 100, new Range(0, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
|
||||
->inject('response')
|
||||
->action(function ($code, $width, $height, $quality, $response) use ($avatarCallback) {
|
||||
return $avatarCallback('flags', $code, $width, $height, $quality, $response);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/avatars/image')
|
||||
->desc('Get Image from URL')
|
||||
@@ -151,6 +154,7 @@ App::get('/v1/avatars/image')
|
||||
->param('url', '', new URL(), 'Image URL which you want to crop.')
|
||||
->param('width', 400, new Range(0, 2000), 'Resize preview image width, Pass an integer between 0 to 2000.', true)
|
||||
->param('height', 400, new Range(0, 2000), 'Resize preview image height, Pass an integer between 0 to 2000.', true)
|
||||
->inject('response')
|
||||
->action(function ($url, $width, $height, $response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -203,7 +207,7 @@ App::get('/v1/avatars/image')
|
||||
;
|
||||
|
||||
unset($resize);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/avatars/favicon')
|
||||
->desc('Get Favicon')
|
||||
@@ -217,6 +221,7 @@ App::get('/v1/avatars/favicon')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_IMAGE)
|
||||
->param('url', '', new URL(), 'Website URL which you want to fetch the favicon from.')
|
||||
->inject('response')
|
||||
->action(function ($url, $response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -355,7 +360,7 @@ App::get('/v1/avatars/favicon')
|
||||
->send($data);
|
||||
|
||||
unset($resize);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/avatars/qr')
|
||||
->desc('Get QR Code')
|
||||
@@ -372,6 +377,7 @@ App::get('/v1/avatars/qr')
|
||||
->param('size', 400, new Range(0, 1000), 'QR code size. Pass an integer between 0 to 1000. Defaults to 400.', true)
|
||||
->param('margin', 1, new Range(0, 10), 'Margin from edge. Pass an integer between 0 to 10. Defaults to 1.', true)
|
||||
->param('download', false, new Boolean(true), '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)
|
||||
->inject('response')
|
||||
->action(function ($text, $size, $margin, $download, $response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -392,7 +398,7 @@ App::get('/v1/avatars/qr')
|
||||
->setContentType('image/png')
|
||||
->send($qrcode->render($text))
|
||||
;
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/avatars/initials')
|
||||
->desc('Get User Initials')
|
||||
@@ -410,6 +416,8 @@ App::get('/v1/avatars/initials')
|
||||
->param('height', 500, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
|
||||
->param('color', '', new HexColor(), 'Changes text color. By default a random color will be picked and stay will persistent to the given name.', true)
|
||||
->param('background', '', new HexColor(), 'Changes background color. By default a random color will be picked and stay will persistent to the given name.', true)
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->action(function ($name, $width, $height, $color, $background, $response, $user) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -472,4 +480,4 @@ App::get('/v1/avatars/initials')
|
||||
->setContentType('image/png')
|
||||
->send($image->getImageBlob())
|
||||
;
|
||||
}, ['response', 'user']);
|
||||
});
|
||||
|
||||
@@ -34,6 +34,9 @@ App::post('/v1/database/collections')
|
||||
->param('read', [], 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', [], 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 ($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.', false, ['projectDB'])
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($name, $read, $write, $rules, $response, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -86,7 +89,7 @@ App::post('/v1/database/collections')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($data, Response::MODEL_COLLECTION)
|
||||
;
|
||||
}, ['response', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::get('/v1/database/collections')
|
||||
->desc('List Collections')
|
||||
@@ -103,6 +106,8 @@ App::get('/v1/database/collections')
|
||||
->param('limit', 25, 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, new Range(0, 40000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -110,6 +115,7 @@ App::get('/v1/database/collections')
|
||||
$results = $projectDB->getCollection([
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'orderType' => $orderType,
|
||||
'search' => $search,
|
||||
'filters' => [
|
||||
'$collection='.Database::SYSTEM_COLLECTION_COLLECTIONS,
|
||||
@@ -120,7 +126,7 @@ App::get('/v1/database/collections')
|
||||
'sum' => $projectDB->getSum(),
|
||||
'collections' => $results
|
||||
]), Response::MODEL_COLLECTION_LIST);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/database/collections/:collectionId')
|
||||
->desc('Get Collection')
|
||||
@@ -134,6 +140,8 @@ App::get('/v1/database/collections/:collectionId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_COLLECTION)
|
||||
->param('collectionId', '', new UID(), 'Collection unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($collectionId, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -145,7 +153,7 @@ App::get('/v1/database/collections/:collectionId')
|
||||
}
|
||||
|
||||
$response->dynamic($collection, Response::MODEL_COLLECTION);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::put('/v1/database/collections/:collectionId')
|
||||
->desc('Update Collection')
|
||||
@@ -164,6 +172,9 @@ App::put('/v1/database/collections/:collectionId')
|
||||
->param('read', [], 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', [], 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 ($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, ['projectDB'])
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($collectionId, $name, $read, $write, $rules, $response, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -217,7 +228,7 @@ App::put('/v1/database/collections/:collectionId')
|
||||
;
|
||||
|
||||
$response->dynamic($collection, Response::MODEL_COLLECTION);
|
||||
}, ['response', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::delete('/v1/database/collections/:collectionId')
|
||||
->desc('Delete Collection')
|
||||
@@ -232,6 +243,11 @@ App::delete('/v1/database/collections/:collectionId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('collectionId', '', new UID(), 'Collection unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('events')
|
||||
->inject('audits')
|
||||
->inject('deletes')
|
||||
->action(function ($collectionId, $response, $projectDB, $events, $audits, $deletes) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -249,6 +265,7 @@ App::delete('/v1/database/collections/:collectionId')
|
||||
}
|
||||
|
||||
$deletes
|
||||
->setParam('type', DELETE_TYPE_DOCUMENT)
|
||||
->setParam('document', $collection)
|
||||
;
|
||||
|
||||
@@ -263,7 +280,7 @@ App::delete('/v1/database/collections/:collectionId')
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'events', 'audits', 'deletes']);
|
||||
});
|
||||
|
||||
App::post('/v1/database/collections/:collectionId/documents')
|
||||
->desc('Create Document')
|
||||
@@ -284,6 +301,9 @@ App::post('/v1/database/collections/:collectionId/documents')
|
||||
->param('parentDocument', '', new UID(), 'Parent document unique ID. Use when you want your new document to be a child of a parent document.', true)
|
||||
->param('parentProperty', '', new Key(), 'Parent document property name. Use when you want your new document to be a child of a parent document.', true)
|
||||
->param('parentPropertyType', Document::SET_TYPE_ASSIGN, new WhiteList([Document::SET_TYPE_ASSIGN, Document::SET_TYPE_APPEND, Document::SET_TYPE_PREPEND], true), 'Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType, $response, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -380,7 +400,7 @@ App::post('/v1/database/collections/:collectionId/documents')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($data, Response::MODEL_ANY)
|
||||
;
|
||||
}, ['response', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::get('/v1/database/collections/:collectionId/documents')
|
||||
->desc('List Documents')
|
||||
@@ -401,6 +421,8 @@ App::get('/v1/database/collections/:collectionId/documents')
|
||||
->param('orderType', 'ASC', new WhiteList(['DESC', 'ASC'], true), 'Order direction. Possible values are DESC for descending order, or ASC for ascending order.', true)
|
||||
->param('orderCast', 'string', new WhiteList(['int', 'string', 'date', 'time', 'datetime'], true), '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', '', new Text(256), 'Search query. Enter any free text search. The database will try to find a match against all document attributes and children. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($collectionId, $filters, $limit, $offset, $orderField, $orderType, $orderCast, $search, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -441,7 +463,7 @@ App::get('/v1/database/collections/:collectionId/documents')
|
||||
;
|
||||
|
||||
$response->dynamic($collection, Response::MODEL_DOCUMENT_LIST);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
->desc('Get Document')
|
||||
@@ -456,8 +478,9 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
->label('sdk.response.model', Response::MODEL_ANY)
|
||||
->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).')
|
||||
->param('documentId', null, new UID(), 'Document unique ID.')
|
||||
->action(function ($collectionId, $documentId, $request, $response, $projectDB) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($collectionId, $documentId, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
|
||||
@@ -469,7 +492,7 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
}
|
||||
|
||||
$response->dynamic($document, Response::MODEL_ANY);
|
||||
}, ['request', 'response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::patch('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
->desc('Update Document')
|
||||
@@ -488,6 +511,9 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
->param('data', [], new JSON(), 'Document data as JSON object.')
|
||||
->param('read', [], 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', [], 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.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($collectionId, $documentId, $data, $read, $write, $response, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -546,7 +572,7 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
;
|
||||
|
||||
$response->dynamic($data, Response::MODEL_ANY);
|
||||
}, ['response', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::delete('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
->desc('Delete Document')
|
||||
@@ -562,6 +588,10 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).')
|
||||
->param('documentId', null, new UID(), 'Document unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('events')
|
||||
->inject('audits')
|
||||
->action(function ($collectionId, $documentId, $response, $projectDB, $events, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -600,4 +630,4 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'events', 'audits']);
|
||||
});
|
||||
@@ -38,6 +38,8 @@ App::post('/v1/functions')
|
||||
->param('events', [], new ArrayList(new WhiteList(array_keys(Config::getParam('events')), true)), 'Events list.', true)
|
||||
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
|
||||
->param('timeout', 15, new Range(1, 900), 'Function maximum execution time in seconds.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($name, $env, $vars, $events, $schedule, $timeout, $response, $projectDB) {
|
||||
$function = $projectDB->createDocument([
|
||||
'$collection' => Database::SYSTEM_COLLECTION_FUNCTIONS,
|
||||
@@ -67,7 +69,7 @@ App::post('/v1/functions')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($function, Response::MODEL_FUNCTION)
|
||||
;
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/functions')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -84,10 +86,13 @@ App::get('/v1/functions')
|
||||
->param('limit', 25, 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, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
|
||||
$results = $projectDB->getCollection([
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'orderType' => $orderType,
|
||||
'search' => $search,
|
||||
'filters' => [
|
||||
'$collection='.Database::SYSTEM_COLLECTION_FUNCTIONS,
|
||||
@@ -98,7 +103,7 @@ App::get('/v1/functions')
|
||||
'sum' => $projectDB->getSum(),
|
||||
'functions' => $results
|
||||
]), Response::MODEL_FUNCTION_LIST);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/functions/:functionId')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -112,6 +117,8 @@ App::get('/v1/functions/:functionId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_FUNCTION)
|
||||
->param('functionId', '', new UID(), 'Function unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($functionId, $response, $projectDB) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
|
||||
@@ -120,7 +127,7 @@ App::get('/v1/functions/:functionId')
|
||||
}
|
||||
|
||||
$response->dynamic($function, Response::MODEL_FUNCTION);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/functions/:functionId/usage')
|
||||
->desc('Get Function Usage')
|
||||
@@ -131,6 +138,10 @@ App::get('/v1/functions/:functionId/usage')
|
||||
->label('sdk.method', 'getUsage')
|
||||
->param('functionId', '', new UID(), 'Function unique ID.')
|
||||
->param('range', '30d', new WhiteList(['24h', '7d', '30d', '90d']), 'Date range.', true)
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('projectDB')
|
||||
->inject('register')
|
||||
->action(function ($functionId, $range, $response, $project, $projectDB, $register) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
@@ -233,7 +244,7 @@ App::get('/v1/functions/:functionId/usage')
|
||||
}, $compute)),
|
||||
],
|
||||
]);
|
||||
}, ['response', 'project', 'projectDB', 'register']);
|
||||
});
|
||||
|
||||
App::put('/v1/functions/:functionId')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -252,6 +263,8 @@ App::put('/v1/functions/:functionId')
|
||||
->param('events', [], new ArrayList(new WhiteList(array_keys(Config::getParam('events')), true)), 'Events list.', true)
|
||||
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
|
||||
->param('timeout', 15, new Range(1, 900), 'Function maximum execution time in seconds.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($functionId, $name, $vars, $events, $schedule, $timeout, $response, $projectDB) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
|
||||
@@ -291,7 +304,7 @@ App::put('/v1/functions/:functionId')
|
||||
}
|
||||
|
||||
$response->dynamic($function, Response::MODEL_FUNCTION);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::patch('/v1/functions/:functionId/tag')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -300,12 +313,14 @@ App::patch('/v1/functions/:functionId/tag')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'updateTag')
|
||||
->label('sdk.description', '/docs/references/functions/update-tag.md')
|
||||
->label('sdk.description', '/docs/references/functions/update-function-tag.md')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_FUNCTION)
|
||||
->param('functionId', '', new UID(), 'Function unique ID.')
|
||||
->param('tag', '', new UID(), 'Tag unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($functionId, $tag, $response, $projectDB) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
$tag = $projectDB->getDocument($tag);
|
||||
@@ -332,7 +347,7 @@ App::patch('/v1/functions/:functionId/tag')
|
||||
}
|
||||
|
||||
$response->dynamic($function, Response::MODEL_FUNCTION);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/functions/:functionId')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -346,6 +361,9 @@ App::delete('/v1/functions/:functionId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('functionId', '', new UID(), 'Function unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('deletes')
|
||||
->action(function ($functionId, $response, $projectDB, $deletes) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -362,11 +380,12 @@ App::delete('/v1/functions/:functionId')
|
||||
}
|
||||
|
||||
$deletes
|
||||
->setParam('type', DELETE_TYPE_DOCUMENT)
|
||||
->setParam('document', $function->getArrayCopy())
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'deletes']);
|
||||
});
|
||||
|
||||
App::post('/v1/functions/:functionId/tags')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -384,6 +403,10 @@ App::post('/v1/functions/:functionId/tags')
|
||||
->param('command', '', new Text('1028'), 'Code execution command.')
|
||||
->param('code', [], new File(), 'Gzip file containing your code.', false)
|
||||
// ->param('code', '', new Text(128), 'Code package. Use the '.APP_NAME.' code packager to create a deployable package file.')
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('usage')
|
||||
->action(function ($functionId, $command, $code, $request, $response, $projectDB, $usage) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
|
||||
@@ -452,7 +475,7 @@ App::post('/v1/functions/:functionId/tags')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($tag, Response::MODEL_TAG)
|
||||
;
|
||||
}, ['request', 'response', 'projectDB', 'usage']);
|
||||
});
|
||||
|
||||
App::get('/v1/functions/:functionId/tags')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -470,6 +493,8 @@ App::get('/v1/functions/:functionId/tags')
|
||||
->param('limit', 25, 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, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($functionId, $search, $limit, $offset, $orderType, $response, $projectDB) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
|
||||
@@ -480,6 +505,7 @@ App::get('/v1/functions/:functionId/tags')
|
||||
$results = $projectDB->getCollection([
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'orderType' => $orderType,
|
||||
'search' => $search,
|
||||
'filters' => [
|
||||
'$collection='.Database::SYSTEM_COLLECTION_TAGS,
|
||||
@@ -491,7 +517,7 @@ App::get('/v1/functions/:functionId/tags')
|
||||
'sum' => $projectDB->getSum(),
|
||||
'tags' => $results
|
||||
]), Response::MODEL_TAG_LIST);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/functions/:functionId/tags/:tagId')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -506,6 +532,8 @@ App::get('/v1/functions/:functionId/tags/:tagId')
|
||||
->label('sdk.response.model', Response::MODEL_TAG)
|
||||
->param('functionId', '', new UID(), 'Function unique ID.')
|
||||
->param('tagId', '', new UID(), 'Tag unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($functionId, $tagId, $response, $projectDB) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
|
||||
@@ -524,7 +552,7 @@ App::get('/v1/functions/:functionId/tags/:tagId')
|
||||
}
|
||||
|
||||
$response->dynamic($tag, Response::MODEL_TAG);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/functions/:functionId/tags/:tagId')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -539,6 +567,9 @@ App::delete('/v1/functions/:functionId/tags/:tagId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('functionId', '', new UID(), 'Function unique ID.')
|
||||
->param('tagId', '', new UID(), 'Tag unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('usage')
|
||||
->action(function ($functionId, $tagId, $response, $projectDB, $usage) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
|
||||
@@ -579,7 +610,7 @@ App::delete('/v1/functions/:functionId/tags/:tagId')
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'usage']);
|
||||
});
|
||||
|
||||
App::post('/v1/functions/:functionId/executions')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -594,6 +625,9 @@ App::post('/v1/functions/:functionId/executions')
|
||||
->label('sdk.response.model', Response::MODEL_EXECUTION)
|
||||
->param('functionId', '', new UID(), 'Function unique ID.')
|
||||
// ->param('async', 1, new Range(0, 1), 'Execute code asynchronously. Pass 1 for true, 0 for false. Default value is 1.', true)
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('projectDB')
|
||||
->action(function ($functionId, /*$async,*/ $response, $project, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
@@ -635,7 +669,6 @@ App::post('/v1/functions/:functionId/executions')
|
||||
throw new Exception('Failed saving execution to DB', 500);
|
||||
}
|
||||
|
||||
// Issue a TLS certificate when domain is verified
|
||||
Resque::enqueue('v1-functions', 'FunctionsV1', [
|
||||
'projectId' => $project->getId(),
|
||||
'functionId' => $function->getId(),
|
||||
@@ -647,7 +680,7 @@ App::post('/v1/functions/:functionId/executions')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($execution, Response::MODEL_EXECUTION)
|
||||
;
|
||||
}, ['response', 'project', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/functions/:functionId/executions')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -665,6 +698,8 @@ App::get('/v1/functions/:functionId/executions')
|
||||
->param('limit', 25, 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, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($functionId, $search, $limit, $offset, $orderType, $response, $projectDB) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
|
||||
@@ -675,6 +710,7 @@ App::get('/v1/functions/:functionId/executions')
|
||||
$results = $projectDB->getCollection([
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'orderType' => $orderType,
|
||||
'search' => $search,
|
||||
'filters' => [
|
||||
'$collection='.Database::SYSTEM_COLLECTION_EXECUTIONS,
|
||||
@@ -686,7 +722,7 @@ App::get('/v1/functions/:functionId/executions')
|
||||
'sum' => $projectDB->getSum(),
|
||||
'executions' => $results
|
||||
]), Response::MODEL_EXECUTION_LIST);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/functions/:functionId/executions/:executionId')
|
||||
->groups(['api', 'functions'])
|
||||
@@ -701,6 +737,8 @@ App::get('/v1/functions/:functionId/executions/:executionId')
|
||||
->label('sdk.response.model', Response::MODEL_EXECUTION)
|
||||
->param('functionId', '', new UID(), 'Function unique ID.')
|
||||
->param('executionId', '', new UID(), 'Execution unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($functionId, $executionId, $response, $projectDB) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
|
||||
@@ -719,4 +757,4 @@ App::get('/v1/functions/:functionId/executions/:executionId')
|
||||
}
|
||||
|
||||
$response->dynamic($execution, Response::MODEL_EXECUTION);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ use Utopia\Exception;
|
||||
use Appwrite\Storage\Device\Local;
|
||||
use Appwrite\Storage\Storage;
|
||||
use Appwrite\ClamAV\Network;
|
||||
use Appwrite\Event\Event;
|
||||
|
||||
App::get('/v1/health')
|
||||
->desc('Get HTTP')
|
||||
@@ -14,21 +15,23 @@ App::get('/v1/health')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'get')
|
||||
->label('sdk.description', '/docs/references/health/get.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['status' => 'OK']);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/version')
|
||||
->desc('Get Version')
|
||||
->groups(['api', 'health'])
|
||||
->label('scope', 'public')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['version' => APP_VERSION_STABLE]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/db')
|
||||
->desc('Get DB')
|
||||
@@ -38,6 +41,8 @@ App::get('/v1/health/db')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getDB')
|
||||
->label('sdk.description', '/docs/references/health/get-db.md')
|
||||
->inject('response')
|
||||
->inject('register')
|
||||
->action(function ($response, $register) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Registry\Registry $register */
|
||||
@@ -45,7 +50,7 @@ App::get('/v1/health/db')
|
||||
$register->get('db'); /* @var $db PDO */
|
||||
|
||||
$response->json(['status' => 'OK']);
|
||||
}, ['response', 'register']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/cache')
|
||||
->desc('Get Cache')
|
||||
@@ -55,13 +60,15 @@ App::get('/v1/health/cache')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getCache')
|
||||
->label('sdk.description', '/docs/references/health/get-cache.md')
|
||||
->inject('response')
|
||||
->inject('register')
|
||||
->action(function ($response, $register) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Registry\Registry $register */
|
||||
$register->get('cache'); /* @var $cache Predis\Client */
|
||||
|
||||
$response->json(['status' => 'OK']);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/time')
|
||||
->desc('Get Time')
|
||||
@@ -71,6 +78,7 @@ App::get('/v1/health/time')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getTime')
|
||||
->label('sdk.description', '/docs/references/health/get-time.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -109,7 +117,7 @@ App::get('/v1/health/time')
|
||||
}
|
||||
|
||||
$response->json(['remote' => $timestamp, 'local' => \time(), 'diff' => $diff]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/queue/webhooks')
|
||||
->desc('Get Webhooks Queue')
|
||||
@@ -119,10 +127,11 @@ App::get('/v1/health/queue/webhooks')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueWebhooks')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-webhooks.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-webhooks')]);
|
||||
$response->json(['size' => Resque::size(Event::WEBHOOK_QUEUE_NAME)]);
|
||||
}, ['response']);
|
||||
|
||||
App::get('/v1/health/queue/tasks')
|
||||
@@ -133,10 +142,11 @@ App::get('/v1/health/queue/tasks')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueTasks')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-tasks.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-tasks')]);
|
||||
$response->json(['size' => Resque::size(Event::TASK_QUEUE_NAME)]);
|
||||
}, ['response']);
|
||||
|
||||
App::get('/v1/health/queue/logs')
|
||||
@@ -147,10 +157,11 @@ App::get('/v1/health/queue/logs')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueLogs')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-logs.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-audit')]);
|
||||
$response->json(['size' => Resque::size(Event::AUDITS_QUEUE_NAME)]);
|
||||
}, ['response']);
|
||||
|
||||
App::get('/v1/health/queue/usage')
|
||||
@@ -161,10 +172,11 @@ App::get('/v1/health/queue/usage')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueUsage')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-usage.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-usage')]);
|
||||
$response->json(['size' => Resque::size(Event::USAGE_QUEUE_NAME)]);
|
||||
}, ['response']);
|
||||
|
||||
App::get('/v1/health/queue/certificates')
|
||||
@@ -175,10 +187,11 @@ App::get('/v1/health/queue/certificates')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueCertificates')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-certificates.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-certificates')]);
|
||||
$response->json(['size' => Resque::size(Event::CERTIFICATES_QUEUE_NAME)]);
|
||||
}, ['response']);
|
||||
|
||||
App::get('/v1/health/queue/functions')
|
||||
@@ -189,10 +202,11 @@ App::get('/v1/health/queue/functions')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueFunctions')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-functions.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-functions')]);
|
||||
$response->json(['size' => Resque::size(Event::FUNCTIONS_QUEUE_NAME)]);
|
||||
}, ['response']);
|
||||
|
||||
App::get('/v1/health/storage/local')
|
||||
@@ -203,6 +217,7 @@ App::get('/v1/health/storage/local')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getStorageLocal')
|
||||
->label('sdk.description', '/docs/references/health/get-storage-local.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -224,7 +239,7 @@ App::get('/v1/health/storage/local')
|
||||
}
|
||||
|
||||
$response->json(['status' => 'OK']);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/anti-virus')
|
||||
->desc('Get Anti virus')
|
||||
@@ -234,6 +249,7 @@ App::get('/v1/health/anti-virus')
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getAntiVirus')
|
||||
->label('sdk.description', '/docs/references/health/get-storage-anti-virus.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -247,7 +263,7 @@ App::get('/v1/health/anti-virus')
|
||||
'status' => (@$antiVirus->ping()) ? 'online' : 'offline',
|
||||
'version' => @$antiVirus->version(),
|
||||
]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/stats') // Currently only used internally
|
||||
->desc('Get System Stats')
|
||||
@@ -257,6 +273,8 @@ App::get('/v1/health/stats') // Currently only used internally
|
||||
// ->label('sdk.namespace', 'health')
|
||||
// ->label('sdk.method', 'getStats')
|
||||
->label('docs', false)
|
||||
->inject('response')
|
||||
->inject('register')
|
||||
->action(function ($response, $register) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Registry\Registry $register */
|
||||
@@ -288,4 +306,4 @@ App::get('/v1/health/stats') // Currently only used internally
|
||||
'memory_used_peak_human' => $cacheStats['used_memory_peak_human'] ?? 0,
|
||||
],
|
||||
]);
|
||||
}, ['response', 'register']);
|
||||
});
|
||||
|
||||
@@ -16,6 +16,10 @@ App::get('/v1/locale')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_LOCALE)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('locale')
|
||||
->inject('geodb')
|
||||
->action(function ($request, $response, $locale, $geodb) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -64,7 +68,7 @@ App::get('/v1/locale')
|
||||
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache
|
||||
;
|
||||
$response->dynamic(new Document($output), Response::MODEL_LOCALE);
|
||||
}, ['request', 'response', 'locale', 'geodb']);
|
||||
});
|
||||
|
||||
App::get('/v1/locale/countries')
|
||||
->desc('List Countries')
|
||||
@@ -77,6 +81,8 @@ App::get('/v1/locale/countries')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
|
||||
->inject('response')
|
||||
->inject('locale')
|
||||
->action(function ($response, $locale) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Locale\Locale $locale */
|
||||
@@ -94,7 +100,7 @@ App::get('/v1/locale/countries')
|
||||
}
|
||||
|
||||
$response->dynamic(new Document(['countries' => $output, 'sum' => \count($output)]), Response::MODEL_COUNTRY_LIST);
|
||||
}, ['response', 'locale']);
|
||||
});
|
||||
|
||||
App::get('/v1/locale/countries/eu')
|
||||
->desc('List EU Countries')
|
||||
@@ -106,7 +112,9 @@ App::get('/v1/locale/countries/eu')
|
||||
->label('sdk.description', '/docs/references/locale/get-countries-eu.md')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
|
||||
->label('sdk.response.model', Response::MODEL_COUNTRY_LIST)
|
||||
->inject('response')
|
||||
->inject('locale')
|
||||
->action(function ($response, $locale) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Locale\Locale $locale */
|
||||
@@ -127,7 +135,7 @@ App::get('/v1/locale/countries/eu')
|
||||
}
|
||||
|
||||
$response->dynamic(new Document(['countries' => $output, 'sum' => \count($output)]), Response::MODEL_COUNTRY_LIST);
|
||||
}, ['response', 'locale']);
|
||||
});
|
||||
|
||||
App::get('/v1/locale/countries/phones')
|
||||
->desc('List Countries Phone Codes')
|
||||
@@ -140,6 +148,8 @@ App::get('/v1/locale/countries/phones')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_PHONE_LIST)
|
||||
->inject('response')
|
||||
->inject('locale')
|
||||
->action(function ($response, $locale) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Locale\Locale $locale */
|
||||
@@ -161,7 +171,7 @@ App::get('/v1/locale/countries/phones')
|
||||
}
|
||||
|
||||
$response->dynamic(new Document(['phones' => $output, 'sum' => \count($output)]), Response::MODEL_PHONE_LIST);
|
||||
}, ['response', 'locale']);
|
||||
});
|
||||
|
||||
App::get('/v1/locale/continents')
|
||||
->desc('List Continents')
|
||||
@@ -174,6 +184,8 @@ App::get('/v1/locale/continents')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_CONTINENT_LIST)
|
||||
->inject('response')
|
||||
->inject('locale')
|
||||
->action(function ($response, $locale) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Locale\Locale $locale */
|
||||
@@ -190,7 +202,7 @@ App::get('/v1/locale/continents')
|
||||
}
|
||||
|
||||
$response->dynamic(new Document(['continents' => $output, 'sum' => \count($output)]), Response::MODEL_CONTINENT_LIST);
|
||||
}, ['response', 'locale']);
|
||||
});
|
||||
|
||||
App::get('/v1/locale/currencies')
|
||||
->desc('List Currencies')
|
||||
@@ -203,6 +215,7 @@ App::get('/v1/locale/currencies')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_CURRENCY_LIST)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -213,7 +226,7 @@ App::get('/v1/locale/currencies')
|
||||
}, $list);
|
||||
|
||||
$response->dynamic(new Document(['currencies' => $list, 'sum' => \count($list)]), Response::MODEL_CURRENCY_LIST);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
|
||||
App::get('/v1/locale/languages')
|
||||
@@ -227,6 +240,7 @@ App::get('/v1/locale/languages')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_LANGUAGE_LIST)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -237,4 +251,4 @@ App::get('/v1/locale/languages')
|
||||
}, $list);
|
||||
|
||||
$response->dynamic(new Document(['languages' => $list, 'sum' => \count($list)]), Response::MODEL_LANGUAGE_LIST);
|
||||
}, ['response']);
|
||||
});
|
||||
@@ -40,6 +40,9 @@ App::post('/v1/projects')
|
||||
->param('legalCity', '', new Text(256), 'Project legal City. Max length: 256 chars.', true)
|
||||
->param('legalAddress', '', new Text(256), 'Project legal Address. Max length: 256 chars.', true)
|
||||
->param('legalTaxId', '', new Text(256), 'Project legal Tax ID. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->inject('projectDB')
|
||||
->action(function ($name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $consoleDB, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -87,7 +90,7 @@ App::post('/v1/projects')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($project, Response::MODEL_PROJECT)
|
||||
;
|
||||
}, ['response', 'consoleDB', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects')
|
||||
->desc('List Projects')
|
||||
@@ -102,6 +105,8 @@ App::get('/v1/projects')
|
||||
->param('limit', 25, 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, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($search, $limit, $offset, $orderType, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -109,6 +114,7 @@ App::get('/v1/projects')
|
||||
$results = $consoleDB->getCollection([
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'orderType' => $orderType,
|
||||
'search' => $search,
|
||||
'filters' => [
|
||||
'$collection='.Database::SYSTEM_COLLECTION_PROJECTS,
|
||||
@@ -119,7 +125,7 @@ App::get('/v1/projects')
|
||||
'sum' => $consoleDB->getSum(),
|
||||
'projects' => $results
|
||||
]), Response::MODEL_PROJECT_LIST);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId')
|
||||
->desc('Get Project')
|
||||
@@ -131,6 +137,8 @@ App::get('/v1/projects/:projectId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_PROJECT)
|
||||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -142,7 +150,7 @@ App::get('/v1/projects/:projectId')
|
||||
}
|
||||
|
||||
$response->dynamic($project, Response::MODEL_PROJECT);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/usage')
|
||||
->desc('Get Project')
|
||||
@@ -152,6 +160,10 @@ App::get('/v1/projects/:projectId/usage')
|
||||
->label('sdk.method', 'getUsage')
|
||||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->param('range', '30d', new WhiteList(['24h', '7d', '30d', '90d'], true), 'Date range.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->inject('projectDB')
|
||||
->inject('register')
|
||||
->action(function ($projectId, $range, $response, $consoleDB, $projectDB, $register) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -191,6 +203,7 @@ App::get('/v1/projects/:projectId/usage')
|
||||
|
||||
$requests = [];
|
||||
$network = [];
|
||||
$functions = [];
|
||||
|
||||
if ($client) {
|
||||
$start = $period[$range]['start']->format(DateTime::RFC3339);
|
||||
@@ -218,6 +231,17 @@ App::get('/v1/projects/:projectId/usage')
|
||||
'date' => \strtotime($point['time']),
|
||||
];
|
||||
}
|
||||
|
||||
// Functions
|
||||
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)');
|
||||
$points = $result->getPoints();
|
||||
|
||||
foreach ($points as $point) {
|
||||
$functions[] = [
|
||||
'value' => (!empty($point['value'])) ? $point['value'] : 0,
|
||||
'date' => \strtotime($point['time']),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Users
|
||||
@@ -275,6 +299,12 @@ App::get('/v1/projects/:projectId/usage')
|
||||
return $item['value'];
|
||||
}, $network)),
|
||||
],
|
||||
'functions' => [
|
||||
'data' => $functions,
|
||||
'total' => \array_sum(\array_map(function ($item) {
|
||||
return $item['value'];
|
||||
}, $functions)),
|
||||
],
|
||||
'collections' => [
|
||||
'data' => $collections,
|
||||
'total' => $collectionsTotal,
|
||||
@@ -312,7 +342,7 @@ App::get('/v1/projects/:projectId/usage')
|
||||
),
|
||||
],
|
||||
]);
|
||||
}, ['response', 'consoleDB', 'projectDB', 'register']);
|
||||
});
|
||||
|
||||
App::patch('/v1/projects/:projectId')
|
||||
->desc('Update Project')
|
||||
@@ -334,6 +364,8 @@ App::patch('/v1/projects/:projectId')
|
||||
->param('legalCity', '', new Text(256), 'Project legal city. Max length: 256 chars.', true)
|
||||
->param('legalAddress', '', new Text(256), 'Project legal address. Max length: 256 chars.', true)
|
||||
->param('legalTaxId', '', new Text(256), 'Project legal tax ID. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $name, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -362,7 +394,7 @@ App::patch('/v1/projects/:projectId')
|
||||
}
|
||||
|
||||
$response->dynamic($project, Response::MODEL_PROJECT);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::patch('/v1/projects/:projectId/oauth2')
|
||||
->desc('Update Project OAuth2')
|
||||
@@ -377,6 +409,8 @@ App::patch('/v1/projects/:projectId/oauth2')
|
||||
->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'Provider Name', false)
|
||||
->param('appId', '', new Text(256), 'Provider app ID. Max length: 256 chars.', true)
|
||||
->param('secret', '', new text(512), 'Provider secret key. Max length: 512 chars.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $provider, $appId, $secret, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -397,7 +431,7 @@ App::patch('/v1/projects/:projectId/oauth2')
|
||||
}
|
||||
|
||||
$response->dynamic($project, Response::MODEL_PROJECT);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/projects/:projectId')
|
||||
->desc('Delete Project')
|
||||
@@ -410,6 +444,10 @@ App::delete('/v1/projects/:projectId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->param('password', '', new UID(), 'Your user password for confirmation. Must be between 6 to 32 chars.')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('consoleDB')
|
||||
->inject('deletes')
|
||||
->action(function ($projectId, $password, $response, $user, $consoleDB, $deletes) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -426,7 +464,10 @@ App::delete('/v1/projects/:projectId')
|
||||
throw new Exception('Project not found', 404);
|
||||
}
|
||||
|
||||
$deletes->setParam('document', $project->getArrayCopy());
|
||||
$deletes
|
||||
->setParam('type', DELETE_TYPE_DOCUMENT)
|
||||
->setParam('document', $project->getArrayCopy())
|
||||
;
|
||||
|
||||
foreach (['keys', 'webhooks', 'tasks', 'platforms', 'domains'] as $key) { // Delete all children (keys, webhooks, tasks [stop tasks?], platforms)
|
||||
$list = $project->getAttribute('webhooks', []);
|
||||
@@ -447,7 +488,7 @@ App::delete('/v1/projects/:projectId')
|
||||
}
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'user', 'consoleDB', 'deletes']);
|
||||
});
|
||||
|
||||
// Webhooks
|
||||
|
||||
@@ -467,6 +508,8 @@ App::post('/v1/projects/:projectId/webhooks')
|
||||
->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.')
|
||||
->param('httpUser', '', new Text(256), 'Webhook HTTP user. Max length: 256 chars.', true)
|
||||
->param('httpPass', '', new Text(256), 'Webhook HTTP password. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $name, $events, $url, $security, $httpUser, $httpPass, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -509,7 +552,7 @@ App::post('/v1/projects/:projectId/webhooks')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($webhook, Response::MODEL_WEBHOOK)
|
||||
;
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/webhooks')
|
||||
->desc('List Webhooks')
|
||||
@@ -521,6 +564,8 @@ App::get('/v1/projects/:projectId/webhooks')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_WEBHOOK_LIST)
|
||||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -537,7 +582,7 @@ App::get('/v1/projects/:projectId/webhooks')
|
||||
'sum' => count($webhooks),
|
||||
'webhooks' => $webhooks
|
||||
]), Response::MODEL_WEBHOOK_LIST);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/webhooks/:webhookId')
|
||||
->desc('Get Webhook')
|
||||
@@ -550,6 +595,8 @@ App::get('/v1/projects/:projectId/webhooks/:webhookId')
|
||||
->label('sdk.response.model', Response::MODEL_WEBHOOK)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('webhookId', null, new UID(), 'Webhook unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $webhookId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -567,7 +614,7 @@ App::get('/v1/projects/:projectId/webhooks/:webhookId')
|
||||
}
|
||||
|
||||
$response->dynamic($webhook, Response::MODEL_WEBHOOK);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::put('/v1/projects/:projectId/webhooks/:webhookId')
|
||||
->desc('Update Webhook')
|
||||
@@ -586,6 +633,8 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId')
|
||||
->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.')
|
||||
->param('httpUser', '', new Text(256), 'Webhook HTTP user. Max length: 256 chars.', true)
|
||||
->param('httpPass', '', new Text(256), 'Webhook HTTP password. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $webhookId, $name, $events, $url, $security, $httpUser, $httpPass, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -618,7 +667,7 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId')
|
||||
}
|
||||
|
||||
$response->dynamic($webhook, Response::MODEL_WEBHOOK);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/projects/:projectId/webhooks/:webhookId')
|
||||
->desc('Delete Webhook')
|
||||
@@ -631,6 +680,8 @@ App::delete('/v1/projects/:projectId/webhooks/:webhookId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('webhookId', null, new UID(), 'Webhook unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $webhookId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -652,7 +703,7 @@ App::delete('/v1/projects/:projectId/webhooks/:webhookId')
|
||||
}
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
// Keys
|
||||
|
||||
@@ -668,6 +719,8 @@ App::post('/v1/projects/:projectId/keys')
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('name', null, new Text(128), 'Key name. Max length: 128 chars.')
|
||||
->param('scopes', null, new ArrayList(new WhiteList(Config::getParam('scopes'), true)), 'Key scopes list.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $name, $scopes, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -705,7 +758,7 @@ App::post('/v1/projects/:projectId/keys')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($key, Response::MODEL_KEY)
|
||||
;
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/keys')
|
||||
->desc('List Keys')
|
||||
@@ -717,6 +770,8 @@ App::get('/v1/projects/:projectId/keys')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_KEY_LIST)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -733,7 +788,7 @@ App::get('/v1/projects/:projectId/keys')
|
||||
'sum' => count($keys),
|
||||
'keys' => $keys
|
||||
]), Response::MODEL_KEY_LIST);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/keys/:keyId')
|
||||
->desc('Get Key')
|
||||
@@ -746,6 +801,8 @@ App::get('/v1/projects/:projectId/keys/:keyId')
|
||||
->label('sdk.response.model', Response::MODEL_KEY)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('keyId', null, new UID(), 'Key unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $keyId, $response, $consoleDB) {
|
||||
$project = $consoleDB->getDocument($projectId);
|
||||
|
||||
@@ -760,7 +817,7 @@ App::get('/v1/projects/:projectId/keys/:keyId')
|
||||
}
|
||||
|
||||
$response->dynamic($key, Response::MODEL_KEY);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::put('/v1/projects/:projectId/keys/:keyId')
|
||||
->desc('Update Key')
|
||||
@@ -775,6 +832,8 @@ App::put('/v1/projects/:projectId/keys/:keyId')
|
||||
->param('keyId', null, new UID(), 'Key unique ID.')
|
||||
->param('name', null, new Text(128), 'Key name. Max length: 128 chars.')
|
||||
->param('scopes', null, new ArrayList(new WhiteList(Config::getParam('scopes'), true)), 'Key scopes list')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $keyId, $name, $scopes, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -801,7 +860,7 @@ App::put('/v1/projects/:projectId/keys/:keyId')
|
||||
}
|
||||
|
||||
$response->dynamic($key, Response::MODEL_KEY);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/projects/:projectId/keys/:keyId')
|
||||
->desc('Delete Key')
|
||||
@@ -814,6 +873,8 @@ App::delete('/v1/projects/:projectId/keys/:keyId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('keyId', null, new UID(), 'Key unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $keyId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -835,7 +896,7 @@ App::delete('/v1/projects/:projectId/keys/:keyId')
|
||||
}
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
// Tasks
|
||||
|
||||
@@ -858,6 +919,8 @@ App::post('/v1/projects/:projectId/tasks')
|
||||
->param('httpHeaders', null, new ArrayList(new Text(256)), 'Task HTTP headers list.', true)
|
||||
->param('httpUser', '', new Text(256), 'Task HTTP user. Max length: 256 chars.', true)
|
||||
->param('httpPass', '', new Text(256), 'Task HTTP password. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -915,7 +978,7 @@ App::post('/v1/projects/:projectId/tasks')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($task, Response::MODEL_TASK)
|
||||
;
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/tasks')
|
||||
->desc('List Tasks')
|
||||
@@ -927,6 +990,8 @@ App::get('/v1/projects/:projectId/tasks')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_TASK_LIST)
|
||||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -944,7 +1009,7 @@ App::get('/v1/projects/:projectId/tasks')
|
||||
'tasks' => $tasks
|
||||
]), Response::MODEL_TASK_LIST);
|
||||
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/tasks/:taskId')
|
||||
->desc('Get Task')
|
||||
@@ -957,6 +1022,8 @@ App::get('/v1/projects/:projectId/tasks/:taskId')
|
||||
->label('sdk.response.model', Response::MODEL_TASK)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('taskId', null, new UID(), 'Task unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $taskId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -974,7 +1041,7 @@ App::get('/v1/projects/:projectId/tasks/:taskId')
|
||||
}
|
||||
|
||||
$response->dynamic($task, Response::MODEL_TASK);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::put('/v1/projects/:projectId/tasks/:taskId')
|
||||
->desc('Update Task')
|
||||
@@ -996,6 +1063,8 @@ App::put('/v1/projects/:projectId/tasks/:taskId')
|
||||
->param('httpHeaders', null, new ArrayList(new Text(256)), 'Task HTTP headers list.', true)
|
||||
->param('httpUser', '', new Text(256), 'Task HTTP user. Max length: 256 chars.', true)
|
||||
->param('httpPass', '', new Text(256), 'Task HTTP password. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $taskId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1040,7 +1109,7 @@ App::put('/v1/projects/:projectId/tasks/:taskId')
|
||||
}
|
||||
|
||||
$response->dynamic($task, Response::MODEL_TASK);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/projects/:projectId/tasks/:taskId')
|
||||
->desc('Delete Task')
|
||||
@@ -1053,6 +1122,8 @@ App::delete('/v1/projects/:projectId/tasks/:taskId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('taskId', null, new UID(), 'Task unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $taskId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1074,7 +1145,7 @@ App::delete('/v1/projects/:projectId/tasks/:taskId')
|
||||
}
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
// Platforms
|
||||
|
||||
@@ -1093,6 +1164,8 @@ App::post('/v1/projects/:projectId/platforms')
|
||||
->param('key', '', new Text(256), 'Package name for android or bundle ID for iOS. Max length: 256 chars.', true)
|
||||
->param('store', '', new Text(256), 'App store or Google Play store ID. Max length: 256 chars.', true)
|
||||
->param('hostname', '', new Text(256), 'Platform client hostname. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $type, $name, $key, $store, $hostname, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1134,7 +1207,7 @@ App::post('/v1/projects/:projectId/platforms')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($platform, Response::MODEL_PLATFORM)
|
||||
;
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/platforms')
|
||||
->desc('List Platforms')
|
||||
@@ -1146,6 +1219,8 @@ App::get('/v1/projects/:projectId/platforms')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_PLATFORM_LIST)
|
||||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1162,7 +1237,7 @@ App::get('/v1/projects/:projectId/platforms')
|
||||
'sum' => count($platforms),
|
||||
'platforms' => $platforms
|
||||
]), Response::MODEL_PLATFORM_LIST);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/platforms/:platformId')
|
||||
->desc('Get Platform')
|
||||
@@ -1175,6 +1250,8 @@ App::get('/v1/projects/:projectId/platforms/:platformId')
|
||||
->label('sdk.response.model', Response::MODEL_PLATFORM)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('platformId', null, new UID(), 'Platform unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $platformId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1192,7 +1269,7 @@ App::get('/v1/projects/:projectId/platforms/:platformId')
|
||||
}
|
||||
|
||||
$response->dynamic($platform, Response::MODEL_PLATFORM);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::put('/v1/projects/:projectId/platforms/:platformId')
|
||||
->desc('Update Platform')
|
||||
@@ -1209,6 +1286,8 @@ App::put('/v1/projects/:projectId/platforms/:platformId')
|
||||
->param('key', '', new Text(256), 'Package name for android or bundle ID for iOS. Max length: 256 chars.', true)
|
||||
->param('store', '', new Text(256), 'App store or Google Play store ID. Max length: 256 chars.', true)
|
||||
->param('hostname', '', new Text(256), 'Platform client URL. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $platformId, $name, $key, $store, $hostname, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1238,7 +1317,7 @@ App::put('/v1/projects/:projectId/platforms/:platformId')
|
||||
}
|
||||
|
||||
$response->dynamic($platform, Response::MODEL_PLATFORM);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/projects/:projectId/platforms/:platformId')
|
||||
->desc('Delete Platform')
|
||||
@@ -1251,6 +1330,8 @@ App::delete('/v1/projects/:projectId/platforms/:platformId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('platformId', null, new UID(), 'Platform unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $platformId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1272,7 +1353,7 @@ App::delete('/v1/projects/:projectId/platforms/:platformId')
|
||||
}
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
// Domains
|
||||
|
||||
@@ -1287,6 +1368,8 @@ App::post('/v1/projects/:projectId/domains')
|
||||
->label('sdk.response.model', Response::MODEL_DOMAIN)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('domain', null, new DomainValidator(), 'Domain name.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $domain, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1341,7 +1424,7 @@ App::post('/v1/projects/:projectId/domains')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($domain, Response::MODEL_DOMAIN)
|
||||
;
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/domains')
|
||||
->desc('List Domains')
|
||||
@@ -1353,6 +1436,8 @@ App::get('/v1/projects/:projectId/domains')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_DOMAIN_LIST)
|
||||
->param('projectId', '', new UID(), 'Project unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1369,7 +1454,7 @@ App::get('/v1/projects/:projectId/domains')
|
||||
'sum' => count($domains),
|
||||
'domains' => $domains
|
||||
]), Response::MODEL_DOMAIN_LIST);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/domains/:domainId')
|
||||
->desc('Get Domain')
|
||||
@@ -1382,6 +1467,8 @@ App::get('/v1/projects/:projectId/domains/:domainId')
|
||||
->label('sdk.response.model', Response::MODEL_DOMAIN)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('domainId', null, new UID(), 'Domain unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $domainId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1399,7 +1486,7 @@ App::get('/v1/projects/:projectId/domains/:domainId')
|
||||
}
|
||||
|
||||
$response->dynamic($domain, Response::MODEL_DOMAIN);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::patch('/v1/projects/:projectId/domains/:domainId/verification')
|
||||
->desc('Update Domain Verification Status')
|
||||
@@ -1412,6 +1499,8 @@ App::patch('/v1/projects/:projectId/domains/:domainId/verification')
|
||||
->label('sdk.response.model', Response::MODEL_DOMAIN)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('domainId', null, new UID(), 'Domain unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $domainId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1460,7 +1549,7 @@ App::patch('/v1/projects/:projectId/domains/:domainId/verification')
|
||||
]);
|
||||
|
||||
$response->dynamic($domain, Response::MODEL_DOMAIN);
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/projects/:projectId/domains/:domainId')
|
||||
->desc('Delete Domain')
|
||||
@@ -1473,6 +1562,8 @@ App::delete('/v1/projects/:projectId/domains/:domainId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('domainId', null, new UID(), 'Domain unique ID.')
|
||||
->inject('response')
|
||||
->inject('consoleDB')
|
||||
->action(function ($projectId, $domainId, $response, $consoleDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
@@ -1494,4 +1585,4 @@ App::delete('/v1/projects/:projectId/domains/:domainId')
|
||||
}
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'consoleDB']);
|
||||
});
|
||||
@@ -40,10 +40,14 @@ App::post('/v1/storage/files')
|
||||
->param('file', [], new File(), 'Binary file.', false)
|
||||
->param('read', [], 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', [], 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(function ($file, $read, $write, $request, $response, $user, $projectDB, $audits, $usage) {
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->action(function ($file, $read, $write, $request, $response, $projectDB, $audits, $usage) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
/** @var Appwrite\Event\Event $audits */
|
||||
/** @var Appwrite\Event\Event $usage */
|
||||
@@ -154,7 +158,7 @@ App::post('/v1/storage/files')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($file, Response::MODEL_FILE)
|
||||
;
|
||||
}, ['request', 'response', 'user', 'projectDB', 'audits', 'usage']);
|
||||
});
|
||||
|
||||
App::get('/v1/storage/files')
|
||||
->desc('List Files')
|
||||
@@ -171,6 +175,8 @@ App::get('/v1/storage/files')
|
||||
->param('limit', 25, 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, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -189,7 +195,7 @@ App::get('/v1/storage/files')
|
||||
'sum' => $projectDB->getSum(),
|
||||
'files' => $results
|
||||
]), Response::MODEL_FILE_LIST);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/storage/files/:fileId')
|
||||
->desc('Get File')
|
||||
@@ -203,6 +209,8 @@ App::get('/v1/storage/files/:fileId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_FILE)
|
||||
->param('fileId', '', new UID(), 'File unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($fileId, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -214,7 +222,7 @@ App::get('/v1/storage/files/:fileId')
|
||||
}
|
||||
|
||||
$response->dynamic($file, Response::MODEL_FILE);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/storage/files/:fileId/preview')
|
||||
->desc('Get File Preview')
|
||||
@@ -233,6 +241,10 @@ App::get('/v1/storage/files/:fileId/preview')
|
||||
->param('quality', 100, new Range(0, 100), 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
|
||||
->param('background', '', 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', '', new WhiteList(\array_keys(Config::getParam('storage-outputs')), true), 'Output format type (jpeg, jpg, png, gif and webp).', true)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('projectDB')
|
||||
->action(function ($fileId, $width, $height, $quality, $background, $output, $request, $response, $project, $projectDB) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -341,7 +353,7 @@ App::get('/v1/storage/files/:fileId/preview')
|
||||
;
|
||||
|
||||
unset($resize);
|
||||
}, ['request', 'response', 'project', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/storage/files/:fileId/download')
|
||||
->desc('Get File for Download')
|
||||
@@ -355,6 +367,8 @@ App::get('/v1/storage/files/:fileId/download')
|
||||
->label('sdk.response.type', '*/*')
|
||||
->label('sdk.methodType', 'location')
|
||||
->param('fileId', '', new UID(), 'File unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($fileId, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -397,7 +411,7 @@ App::get('/v1/storage/files/:fileId/download')
|
||||
->addHeader('X-Peak', \memory_get_peak_usage())
|
||||
->send($source)
|
||||
;
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/storage/files/:fileId/view')
|
||||
->desc('Get File for View')
|
||||
@@ -411,8 +425,9 @@ App::get('/v1/storage/files/:fileId/view')
|
||||
->label('sdk.response.type', '*/*')
|
||||
->label('sdk.methodType', 'location')
|
||||
->param('fileId', '', new UID(), 'File unique ID.')
|
||||
->param('as', '', new WhiteList(['pdf', /*'html',*/ 'text'], true), '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, $response, $projectDB) {
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($fileId, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
|
||||
@@ -454,13 +469,6 @@ App::get('/v1/storage/files/:fileId/view')
|
||||
$output = $compressor->decompress($source);
|
||||
$fileName = $file->getAttribute('name', '');
|
||||
|
||||
$contentTypes = [
|
||||
'pdf' => 'application/pdf',
|
||||
'text' => 'text/plain',
|
||||
];
|
||||
|
||||
$contentType = (\array_key_exists($as, $contentTypes)) ? $contentTypes[$as] : $contentType;
|
||||
|
||||
// Response
|
||||
$response
|
||||
->setContentType($contentType)
|
||||
@@ -471,7 +479,7 @@ App::get('/v1/storage/files/:fileId/view')
|
||||
->addHeader('X-Peak', \memory_get_peak_usage())
|
||||
->send($output)
|
||||
;
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::put('/v1/storage/files/:fileId')
|
||||
->desc('Update File')
|
||||
@@ -488,6 +496,9 @@ App::put('/v1/storage/files/:fileId')
|
||||
->param('fileId', '', new UID(), 'File unique ID.')
|
||||
->param('read', [], 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', [], 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.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->action(function ($fileId, $read, $write, $response, $projectDB, $audits) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -517,7 +528,7 @@ App::put('/v1/storage/files/:fileId')
|
||||
;
|
||||
|
||||
$response->dynamic($file, Response::MODEL_FILE);
|
||||
}, ['response', 'projectDB', 'audits']);
|
||||
});
|
||||
|
||||
App::delete('/v1/storage/files/:fileId')
|
||||
->desc('Delete File')
|
||||
@@ -532,6 +543,11 @@ App::delete('/v1/storage/files/:fileId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('fileId', '', new UID(), 'File unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('events')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->action(function ($fileId, $response, $projectDB, $events, $audits, $usage) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -567,7 +583,7 @@ App::delete('/v1/storage/files/:fileId')
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'events', 'audits', 'usage']);
|
||||
});
|
||||
|
||||
// App::get('/v1/storage/files/:fileId/scan')
|
||||
// ->desc('Scan Storage')
|
||||
|
||||
@@ -34,6 +34,9 @@ App::post('/v1/teams')
|
||||
->label('sdk.response.model', Response::MODEL_TEAM)
|
||||
->param('name', null, new Text(128), 'Team name. Max length: 128 chars.')
|
||||
->param('roles', ['owner'], new ArrayList(new Key()), '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). Max length for each role is 32 chars.', true)
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->action(function ($name, $roles, $response, $user, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
@@ -91,7 +94,7 @@ App::post('/v1/teams')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($team, Response::MODEL_TEAM)
|
||||
;
|
||||
}, ['response', 'user', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/teams')
|
||||
->desc('List Teams')
|
||||
@@ -108,6 +111,8 @@ App::get('/v1/teams')
|
||||
->param('limit', 25, 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, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -126,7 +131,7 @@ App::get('/v1/teams')
|
||||
'sum' => $projectDB->getSum(),
|
||||
'teams' => $results
|
||||
]), Response::MODEL_TEAM_LIST);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/teams/:teamId')
|
||||
->desc('Get Team')
|
||||
@@ -140,6 +145,8 @@ App::get('/v1/teams/:teamId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_TEAM)
|
||||
->param('teamId', '', new UID(), 'Team unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($teamId, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -151,7 +158,7 @@ App::get('/v1/teams/:teamId')
|
||||
}
|
||||
|
||||
$response->dynamic($team, Response::MODEL_TEAM);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::put('/v1/teams/:teamId')
|
||||
->desc('Update Team')
|
||||
@@ -167,6 +174,8 @@ App::put('/v1/teams/:teamId')
|
||||
->label('sdk.response.model', Response::MODEL_TEAM)
|
||||
->param('teamId', '', new UID(), 'Team unique ID.')
|
||||
->param('name', null, new Text(128), 'Team name. Max length: 128 chars.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($teamId, $name, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -186,7 +195,7 @@ App::put('/v1/teams/:teamId')
|
||||
}
|
||||
|
||||
$response->dynamic($team, Response::MODEL_TEAM);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/teams/:teamId')
|
||||
->desc('Delete Team')
|
||||
@@ -201,6 +210,9 @@ App::delete('/v1/teams/:teamId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('teamId', '', new UID(), 'Team unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('events')
|
||||
->action(function ($teamId, $response, $projectDB, $events) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -236,7 +248,7 @@ App::delete('/v1/teams/:teamId')
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'events']);
|
||||
});
|
||||
|
||||
App::post('/v1/teams/:teamId/memberships')
|
||||
->desc('Create Team Membership')
|
||||
@@ -255,6 +267,13 @@ App::post('/v1/teams/:teamId/memberships')
|
||||
->param('name', '', new Text(128), 'New team member name. Max length: 128 chars.', true)
|
||||
->param('roles', [], new ArrayList(new Key()), '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). Max length for each role is 32 chars.')
|
||||
->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) // TODO add our own built-in confirm page
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('locale')
|
||||
->inject('audits')
|
||||
->inject('mails')
|
||||
->action(function ($teamId, $email, $name, $roles, $url, $response, $project, $user, $projectDB, $locale, $audits, $mails) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
@@ -431,7 +450,7 @@ App::post('/v1/teams/:teamId/memberships')
|
||||
'name' => $name,
|
||||
])), Response::MODEL_MEMBERSHIP)
|
||||
;
|
||||
}, ['response', 'project', 'user', 'projectDB', 'locale', 'audits', 'mails']);
|
||||
});
|
||||
|
||||
App::get('/v1/teams/:teamId/memberships')
|
||||
->desc('Get Team Memberships')
|
||||
@@ -449,6 +468,8 @@ App::get('/v1/teams/:teamId/memberships')
|
||||
->param('limit', 25, 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, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($teamId, $search, $limit, $offset, $orderType, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -469,7 +490,6 @@ App::get('/v1/teams/:teamId/memberships')
|
||||
'teamId='.$teamId,
|
||||
],
|
||||
]);
|
||||
|
||||
$users = [];
|
||||
|
||||
foreach ($memberships as $membership) {
|
||||
@@ -483,7 +503,7 @@ App::get('/v1/teams/:teamId/memberships')
|
||||
}
|
||||
|
||||
$response->dynamic(new Document(['sum' => $projectDB->getSum(), 'memberships' => $users]), Response::MODEL_MEMBERSHIP_LIST);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::patch('/v1/teams/:teamId/memberships/:inviteId/status')
|
||||
->desc('Update Team Membership Status')
|
||||
@@ -501,6 +521,12 @@ App::patch('/v1/teams/:teamId/memberships/:inviteId/status')
|
||||
->param('inviteId', '', new UID(), 'Invite unique ID.')
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->param('secret', '', new Text(256), 'Secret key.')
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->inject('projectDB')
|
||||
->inject('geodb')
|
||||
->inject('audits')
|
||||
->action(function ($teamId, $inviteId, $userId, $secret, $request, $response, $user, $projectDB, $geodb, $audits) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -663,7 +689,7 @@ App::patch('/v1/teams/:teamId/memberships/:inviteId/status')
|
||||
'email' => $user->getAttribute('email'),
|
||||
'name' => $user->getAttribute('name'),
|
||||
])), Response::MODEL_MEMBERSHIP);
|
||||
}, ['request', 'response', 'user', 'projectDB', 'geodb', 'audits']);
|
||||
});
|
||||
|
||||
App::delete('/v1/teams/:teamId/memberships/:inviteId')
|
||||
->desc('Delete Team Membership')
|
||||
@@ -679,6 +705,10 @@ App::delete('/v1/teams/:teamId/memberships/:inviteId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('teamId', '', new UID(), 'Team unique ID.')
|
||||
->param('inviteId', '', new UID(), 'Invite unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('audits')
|
||||
->inject('events')
|
||||
->action(function ($teamId, $inviteId, $response, $projectDB, $audits, $events) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -726,4 +756,4 @@ App::delete('/v1/teams/:teamId/memberships/:inviteId')
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'audits', 'events']);
|
||||
});
|
||||
|
||||
@@ -33,6 +33,8 @@ App::post('/v1/users')
|
||||
->param('email', '', new Email(), 'User email.')
|
||||
->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.')
|
||||
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($email, $password, $name, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -73,7 +75,7 @@ App::post('/v1/users')
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->dynamic($user, Response::MODEL_USER)
|
||||
;
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/users')
|
||||
->desc('List Users')
|
||||
@@ -90,6 +92,8 @@ App::get('/v1/users')
|
||||
->param('limit', 25, 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, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -108,7 +112,7 @@ App::get('/v1/users')
|
||||
'sum' => $projectDB->getSum(),
|
||||
'users' => $results
|
||||
]), Response::MODEL_USER_LIST);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/users/:userId')
|
||||
->desc('Get User')
|
||||
@@ -122,6 +126,8 @@ App::get('/v1/users/:userId')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_USER)
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($userId, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -133,7 +139,7 @@ App::get('/v1/users/:userId')
|
||||
}
|
||||
|
||||
$response->dynamic($user, Response::MODEL_USER);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/users/:userId/prefs')
|
||||
->desc('Get User Preferences')
|
||||
@@ -147,6 +153,8 @@ App::get('/v1/users/:userId/prefs')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_ANY)
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($userId, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -160,7 +168,7 @@ App::get('/v1/users/:userId/prefs')
|
||||
$prefs = $user->getAttribute('prefs', '');
|
||||
|
||||
$response->dynamic(new Document($prefs), Response::MODEL_ANY);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/v1/users/:userId/sessions')
|
||||
->desc('Get User Sessions')
|
||||
@@ -174,6 +182,9 @@ App::get('/v1/users/:userId/sessions')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_SESSION_LIST)
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('locale')
|
||||
->action(function ($userId, $response, $projectDB, $locale) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -220,6 +231,12 @@ App::get('/v1/users/:userId/logs')
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_LOG_LIST)
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->inject('response')
|
||||
->inject('register')
|
||||
->inject('project')
|
||||
->inject('projectDB')
|
||||
->inject('locale')
|
||||
->inject('geodb')
|
||||
->action(function ($userId, $response, $register, $project, $projectDB, $locale, $geodb) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Registry\Registry $register */
|
||||
@@ -314,7 +331,7 @@ App::get('/v1/users/:userId/logs')
|
||||
}
|
||||
|
||||
$response->dynamic(new Document(['logs' => $output]), Response::MODEL_LOG_LIST);
|
||||
}, ['response', 'register', 'project', 'projectDB', 'locale', 'geodb']);
|
||||
});
|
||||
|
||||
App::patch('/v1/users/:userId/status')
|
||||
->desc('Update User Status')
|
||||
@@ -330,6 +347,8 @@ App::patch('/v1/users/:userId/status')
|
||||
->label('sdk.response.model', Response::MODEL_USER)
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->param('status', '', new WhiteList([Auth::USER_STATUS_ACTIVATED, Auth::USER_STATUS_BLOCKED, Auth::USER_STATUS_UNACTIVATED], true), '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)
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($userId, $status, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -349,7 +368,7 @@ App::patch('/v1/users/:userId/status')
|
||||
}
|
||||
|
||||
$response->dynamic($user, Response::MODEL_USER);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::patch('/v1/users/:userId/prefs')
|
||||
->desc('Update User Preferences')
|
||||
@@ -364,6 +383,8 @@ App::patch('/v1/users/:userId/prefs')
|
||||
->label('sdk.response.model', Response::MODEL_ANY)
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->param('prefs', '', new Assoc(), 'Prefs key-value JSON object.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->action(function ($userId, $prefs, $response, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -383,7 +404,7 @@ App::patch('/v1/users/:userId/prefs')
|
||||
}
|
||||
|
||||
$response->dynamic(new Document($prefs), Response::MODEL_ANY);
|
||||
}, ['response', 'projectDB']);
|
||||
});
|
||||
|
||||
App::delete('/v1/users/:userId/sessions/:sessionId')
|
||||
->desc('Delete User Session')
|
||||
@@ -400,6 +421,9 @@ App::delete('/v1/users/:userId/sessions/:sessionId')
|
||||
->label('abuse-limit', 100)
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->param('sessionId', null, new UID(), 'User unique session ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('events')
|
||||
->action(function ($userId, $sessionId, $response, $projectDB, $events) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -427,7 +451,7 @@ App::delete('/v1/users/:userId/sessions/:sessionId')
|
||||
|
||||
// TODO : Response filter implementation
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'events']);
|
||||
});
|
||||
|
||||
App::delete('/v1/users/:userId/sessions')
|
||||
->desc('Delete User Sessions')
|
||||
@@ -443,6 +467,9 @@ App::delete('/v1/users/:userId/sessions')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->label('abuse-limit', 100)
|
||||
->param('userId', '', new UID(), 'User unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('events')
|
||||
->action(function ($userId, $response, $projectDB, $events) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -468,7 +495,7 @@ App::delete('/v1/users/:userId/sessions')
|
||||
|
||||
// TODO : Response filter implementation
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'events']);
|
||||
});
|
||||
|
||||
App::delete('/v1/users/:userId')
|
||||
->desc('Delete User')
|
||||
@@ -484,6 +511,10 @@ App::delete('/v1/users/:userId')
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->label('abuse-limit', 100)
|
||||
->param('userId', '', function () {return new UID();}, 'User unique ID.')
|
||||
->inject('response')
|
||||
->inject('projectDB')
|
||||
->inject('events')
|
||||
->inject('deletes')
|
||||
->action(function ($userId, $response, $projectDB, $events, $deletes) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -516,6 +547,7 @@ App::delete('/v1/users/:userId')
|
||||
}
|
||||
|
||||
$deletes
|
||||
->setParam('type', DELETE_TYPE_DOCUMENT)
|
||||
->setParam('document', $user)
|
||||
;
|
||||
|
||||
@@ -525,4 +557,4 @@ App::delete('/v1/users/:userId')
|
||||
|
||||
// TODO : Response filter implementation
|
||||
$response->noContent();
|
||||
}, ['response', 'projectDB', 'events', 'deletes']);
|
||||
});
|
||||
|
||||
@@ -44,6 +44,8 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
||||
/** @var Appwrite\Event\Event $audits */
|
||||
/** @var Appwrite\Event\Event $usage */
|
||||
/** @var Appwrite\Event\Event $deletes */
|
||||
/** @var Appwrite\Event\Event $functions */
|
||||
|
||||
/** @var bool $mode */
|
||||
/** @var array $clients */
|
||||
|
||||
@@ -243,11 +245,15 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
||||
/*
|
||||
* Background Jobs
|
||||
*/
|
||||
|
||||
$events
|
||||
->setParam('projectId', $project->getId())
|
||||
->setParam('userId', $user->getId())
|
||||
->setParam('event', $route->getLabel('event', ''))
|
||||
->setParam('payload', [])
|
||||
->setParam('functionId', null)
|
||||
->setParam('executionId', null)
|
||||
->setParam('trigger', 'event')
|
||||
;
|
||||
|
||||
$audits
|
||||
@@ -273,6 +279,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
||||
$deletes
|
||||
->setParam('projectId', $project->getId())
|
||||
;
|
||||
|
||||
}, ['utopia', 'request', 'response', 'console', 'project', 'user', 'locale', 'events', 'audits', 'usage', 'deletes', 'clients']);
|
||||
|
||||
App::shutdown(function ($utopia, $request, $response, $project, $events, $audits, $usage, $deletes, $mode) {
|
||||
@@ -284,6 +291,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits
|
||||
/** @var Appwrite\Event\Event $audits */
|
||||
/** @var Appwrite\Event\Event $usage */
|
||||
/** @var Appwrite\Event\Event $deletes */
|
||||
/** @var Appwrite\Event\Event $functions */
|
||||
/** @var bool $mode */
|
||||
|
||||
if (!empty($events->getParam('event'))) {
|
||||
@@ -291,12 +299,15 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits
|
||||
$events->setParam('payload', $response->getPayload());
|
||||
}
|
||||
|
||||
$events
|
||||
$webhooks = clone $events;
|
||||
$functions = clone $events;
|
||||
|
||||
$webhooks
|
||||
->setQueue('v1-webhooks')
|
||||
->setClass('WebhooksV1')
|
||||
->trigger();
|
||||
|
||||
$events
|
||||
$functions
|
||||
->setQueue('v1-functions')
|
||||
->setClass('FunctionsV1')
|
||||
->trigger();
|
||||
@@ -306,7 +317,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits
|
||||
$audits->trigger();
|
||||
}
|
||||
|
||||
if (!empty($deletes->getParam('document'))) {
|
||||
if (!empty($deletes->getParam('type')) && !empty($deletes->getParam('document'))) {
|
||||
$deletes->trigger();
|
||||
}
|
||||
|
||||
@@ -322,6 +333,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits
|
||||
->trigger()
|
||||
;
|
||||
}
|
||||
|
||||
}, ['utopia', 'request', 'response', 'project', 'events', 'audits', 'usage', 'deletes', 'mode']);
|
||||
|
||||
App::options(function ($request, $response) {
|
||||
@@ -400,7 +412,7 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) {
|
||||
->addHeader('Pragma', 'no-cache')
|
||||
->setStatusCode($code)
|
||||
;
|
||||
|
||||
|
||||
if ($template) {
|
||||
$comp = new View($template);
|
||||
|
||||
@@ -423,13 +435,14 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) {
|
||||
}
|
||||
|
||||
$response->dynamic(new Document($output),
|
||||
$utopia->isDevelopment() ? Response::MODEL_ERROR_DEV : Response::MODEL_LOCALE);
|
||||
$utopia->isDevelopment() ? Response::MODEL_ERROR_DEV : Response::MODEL_ERROR);
|
||||
}, ['error', 'utopia', 'request', 'response', 'layout', 'project']);
|
||||
|
||||
App::get('/manifest.json')
|
||||
->desc('Progressive app manifest file')
|
||||
->label('scope', 'public')
|
||||
->label('docs', false)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -450,30 +463,34 @@ App::get('/manifest.json')
|
||||
],
|
||||
],
|
||||
]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/robots.txt')
|
||||
->desc('Robots.txt File')
|
||||
->label('scope', 'public')
|
||||
->label('docs', false)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
$template = new View(__DIR__.'/../views/general/robots.phtml');
|
||||
$response->text($template->render(false));
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/humans.txt')
|
||||
->desc('Humans.txt File')
|
||||
->label('scope', 'public')
|
||||
->label('docs', false)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
$template = new View(__DIR__.'/../views/general/humans.phtml');
|
||||
$response->text($template->render(false));
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/.well-known/acme-challenge')
|
||||
->desc('SSL Verification')
|
||||
->label('scope', 'public')
|
||||
->label('docs', false)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->action(function ($request, $response) {
|
||||
$base = \realpath(APP_STORAGE_CERTIFICATES);
|
||||
$path = \str_replace('/.well-known/acme-challenge/', '', $request->getParam('q'));
|
||||
@@ -502,7 +519,7 @@ App::get('/.well-known/acme-challenge')
|
||||
}
|
||||
|
||||
$response->text($content);
|
||||
}, ['request', 'response']);
|
||||
});
|
||||
|
||||
include_once __DIR__ . '/shared/api.php';
|
||||
include_once __DIR__ . '/shared/web.php';
|
||||
|
||||
+38
-13
@@ -14,6 +14,7 @@ App::get('/v1/mock/tests/foo')
|
||||
->desc('Mock a get request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'foo')
|
||||
->label('sdk.method', 'get')
|
||||
->label('sdk.description', 'Mock a get request for SDK tests')
|
||||
@@ -28,6 +29,7 @@ App::post('/v1/mock/tests/foo')
|
||||
->desc('Mock a post request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'foo')
|
||||
->label('sdk.method', 'post')
|
||||
->label('sdk.description', 'Mock a post request for SDK tests')
|
||||
@@ -42,6 +44,7 @@ App::patch('/v1/mock/tests/foo')
|
||||
->desc('Mock a patch request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'foo')
|
||||
->label('sdk.method', 'patch')
|
||||
->label('sdk.description', 'Mock a get request for SDK tests')
|
||||
@@ -56,6 +59,7 @@ App::put('/v1/mock/tests/foo')
|
||||
->desc('Mock a put request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'foo')
|
||||
->label('sdk.method', 'put')
|
||||
->label('sdk.description', 'Mock a put request for SDK tests')
|
||||
@@ -70,6 +74,7 @@ App::delete('/v1/mock/tests/foo')
|
||||
->desc('Mock a delete request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'foo')
|
||||
->label('sdk.method', 'delete')
|
||||
->label('sdk.description', 'Mock a delete request for SDK tests')
|
||||
@@ -84,6 +89,7 @@ App::get('/v1/mock/tests/bar')
|
||||
->desc('Mock a get request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'bar')
|
||||
->label('sdk.method', 'get')
|
||||
->label('sdk.description', 'Mock a get request for SDK tests')
|
||||
@@ -98,6 +104,7 @@ App::post('/v1/mock/tests/bar')
|
||||
->desc('Mock a post request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'bar')
|
||||
->label('sdk.method', 'post')
|
||||
->label('sdk.description', 'Mock a post request for SDK tests')
|
||||
@@ -112,6 +119,7 @@ App::patch('/v1/mock/tests/bar')
|
||||
->desc('Mock a patch request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'bar')
|
||||
->label('sdk.method', 'patch')
|
||||
->label('sdk.description', 'Mock a get request for SDK tests')
|
||||
@@ -126,6 +134,7 @@ App::put('/v1/mock/tests/bar')
|
||||
->desc('Mock a put request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'bar')
|
||||
->label('sdk.method', 'put')
|
||||
->label('sdk.description', 'Mock a put request for SDK tests')
|
||||
@@ -140,6 +149,7 @@ App::delete('/v1/mock/tests/bar')
|
||||
->desc('Mock a delete request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'bar')
|
||||
->label('sdk.method', 'delete')
|
||||
->label('sdk.description', 'Mock a delete request for SDK tests')
|
||||
@@ -154,6 +164,7 @@ App::post('/v1/mock/tests/general/upload')
|
||||
->desc('Mock a post request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'general')
|
||||
->label('sdk.method', 'upload')
|
||||
->label('sdk.description', 'Mock a delete request for SDK tests')
|
||||
@@ -163,6 +174,7 @@ App::post('/v1/mock/tests/general/upload')
|
||||
->param('y', '', new Numeric(), 'Sample numeric param')
|
||||
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
|
||||
->param('file', [], new File(), 'Sample file param', false)
|
||||
->inject('request')
|
||||
->action(function ($x, $y, $z, $file, $request) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
|
||||
@@ -188,26 +200,29 @@ App::post('/v1/mock/tests/general/upload')
|
||||
throw new Exception('Wrong file uploaded', 400);
|
||||
}
|
||||
}
|
||||
}, ['request']);
|
||||
});
|
||||
|
||||
App::get('/v1/mock/tests/general/redirect')
|
||||
->desc('Mock a post request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'general')
|
||||
->label('sdk.method', 'redirect')
|
||||
->label('sdk.description', 'Mock a redirect request for SDK tests')
|
||||
->label('sdk.mock', true)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->redirect('/v1/mock/tests/general/redirected');
|
||||
}, ['response']);
|
||||
$response->redirect('/v1/mock/tests/general/redirect/done');
|
||||
});
|
||||
|
||||
App::get('/v1/mock/tests/general/redirected')
|
||||
App::get('/v1/mock/tests/general/redirect/done')
|
||||
->desc('Mock a post request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'general')
|
||||
->label('sdk.method', 'redirected')
|
||||
->label('sdk.description', 'Mock a redirected request for SDK tests')
|
||||
@@ -219,46 +234,51 @@ App::get('/v1/mock/tests/general/set-cookie')
|
||||
->desc('Mock a cookie request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'general')
|
||||
->label('sdk.method', 'setCookie')
|
||||
->label('sdk.description', 'Mock a set cookie request for SDK tests')
|
||||
->label('sdk.mock', true)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->addCookie('cookieName', 'cookieValue', \time() + 31536000, '/', 'localhost', true, true);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/mock/tests/general/get-cookie')
|
||||
->desc('Mock a cookie request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'general')
|
||||
->label('sdk.method', 'getCookie')
|
||||
->label('sdk.description', 'Mock a get cookie request for SDK tests')
|
||||
->label('sdk.mock', true)
|
||||
->inject('request')
|
||||
->action(function ($request) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
|
||||
if ($request->getCookie('cookieName', '') !== 'cookieValue') {
|
||||
throw new Exception('Missing cookie value', 400);
|
||||
}
|
||||
}, ['request']);
|
||||
});
|
||||
|
||||
App::get('/v1/mock/tests/general/empty')
|
||||
->desc('Mock a post request for SDK tests')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'general')
|
||||
->label('sdk.method', 'empty')
|
||||
->label('sdk.description', 'Mock a redirected request for SDK tests')
|
||||
->label('sdk.mock', true)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->noContent();
|
||||
exit();
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/mock/tests/general/oauth2')
|
||||
->desc('Mock an OAuth2 login route')
|
||||
@@ -270,11 +290,12 @@ App::get('/v1/mock/tests/general/oauth2')
|
||||
->param('redirect_uri', '', new Host(['localhost']), 'OAuth2 Redirect URI.') // Important to deny an open redirect attack
|
||||
->param('scope', '', new Text(100), 'OAuth2 scope list.')
|
||||
->param('state', '', new Text(1024), 'OAuth2 state.')
|
||||
->inject('response')
|
||||
->action(function ($clientId, $redirectURI, $scope, $state, $response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->redirect($redirectURI.'?'.\http_build_query(['code' => 'abcdef', 'state' => $state]));
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/mock/tests/general/oauth2/token')
|
||||
->desc('Mock an OAuth2 login route')
|
||||
@@ -286,6 +307,7 @@ App::get('/v1/mock/tests/general/oauth2/token')
|
||||
->param('redirect_uri', '', new Host(['localhost']), 'OAuth2 Redirect URI.')
|
||||
->param('client_secret', '', new Text(100), 'OAuth2 scope list.')
|
||||
->param('code', '', new Text(100), 'OAuth2 state.')
|
||||
->inject('response')
|
||||
->action(function ($clientId, $redirectURI, $clientSecret, $code, $response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -302,7 +324,7 @@ App::get('/v1/mock/tests/general/oauth2/token')
|
||||
}
|
||||
|
||||
$response->json(['access_token' => '123456']);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/mock/tests/general/oauth2/user')
|
||||
->desc('Mock an OAuth2 user route')
|
||||
@@ -310,6 +332,7 @@ App::get('/v1/mock/tests/general/oauth2/user')
|
||||
->label('scope', 'public')
|
||||
->label('docs', false)
|
||||
->param('token', '', new Text(100), 'OAuth2 Access Token.')
|
||||
->inject('response')
|
||||
->action(function ($token, $response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -322,24 +345,26 @@ App::get('/v1/mock/tests/general/oauth2/user')
|
||||
'name' => 'User Name',
|
||||
'email' => 'user@localhost.test',
|
||||
]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/mock/tests/general/oauth2/success')
|
||||
->label('scope', 'public')
|
||||
->groups(['mock'])
|
||||
->label('docs', false)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json([
|
||||
'result' => 'success',
|
||||
]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/mock/tests/general/oauth2/failure')
|
||||
->groups(['mock'])
|
||||
->label('scope', 'public')
|
||||
->label('docs', false)
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
@@ -348,7 +373,7 @@ App::get('/v1/mock/tests/general/oauth2/failure')
|
||||
->json([
|
||||
'result' => 'failure',
|
||||
]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::shutdown(function($utopia, $response, $request) {
|
||||
/** @var Utopia\App $utopia */
|
||||
|
||||
@@ -43,6 +43,7 @@ App::get('/error/:code')
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false)
|
||||
->inject('layout')
|
||||
->action(function ($code, $layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -55,12 +56,13 @@ App::get('/error/:code')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Error')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -73,12 +75,13 @@ App::get('/console')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Console')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/account')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -93,12 +96,13 @@ App::get('/console/account')
|
||||
$layout
|
||||
->setParam('title', 'Account - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/notifications')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -107,12 +111,13 @@ App::get('/console/notifications')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Notifications')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/home')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -121,12 +126,13 @@ App::get('/console/home')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Console')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/settings')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -142,12 +148,13 @@ App::get('/console/settings')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Settings')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/webhooks')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -160,12 +167,13 @@ App::get('/console/webhooks')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Webhooks')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/keys')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -177,12 +185,13 @@ App::get('/console/keys')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - API Keys')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/tasks')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -191,12 +200,13 @@ App::get('/console/tasks')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Tasks')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/database')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -205,13 +215,16 @@ App::get('/console/database')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Database')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/database/collection')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->param('id', '', new UID(), 'Collection unique ID.')
|
||||
->inject('response')
|
||||
->inject('layout')
|
||||
->inject('projectDB')
|
||||
->action(function ($id, $response, $layout, $projectDB) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\View $layout */
|
||||
@@ -241,13 +254,15 @@ App::get('/console/database/collection')
|
||||
->addHeader('Expires', 0)
|
||||
->addHeader('Pragma', 'no-cache')
|
||||
;
|
||||
}, ['response', 'layout', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/console/database/document')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->param('collection', '', new UID(), 'Collection unique ID.')
|
||||
->inject('layout')
|
||||
->inject('projectDB')
|
||||
->action(function ($collection, $layout, $projectDB) {
|
||||
/** @var Utopia\View $layout */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
@@ -274,12 +289,13 @@ App::get('/console/database/document')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Database Document')
|
||||
->setParam('body', $page);
|
||||
}, ['layout', 'projectDB']);
|
||||
});
|
||||
|
||||
App::get('/console/storage')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
$page = new View(__DIR__.'/../../views/console/storage/index.phtml');
|
||||
@@ -293,12 +309,13 @@ App::get('/console/storage')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Storage')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/users')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -309,12 +326,13 @@ App::get('/console/users')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Users')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/users/user')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -323,12 +341,13 @@ App::get('/console/users/user')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - User')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/users/teams/team')
|
||||
->groups(['web', 'console'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -337,13 +356,14 @@ App::get('/console/users/teams/team')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Team')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/functions')
|
||||
->groups(['web', 'console'])
|
||||
->desc('Platform console project functions')
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
$page = new View(__DIR__.'/../../views/console/functions/index.phtml');
|
||||
|
||||
@@ -354,13 +374,14 @@ App::get('/console/functions')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Functions')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/functions/function')
|
||||
->groups(['web', 'console'])
|
||||
->desc('Platform console project function')
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
$page = new View(__DIR__.'/../../views/console/functions/function.phtml');
|
||||
|
||||
@@ -374,13 +395,14 @@ App::get('/console/functions/function')
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Function')
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/console/version')
|
||||
->groups(['web', 'console'])
|
||||
->desc('Check for new version')
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
try {
|
||||
$version = \json_decode(@\file_get_contents(App::getEnv('_APP_HOME', 'http://localhost').'/v1/health/version'), true);
|
||||
@@ -393,4 +415,4 @@ App::get('/console/version')
|
||||
} catch (\Throwable $th) {
|
||||
throw new Exception('Failed to check for a newer version', 500);
|
||||
}
|
||||
}, ['response']);
|
||||
});
|
||||
@@ -7,6 +7,7 @@ use Utopia\App;
|
||||
use Utopia\View;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Exception;
|
||||
use Utopia\Validator\Range;
|
||||
use Utopia\Validator\WhiteList;
|
||||
|
||||
App::init(function ($layout) {
|
||||
@@ -40,16 +41,18 @@ App::get('/')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->redirect('/auth/signin');
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/auth/signin')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -58,12 +61,13 @@ App::get('/auth/signin')
|
||||
$layout
|
||||
->setParam('title', 'Sign In - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/auth/signup')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
$page = new View(__DIR__.'/../../views/home/auth/signup.phtml');
|
||||
@@ -71,12 +75,13 @@ App::get('/auth/signup')
|
||||
$layout
|
||||
->setParam('title', 'Sign Up - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/auth/recovery')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -85,12 +90,13 @@ App::get('/auth/recovery')
|
||||
$layout
|
||||
->setParam('title', 'Password Recovery - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/auth/confirm')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -99,12 +105,13 @@ App::get('/auth/confirm')
|
||||
$layout
|
||||
->setParam('title', 'Account Confirmation - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/auth/join')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -113,12 +120,13 @@ App::get('/auth/join')
|
||||
$layout
|
||||
->setParam('title', 'Invitation - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/auth/recovery/reset')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -127,12 +135,13 @@ App::get('/auth/recovery/reset')
|
||||
$layout
|
||||
->setParam('title', 'Password Reset - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/auth/oauth2/success')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -144,12 +153,13 @@ App::get('/auth/oauth2/success')
|
||||
->setParam('header', [])
|
||||
->setParam('footer', [])
|
||||
;
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/auth/oauth2/failure')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->inject('layout')
|
||||
->action(function ($layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -161,13 +171,14 @@ App::get('/auth/oauth2/failure')
|
||||
->setParam('header', [])
|
||||
->setParam('footer', [])
|
||||
;
|
||||
}, ['layout']);
|
||||
});
|
||||
|
||||
App::get('/error/:code')
|
||||
->groups(['web', 'home'])
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'home')
|
||||
->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false)
|
||||
->inject('layout')
|
||||
->action(function ($code, $layout) {
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
@@ -180,7 +191,7 @@ App::get('/error/:code')
|
||||
$layout
|
||||
->setParam('title', 'Error'.' - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
}, ['layout']);
|
||||
}, ['']);
|
||||
|
||||
App::get('/specs/:format')
|
||||
->groups(['web', 'home'])
|
||||
@@ -188,7 +199,11 @@ App::get('/specs/:format')
|
||||
->label('docs', false)
|
||||
->param('format', 'swagger2', new WhiteList(['swagger2', 'open-api3'], true), 'Spec format.', true)
|
||||
->param('platform', APP_PLATFORM_CLIENT, new WhiteList([APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER, APP_PLATFORM_CONSOLE], true), 'Choose target platform.', true)
|
||||
->action(function ($format, $platform, $utopia, $request, $response) {
|
||||
->param('tests', 0, function () {return new Range(0, 1);}, 'Include only test services.', true)
|
||||
->inject('utopia')
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->action(function ($format, $platform, $tests, $utopia, $request, $response) {
|
||||
/** @var Utopia\App $utopia */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
@@ -277,7 +292,11 @@ App::get('/specs/:format')
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($route->getLabel('sdk.mock', false)) {
|
||||
if ($route->getLabel('sdk.mock', false) && !$tests) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$route->getLabel('sdk.mock', false) && $tests) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -341,4 +360,4 @@ App::get('/specs/:format')
|
||||
|
||||
$response
|
||||
->json($specs->parse());
|
||||
}, ['utopia', 'request', 'response']);
|
||||
});
|
||||
+3
-2
@@ -115,8 +115,9 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo
|
||||
if(App::isDevelopment()) {
|
||||
$swooleResponse->end('error: '.$th->getMessage());
|
||||
}
|
||||
|
||||
$swooleResponse->end('500: Server Error');
|
||||
else {
|
||||
$swooleResponse->end('500: Server Error');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+12
-7
@@ -4,7 +4,7 @@
|
||||
* Init
|
||||
*
|
||||
* Initializes both Appwrite API entry point, queue workers, and CLI tasks.
|
||||
* Set configuration, framework resources, app constants
|
||||
* Set configuration, framework resources & app constants
|
||||
*
|
||||
*/
|
||||
if (\file_exists(__DIR__.'/../vendor/autoload.php')) {
|
||||
@@ -37,7 +37,7 @@ const APP_USERAGENT = APP_NAME.'-Server v%s. Please report abuse at %s';
|
||||
const APP_MODE_DEFAULT = 'default';
|
||||
const APP_MODE_ADMIN = 'admin';
|
||||
const APP_PAGING_LIMIT = 12;
|
||||
const APP_CACHE_BUSTER = 141;
|
||||
const APP_CACHE_BUSTER = 142;
|
||||
const APP_VERSION_STABLE = '0.7.0';
|
||||
const APP_STORAGE_UPLOADS = '/storage/uploads';
|
||||
const APP_STORAGE_FUNCTIONS = '/storage/functions';
|
||||
@@ -52,7 +52,12 @@ const APP_SOCIAL_INSTAGRAM = 'https://www.instagram.com/appwrite.io';
|
||||
const APP_SOCIAL_GITHUB = 'https://github.com/appwrite';
|
||||
const APP_SOCIAL_DISCORD = 'https://appwrite.io/discord';
|
||||
const APP_SOCIAL_DEV = 'https://dev.to/appwrite';
|
||||
const APP_SOCIAL_STACKSHARE = 'https://stackshare.io/appwrite';
|
||||
const APP_SOCIAL_STACKSHARE = 'https://stackshare.io/appwrite';
|
||||
// Deletion Types
|
||||
const DELETE_TYPE_DOCUMENT = 'document';
|
||||
const DELETE_TYPE_EXECUTIONS = 'executions';
|
||||
const DELETE_TYPE_AUDIT = 'audit';
|
||||
const DELETE_TYPE_ABUSE = 'abuse';
|
||||
|
||||
$register = new Registry();
|
||||
|
||||
@@ -298,19 +303,19 @@ App::setResource('events', function($register) {
|
||||
}, ['register']);
|
||||
|
||||
App::setResource('audits', function($register) {
|
||||
return new Event('v1-audits', 'AuditsV1');
|
||||
return new Event(Event::AUDITS_QUEUE_NAME, Event::AUDITS_CLASS_NAME);
|
||||
}, ['register']);
|
||||
|
||||
App::setResource('usage', function($register) {
|
||||
return new Event('v1-usage', 'UsageV1');
|
||||
return new Event(Event::USAGE_QUEUE_NAME, Event::USAGE_CLASS_NAME);
|
||||
}, ['register']);
|
||||
|
||||
App::setResource('mails', function($register) {
|
||||
return new Event('v1-mails', 'MailsV1');
|
||||
return new Event(Event::MAILS_QUEUE_NAME, Event::MAILS_CLASS_NAME);
|
||||
}, ['register']);
|
||||
|
||||
App::setResource('deletes', function($register) {
|
||||
return new Event('v1-deletes', 'DeletesV1');
|
||||
return new Event(Event::DELETE_QUEUE_NAME, Event::DELETE_CLASS_NAME);
|
||||
}, ['register']);
|
||||
|
||||
// Test Mock
|
||||
|
||||
+1
-1
@@ -43,4 +43,4 @@ $preloader
|
||||
->paths(realpath(__DIR__ . '/../app/config'))
|
||||
->paths(realpath(__DIR__ . '/../app/controllers'))
|
||||
->paths(realpath(__DIR__ . '/../src'))
|
||||
->load();
|
||||
->load();
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
## 0.3.2
|
||||
|
||||
- Fixed package namespaces
|
||||
|
||||
## 0.3.1
|
||||
|
||||
- Downgraded meta package version to 1.1.8
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- Updated package dependencies (@lohanidamodar)
|
||||
- Added Flutter for Web compatibility (@lohanidamodar)
|
||||
|
||||
## 0.2.3
|
||||
|
||||
- Fixed OAuth2 cookie bug, where a new session cookie couldn't overwrite an old cookie
|
||||
|
||||
## 0.2.2
|
||||
|
||||
- Fixed an error that happend when the OAuth session creation request was sent before any other API call
|
||||
- Fixed a bug in the Avatars service where location URL generation had syntax error
|
||||
|
||||
## 0.2.1
|
||||
|
||||
- Fixed callback scheme
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- Updated flutter_web_auth plugin to version 0.2.4
|
||||
- Added per project unique callback for OAuth2 redirects to aviod conflicts between multiple Appwrite projects
|
||||
|
||||
## 0.1.1
|
||||
|
||||
- Updated flutter_web_auth version
|
||||
|
||||
## 0.1.0
|
||||
|
||||
- Added examples file
|
||||
- Some minor style fixes
|
||||
|
||||
## 0.0.14
|
||||
|
||||
- Using MultipartFile for file uploads
|
||||
|
||||
## 0.0.13
|
||||
|
||||
- Fix for file upload method
|
||||
|
||||
## 0.0.12
|
||||
|
||||
- Added file upload support for storage service
|
||||
|
||||
## 0.0.11
|
||||
|
||||
- Added integration with web auth plugin to support Appwrite OAuth API
|
||||
|
||||
## 0.0.9
|
||||
|
||||
- Updated deafult params
|
||||
|
||||
## 0.0.8
|
||||
|
||||
- Fixed compilation error in Client class
|
||||
- Shorter description for package
|
||||
@@ -1,12 +0,0 @@
|
||||
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:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
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.
|
||||
@@ -1,38 +0,0 @@
|
||||
# Appwrite Flutter (Dev Channel) SDK
|
||||
|
||||
[](https://pub.dartlang.org/packages/appwrite)
|
||||

|
||||

|
||||
|
||||
**This SDK is compatible with Appwrite server version 0.6.2. For older versions, please check previous releases.**
|
||||
|
||||
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
|
||||
Use the Flutter (Dev Channel) SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
|
||||
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
Add this to your package's `pubspec.yaml` file:
|
||||
|
||||
```yml
|
||||
dependencies:
|
||||
appwrite_dev: ^0.3.2
|
||||
```
|
||||
|
||||
You can install packages from the command line:
|
||||
|
||||
```bash
|
||||
pub get appwrite_dev
|
||||
```
|
||||
|
||||
## Contribution
|
||||
|
||||
This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.
|
||||
|
||||
## License
|
||||
|
||||
Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.deleteSessions( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.delete( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.getLogs( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.getPrefs( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.getSessions( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.get( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getContinents( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountriesEU( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountriesPhones( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountries( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCurrencies( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite_dev/appwrite_dev.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.get( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
# Examples
|
||||
|
||||
Init your Appwrite client:
|
||||
|
||||
```dart
|
||||
Client client = Client();
|
||||
|
||||
client
|
||||
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
|
||||
.setProject('5e8cf4f46b5e8') // Your project ID
|
||||
.setSelfSigned() // Remove in production
|
||||
;
|
||||
|
||||
```
|
||||
|
||||
Create a new user and session:
|
||||
|
||||
```dart
|
||||
Account account = Account(client);
|
||||
|
||||
Response user = await account.create(email: 'me@appwrite.io', password: 'password', name: 'My Name');
|
||||
|
||||
Response session = await account.createSession(email: 'me@appwrite.io', password: 'password');
|
||||
|
||||
```
|
||||
|
||||
Fetch user profile:
|
||||
|
||||
```dart
|
||||
Account account = Account(client);
|
||||
|
||||
Response profile = await account.get();
|
||||
```
|
||||
|
||||
Upload File:
|
||||
|
||||
```dart
|
||||
Storage storage = Storage(client);
|
||||
|
||||
MultipartFile file = MultipartFile.fromFile('./path-to-file/image.jpg', filename: 'image.jpg');
|
||||
|
||||
storage.createFile(
|
||||
file: file,
|
||||
read: ['*'],
|
||||
write: []
|
||||
)
|
||||
.then((response) {
|
||||
print(response); // File uploaded!
|
||||
})
|
||||
.catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
```
|
||||
|
||||
All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs)
|
||||
@@ -1,10 +0,0 @@
|
||||
export 'package:dio/dio.dart' show Response;
|
||||
|
||||
export 'client.dart';
|
||||
export 'enums.dart';
|
||||
export 'services/account.dart';
|
||||
export 'services/avatars.dart';
|
||||
export 'services/database.dart';
|
||||
export 'services/locale.dart';
|
||||
export 'services/storage.dart';
|
||||
export 'services/teams.dart';
|
||||
@@ -1,10 +0,0 @@
|
||||
export 'package:dio/dio.dart' show Response;
|
||||
|
||||
export 'client.dart';
|
||||
export 'enums.dart';
|
||||
export 'services/account.dart';
|
||||
export 'services/avatars.dart';
|
||||
export 'services/database.dart';
|
||||
export 'services/locale.dart';
|
||||
export 'services/storage.dart';
|
||||
export 'services/teams.dart';
|
||||
@@ -1,134 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:dio/adapter.dart';
|
||||
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
|
||||
import 'package:cookie_jar/cookie_jar.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
|
||||
import 'enums.dart';
|
||||
|
||||
class Client {
|
||||
String endPoint;
|
||||
String type = 'unknown';
|
||||
Map<String, String> headers;
|
||||
Map<String, String> config;
|
||||
bool selfSigned;
|
||||
bool initialized = false;
|
||||
Dio http;
|
||||
PersistCookieJar cookieJar;
|
||||
|
||||
Client({this.endPoint = 'https://appwrite.io/v1', this.selfSigned = false, Dio http}) : this.http = http ?? Dio() {
|
||||
// Platform is not supported in web so if web, set type to web automatically and skip Platform check
|
||||
if(kIsWeb) {
|
||||
type = 'web';
|
||||
}else{
|
||||
type = (Platform.isIOS) ? 'ios' : type;
|
||||
type = (Platform.isMacOS) ? 'macos' : type;
|
||||
type = (Platform.isAndroid) ? 'android' : type;
|
||||
type = (Platform.isLinux) ? 'linux' : type;
|
||||
type = (Platform.isWindows) ? 'windows' : type;
|
||||
type = (Platform.isFuchsia) ? 'fuchsia' : type;
|
||||
}
|
||||
|
||||
this.headers = {
|
||||
'content-type': 'application/json',
|
||||
'x-sdk-version': 'appwrite:flutter:0.3.2',
|
||||
};
|
||||
|
||||
this.config = {};
|
||||
|
||||
assert(endPoint.startsWith(RegExp("http://|https://")), "endPoint $endPoint must start with 'http'");
|
||||
}
|
||||
|
||||
Future<Directory> _getCookiePath() async {
|
||||
final directory = await getApplicationDocumentsDirectory();
|
||||
final path = directory.path;
|
||||
final Directory dir = new Directory('$path/cookies');
|
||||
await dir.create();
|
||||
return dir;
|
||||
}
|
||||
|
||||
/// Your project ID
|
||||
Client setProject(value) {
|
||||
config['project'] = value;
|
||||
addHeader('X-Appwrite-Project', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
Client setLocale(value) {
|
||||
config['locale'] = value;
|
||||
addHeader('X-Appwrite-Locale', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
Client setSelfSigned({bool status = true}) {
|
||||
selfSigned = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
Client setEndpoint(String endPoint) {
|
||||
this.endPoint = endPoint;
|
||||
this.http.options.baseUrl = this.endPoint;
|
||||
return this;
|
||||
}
|
||||
|
||||
Client addHeader(String key, String value) {
|
||||
headers[key] = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Future init() async {
|
||||
if(!initialized) {
|
||||
// if web skip cookie implementation and origin header as those are automatically handled by browsers
|
||||
if(!kIsWeb) {
|
||||
final Directory cookieDir = await _getCookiePath();
|
||||
cookieJar = new PersistCookieJar(dir:cookieDir.path);
|
||||
this.http.interceptors.add(CookieManager(cookieJar));
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName);
|
||||
}else{
|
||||
// if web set httpClientAdapter as BrowserHttpClientAdapter with withCredentials true to make cookies work
|
||||
this.http.options.extra['withCredentials'] = true;
|
||||
}
|
||||
|
||||
this.http.options.baseUrl = this.endPoint;
|
||||
this.http.options.validateStatus = (status) => status < 400;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> call(HttpMethod method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) async {
|
||||
if(selfSigned) {
|
||||
// Allow self signed requests
|
||||
(http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) {
|
||||
client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
|
||||
return client;
|
||||
};
|
||||
}
|
||||
|
||||
await this.init();
|
||||
|
||||
// Origin is hardcoded for testing
|
||||
Options options = Options(
|
||||
headers: {...this.headers, ...headers},
|
||||
method: method.name(),
|
||||
);
|
||||
|
||||
if(headers['content-type'] == 'multipart/form-data') {
|
||||
return http.request(path, data: FormData.fromMap(params), options: options);
|
||||
}
|
||||
|
||||
if (method == HttpMethod.get) {
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
return http.get(path, queryParameters: params, options: options);
|
||||
} else {
|
||||
return http.request(path, data: params, options: options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
enum HttpMethod { get, post, put, delete, patch }
|
||||
|
||||
extension HttpMethodString on HttpMethod {
|
||||
String name() {
|
||||
return this.toString().split('.').last.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
enum OrderType { asc, desc }
|
||||
|
||||
extension OrderTypeString on OrderType {
|
||||
String name() {
|
||||
return this.toString().split('.').last.toUpperCase();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import 'client.dart';
|
||||
|
||||
class Service {
|
||||
final Client client;
|
||||
|
||||
const Service(this.client);
|
||||
}
|
||||
@@ -1,424 +0,0 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_web_auth/flutter_web_auth.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Account extends Service {
|
||||
Account(Client client): super(client);
|
||||
|
||||
/// Get Account
|
||||
///
|
||||
/// Get currently logged in user data as JSON object.
|
||||
///
|
||||
Future<Response> get() {
|
||||
final String path = '/account';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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/client/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/client/account#createSession).
|
||||
///
|
||||
Future<Response> create({@required String email, @required String password, String name = ''}) {
|
||||
final String path = '/account';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'password': password,
|
||||
'name': name,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> delete() {
|
||||
final String path = '/account';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> updateEmail({@required String email, @required String password}) {
|
||||
final String path = '/account/email';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'password': password,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> getLogs() {
|
||||
final String path = '/account/logs';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Account Name
|
||||
///
|
||||
/// Update currently logged in user account name.
|
||||
///
|
||||
Future<Response> updateName({@required String name}) {
|
||||
final String path = '/account/name';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Account Password
|
||||
///
|
||||
/// Update currently logged in user password. For validation, user is required
|
||||
/// to pass the password twice.
|
||||
///
|
||||
Future<Response> updatePassword({@required String password, @required String oldPassword}) {
|
||||
final String path = '/account/password';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'password': password,
|
||||
'oldPassword': oldPassword,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Account Preferences
|
||||
///
|
||||
/// Get currently logged in user preferences as a key-value object.
|
||||
///
|
||||
Future<Response> getPrefs() {
|
||||
final String path = '/account/prefs';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Account Preferences
|
||||
///
|
||||
/// Update currently logged in user account preferences. You can pass only the
|
||||
/// specific settings you wish to update.
|
||||
///
|
||||
Future<Response> updatePrefs({@required dynamic prefs}) {
|
||||
final String path = '/account/prefs';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'prefs': prefs,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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/client/account#updateRecovery)
|
||||
/// endpoint to complete the process.
|
||||
///
|
||||
Future<Response> createRecovery({@required String email, @required String url}) {
|
||||
final String path = '/account/recovery';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'url': url,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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/client/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<Response> updateRecovery({@required String userId, @required String secret, @required String password, @required String passwordAgain}) {
|
||||
final String path = '/account/recovery';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'userId': userId,
|
||||
'secret': secret,
|
||||
'password': password,
|
||||
'passwordAgain': passwordAgain,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Account Sessions
|
||||
///
|
||||
/// Get currently logged in user list of active sessions across different
|
||||
/// devices.
|
||||
///
|
||||
Future<Response> getSessions() {
|
||||
final String path = '/account/sessions';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> createSession({@required String email, @required String password}) {
|
||||
final String path = '/account/sessions';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'password': password,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Delete All Account Sessions
|
||||
///
|
||||
/// Delete all sessions from the user account and remove any sessions cookies
|
||||
/// from the end client.
|
||||
///
|
||||
Future<Response> deleteSessions() {
|
||||
final String path = '/account/sessions';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Create Account Session with OAuth2
|
||||
///
|
||||
/// Allow the user to login to his account using the OAuth2 provider of his
|
||||
/// choice. Each OAuth2 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({@required String provider, String success = 'https://appwrite.io/auth/oauth2/success', String failure = 'https://appwrite.io/auth/oauth2/failure'}) {
|
||||
final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'success': success,
|
||||
'failure': failure,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
|
||||
final List query = [];
|
||||
|
||||
params.forEach((key, value) {
|
||||
if (value is List) {
|
||||
for (var item in value) {
|
||||
query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item));
|
||||
}
|
||||
}
|
||||
else {
|
||||
query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value));
|
||||
}
|
||||
});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri url = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
query: query.join('&')
|
||||
);
|
||||
|
||||
return FlutterWebAuth.authenticate(
|
||||
url: url.toString(),
|
||||
callbackUrlScheme: "appwrite-callback-" + client.config['project']
|
||||
).then((value) async {
|
||||
Uri url = Uri.parse(value);
|
||||
Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']);
|
||||
cookie.domain = Uri.parse(client.endPoint).host;
|
||||
cookie.httpOnly = true;
|
||||
cookie.path = '/';
|
||||
List<Cookie> cookies = [cookie];
|
||||
await client.init();
|
||||
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
|
||||
});
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> deleteSession({@required String sessionId}) {
|
||||
final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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/client/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<Response> createVerification({@required String url}) {
|
||||
final String path = '/account/verification';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'url': url,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> updateVerification({@required String userId, @required String secret}) {
|
||||
final String path = '/account/verification';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'userId': userId,
|
||||
'secret': secret,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
|
||||
}
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Avatars extends Service {
|
||||
Avatars(Client client): super(client);
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get Favicon
|
||||
///
|
||||
/// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
|
||||
/// website URL.
|
||||
///
|
||||
String getFavicon({@required String url}) {
|
||||
final String path = '/avatars/favicon';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'url': url,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getImage({@required String url, int width = 400, int height = 400}) {
|
||||
final String path = '/avatars/image';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'url': url,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getQR({@required String text, int size = 400, int margin = 1, int download = 0}) {
|
||||
final String path = '/avatars/qr';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'text': text,
|
||||
'size': size,
|
||||
'margin': margin,
|
||||
'download': download,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Database extends Service {
|
||||
Database(Client client): super(client);
|
||||
|
||||
/// 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).
|
||||
///
|
||||
Future<Response> listDocuments({@required String collectionId, List filters = const [], int offset = 0, int limit = 50, String orderField = '\$id', OrderType orderType = OrderType.asc, String orderCast = 'string', String search = '', int first = 0, int last = 0}) {
|
||||
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'filters': filters,
|
||||
'offset': offset,
|
||||
'limit': limit,
|
||||
'orderField': orderField,
|
||||
'orderType': orderType.name(),
|
||||
'orderCast': orderCast,
|
||||
'search': search,
|
||||
'first': first,
|
||||
'last': last,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Create Document
|
||||
///
|
||||
/// Create a new Document. Before using this route, you should create a new
|
||||
/// collection resource using either a [server
|
||||
/// integration](/docs/server/database?sdk=nodejs#createCollection) API or
|
||||
/// directly from your database console.
|
||||
///
|
||||
Future<Response> createDocument({@required String collectionId, @required dynamic data, @required List read, @required List write, String parentDocument = '', String parentProperty = '', String parentPropertyType = 'assign'}) {
|
||||
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'data': data,
|
||||
'read': read,
|
||||
'write': write,
|
||||
'parentDocument': parentDocument,
|
||||
'parentProperty': parentProperty,
|
||||
'parentPropertyType': parentPropertyType,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Document
|
||||
///
|
||||
/// Get document by its unique ID. This endpoint response returns a JSON object
|
||||
/// with the document data.
|
||||
///
|
||||
Future<Response> getDocument({@required String collectionId, @required String documentId}) {
|
||||
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Document
|
||||
Future<Response> updateDocument({@required String collectionId, @required String documentId, @required dynamic data, @required List read, @required List write}) {
|
||||
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'data': data,
|
||||
'read': read,
|
||||
'write': write,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> deleteDocument({@required String collectionId, @required String documentId}) {
|
||||
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Locale extends Service {
|
||||
Locale(Client client): super(client);
|
||||
|
||||
/// 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))
|
||||
///
|
||||
Future<Response> get() {
|
||||
final String path = '/locale';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// List Continents
|
||||
///
|
||||
/// List of all continents. You can use the locale header to get the data in a
|
||||
/// supported language.
|
||||
///
|
||||
Future<Response> getContinents() {
|
||||
final String path = '/locale/continents';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// List Countries
|
||||
///
|
||||
/// List of all countries. You can use the locale header to get the data in a
|
||||
/// supported language.
|
||||
///
|
||||
Future<Response> getCountries() {
|
||||
final String path = '/locale/countries';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> getCountriesEU() {
|
||||
final String path = '/locale/countries/eu';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// List Countries Phone Codes
|
||||
///
|
||||
/// List of all countries phone codes. You can use the locale header to get the
|
||||
/// data in a supported language.
|
||||
///
|
||||
Future<Response> getCountriesPhones() {
|
||||
final String path = '/locale/countries/phones';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> getCurrencies() {
|
||||
final String path = '/locale/currencies';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Storage extends Service {
|
||||
Storage(Client client): super(client);
|
||||
|
||||
/// 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).
|
||||
///
|
||||
Future<Response> listFiles({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
|
||||
final String path = '/storage/files';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'search': search,
|
||||
'limit': limit,
|
||||
'offset': offset,
|
||||
'orderType': orderType.name(),
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> createFile({@required MultipartFile file, @required List read, @required List write}) {
|
||||
final String path = '/storage/files';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'file': file,
|
||||
'read': read,
|
||||
'write': write,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'multipart/form-data',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get File
|
||||
///
|
||||
/// Get file by its unique ID. This endpoint response returns a JSON object
|
||||
/// with the file metadata.
|
||||
///
|
||||
Future<Response> getFile({@required String fileId}) {
|
||||
final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update File
|
||||
///
|
||||
/// Update file by its unique ID. Only users with write permissions have access
|
||||
/// to update this resource.
|
||||
///
|
||||
Future<Response> updateFile({@required String fileId, @required List read, @required List write}) {
|
||||
final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'read': read,
|
||||
'write': write,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Delete File
|
||||
///
|
||||
/// Delete a file by its unique ID. Only users with write permissions have
|
||||
/// access to delete this resource.
|
||||
///
|
||||
Future<Response> deleteFile({@required String fileId}) {
|
||||
final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getFileDownload({@required String fileId}) {
|
||||
final String path = '/storage/files/{fileId}/download'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getFilePreview({@required String fileId, int width = 0, int height = 0, int quality = 100, String background = '', String output = ''}) {
|
||||
final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'background': background,
|
||||
'output': output,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getFileView({@required String fileId, String as = ''}) {
|
||||
final String path = '/storage/files/{fileId}/view'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'as': as,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Teams extends Service {
|
||||
Teams(Client client): super(client);
|
||||
|
||||
/// 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).
|
||||
///
|
||||
Future<Response> list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
|
||||
final String path = '/teams';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'search': search,
|
||||
'limit': limit,
|
||||
'offset': offset,
|
||||
'orderType': orderType.name(),
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> create({@required String name, List roles = const ["owner"]}) {
|
||||
final String path = '/teams';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
'roles': roles,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Team
|
||||
///
|
||||
/// Get team by its unique ID. All team members have read access for this
|
||||
/// resource.
|
||||
///
|
||||
Future<Response> get({@required String teamId}) {
|
||||
final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Team
|
||||
///
|
||||
/// Update team by its unique ID. Only team owners have write access for this
|
||||
/// resource.
|
||||
///
|
||||
Future<Response> update({@required String teamId, @required String name}) {
|
||||
final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Delete Team
|
||||
///
|
||||
/// Delete team by its unique ID. Only team owners have write access for this
|
||||
/// resource.
|
||||
///
|
||||
Future<Response> delete({@required String teamId}) {
|
||||
final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Team Memberships
|
||||
///
|
||||
/// Get team members by the team unique ID. All team members have read access
|
||||
/// for this list of resources.
|
||||
///
|
||||
Future<Response> getMemberships({@required String teamId}) {
|
||||
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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/client/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.
|
||||
///
|
||||
Future<Response> createMembership({@required String teamId, @required String email, @required List roles, @required String url, String name = ''}) {
|
||||
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'name': name,
|
||||
'roles': roles,
|
||||
'url': url,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> deleteMembership({@required String teamId, @required String inviteId}) {
|
||||
final String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> updateMembershipStatus({@required String teamId, @required String inviteId, @required String userId, @required String secret}) {
|
||||
final String path = '/teams/{teamId}/memberships/{inviteId}/status'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'userId': userId,
|
||||
'secret': secret,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
name: appwrite_dev
|
||||
version: 0.3.2
|
||||
description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
|
||||
homepage: https://appwrite.io
|
||||
repository: https://github.com/appwrite/sdk-for-flutter-dev
|
||||
issue_tracker: https://github.com/appwrite/sdk-generator/issues
|
||||
documentation: https://appwrite.io/support
|
||||
environment:
|
||||
sdk: '>=2.6.0 <3.0.0'
|
||||
dependencies:
|
||||
meta: ^1.1.8
|
||||
path_provider: ^1.6.14
|
||||
package_info: ^0.4.3
|
||||
dio: ^3.0.10
|
||||
cookie_jar: ^1.0.1
|
||||
dio_cookie_manager: ^1.0.0
|
||||
flutter_web_auth: ^0.2.4
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
@@ -1,60 +0,0 @@
|
||||
## 0.3.0-dev.2
|
||||
|
||||
- Fix for an error when using a self-signed certificate for Web
|
||||
|
||||
## 0.3.0-dev.1
|
||||
|
||||
- Updated package dependencies (@lohanidamodar)
|
||||
- Added Flutter for Web compatibility (@lohanidamodar)
|
||||
|
||||
## 0.2.3
|
||||
|
||||
- Fixed OAuth2 cookie bug, where a new session cookie couldn't overwrite an old cookie
|
||||
|
||||
## 0.2.2
|
||||
|
||||
- Fixed an error that happend when the OAuth session creation request was sent before any other API call
|
||||
- Fixed a bug in the Avatars service where location URL generation had syntax error
|
||||
|
||||
## 0.2.1
|
||||
|
||||
- Fixed callback scheme
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- Updated flutter_web_auth plugin to version 0.2.4
|
||||
- Added per project unique callback for OAuth2 redirects to aviod conflicts between multiple Appwrite projects
|
||||
|
||||
## 0.1.1
|
||||
|
||||
- Updated flutter_web_auth version
|
||||
|
||||
## 0.1.0
|
||||
|
||||
- Added examples file
|
||||
- Some minor style fixes
|
||||
|
||||
## 0.0.14
|
||||
|
||||
- Using MultipartFile for file uploads
|
||||
|
||||
## 0.0.13
|
||||
|
||||
- Fix for file upload method
|
||||
|
||||
## 0.0.12
|
||||
|
||||
- Added file upload support for storage service
|
||||
|
||||
## 0.0.11
|
||||
|
||||
- Added integration with web auth plugin to support Appwrite OAuth API
|
||||
|
||||
## 0.0.9
|
||||
|
||||
- Updated deafult params
|
||||
|
||||
## 0.0.8
|
||||
|
||||
- Fixed compilation error in Client class
|
||||
- Shorter description for package
|
||||
@@ -1,12 +0,0 @@
|
||||
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:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
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.
|
||||
@@ -1,38 +0,0 @@
|
||||
# Appwrite Flutter SDK
|
||||
|
||||
[](https://pub.dartlang.org/packages/appwrite)
|
||||

|
||||

|
||||
|
||||
**This SDK is compatible with Appwrite server version 0.6.2. For older versions, please check previous releases.**
|
||||
|
||||
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
|
||||
Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
|
||||
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
Add this to your package's `pubspec.yaml` file:
|
||||
|
||||
```yml
|
||||
dependencies:
|
||||
appwrite: ^0.3.0-dev.2
|
||||
```
|
||||
|
||||
You can install packages from the command line:
|
||||
|
||||
```bash
|
||||
pub get appwrite
|
||||
```
|
||||
|
||||
## Contribution
|
||||
|
||||
This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.
|
||||
|
||||
## License
|
||||
|
||||
Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.deleteSessions( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountriesPhones( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
# Examples
|
||||
|
||||
Init your Appwrite client:
|
||||
|
||||
```dart
|
||||
Client client = Client();
|
||||
|
||||
client
|
||||
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
|
||||
.setProject('5e8cf4f46b5e8') // Your project ID
|
||||
.setSelfSigned() // Remove in production
|
||||
;
|
||||
|
||||
```
|
||||
|
||||
Create a new user and session:
|
||||
|
||||
```dart
|
||||
Account account = Account(client);
|
||||
|
||||
Response user = await account.create(email: 'me@appwrite.io', password: 'password', name: 'My Name');
|
||||
|
||||
Response session = await account.createSession(email: 'me@appwrite.io', password: 'password');
|
||||
|
||||
```
|
||||
|
||||
Fetch user profile:
|
||||
|
||||
```dart
|
||||
Account account = Account(client);
|
||||
|
||||
Response profile = await account.get();
|
||||
```
|
||||
|
||||
Upload File:
|
||||
|
||||
```dart
|
||||
Storage storage = Storage(client);
|
||||
|
||||
MultipartFile file = MultipartFile.fromFile('./path-to-file/image.jpg', filename: 'image.jpg');
|
||||
|
||||
storage.createFile(
|
||||
file: file,
|
||||
read: ['*'],
|
||||
write: []
|
||||
)
|
||||
.then((response) {
|
||||
print(response); // File uploaded!
|
||||
})
|
||||
.catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
```
|
||||
|
||||
All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs)
|
||||
@@ -1,10 +0,0 @@
|
||||
export 'package:dio/dio.dart' show Response;
|
||||
|
||||
export 'client.dart';
|
||||
export 'enums.dart';
|
||||
export 'services/account.dart';
|
||||
export 'services/avatars.dart';
|
||||
export 'services/database.dart';
|
||||
export 'services/locale.dart';
|
||||
export 'services/storage.dart';
|
||||
export 'services/teams.dart';
|
||||
@@ -1,134 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:dio/adapter.dart';
|
||||
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
|
||||
import 'package:cookie_jar/cookie_jar.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
|
||||
import 'enums.dart';
|
||||
|
||||
class Client {
|
||||
String endPoint;
|
||||
String type = 'unknown';
|
||||
Map<String, String> headers;
|
||||
Map<String, String> config;
|
||||
bool selfSigned;
|
||||
bool initialized = false;
|
||||
Dio http;
|
||||
PersistCookieJar cookieJar;
|
||||
|
||||
Client({this.endPoint = 'https://appwrite.io/v1', this.selfSigned = false, Dio http}) : this.http = http ?? Dio() {
|
||||
// Platform is not supported in web so if web, set type to web automatically and skip Platform check
|
||||
if(kIsWeb) {
|
||||
type = 'web';
|
||||
}else{
|
||||
type = (Platform.isIOS) ? 'ios' : type;
|
||||
type = (Platform.isMacOS) ? 'macos' : type;
|
||||
type = (Platform.isAndroid) ? 'android' : type;
|
||||
type = (Platform.isLinux) ? 'linux' : type;
|
||||
type = (Platform.isWindows) ? 'windows' : type;
|
||||
type = (Platform.isFuchsia) ? 'fuchsia' : type;
|
||||
}
|
||||
|
||||
this.headers = {
|
||||
'content-type': 'application/json',
|
||||
'x-sdk-version': 'appwrite:flutter:0.3.0-dev.2',
|
||||
};
|
||||
|
||||
this.config = {};
|
||||
|
||||
assert(endPoint.startsWith(RegExp("http://|https://")), "endPoint $endPoint must start with 'http'");
|
||||
}
|
||||
|
||||
Future<Directory> _getCookiePath() async {
|
||||
final directory = await getApplicationDocumentsDirectory();
|
||||
final path = directory.path;
|
||||
final Directory dir = new Directory('$path/cookies');
|
||||
await dir.create();
|
||||
return dir;
|
||||
}
|
||||
|
||||
/// Your project ID
|
||||
Client setProject(value) {
|
||||
config['project'] = value;
|
||||
addHeader('X-Appwrite-Project', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
Client setLocale(value) {
|
||||
config['locale'] = value;
|
||||
addHeader('X-Appwrite-Locale', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
Client setSelfSigned({bool status = true}) {
|
||||
selfSigned = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
Client setEndpoint(String endPoint) {
|
||||
this.endPoint = endPoint;
|
||||
this.http.options.baseUrl = this.endPoint;
|
||||
return this;
|
||||
}
|
||||
|
||||
Client addHeader(String key, String value) {
|
||||
headers[key] = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Future init() async {
|
||||
if(!initialized) {
|
||||
// if web skip cookie implementation and origin header as those are automatically handled by browsers
|
||||
if(!kIsWeb) {
|
||||
final Directory cookieDir = await _getCookiePath();
|
||||
cookieJar = new PersistCookieJar(dir:cookieDir.path);
|
||||
this.http.interceptors.add(CookieManager(cookieJar));
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName);
|
||||
}else{
|
||||
// if web set httpClientAdapter as BrowserHttpClientAdapter with withCredentials true to make cookies work
|
||||
this.http.options.extra['withCredentials'] = true;
|
||||
}
|
||||
|
||||
this.http.options.baseUrl = this.endPoint;
|
||||
this.http.options.validateStatus = (status) => status < 400;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> call(HttpMethod method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) async {
|
||||
if(selfSigned && !kIsWeb) {
|
||||
// Allow self signed requests
|
||||
(http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) {
|
||||
client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
|
||||
return client;
|
||||
};
|
||||
}
|
||||
|
||||
await this.init();
|
||||
|
||||
// Origin is hardcoded for testing
|
||||
Options options = Options(
|
||||
headers: {...this.headers, ...headers},
|
||||
method: method.name(),
|
||||
);
|
||||
|
||||
if(headers['content-type'] == 'multipart/form-data') {
|
||||
return http.request(path, data: FormData.fromMap(params), options: options);
|
||||
}
|
||||
|
||||
if (method == HttpMethod.get) {
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
return http.get(path, queryParameters: params, options: options);
|
||||
} else {
|
||||
return http.request(path, data: params, options: options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
enum HttpMethod { get, post, put, delete, patch }
|
||||
|
||||
extension HttpMethodString on HttpMethod {
|
||||
String name() {
|
||||
return this.toString().split('.').last.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
enum OrderType { asc, desc }
|
||||
|
||||
extension OrderTypeString on OrderType {
|
||||
String name() {
|
||||
return this.toString().split('.').last.toUpperCase();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import 'client.dart';
|
||||
|
||||
class Service {
|
||||
final Client client;
|
||||
|
||||
const Service(this.client);
|
||||
}
|
||||
@@ -1,435 +0,0 @@
|
||||
|
||||
import 'dart:io';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_web_auth/flutter_web_auth.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Account extends Service {
|
||||
Account(Client client): super(client);
|
||||
|
||||
/// Get Account
|
||||
///
|
||||
/// Get currently logged in user data as JSON object.
|
||||
///
|
||||
Future<Response> get() {
|
||||
final String path = '/account';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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/client/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/client/account#createSession).
|
||||
///
|
||||
Future<Response> create({@required String email, @required String password, String name = ''}) {
|
||||
final String path = '/account';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'password': password,
|
||||
'name': name,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> delete() {
|
||||
final String path = '/account';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> updateEmail({@required String email, @required String password}) {
|
||||
final String path = '/account/email';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'password': password,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> getLogs() {
|
||||
final String path = '/account/logs';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Account Name
|
||||
///
|
||||
/// Update currently logged in user account name.
|
||||
///
|
||||
Future<Response> updateName({@required String name}) {
|
||||
final String path = '/account/name';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Account Password
|
||||
///
|
||||
/// Update currently logged in user password. For validation, user is required
|
||||
/// to pass the password twice.
|
||||
///
|
||||
Future<Response> updatePassword({@required String password, @required String oldPassword}) {
|
||||
final String path = '/account/password';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'password': password,
|
||||
'oldPassword': oldPassword,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Account Preferences
|
||||
///
|
||||
/// Get currently logged in user preferences as a key-value object.
|
||||
///
|
||||
Future<Response> getPrefs() {
|
||||
final String path = '/account/prefs';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Account Preferences
|
||||
///
|
||||
/// Update currently logged in user account preferences. You can pass only the
|
||||
/// specific settings you wish to update.
|
||||
///
|
||||
Future<Response> updatePrefs({@required dynamic prefs}) {
|
||||
final String path = '/account/prefs';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'prefs': prefs,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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/client/account#updateRecovery)
|
||||
/// endpoint to complete the process.
|
||||
///
|
||||
Future<Response> createRecovery({@required String email, @required String url}) {
|
||||
final String path = '/account/recovery';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'url': url,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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/client/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<Response> updateRecovery({@required String userId, @required String secret, @required String password, @required String passwordAgain}) {
|
||||
final String path = '/account/recovery';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'userId': userId,
|
||||
'secret': secret,
|
||||
'password': password,
|
||||
'passwordAgain': passwordAgain,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Account Sessions
|
||||
///
|
||||
/// Get currently logged in user list of active sessions across different
|
||||
/// devices.
|
||||
///
|
||||
Future<Response> getSessions() {
|
||||
final String path = '/account/sessions';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> createSession({@required String email, @required String password}) {
|
||||
final String path = '/account/sessions';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'password': password,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Delete All Account Sessions
|
||||
///
|
||||
/// Delete all sessions from the user account and remove any sessions cookies
|
||||
/// from the end client.
|
||||
///
|
||||
Future<Response> deleteSessions() {
|
||||
final String path = '/account/sessions';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Create Account Session with OAuth2
|
||||
///
|
||||
/// Allow the user to login to his account using the OAuth2 provider of his
|
||||
/// choice. Each OAuth2 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({@required String provider, String success = 'https://appwrite.io/auth/oauth2/success', String failure = 'https://appwrite.io/auth/oauth2/failure', List scopes = const []}) {
|
||||
final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'success': success,
|
||||
'failure': failure,
|
||||
'scopes': scopes,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
|
||||
final List query = [];
|
||||
|
||||
params.forEach((key, value) {
|
||||
if (value is List) {
|
||||
for (var item in value) {
|
||||
query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item));
|
||||
}
|
||||
}
|
||||
else {
|
||||
query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value));
|
||||
}
|
||||
});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri url = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
query: query.join('&')
|
||||
);
|
||||
|
||||
if(kIsWeb) {
|
||||
html.window.location.href = url.toString();
|
||||
return null;
|
||||
}else{
|
||||
|
||||
return FlutterWebAuth.authenticate(
|
||||
url: url.toString(),
|
||||
callbackUrlScheme: "appwrite-callback-" + client.config['project']
|
||||
).then((value) async {
|
||||
Uri url = Uri.parse(value);
|
||||
Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']);
|
||||
cookie.domain = Uri.parse(client.endPoint).host;
|
||||
cookie.httpOnly = true;
|
||||
cookie.path = '/';
|
||||
List<Cookie> cookies = [cookie];
|
||||
await client.init();
|
||||
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> deleteSession({@required String sessionId}) {
|
||||
final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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 provided to be attached to the verification email. The provided URL
|
||||
/// should redirect the user back to 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/client/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<Response> createVerification({@required String url}) {
|
||||
final String path = '/account/verification';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'url': url,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> updateVerification({@required String userId, @required String secret}) {
|
||||
final String path = '/account/verification';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'userId': userId,
|
||||
'secret': secret,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
|
||||
}
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Avatars extends Service {
|
||||
Avatars(Client client): super(client);
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get Favicon
|
||||
///
|
||||
/// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
|
||||
/// website URL.
|
||||
///
|
||||
String getFavicon({@required String url}) {
|
||||
final String path = '/avatars/favicon';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'url': url,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getImage({@required String url, int width = 400, int height = 400}) {
|
||||
final String path = '/avatars/image';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'url': url,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get User Initials
|
||||
///
|
||||
/// Use this endpoint to show your user initials avatar icon on your website or
|
||||
/// app. By default, this route will try to print your logged-in user name or
|
||||
/// email initials. You can also overwrite the user name if you pass the 'name'
|
||||
/// parameter. If no name is given and no user is logged, an empty avatar will
|
||||
/// be returned.
|
||||
///
|
||||
/// You can use the color and background params to change the avatar colors. By
|
||||
/// default, a random theme will be selected. The random theme will persist for
|
||||
/// the user's initials when reloading the same theme will always return for
|
||||
/// the same initials.
|
||||
///
|
||||
String getInitials({String name = '', int width = 500, int height = 500, String color = '', String background = ''}) {
|
||||
final String path = '/avatars/initials';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'color': color,
|
||||
'background': background,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getQR({@required String text, int size = 400, int margin = 1, bool download = false}) {
|
||||
final String path = '/avatars/qr';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'text': text,
|
||||
'size': size,
|
||||
'margin': margin,
|
||||
'download': download,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Database extends Service {
|
||||
Database(Client client): super(client);
|
||||
|
||||
/// 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).
|
||||
///
|
||||
Future<Response> listDocuments({@required String collectionId, List filters = const [], int offset = 0, int limit = 50, String orderField = '\$id', OrderType orderType = OrderType.asc, String orderCast = 'string', String search = ''}) {
|
||||
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'filters': filters,
|
||||
'offset': offset,
|
||||
'limit': limit,
|
||||
'orderField': orderField,
|
||||
'orderType': orderType.name(),
|
||||
'orderCast': orderCast,
|
||||
'search': search,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Create Document
|
||||
///
|
||||
/// Create a new Document. Before using this route, you should create a new
|
||||
/// collection resource using either a [server
|
||||
/// integration](/docs/server/database?sdk=nodejs#createCollection) API or
|
||||
/// directly from your database console.
|
||||
///
|
||||
Future<Response> createDocument({@required String collectionId, @required dynamic data, @required List read, @required List write, String parentDocument = '', String parentProperty = '', String parentPropertyType = 'assign'}) {
|
||||
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'data': data,
|
||||
'read': read,
|
||||
'write': write,
|
||||
'parentDocument': parentDocument,
|
||||
'parentProperty': parentProperty,
|
||||
'parentPropertyType': parentPropertyType,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Document
|
||||
///
|
||||
/// Get document by its unique ID. This endpoint response returns a JSON object
|
||||
/// with the document data.
|
||||
///
|
||||
Future<Response> getDocument({@required String collectionId, @required String documentId}) {
|
||||
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Document
|
||||
Future<Response> updateDocument({@required String collectionId, @required String documentId, @required dynamic data, @required List read, @required List write}) {
|
||||
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'data': data,
|
||||
'read': read,
|
||||
'write': write,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> deleteDocument({@required String collectionId, @required String documentId}) {
|
||||
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Locale extends Service {
|
||||
Locale(Client client): super(client);
|
||||
|
||||
/// 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))
|
||||
///
|
||||
Future<Response> get() {
|
||||
final String path = '/locale';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// List Continents
|
||||
///
|
||||
/// List of all continents. You can use the locale header to get the data in a
|
||||
/// supported language.
|
||||
///
|
||||
Future<Response> getContinents() {
|
||||
final String path = '/locale/continents';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// List Countries
|
||||
///
|
||||
/// List of all countries. You can use the locale header to get the data in a
|
||||
/// supported language.
|
||||
///
|
||||
Future<Response> getCountries() {
|
||||
final String path = '/locale/countries';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> getCountriesEU() {
|
||||
final String path = '/locale/countries/eu';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// List Countries Phone Codes
|
||||
///
|
||||
/// List of all countries phone codes. You can use the locale header to get the
|
||||
/// data in a supported language.
|
||||
///
|
||||
Future<Response> getCountriesPhones() {
|
||||
final String path = '/locale/countries/phones';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// List Currencies
|
||||
///
|
||||
/// List of all currencies, including currency symbol, 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.
|
||||
///
|
||||
Future<Response> getCurrencies() {
|
||||
final String path = '/locale/currencies';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// List Languages
|
||||
///
|
||||
/// List of all languages classified by ISO 639-1 including 2-letter code, name
|
||||
/// in English, and name in the respective language.
|
||||
///
|
||||
Future<Response> getLanguages() {
|
||||
final String path = '/locale/languages';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Storage extends Service {
|
||||
Storage(Client client): super(client);
|
||||
|
||||
/// 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).
|
||||
///
|
||||
Future<Response> listFiles({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
|
||||
final String path = '/storage/files';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'search': search,
|
||||
'limit': limit,
|
||||
'offset': offset,
|
||||
'orderType': orderType.name(),
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> createFile({@required MultipartFile file, @required List read, @required List write}) {
|
||||
final String path = '/storage/files';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'file': file,
|
||||
'read': read,
|
||||
'write': write,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'multipart/form-data',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get File
|
||||
///
|
||||
/// Get file by its unique ID. This endpoint response returns a JSON object
|
||||
/// with the file metadata.
|
||||
///
|
||||
Future<Response> getFile({@required String fileId}) {
|
||||
final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update File
|
||||
///
|
||||
/// Update file by its unique ID. Only users with write permissions have access
|
||||
/// to update this resource.
|
||||
///
|
||||
Future<Response> updateFile({@required String fileId, @required List read, @required List write}) {
|
||||
final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'read': read,
|
||||
'write': write,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Delete File
|
||||
///
|
||||
/// Delete a file by its unique ID. Only users with write permissions have
|
||||
/// access to delete this resource.
|
||||
///
|
||||
Future<Response> deleteFile({@required String fileId}) {
|
||||
final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getFileDownload({@required String fileId}) {
|
||||
final String path = '/storage/files/{fileId}/download'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getFilePreview({@required String fileId, int width = 0, int height = 0, int quality = 100, String background = '', String output = ''}) {
|
||||
final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'background': background,
|
||||
'output': output,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
String getFileView({@required String fileId, String as = ''}) {
|
||||
final String path = '/storage/files/{fileId}/view'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'as': as,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
params.keys.forEach((key) {if (params[key] is int || params[key] is double) {
|
||||
params[key] = params[key].toString();
|
||||
}});
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return location.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
import "../service.dart";
|
||||
|
||||
class Teams extends Service {
|
||||
Teams(Client client): super(client);
|
||||
|
||||
/// 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).
|
||||
///
|
||||
Future<Response> list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
|
||||
final String path = '/teams';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'search': search,
|
||||
'limit': limit,
|
||||
'offset': offset,
|
||||
'orderType': orderType.name(),
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> create({@required String name, List roles = const ["owner"]}) {
|
||||
final String path = '/teams';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
'roles': roles,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Team
|
||||
///
|
||||
/// Get team by its unique ID. All team members have read access for this
|
||||
/// resource.
|
||||
///
|
||||
Future<Response> get({@required String teamId}) {
|
||||
final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Update Team
|
||||
///
|
||||
/// Update team by its unique ID. Only team owners have write access for this
|
||||
/// resource.
|
||||
///
|
||||
Future<Response> update({@required String teamId, @required String name}) {
|
||||
final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Delete Team
|
||||
///
|
||||
/// Delete team by its unique ID. Only team owners have write access for this
|
||||
/// resource.
|
||||
///
|
||||
Future<Response> delete({@required String teamId}) {
|
||||
final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// Get Team Memberships
|
||||
///
|
||||
/// Get team members by the team unique ID. All team members have read access
|
||||
/// for this list of resources.
|
||||
///
|
||||
Future<Response> getMemberships({@required String teamId, String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
|
||||
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'search': search,
|
||||
'limit': limit,
|
||||
'offset': offset,
|
||||
'orderType': orderType.name(),
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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/client/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.
|
||||
///
|
||||
Future<Response> createMembership({@required String teamId, @required String email, @required List roles, @required String url, String name = ''}) {
|
||||
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'email': email,
|
||||
'name': name,
|
||||
'roles': roles,
|
||||
'url': url,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> deleteMembership({@required String teamId, @required String inviteId}) {
|
||||
final String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
Future<Response> updateMembershipStatus({@required String teamId, @required String inviteId, @required String userId, @required String secret}) {
|
||||
final String path = '/teams/{teamId}/memberships/{inviteId}/status'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'userId': userId,
|
||||
'secret': secret,
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
name: appwrite
|
||||
version: 0.3.0-dev.2
|
||||
description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
|
||||
homepage: https://appwrite.io
|
||||
repository: https://github.com/appwrite/sdk-for-flutter
|
||||
issue_tracker: https://github.com/appwrite/sdk-generator/issues
|
||||
documentation: https://appwrite.io/support
|
||||
environment:
|
||||
sdk: '>=2.6.0 <3.0.0'
|
||||
dependencies:
|
||||
meta: ^1.1.8
|
||||
path_provider: ^1.6.14
|
||||
package_info: ^0.4.3
|
||||
dio: ^3.0.10
|
||||
cookie_jar: ^1.0.1
|
||||
dio_cookie_manager: ^1.0.0
|
||||
flutter_web_auth: ^0.2.4
|
||||
universal_html: ^1.2.3
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
@@ -1,12 +0,0 @@
|
||||
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:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
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.
|
||||
@@ -1,35 +0,0 @@
|
||||
// swift-tools-version:5.1
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
//
|
||||
// Created by Armino <devel@boioiong.com>
|
||||
// GitHub: https://github.com/armino-dev/sdk-generator
|
||||
//
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Appwrite",
|
||||
products: [
|
||||
// Products define the executables and libraries produced by a package,
|
||||
// and make them visible to other packages.
|
||||
.library(
|
||||
name: "Appwrite",
|
||||
targets: ["Appwrite"]),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package.
|
||||
// A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package,
|
||||
// and on products in packages which this package depends on.
|
||||
.target(
|
||||
name: "Appwrite",
|
||||
dependencies: []),
|
||||
.testTarget(
|
||||
name: "AppwriteTests",
|
||||
dependencies: [Appwrite]),
|
||||
]
|
||||
)
|
||||
@@ -1,24 +0,0 @@
|
||||
# Appwrite Swift SDK
|
||||
|
||||

|
||||

|
||||
|
||||
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
|
||||
Use the Swift SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
|
||||
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
git clone appwrite/sdk-for-swift
|
||||
cd sdk-for-swift
|
||||
swift run
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
|
||||
@@ -1,231 +0,0 @@
|
||||
//
|
||||
// Client.swift
|
||||
//
|
||||
// Created by Armino <devel@boioiong.com>
|
||||
// GitHub: https://github.com/armino-dev/sdk-generator
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class Client {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
open var selfSigned = false
|
||||
|
||||
open var endpoint = "https://appwrite.io/v1"
|
||||
|
||||
open var headers: [String: String] = [
|
||||
"content-type": "",
|
||||
"x-sdk-version": "appwrite:swift:"
|
||||
]
|
||||
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
// default constructor
|
||||
public init() {
|
||||
|
||||
}
|
||||
|
||||
///
|
||||
/// Set Project
|
||||
///
|
||||
/// Your project ID
|
||||
///
|
||||
/// @param String value
|
||||
///
|
||||
/// @return Client
|
||||
///
|
||||
open func setProject(value: String) -> Client {
|
||||
|
||||
self.addHeader(key: "X-Appwrite-Project", value: value)
|
||||
return self
|
||||
}
|
||||
|
||||
///
|
||||
/// Set Locale
|
||||
///
|
||||
/// @param String value
|
||||
///
|
||||
/// @return Client
|
||||
///
|
||||
open func setLocale(value: String) -> Client {
|
||||
|
||||
self.addHeader(key: "X-Appwrite-Locale", value: value)
|
||||
return self
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// @param Bool status
|
||||
/// @return Client
|
||||
///
|
||||
open func setSelfSigned(status: Bool = true) -> Client {
|
||||
|
||||
self.selfSigned = status
|
||||
return self
|
||||
}
|
||||
|
||||
///
|
||||
/// @param String endpoint
|
||||
/// @return Client
|
||||
///
|
||||
open func setEndpoint(endpoint: String) -> Client {
|
||||
|
||||
self.endpoint = endpoint
|
||||
return self
|
||||
}
|
||||
|
||||
///
|
||||
/// @param String key
|
||||
/// @param String value
|
||||
///
|
||||
open func addHeader(key: String, value: String) -> Client {
|
||||
|
||||
self.headers[key.lowercased()] = value.lowercased()
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
///
|
||||
open func httpBuildQuery(params: [String: Any], prefix: String = "") -> String {
|
||||
var output: String = ""
|
||||
for (key, value) in params {
|
||||
let finalKey: String = prefix.isEmpty ? key : (prefix + "[" + key + "]")
|
||||
if (value is AnyCollection<Any>) {
|
||||
output += self.httpBuildQuery(params: value as! [String : Any], prefix: finalKey)
|
||||
} else {
|
||||
output += "\(value)"
|
||||
}
|
||||
output += "&"
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
///
|
||||
/// Make an API call
|
||||
///
|
||||
/// @param String method
|
||||
/// @param String path
|
||||
/// @param Array params
|
||||
/// @param Array headers
|
||||
/// @return Array|String
|
||||
/// @throws Exception
|
||||
///
|
||||
func call(method:String, path:String = "", headers:[String: String] = [:], params:[String: Any] = [:]) -> Any {
|
||||
|
||||
self.headers.merge(headers){(_, new) in new}
|
||||
let targetURL:URL = URL(string: self.endpoint + path + (( method == HTTPMethod.get.rawValue && !params.isEmpty ) ? "?" + httpBuildQuery(params: params) : ""))!
|
||||
|
||||
var query: String = ""
|
||||
|
||||
var responseStatus: Int = HTTPStatus.unknown.rawValue
|
||||
var responseType: String = ""
|
||||
var responseBody: Any = ""
|
||||
|
||||
switch (self.headers["content-type"]) {
|
||||
case "application/json":
|
||||
do {
|
||||
let json = try JSONSerialization.data(withJSONObject:params, options: [])
|
||||
query = String( data: json, encoding: String.Encoding.utf8)!
|
||||
} catch {
|
||||
print("Failed to parse json: \(error.localizedDescription)")
|
||||
}
|
||||
break
|
||||
default:
|
||||
query = self.httpBuildQuery(params: params)
|
||||
break
|
||||
}
|
||||
|
||||
var request = URLRequest(url: targetURL)
|
||||
let session = URLSession.shared
|
||||
|
||||
for (key, value) in self.headers {
|
||||
request.setValue(value, forHTTPHeaderField: key)
|
||||
}
|
||||
|
||||
request.httpMethod = method
|
||||
if (method.uppercased() == "POST") {
|
||||
request.httpBody = query.data(using: .utf8)
|
||||
}
|
||||
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
|
||||
session.dataTask(with: request) { data, response, error in
|
||||
if (error != nil) {
|
||||
print(error!)
|
||||
return
|
||||
}
|
||||
do {
|
||||
let httpResponse = response as! HTTPURLResponse
|
||||
responseStatus = httpResponse.statusCode
|
||||
|
||||
if (responseStatus == HTTPStatus.internalServerError.rawValue) {
|
||||
print(responseStatus)
|
||||
return
|
||||
}
|
||||
|
||||
responseType = httpResponse.mimeType ?? ""
|
||||
|
||||
if (responseType == "application/json") {
|
||||
let json = try JSONSerialization.jsonObject(with: data!, options: [])
|
||||
responseBody = json
|
||||
} else {
|
||||
responseBody = String(data: data!, encoding: String.Encoding.utf8)!
|
||||
}
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
|
||||
semaphore.signal()
|
||||
}.resume()
|
||||
|
||||
_ = semaphore.wait(wallTimeout: .distantFuture)
|
||||
|
||||
return responseBody
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Client {
|
||||
|
||||
public enum HTTPStatus: Int {
|
||||
case unknown = -1
|
||||
|
||||
case ok = 200
|
||||
case created = 201
|
||||
case accepted = 202
|
||||
|
||||
case movedPermanently = 301
|
||||
case found = 302
|
||||
|
||||
case badRequest = 400
|
||||
case notAuthorized = 401
|
||||
case paymentRequired = 402
|
||||
case forbidden = 403
|
||||
case notFound = 404
|
||||
case methodNotAllowed = 405
|
||||
case notAcceptable = 406
|
||||
|
||||
case internalServerError = 500
|
||||
case notImplemented = 501
|
||||
}
|
||||
|
||||
public enum HTTPMethod: String {
|
||||
case get
|
||||
|
||||
case post
|
||||
case put
|
||||
case patch
|
||||
|
||||
case delete
|
||||
|
||||
case head
|
||||
case options
|
||||
case connect
|
||||
case trace
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
//
|
||||
// Service.swift
|
||||
//
|
||||
// Created by Armino <devel@boioiong.com>
|
||||
// GitHub: https://github.com/armino-dev/sdk-generator
|
||||
//
|
||||
|
||||
open class Service {
|
||||
|
||||
open var client: Client;
|
||||
|
||||
public init(client: Client)
|
||||
{
|
||||
self.client = client
|
||||
}
|
||||
}
|
||||
@@ -1,491 +0,0 @@
|
||||
|
||||
|
||||
class Account: Service
|
||||
{
|
||||
/**
|
||||
* Get Account
|
||||
*
|
||||
* Get currently logged in user data as JSON object.
|
||||
*
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func get() -> Array<Any> {
|
||||
let path: String = "/account"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/client/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/client/account#createSession).
|
||||
*
|
||||
* @param String _email
|
||||
* @param String _password
|
||||
* @param String _name
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func create(_email: String, _password: String, _name: String = "") -> Array<Any> {
|
||||
let path: String = "/account"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["email"] = _email
|
||||
params["password"] = _password
|
||||
params["name"] = _name
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.post.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: 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
|
||||
*/
|
||||
|
||||
func delete() -> Array<Any> {
|
||||
let path: String = "/account"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.delete.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: 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
|
||||
*/
|
||||
|
||||
func updateEmail(_email: String, _password: String) -> Array<Any> {
|
||||
let path: String = "/account/email"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["email"] = _email
|
||||
params["password"] = _password
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.patch.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getLogs() -> Array<Any> {
|
||||
let path: String = "/account/logs"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Account Name
|
||||
*
|
||||
* Update currently logged in user account name.
|
||||
*
|
||||
* @param String _name
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func updateName(_name: String) -> Array<Any> {
|
||||
let path: String = "/account/name"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["name"] = _name
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.patch.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: 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
|
||||
*/
|
||||
|
||||
func updatePassword(_password: String, _oldPassword: String) -> Array<Any> {
|
||||
let path: String = "/account/password"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["password"] = _password
|
||||
params["oldPassword"] = _oldPassword
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.patch.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Account Preferences
|
||||
*
|
||||
* Get currently logged in user preferences as a key-value object.
|
||||
*
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getPrefs() -> Array<Any> {
|
||||
let path: String = "/account/prefs"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func updatePrefs(_prefs: object) -> Array<Any> {
|
||||
let path: String = "/account/prefs"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["prefs"] = _prefs
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.patch.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/client/account#updateRecovery)
|
||||
* endpoint to complete the process.
|
||||
*
|
||||
* @param String _email
|
||||
* @param String _url
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func createRecovery(_email: String, _url: String) -> Array<Any> {
|
||||
let path: String = "/account/recovery"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["email"] = _email
|
||||
params["url"] = _url
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.post.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/client/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 _password
|
||||
* @param String _passwordAgain
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func updateRecovery(_userId: String, _secret: String, _password: String, _passwordAgain: String) -> Array<Any> {
|
||||
let path: String = "/account/recovery"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["userId"] = _userId
|
||||
params["secret"] = _secret
|
||||
params["password"] = _password
|
||||
params["passwordAgain"] = _passwordAgain
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.put.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Account Sessions
|
||||
*
|
||||
* Get currently logged in user list of active sessions across different
|
||||
* devices.
|
||||
*
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getSessions() -> Array<Any> {
|
||||
let path: String = "/account/sessions"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func createSession(_email: String, _password: String) -> Array<Any> {
|
||||
let path: String = "/account/sessions"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["email"] = _email
|
||||
params["password"] = _password
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.post.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete All Account Sessions
|
||||
*
|
||||
* Delete all sessions from the user account and remove any sessions cookies
|
||||
* from the end client.
|
||||
*
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func deleteSessions() -> Array<Any> {
|
||||
let path: String = "/account/sessions"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.delete.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Account Session with OAuth2
|
||||
*
|
||||
* Allow the user to login to his account using the OAuth2 provider of his
|
||||
* choice. Each OAuth2 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
|
||||
* @param Array<Any> _scopes
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func createOAuth2Session(_provider: String, _success: String = "https://appwrite.io/auth/oauth2/success", _failure: String = "https://appwrite.io/auth/oauth2/failure", _scopes: Array<Any> = []) -> Array<Any> {
|
||||
var path: String = "/account/sessions/oauth2/{provider}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{provider}",
|
||||
with: _provider
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["success"] = _success
|
||||
params["failure"] = _failure
|
||||
params["scopes"] = _scopes
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func deleteSession(_sessionId: String) -> Array<Any> {
|
||||
var path: String = "/account/sessions/{sessionId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{sessionId}",
|
||||
with: _sessionId
|
||||
)
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.delete.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 provided to be attached to the verification email. The provided URL
|
||||
* should redirect the user back to 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/client/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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func createVerification(_url: String) -> Array<Any> {
|
||||
let path: String = "/account/verification"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["url"] = _url
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.post.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func updateVerification(_userId: String, _secret: String) -> Array<Any> {
|
||||
let path: String = "/account/verification"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["userId"] = _userId
|
||||
params["secret"] = _secret
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.put.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,233 +0,0 @@
|
||||
|
||||
|
||||
class Avatars: Service
|
||||
{
|
||||
/**
|
||||
* 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 Int _width
|
||||
* @param Int _height
|
||||
* @param Int _quality
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getBrowser(_code: String, _width: Int = 100, _height: Int = 100, _quality: Int = 100) -> Array<Any> {
|
||||
var path: String = "/avatars/browsers/{code}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{code}",
|
||||
with: _code
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["width"] = _width
|
||||
params["height"] = _height
|
||||
params["quality"] = _quality
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Int _width
|
||||
* @param Int _height
|
||||
* @param Int _quality
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getCreditCard(_code: String, _width: Int = 100, _height: Int = 100, _quality: Int = 100) -> Array<Any> {
|
||||
var path: String = "/avatars/credit-cards/{code}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{code}",
|
||||
with: _code
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["width"] = _width
|
||||
params["height"] = _height
|
||||
params["quality"] = _quality
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Favicon
|
||||
*
|
||||
* Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
|
||||
* website URL.
|
||||
*
|
||||
* @param String _url
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getFavicon(_url: String) -> Array<Any> {
|
||||
let path: String = "/avatars/favicon"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["url"] = _url
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Int _width
|
||||
* @param Int _height
|
||||
* @param Int _quality
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getFlag(_code: String, _width: Int = 100, _height: Int = 100, _quality: Int = 100) -> Array<Any> {
|
||||
var path: String = "/avatars/flags/{code}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{code}",
|
||||
with: _code
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["width"] = _width
|
||||
params["height"] = _height
|
||||
params["quality"] = _quality
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Int _width
|
||||
* @param Int _height
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getImage(_url: String, _width: Int = 400, _height: Int = 400) -> Array<Any> {
|
||||
let path: String = "/avatars/image"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["url"] = _url
|
||||
params["width"] = _width
|
||||
params["height"] = _height
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User Initials
|
||||
*
|
||||
* Use this endpoint to show your user initials avatar icon on your website or
|
||||
* app. By default, this route will try to print your logged-in user name or
|
||||
* email initials. You can also overwrite the user name if you pass the 'name'
|
||||
* parameter. If no name is given and no user is logged, an empty avatar will
|
||||
* be returned.
|
||||
*
|
||||
* You can use the color and background params to change the avatar colors. By
|
||||
* default, a random theme will be selected. The random theme will persist for
|
||||
* the user's initials when reloading the same theme will always return for
|
||||
* the same initials.
|
||||
*
|
||||
* @param String _name
|
||||
* @param Int _width
|
||||
* @param Int _height
|
||||
* @param String _color
|
||||
* @param String _background
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getInitials(_name: String = "", _width: Int = 500, _height: Int = 500, _color: String = "", _background: String = "") -> Array<Any> {
|
||||
let path: String = "/avatars/initials"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["name"] = _name
|
||||
params["width"] = _width
|
||||
params["height"] = _height
|
||||
params["color"] = _color
|
||||
params["background"] = _background
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Int _size
|
||||
* @param Int _margin
|
||||
* @param Bool _download
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getQR(_text: String, _size: Int = 400, _margin: Int = 1, _download: Bool = false) -> Array<Any> {
|
||||
let path: String = "/avatars/qr"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["text"] = _text
|
||||
params["size"] = _size
|
||||
params["margin"] = _margin
|
||||
params["download"] = _download
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
|
||||
|
||||
class Database: Service
|
||||
{
|
||||
/**
|
||||
* 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<Any> _filters
|
||||
* @param Int _limit
|
||||
* @param Int _offset
|
||||
* @param String _orderField
|
||||
* @param String _orderType
|
||||
* @param String _orderCast
|
||||
* @param String _search
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func listDocuments(_collectionId: String, _filters: Array<Any> = [], _limit: Int = 25, _offset: Int = 0, _orderField: String = "$id", _orderType: String = "ASC", _orderCast: String = "string", _search: String = "") -> Array<Any> {
|
||||
var path: String = "/database/collections/{collectionId}/documents"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{collectionId}",
|
||||
with: _collectionId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["filters"] = _filters
|
||||
params["limit"] = _limit
|
||||
params["offset"] = _offset
|
||||
params["orderField"] = _orderField
|
||||
params["orderType"] = _orderType
|
||||
params["orderCast"] = _orderCast
|
||||
params["search"] = _search
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Document
|
||||
*
|
||||
* Create a new Document. Before using this route, you should create a new
|
||||
* collection resource using either a [server
|
||||
* integration](/docs/server/database?sdk=nodejs#createCollection) API or
|
||||
* directly from your database console.
|
||||
*
|
||||
* @param String _collectionId
|
||||
* @param object _data
|
||||
* @param Array<Any> _read
|
||||
* @param Array<Any> _write
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func createDocument(_collectionId: String, _data: object, _read: Array<Any>, _write: Array<Any>) -> Array<Any> {
|
||||
var path: String = "/database/collections/{collectionId}/documents"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{collectionId}",
|
||||
with: _collectionId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["data"] = _data
|
||||
params["read"] = _read
|
||||
params["write"] = _write
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.post.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getDocument(_collectionId: String, _documentId: String) -> Array<Any> {
|
||||
var path: String = "/database/collections/{collectionId}/documents/{documentId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{collectionId}",
|
||||
with: _collectionId
|
||||
)
|
||||
path = path.replacingOccurrences(
|
||||
of: "{documentId}",
|
||||
with: _documentId
|
||||
)
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Document
|
||||
*
|
||||
* @param String _collectionId
|
||||
* @param String _documentId
|
||||
* @param object _data
|
||||
* @param Array<Any> _read
|
||||
* @param Array<Any> _write
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func updateDocument(_collectionId: String, _documentId: String, _data: object, _read: Array<Any>, _write: Array<Any>) -> Array<Any> {
|
||||
var path: String = "/database/collections/{collectionId}/documents/{documentId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{collectionId}",
|
||||
with: _collectionId
|
||||
)
|
||||
path = path.replacingOccurrences(
|
||||
of: "{documentId}",
|
||||
with: _documentId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["data"] = _data
|
||||
params["read"] = _read
|
||||
params["write"] = _write
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.patch.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func deleteDocument(_collectionId: String, _documentId: String) -> Array<Any> {
|
||||
var path: String = "/database/collections/{collectionId}/documents/{documentId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{collectionId}",
|
||||
with: _collectionId
|
||||
)
|
||||
path = path.replacingOccurrences(
|
||||
of: "{documentId}",
|
||||
with: _documentId
|
||||
)
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.delete.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
|
||||
|
||||
class Locale: Service
|
||||
{
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func get() -> Array<Any> {
|
||||
let path: String = "/locale"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* List Continents
|
||||
*
|
||||
* List of all continents. You can use the locale header to get the data in a
|
||||
* supported language.
|
||||
*
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getContinents() -> Array<Any> {
|
||||
let path: String = "/locale/continents"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* List Countries
|
||||
*
|
||||
* List of all countries. You can use the locale header to get the data in a
|
||||
* supported language.
|
||||
*
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getCountries() -> Array<Any> {
|
||||
let path: String = "/locale/countries"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getCountriesEU() -> Array<Any> {
|
||||
let path: String = "/locale/countries/eu"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getCountriesPhones() -> Array<Any> {
|
||||
let path: String = "/locale/countries/phones"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* List Currencies
|
||||
*
|
||||
* List of all currencies, including currency symbol, 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getCurrencies() -> Array<Any> {
|
||||
let path: String = "/locale/currencies"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* List Languages
|
||||
*
|
||||
* List of all languages classified by ISO 639-1 including 2-letter code, name
|
||||
* in English, and name in the respective language.
|
||||
*
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getLanguages() -> Array<Any> {
|
||||
let path: String = "/locale/languages"
|
||||
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
|
||||
|
||||
class Storage: Service
|
||||
{
|
||||
/**
|
||||
* 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 Int _limit
|
||||
* @param Int _offset
|
||||
* @param String _orderType
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func listFiles(_search: String = "", _limit: Int = 25, _offset: Int = 0, _orderType: String = "ASC") -> Array<Any> {
|
||||
let path: String = "/storage/files"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["search"] = _search
|
||||
params["limit"] = _limit
|
||||
params["offset"] = _offset
|
||||
params["orderType"] = _orderType
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Array<Any> _file
|
||||
* @param Array<Any> _read
|
||||
* @param Array<Any> _write
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func createFile(_file: Array<Any>, _read: Array<Any>, _write: Array<Any>) -> Array<Any> {
|
||||
let path: String = "/storage/files"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["file"] = _file
|
||||
params["read"] = _read
|
||||
params["write"] = _write
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.post.rawValue, path: path, headers: [
|
||||
"content-type": "multipart/form-data",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get File
|
||||
*
|
||||
* Get file by its unique ID. This endpoint response returns a JSON object
|
||||
* with the file metadata.
|
||||
*
|
||||
* @param String _fileId
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getFile(_fileId: String) -> Array<Any> {
|
||||
var path: String = "/storage/files/{fileId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{fileId}",
|
||||
with: _fileId
|
||||
)
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update File
|
||||
*
|
||||
* Update file by its unique ID. Only users with write permissions have access
|
||||
* to update this resource.
|
||||
*
|
||||
* @param String _fileId
|
||||
* @param Array<Any> _read
|
||||
* @param Array<Any> _write
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func updateFile(_fileId: String, _read: Array<Any>, _write: Array<Any>) -> Array<Any> {
|
||||
var path: String = "/storage/files/{fileId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{fileId}",
|
||||
with: _fileId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["read"] = _read
|
||||
params["write"] = _write
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.put.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete File
|
||||
*
|
||||
* Delete a file by its unique ID. Only users with write permissions have
|
||||
* access to delete this resource.
|
||||
*
|
||||
* @param String _fileId
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func deleteFile(_fileId: String) -> Array<Any> {
|
||||
var path: String = "/storage/files/{fileId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{fileId}",
|
||||
with: _fileId
|
||||
)
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.delete.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getFileDownload(_fileId: String) -> Array<Any> {
|
||||
var path: String = "/storage/files/{fileId}/download"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{fileId}",
|
||||
with: _fileId
|
||||
)
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Int _width
|
||||
* @param Int _height
|
||||
* @param Int _quality
|
||||
* @param String _background
|
||||
* @param String _output
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getFilePreview(_fileId: String, _width: Int = 0, _height: Int = 0, _quality: Int = 100, _background: String = "", _output: String = "") -> Array<Any> {
|
||||
var path: String = "/storage/files/{fileId}/preview"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{fileId}",
|
||||
with: _fileId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["width"] = _width
|
||||
params["height"] = _height
|
||||
params["quality"] = _quality
|
||||
params["background"] = _background
|
||||
params["output"] = _output
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getFileView(_fileId: String, _as: String = "") -> Array<Any> {
|
||||
var path: String = "/storage/files/{fileId}/view"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{fileId}",
|
||||
with: _fileId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["as"] = _as
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,298 +0,0 @@
|
||||
|
||||
|
||||
class Teams: Service
|
||||
{
|
||||
/**
|
||||
* 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 Int _limit
|
||||
* @param Int _offset
|
||||
* @param String _orderType
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func list(_search: String = "", _limit: Int = 25, _offset: Int = 0, _orderType: String = "ASC") -> Array<Any> {
|
||||
let path: String = "/teams"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["search"] = _search
|
||||
params["limit"] = _limit
|
||||
params["offset"] = _offset
|
||||
params["orderType"] = _orderType
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<Any> _roles
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func create(_name: String, _roles: Array<Any> = ["owner"]) -> Array<Any> {
|
||||
let path: String = "/teams"
|
||||
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["name"] = _name
|
||||
params["roles"] = _roles
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.post.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Team
|
||||
*
|
||||
* Get team by its unique ID. All team members have read access for this
|
||||
* resource.
|
||||
*
|
||||
* @param String _teamId
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func get(_teamId: String) -> Array<Any> {
|
||||
var path: String = "/teams/{teamId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{teamId}",
|
||||
with: _teamId
|
||||
)
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Team
|
||||
*
|
||||
* Update team by its unique ID. Only team owners have write access for this
|
||||
* resource.
|
||||
*
|
||||
* @param String _teamId
|
||||
* @param String _name
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func update(_teamId: String, _name: String) -> Array<Any> {
|
||||
var path: String = "/teams/{teamId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{teamId}",
|
||||
with: _teamId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["name"] = _name
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.put.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Team
|
||||
*
|
||||
* Delete team by its unique ID. Only team owners have write access for this
|
||||
* resource.
|
||||
*
|
||||
* @param String _teamId
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func delete(_teamId: String) -> Array<Any> {
|
||||
var path: String = "/teams/{teamId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{teamId}",
|
||||
with: _teamId
|
||||
)
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.delete.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param String _search
|
||||
* @param Int _limit
|
||||
* @param Int _offset
|
||||
* @param String _orderType
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func getMemberships(_teamId: String, _search: String = "", _limit: Int = 25, _offset: Int = 0, _orderType: String = "ASC") -> Array<Any> {
|
||||
var path: String = "/teams/{teamId}/memberships"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{teamId}",
|
||||
with: _teamId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["search"] = _search
|
||||
params["limit"] = _limit
|
||||
params["offset"] = _offset
|
||||
params["orderType"] = _orderType
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.get.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/client/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<Any> _roles
|
||||
* @param String _url
|
||||
* @param String _name
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func createMembership(_teamId: String, _email: String, _roles: Array<Any>, _url: String, _name: String = "") -> Array<Any> {
|
||||
var path: String = "/teams/{teamId}/memberships"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{teamId}",
|
||||
with: _teamId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["email"] = _email
|
||||
params["name"] = _name
|
||||
params["roles"] = _roles
|
||||
params["url"] = _url
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.post.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func deleteMembership(_teamId: String, _inviteId: String) -> Array<Any> {
|
||||
var path: String = "/teams/{teamId}/memberships/{inviteId}"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{teamId}",
|
||||
with: _teamId
|
||||
)
|
||||
path = path.replacingOccurrences(
|
||||
of: "{inviteId}",
|
||||
with: _inviteId
|
||||
)
|
||||
|
||||
let params: [String: Any] = [:]
|
||||
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.delete.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Exception
|
||||
* @return array
|
||||
*/
|
||||
|
||||
func updateMembershipStatus(_teamId: String, _inviteId: String, _userId: String, _secret: String) -> Array<Any> {
|
||||
var path: String = "/teams/{teamId}/memberships/{inviteId}/status"
|
||||
|
||||
path = path.replacingOccurrences(
|
||||
of: "{teamId}",
|
||||
with: _teamId
|
||||
)
|
||||
path = path.replacingOccurrences(
|
||||
of: "{inviteId}",
|
||||
with: _inviteId
|
||||
)
|
||||
|
||||
var params: [String: Any] = [:]
|
||||
|
||||
params["userId"] = _userId
|
||||
params["secret"] = _secret
|
||||
|
||||
return [self.client.call(method: Client.HTTPMethod.patch.rawValue, path: path, headers: [
|
||||
"content-type": "application/json",
|
||||
], params: params)];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,240 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
# Account Service
|
||||
|
||||
## Get Account
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/account
|
||||
```
|
||||
|
||||
** Get currently logged in user data as JSON object. **
|
||||
|
||||
## Create Account
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/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/client/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/client/account#createSession). **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| email | string | User email. | |
|
||||
| password | string | User password. Must be between 6 to 32 chars. | |
|
||||
| name | string | User name. | |
|
||||
|
||||
## 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 | User email. | |
|
||||
| password | string | User password. Must be between 6 to 32 chars. | |
|
||||
|
||||
## Get Account Logs
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/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. **
|
||||
|
||||
## 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 user password. Must be between 6 to 32 chars. | |
|
||||
| oldPassword | string | Old user password. Must be between 6 to 32 chars. | |
|
||||
|
||||
## Get Account Preferences
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/account/prefs
|
||||
```
|
||||
|
||||
** Get currently logged in user preferences as a key-value object. **
|
||||
|
||||
## Update Account Preferences
|
||||
|
||||
```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 | object | Prefs key-value JSON object. | |
|
||||
|
||||
## Create Password Recovery
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/account/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/client/account#updateRecovery) endpoint to complete the process. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| email | string | User email. | |
|
||||
| url | string | URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | |
|
||||
|
||||
## Complete Password Recovery
|
||||
|
||||
```http request
|
||||
PUT https://appwrite.io/v1/account/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/client/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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| userId | string | User account UID address. | |
|
||||
| secret | string | Valid reset token. | |
|
||||
| password | string | New password. Must be between 6 to 32 chars. | |
|
||||
| passwordAgain | string | New password again. Must be between 6 to 32 chars. | |
|
||||
|
||||
## Get Account Sessions
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/account/sessions
|
||||
```
|
||||
|
||||
** Get currently logged in user list of active sessions across different devices. **
|
||||
|
||||
## Create Account Session
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/account/sessions
|
||||
```
|
||||
|
||||
** 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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| email | string | User email. | |
|
||||
| password | string | User password. Must be between 6 to 32 chars. | |
|
||||
|
||||
## Delete All Account Sessions
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/account/sessions
|
||||
```
|
||||
|
||||
** Delete all sessions from the user account and remove any sessions cookies from the end client. **
|
||||
|
||||
## Create Account Session with OAuth2
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/account/sessions/oauth2/{provider}
|
||||
```
|
||||
|
||||
** Allow the user to login to his account using the OAuth2 provider of his choice. Each OAuth2 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** OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, twitch, vk, yahoo, yandex. | |
|
||||
| success | string | URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | https://appwrite.io/auth/oauth2/success |
|
||||
| failure | string | URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | https://appwrite.io/auth/oauth2/failure |
|
||||
| scopes | array | A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. | [] |
|
||||
|
||||
## Delete Account Session
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/account/sessions/{sessionId}
|
||||
```
|
||||
|
||||
** 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 |
|
||||
| --- | --- | --- | --- |
|
||||
| sessionId | string | **Required** Session unique ID. Use the string 'current' to delete the current device session. | |
|
||||
|
||||
## Create Email Verification
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/account/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 provided to be attached to the verification email. The provided URL should redirect the user back to 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/client/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.
|
||||
**
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| url | string | URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | |
|
||||
|
||||
## Complete Email Verification
|
||||
|
||||
```http request
|
||||
PUT https://appwrite.io/v1/account/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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| userId | string | User unique ID. | |
|
||||
| secret | string | Valid verification token. | |
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
# Avatars Service
|
||||
|
||||
## Get Browser Icon
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/browsers/{code}
|
||||
```
|
||||
|
||||
** 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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| 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 |
|
||||
|
||||
## Get Credit Card Icon
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/credit-cards/{code}
|
||||
```
|
||||
|
||||
** 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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| 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 |
|
||||
|
||||
## Get Favicon
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/favicon
|
||||
```
|
||||
|
||||
** Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote website URL. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| url | string | **Required** Website URL which you want to fetch the favicon from. | |
|
||||
|
||||
## Get Country Flag
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/flags/{code}
|
||||
```
|
||||
|
||||
** 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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| 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 |
|
||||
|
||||
## Get Image from URL
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/image
|
||||
```
|
||||
|
||||
** 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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| 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 2000. | 400 |
|
||||
| height | integer | Resize preview image height, Pass an integer between 0 to 2000. | 400 |
|
||||
|
||||
## Get User Initials
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/initials
|
||||
```
|
||||
|
||||
** Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned.
|
||||
|
||||
You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| name | string | Full Name. When empty, current user name or email will be used. | |
|
||||
| width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100. | 500 |
|
||||
| height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100. | 500 |
|
||||
| color | string | Changes text color. By default a random color will be picked and stay will persistent to the given name. | |
|
||||
| background | string | Changes background color. By default a random color will be picked and stay will persistent to the given name. | |
|
||||
|
||||
## Get QR Code
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/qr
|
||||
```
|
||||
|
||||
** 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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| 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 | boolean | 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. | |
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
# Database Service
|
||||
|
||||
## List Documents
|
||||
|
||||
```http request
|
||||
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). **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#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.$id>=5bed2d152c362'. | [] |
|
||||
| limit | integer | Maximum number of documents to return in response. Use this value to manage pagination. | 25 |
|
||||
| offset | integer | Offset value. Use this value to manage pagination. | 0 |
|
||||
| orderField | string | Document field that results will be sorted by. | $id |
|
||||
| orderType | string | Order direction. Possible values are DESC for descending order, or ASC for ascending order. | ASC |
|
||||
| orderCast | string | 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. | string |
|
||||
| search | string | Search query. Enter any free text search. The database will try to find a match against all document attributes and children. | |
|
||||
|
||||
## Create Document
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/database/collections/{collectionId}/documents
|
||||
```
|
||||
|
||||
** Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](/docs/server/database?sdk=nodejs#createCollection) API or directly from your database console. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). | |
|
||||
| data | object | Document data as JSON object. | |
|
||||
| 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. | |
|
||||
|
||||
## Get Document
|
||||
|
||||
```http request
|
||||
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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). | |
|
||||
| documentId | string | **Required** Document unique ID. | |
|
||||
|
||||
## Update Document
|
||||
|
||||
```http request
|
||||
PATCH https://appwrite.io/v1/database/collections/{collectionId}/documents/{documentId}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). | |
|
||||
| documentId | string | **Required** Document unique ID. | |
|
||||
| data | object | Document data as JSON object. | |
|
||||
| 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/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. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). | |
|
||||
| documentId | string | **Required** Document unique ID. | |
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
|
||||
var client: Client = Client()
|
||||
|
||||
client
|
||||
.setEndpoint(endpoint: "https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
|
||||
.setProject(value: "5df5acd0d48c2") // Your project ID
|
||||
|
||||
var account: Account = Account(client: client);
|
||||
|
||||
var result = account.createOAuth2Session(_provider: "amazon");
|
||||
@@ -1,14 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
|
||||
var client: Client = Client()
|
||||
|
||||
client
|
||||
.setEndpoint(endpoint: "https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
|
||||
.setProject(value: "5df5acd0d48c2") // Your project ID
|
||||
|
||||
var account: Account = Account(client: client);
|
||||
|
||||
var result = account.createRecovery(_email: "email@example.com", _url: "https://example.com");
|
||||
@@ -1,14 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
|
||||
var client: Client = Client()
|
||||
|
||||
client
|
||||
.setEndpoint(endpoint: "https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
|
||||
.setProject(value: "5df5acd0d48c2") // Your project ID
|
||||
|
||||
var account: Account = Account(client: client);
|
||||
|
||||
var result = account.createSession(_email: "email@example.com", _password: "password");
|
||||
@@ -1,14 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
|
||||
var client: Client = Client()
|
||||
|
||||
client
|
||||
.setEndpoint(endpoint: "https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
|
||||
.setProject(value: "5df5acd0d48c2") // Your project ID
|
||||
|
||||
var account: Account = Account(client: client);
|
||||
|
||||
var result = account.createVerification(_url: "https://example.com");
|
||||
@@ -1,14 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
|
||||
var client: Client = Client()
|
||||
|
||||
client
|
||||
.setEndpoint(endpoint: "https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
|
||||
.setProject(value: "5df5acd0d48c2") // Your project ID
|
||||
|
||||
var account: Account = Account(client: client);
|
||||
|
||||
var result = account.create(_email: "email@example.com", _password: "password");
|
||||
@@ -1,14 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
|
||||
var client: Client = Client()
|
||||
|
||||
client
|
||||
.setEndpoint(endpoint: "https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
|
||||
.setProject(value: "5df5acd0d48c2") // Your project ID
|
||||
|
||||
var account: Account = Account(client: client);
|
||||
|
||||
var result = account.deleteSession(_sessionId: "[SESSION_ID]");
|
||||
@@ -1,14 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
|
||||
var client: Client = Client()
|
||||
|
||||
client
|
||||
.setEndpoint(endpoint: "https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
|
||||
.setProject(value: "5df5acd0d48c2") // Your project ID
|
||||
|
||||
var account: Account = Account(client: client);
|
||||
|
||||
var result = account.deleteSessions();
|
||||
@@ -1,14 +0,0 @@
|
||||
/// Swift Appwrite SDK
|
||||
/// Produced by Appwrite SDK Generator
|
||||
///
|
||||
|
||||
|
||||
var client: Client = Client()
|
||||
|
||||
client
|
||||
.setEndpoint(endpoint: "https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
|
||||
.setProject(value: "5df5acd0d48c2") // Your project ID
|
||||
|
||||
var account: Account = Account(client: client);
|
||||
|
||||
var result = account.delete();
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user