diff --git a/.dockerignore b/.dockerignore index 7fff0265d6..b92827b7c8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,4 +6,5 @@ public/styles .git .idea .cd .babelrc -.DS_Store \ No newline at end of file +.DS_Store +debug \ No newline at end of file diff --git a/.env b/.env new file mode 100644 index 0000000000..581af6d978 --- /dev/null +++ b/.env @@ -0,0 +1,41 @@ +_APP_ENV=production +_APP_ENV=development +_APP_SYSTEM_EMAIL_NAME=Appwrite +_APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io +_APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io +_APP_SYSTEM_RESPONSE_FORMAT= +_APP_OPTIONS_ABUSE=disabled +_APP_OPTIONS_FORCE_HTTPS=disabled +_APP_OPENSSL_KEY_V1=your-secret-key +_APP_DOMAIN=demo.appwrite.io +_APP_DOMAIN_TARGET=demo.appwrite.io +_APP_REDIS_HOST=redis +_APP_REDIS_PORT=6379 +_APP_DB_HOST=mariadb +_APP_DB_PORT=3306 +_APP_DB_SCHEMA=appwrite +_APP_DB_USER=user +_APP_DB_PASS=password +_APP_STORAGE_ANTIVIRUS=enabled +_APP_STORAGE_ANTIVIRUS_HOST=clamav +_APP_STORAGE_ANTIVIRUS_PORT=3310 +_APP_INFLUXDB_HOST=influxdb +_APP_INFLUXDB_PORT=8086 +_APP_STATSD_HOST=telegraf +_APP_STATSD_PORT=8125 +_APP_SMTP_HOST=maildev +_APP_SMTP_PORT=25 +_APP_SMTP_SECURE= +_APP_SMTP_USERNAME= +_APP_SMTP_PASSWORD= +_APP_STORAGE_LIMIT=10000000 +_APP_FUNCTIONS_TIMEOUT=900 +_APP_FUNCTIONS_CONTAINERS=10 +_APP_FUNCTIONS_CPUS=1 +_APP_FUNCTIONS_MEMORY=256 +_APP_FUNCTIONS_MEMORY_SWAP=256 +_APP_MAINTENANCE_INTERVAL=86400 +_APP_MAINTENANCE_RETENTION_EXECUTION=1209600 +_APP_MAINTENANCE_RETENTION_ABUSE=86400 +_APP_MAINTENANCE_RETENTION_AUDIT=1209600 +_APP_USAGE_STATS=enabled diff --git a/.gitignore b/.gitignore index fa6a24789b..224a970df4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,8 @@ /.vscode/ /vendor/ /node_modules/ -/storage/uploads/ -/storage/cache -/storage/db -/storage/influxdb /tests/resources/storage/ /.idea/ .DS_Store .php_cs.cache -.env \ No newline at end of file +debug/ \ No newline at end of file diff --git a/build.sh b/.travis-ci/build.sh similarity index 100% rename from build.sh rename to .travis-ci/build.sh diff --git a/.travis-ci/deploy.sh b/.travis-ci/deploy.sh new file mode 100644 index 0000000000..b4c132022a --- /dev/null +++ b/.travis-ci/deploy.sh @@ -0,0 +1 @@ +echo 'Nothing to deploy right now.' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index a6fbe5944e..92baeb0fb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ -language: php +dist: xenial -php: - - '7.4' +arch: + - amd64 -addons: - hosts: - - appwrite.test +os: linux + +language: shell notifications: email: @@ -14,20 +14,36 @@ notifications: services: - docker -# cache: -# directories: -# - docker_images - -# before_install: -# - docker load -i docker_images/images.tar || true - -# before_cache: -# - docker save -o docker_images/images.tar appwrite_appwrite +before_install: +- curl -fsSL https://get.docker.com | sh +- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json +- mkdir -p $HOME/.docker +- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json +- sudo service docker start +- > + if [ ! -z "${DOCKERHUB_PULL_USERNAME:-}" ]; then + echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin + fi +- docker --version +- docker buildx create --use +- chmod -R u+x ./.travis-ci install: - docker-compose up -d -- sleep 90 +- sleep 10 script: - docker ps -- docker exec appwrite test +- docker-compose logs appwrite +- docker-compose logs appwrite-worker-functions +- docker-compose exec appwrite doctor +- docker-compose exec appwrite vars +- docker-compose exec appwrite test + +deploy: + - provider: script + edge: true + script: ./.travis-ci/deploy.sh + on: + repo: appwrite/appwrite + branch: deploy diff --git a/CHANGES.md b/CHANGES.md index 2dc3db25a3..ceae7aef56 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,26 +2,97 @@ ## Features -- New route in Locale API to fetch a list of languages (@TorstenDittmann) -- Added Google Fonts to Appwrite for offline availability -- Added a new route in the Avatars API to get user initials avatar -- Added option to delete team from the console -- Added option to view team members from the console -- Added option to join a user to any team from the console -- Added support for Brotli compression (@PedroCisnerosSantana, @Rohitub222) -- New UI micro-interactions and CSS fixes (@AnatoleLucet) -- UI performance & accessibility improvements (#406) +- Improved Webhooks and added new system events - [Learn more]() +- Added response to /locale/languages API with a list of languages (@TorstenDittmann ,[#351](https://github.com/appwrite/appwrite/issues/351)) +- Added a new route in the Avatars API to get user initials avatar ([#386](https://github.com/appwrite/appwrite/issues/386)) +- Added API response payload structure info and examples to the docs site ([#381](https://github.com/appwrite/appwrite/issues/381)) +- Added support for Brotli compression (@PedroCisnerosSantana, @Rohitub222, [#310](https://github.com/appwrite/appwrite/issues/310)) +- New deletion worker ([#521](https://github.com/appwrite/appwrite/issues/521)) +- New maintenance worker - cleaning up system logs and other optimizations ([#766](https://github.com/appwrite/appwrite/pull/766)) +- New email worker - all emails are now sent asynchronously for improved performance (@TorstenDittmann ,[#402](https://github.com/appwrite/appwrite/pull/402)) +- Moved all Appwrite container logs to STDOUT & STDERR ([#389](https://github.com/appwrite/appwrite/issues/389)) - 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 - Added support for boolean 'true' and 'false' in query strings alongside 1 and 0 +- Updated storage calculation to match IEC standards +- Now using Alpine as base Docker image +- Switch standard dev 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, documentation added +- 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) ** + - Removed type attribute from session object response (used only internally) + - ** - might be changed before merging to master + - Added fallback option to 0.6 format for backward compatibility with any changes (@christyjacob4 [#772](https://github.com/appwrite/appwrite/pull/772)) +- Added option to disable mail sending by setting an empty SMTP host value ([#730](https://github.com/appwrite/appwrite/issues/730)) +- Upgraded installation script ([#490](https://github.com/appwrite/appwrite/issues/490)) +- Added new environment variables for ClamAV hostname and port ([#780](https://github.com/appwrite/appwrite/pull/780)) +- New OAuth adapter for Box.com (@armino-dev - [#420](https://github.com/appwrite/appwrite/issues/410)) +- New OAuth adapter for PayPal sandbox (@armino-dev - [#420](https://github.com/appwrite/appwrite/issues/410)) +- New OAuth adapter for Tradeshift (@armino-dev - [#855](https://github.com/appwrite/appwrite/pull/855)) +- New OAuth adapter for Tradeshift sandbox (@armino-dev - [#855](https://github.com/appwrite/appwrite/pull/855)) +- Introducing new permssion types: role:guest & role:member +- Disabled rate-limits on server side integrations +- Refactored migration script + +### User Interface + +- Updated grid for OAuth2 providers list in the console ([#413](https://github.com/appwrite/appwrite/issues/413)) +- Added Google Fonts to Appwrite for offline availability +- Added option to delete user from the console (@PineappleIOnic - [#538](https://github.com/appwrite/appwrite/issues/538)) +- Added option to delete team from the console ([#380](https://github.com/appwrite/appwrite/issues/380)) +- 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 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)) +- Added pagination for projects list on the console home page. +- UI performance & accessibility improvements ([#406](https://github.com/appwrite/appwrite/pull/406)) +- New UI micro-interactions and CSS fixes (@AnatoleLucet) +- Added toggle to hide/show secret keys and passwords inside the dashboard (@kodumbeats, [#535](https://github.com/appwrite/appwrite/issues/535)) + +### Upgrades + +- Upgraded QR codes generator library (@PedroCisnerosSantana - [#475](https://github.com/appwrite/appwrite/issues/475)) +- Upgraded Traefik image to version 2.3 +- Upgraded MariaDB to version 10.5.5 +- Upgraded Redis Docker image to version 6.0 (alpine) +- Upgraded Influxdb Docker image to version 1.8 (alpine) +- Upgraded Redis Resque queue library to version 1.3.6 ([#319](https://github.com/appwrite/appwrite/issues/319)) +- Upgraded ClamAV container image to version 1.0.11 ([#412](https://github.com/appwrite/appwrite/issues/412)) +- Upgraded device detctor to version 3.12.6 +- Upgraded GEOIP DB file to Feb 2021 release + +## Breaking Changes (Read before upgrading!) + +- **Deprecated** `first` and `last` query params for documents list route in the database API +- **Deprecated** Deprectaed Pubjabi Translations ('pn') +- **Deprecated** `PATCH /account/prefs` is now updating the prefs payload and not just merging it +- **Deprecated** `PATCH /users/:userId/prefs` is now updating the prefs payload and not just merging it +- Switched order of limit and offset params in all the SDKs `listDocuments` method for better consistency +- Default `limit` param value in all the SDKs `listDocuments` method is now 25 for better consistency ## 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)) +- Fixed redirect to Appwrite login page when deep link is provided ([#427](https://github.com/appwrite/appwrite/issues/427)) +- Fixed an issue where Creating documents fails for parent documents would result in an error ([#514](https://github.com/appwrite/appwrite/issues/514)) +- Fixed an issue with Email Sending Problem using external smtp ([#707](https://github.com/appwrite/appwrite/issues/707)) +- Fixed an issue where you could not remove a key from User Prefs ([#316](https://github.com/appwrite/appwrite/issues/316)) +- Fixed an issue where events are not fully visible in the console ([#492](https://github.com/appwrite/appwrite/issues/492)) +- Fixed an issue where UI would wrongly validate integers ([#394](https://github.com/appwrite/appwrite/issues/394)) +- Fixed an issue where graphs were cut in mobile view ([#376](https://github.com/appwrite/appwrite/issues/376)) +- Fixed URL issue where console/ would not display list of projects ([#372](https://github.com/appwrite/appwrite/issues/372)) - Fixed output of /v1/health/queue/certificates returning wrong data - Fixed bug where team members count was wrong in some cases - Fixed network calculation for uploaded files @@ -37,19 +108,18 @@ - Fixed Bug when trying to overwrite OAuth cookie in the Flutter SDK - Fixed OAuth redirect when using the self-hosted instance default success URL ([#454](https://github.com/appwrite/appwrite/issues/454)) - Fixed bug denying authentication with Github OAuth provider -- New OAuth adapter for Box.com -- New OAuth adapter for PayPal sandbox - Fixed a bug making read permission overwrite write permission in some cases - -## Breaking Changes -- **Deprecated** `first` and `last` query params for documents list route in the database API -- **Deprecated** Deprecated Punjabi Translations ('pn') +- Fixed consistent property names in databases by enforcing camel case ## Security - Access to Health API now requires authentication with an API Key with access to `health.read` scope allowed - Added option to force HTTPS connection to the Appwrite server (_APP_OPTIONS_FORCE_HTTPS) - Now using your `_APP_SYSTEM_EMAIL_ADDRESS` as the email address for issuing and renewing SSL certificates +- Block iframe access to Appwrite console using the `X-Frame-Options` header. +- Fixed `roles` param input validator +- API Keys are now stored encrypted +- Disabled domains whitlist ACL for the Appwrite console # Version 0.6.2 (PRE-RELEASE) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 66bfca13bb..ff4564d29c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,7 +72,23 @@ cd appwrite docker-compose up -d ``` -After finishing the installation process, you can start writing and editing code. To compile new CSS and JS distribution files, use 'less' and 'build' tasks using gulp as a task manager. +### Code Autocompletion + +To get proper autocompletion for all the different functions and classes in the codebase, you'll need to install Appwrite dependencies on your local machine. You can easily do that with PHP's package manager, [Composer](https://getcomposer.org/). If you don't have Composer installed, you can use the Docker Hub image to get the same result: + +```bash +docker run --rm --interactive --tty \ + --volume $PWD:/app \ + composer install +``` + +### User Interface + +Appwrite uses an internal micro-framework called Litespeed.js to build simple UI components in vanilla JS and [less](http://lesscss.org/) for compiling CSS code. To apply any of your changes to the UI, use the `gulp build` or `gulp less` commands, and restart the Appwrite main container to load the new static files to memory using `docker-compose restart appwrite`. + +### Get Started + +After finishing the installation process, you can start writing and editing code. ## Architecture @@ -145,6 +161,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. @@ -198,8 +218,6 @@ When contributing code, please take into account the following considerations: Security and privacy are extremely important to Appwrite, developers, and users alike. Make sure to follow the best industry standards and practices. - - ## Dependencies Please avoid introducing new dependencies to Appwrite without consulting the team. New dependencies can be very helpful but also introduce new security and privacy issues, complexity, and impact total docker image size. @@ -214,32 +232,77 @@ For us to find the right balance, please open an issue explaining your ideas bef This will allow the Appwrite community to have sufficient discussion about the new feature value and how it fits in the product roadmap and vision. -This is also important for the Appwrite lead developers to be able to give technical input and different emphasis regarding the feature design and architecture. +This is also important for the Appwrite lead developers to be able to give technical input and different emphasis regarding the feature design and architecture. Some bigger features might need to go through our [RFC process](https://github.com/appwrite/rfc). ## Build To build a new version of the Appwrite server, all you need to do is run the build.sh file like this: ```bash -bash ./build.sh 1.0.0 +bash ./build.sh X.X.X ``` Before running the command, make sure you have proper write permissions to the Appwrite docker hub team. -**Build for multicore** +**Build for Multicore** ```bash -docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t appwrite/multicore:0.0.0 --push +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 -To run tests manually, use the Appwrite Docker CLI from your terminal: +To run all tests manually, use the Appwrite Docker CLI from your terminal: ```bash docker-compose exec appwrite test ``` +To run unit tests use: + +```bash +docker-compose exec appwrite test /usr/src/code/tests/unit +``` + +To run end-2-end tests use: + +```bash +docker-compose exec appwrite test /usr/src/code/tests/e2e +``` + +To run end-2-end tests for a spcific service use: + +```bash +docker-compose exec appwrite test /usr/src/code/tests/e2e/Services/[ServiceName] +``` +## Benchmarking + +You can use WRK Docker image to benchmark the server performance. Benchmarking is extremely useful when you want to compare how the server behaves before and after a change has been applied. Replace [APPWRITE_HOSTNAME_OR_IP] with your Appwrite server hostname or IP. Note that localhost is not accessible from inside the WRK container. + +``` + Options: + -c, --connections Connections to keep open + -d, --duration Duration of test + -t, --threads Number of threads to use + + -s, --script Load Lua script file + -H, --header Add header to request + --latency Print latency statistics + --timeout Socket/request timeout + -v, --version Print version details +``` + +```bash +docker run --rm skandyla/wrk -t3 -c100 -d30 https://[APPWRITE_HOSTNAME_OR_IP] +``` + ## Code Maintenance We use some automation tools to help us keep a healthy codebase. @@ -260,6 +323,12 @@ php-cs-fixer fix app/controllers --rules='{"braces": {"allow_single_line_closure php-cs-fixer fix src --rules='{"braces": {"allow_single_line_closure": true}}' ``` +Static Code Analysis: + +```bash +docker-compose exec appwrite /usr/src/code/vendor/bin/psalm +``` + ## Tutorials From time to time, our team will add tutorials that will help contributors find their way in the Appwrite source code. Below is a list of currently available tutorials: diff --git a/Dockerfile b/Dockerfile old mode 100644 new mode 100755 index 9a58abe89e..c7316bd1d4 --- a/Dockerfile +++ b/Dockerfile @@ -1,56 +1,72 @@ -FROM ubuntu:20.04 AS builder - -LABEL maintainer="team@appwrite.io" +FROM composer:2.0 as step0 ARG TESTING=false - -ENV TZ=Asia/Tel_Aviv \ - DEBIAN_FRONTEND=noninteractive \ - PHP_VERSION=7.4 \ - PHP_REDIS_VERSION=5.2.1 - -RUN \ - apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests ca-certificates software-properties-common wget git openssl && \ - LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && \ - apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests make php$PHP_VERSION php$PHP_VERSION-dev zip unzip php$PHP_VERSION-zip && \ - # Redis Extension - wget -q https://github.com/phpredis/phpredis/archive/$PHP_REDIS_VERSION.tar.gz && \ - tar -xf $PHP_REDIS_VERSION.tar.gz && \ - cd phpredis-$PHP_REDIS_VERSION && \ - phpize$PHP_VERSION && \ - ./configure && \ - make && \ - # Composer - wget https://getcomposer.org/composer.phar && \ - chmod +x ./composer.phar && \ - mv ./composer.phar /usr/bin/composer && \ - #Brotli - cd / && \ - git clone https://github.com/eustas/ngx_brotli.git && \ - cd ngx_brotli && git submodule update --init && cd .. +ENV TESTING=$TESTING WORKDIR /usr/local/src/ -# Updating PHP Dependencies and Auto-loading... - -ENV TESTING=$TESTING - -COPY composer.* /usr/local/src/ +COPY composer.lock /usr/local/src/ +COPY composer.json /usr/local/src/ RUN composer update --ignore-platform-reqs --optimize-autoloader \ --no-plugins --no-scripts --prefer-dist \ `if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi` -FROM ubuntu:20.04 +FROM php:7.4-cli-alpine as step1 + +ENV PHP_REDIS_VERSION=5.3.0 \ + PHP_SWOOLE_VERSION=v4.5.8 \ + PHP_MAXMINDDB_VERSION=v1.8.0 \ + PHP_XDEBUG_VERSION=sdebug_2_9-beta + +RUN \ + apk add --no-cache --virtual .deps \ + make \ + automake \ + autoconf \ + gcc \ + g++ \ + git \ + zlib-dev \ + brotli-dev \ + libmaxminddb-dev + +RUN docker-php-ext-install sockets + +RUN \ + # Redis Extension + git clone https://github.com/phpredis/phpredis.git && \ + cd phpredis && \ + git checkout $PHP_REDIS_VERSION && \ + phpize && \ + ./configure && \ + make && make install && \ + cd .. && \ + ## Swoole Extension + git clone https://github.com/swoole/swoole-src.git && \ + cd swoole-src && \ + git checkout $PHP_SWOOLE_VERSION && \ + phpize && \ + ./configure --enable-sockets --enable-http2 && \ + make && make install && \ + cd .. && \ + ## Maxminddb extension + git clone https://github.com/maxmind/MaxMind-DB-Reader-php.git && \ + cd MaxMind-DB-Reader-php && \ + git checkout $PHP_MAXMINDDB_VERSION && \ + cd ext && \ + phpize && \ + ./configure && \ + make && make install && \ + cd ../.. + +FROM php:7.4-cli-alpine as final + LABEL maintainer="team@appwrite.io" ARG VERSION=dev -ENV TZ=Asia/Tel_Aviv \ - DEBIAN_FRONTEND=noninteractive \ - PHP_VERSION=7.4 \ +ENV _APP_SERVER=swoole \ _APP_ENV=production \ _APP_DOMAIN=localhost \ _APP_DOMAIN_TARGET=localhost \ @@ -59,8 +75,10 @@ ENV TZ=Asia/Tel_Aviv \ _APP_OPTIONS_ABUSE=enabled \ _APP_OPTIONS_FORCE_HTTPS=disabled \ _APP_OPENSSL_KEY_V1=your-secret-key \ - _APP_STORAGE_LIMIT=104857600 \ + _APP_STORAGE_LIMIT=10000000 \ _APP_STORAGE_ANTIVIRUS=enabled \ + _APP_STORAGE_ANTIVIRUS_HOST=clamav \ + _APP_STORAGE_ANTIVIRUS_PORT=3310 \ _APP_REDIS_HOST=redis \ _APP_REDIS_PORT=6379 \ _APP_DB_HOST=mariadb \ @@ -74,105 +92,110 @@ ENV TZ=Asia/Tel_Aviv \ _APP_STATSD_PORT=8125 \ _APP_SMTP_HOST=smtp \ _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_VERSION=$VERSION \ + _APP_USAGE_STATS=enabled \ + # 14 Days = 1209600 s + _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 \ + _APP_MAINTENANCE_RETENTION_AUDIT=1209600 \ + # 1 Day = 86400 s + _APP_MAINTENANCE_RETENTION_ABUSE=86400 \ + _APP_MAINTENANCE_INTERVAL=86400 #ENV _APP_SMTP_SECURE '' #ENV _APP_SMTP_USERNAME '' #ENV _APP_SMTP_PASSWORD '' -COPY --from=builder /phpredis-5.2.1/modules/redis.so /usr/lib/php/20190902/ -COPY --from=builder /phpredis-5.2.1/modules/redis.so /usr/lib/php/20190902/ -COPY --from=builder /ngx_brotli /ngx_brotli - RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN \ - apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests wget ca-certificates software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev openssl gnupg htop supervisor && \ - LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && \ - add-apt-repository universe && \ - apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests php$PHP_VERSION php$PHP_VERSION-fpm \ - php$PHP_VERSION-mysqlnd php$PHP_VERSION-curl php$PHP_VERSION-imagick php$PHP_VERSION-mbstring php$PHP_VERSION-dom webp certbot && \ - # Nginx - wget http://nginx.org/download/nginx-1.19.0.tar.gz && \ - tar -xzvf nginx-1.19.0.tar.gz && rm nginx-1.19.0.tar.gz && \ - cd nginx-1.19.0 && \ - ./configure --prefix=/usr/share/nginx \ - --sbin-path=/usr/sbin/nginx \ - --modules-path=/usr/lib/nginx/modules \ - --conf-path=/etc/nginx/nginx.conf \ - --error-log-path=/var/log/nginx/error.log \ - --http-log-path=/var/log/nginx/access.log \ - --pid-path=/run/nginx.pid \ - --lock-path=/var/lock/nginx.lock \ - --user=www-data \ - --group=www-data \ - --build=Ubuntu \ - --with-http_gzip_static_module \ - --with-http_ssl_module \ - --with-http_v2_module \ - --add-module=/ngx_brotli && \ - make && \ - make install && \ - rm -rf ../nginx-1.19.0 && \ - # Redis Extension - echo extension=redis.so >> /etc/php/$PHP_VERSION/fpm/conf.d/redis.ini && \ - echo extension=redis.so >> /etc/php/$PHP_VERSION/cli/conf.d/redis.ini && \ - # Cleanup - cd ../ && \ - apt-get purge -y --auto-remove wget software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev gnupg && \ - apt-get clean && \ - rm -rf /ngx_brotli && \ - rm -rf /var/lib/apt/lists/* + apk update \ + && apk add --no-cache --virtual .deps \ + make \ + automake \ + autoconf \ + gcc \ + g++ \ + curl-dev \ + && apk add --no-cache \ + libstdc++ \ + yaml-dev \ + imagemagick \ + imagemagick-dev \ + certbot \ + docker-cli \ + docker-compose \ + libmaxminddb \ + libmaxminddb-dev \ + && pecl install imagick yaml \ + && docker-php-ext-enable imagick yaml \ + && docker-php-ext-install sockets opcache pdo_mysql \ + && apk del .deps \ + && rm -rf /var/cache/apk/* -# Set Upload Limit (default to 100MB) -RUN echo "upload_max_filesize = ${_APP_STORAGE_LIMIT}" >> /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini -RUN echo "post_max_size = ${_APP_STORAGE_LIMIT}" >> /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini +WORKDIR /usr/src/code -# Add logs file -RUN echo "" >> /var/log/appwrite.log +COPY --from=step0 /usr/local/src/vendor /usr/src/code/vendor +COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ +COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ +COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/maxminddb.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ -# Nginx Configuration (with self-signed ssl certificates) -COPY ./docker/nginx.conf.template /etc/nginx/nginx.conf.template -COPY ./docker/ssl/cert.pem /etc/nginx/ssl/cert.pem -COPY ./docker/ssl/key.pem /etc/nginx/ssl/key.pem - -# PHP Configuration -RUN mkdir -p /var/run/php -COPY ./docker/www.conf /etc/php/$PHP_VERSION/fpm/pool.d/www.conf - -# Add PHP Source Code -COPY ./app /usr/share/nginx/html/app +# Add Source Code +COPY ./app /usr/src/code/app COPY ./bin /usr/local/bin -COPY ./docs /usr/share/nginx/html/docs -COPY ./public /usr/share/nginx/html/public -COPY ./src /usr/share/nginx/html/src -COPY --from=builder /usr/local/src/vendor /usr/share/nginx/html/vendor +COPY ./docs /usr/src/code/docs +COPY ./public /usr/src/code/public +COPY ./src /usr/src/code/src +# Set Volumes RUN mkdir -p /storage/uploads && \ mkdir -p /storage/cache && \ mkdir -p /storage/config && \ mkdir -p /storage/certificates && \ + mkdir -p /storage/functions && \ + mkdir -p /storage/debug && \ chown -Rf www-data.www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \ chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache && \ chown -Rf www-data.www-data /storage/config && chmod -Rf 0755 /storage/config && \ - chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates - -# Supervisord Conf -COPY ./docker/supervisord.conf /etc/supervisord.conf + chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates && \ + chown -Rf www-data.www-data /storage/functions && chmod -Rf 0755 /storage/functions && \ + chown -Rf www-data.www-data /storage/debug && chmod -Rf 0755 /storage/debug # Executables -RUN chmod +x /usr/local/bin/start -RUN chmod +x /usr/local/bin/doctor -RUN chmod +x /usr/local/bin/migrate -RUN chmod +x /usr/local/bin/test +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 && \ + chmod +x /usr/local/bin/sdks && \ + chmod +x /usr/local/bin/ssl && \ + chmod +x /usr/local/bin/test && \ + chmod +x /usr/local/bin/vars && \ + chmod +x /usr/local/bin/worker-audits && \ + chmod +x /usr/local/bin/worker-certificates && \ + chmod +x /usr/local/bin/worker-deletes && \ + chmod +x /usr/local/bin/worker-functions && \ + chmod +x /usr/local/bin/worker-mails && \ + chmod +x /usr/local/bin/worker-tasks && \ + chmod +x /usr/local/bin/worker-usage && \ + chmod +x /usr/local/bin/worker-webhooks # Letsencrypt Permissions RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/ +# Enable Extensions +RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini +RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini +RUN echo extension=maxminddb.so >> /usr/local/etc/php/conf.d/maxminddb.ini + +RUN echo "opcache.preload_user=www-data" >> /usr/local/etc/php/conf.d/appwrite.ini +RUN echo "opcache.preload=/usr/src/code/app/preload.php" >> /usr/local/etc/php/conf.d/appwrite.ini +RUN echo "opcache.enable_cli=1" >> /usr/local/etc/php/conf.d/appwrite.ini + EXPOSE 80 -WORKDIR /usr/share/nginx/html - -CMD ["/bin/bash", "/usr/local/bin/start"] +CMD [ "php", "app/http.php", "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" ] diff --git a/README.md b/README.md index 05c8b26769..035c4dc828 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,9 @@ The easiest way to start running your Appwrite server is by running our docker-c ```bash docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ - --volume "$(pwd)"/appwrite:/install/appwrite:rw \ - -e version=0.6.2 \ - appwrite/install + --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ + --entrypoint="install" \ + appwrite/appwrite:0.7.0 ``` ### Windows @@ -63,9 +63,9 @@ docker run -it --rm \ ```cmd docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ - --volume "%cd%"/appwrite:/install/appwrite:rw ^ - -e version=0.6.2 ^ - appwrite/install + --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ + --entrypoint="install" ^ + appwrite/appwrite:0.7.0 ``` #### PowerShell @@ -73,9 +73,9 @@ docker run -it --rm ^ ```powershell docker run -it --rm , --volume /var/run/docker.sock:/var/run/docker.sock , - --volume ${pwd}/appwrite:/install/appwrite:rw , - -e version=0.6.2 , - appwrite/install + --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw , + --entrypoint="install" , + appwrite/appwrite:0.7.0 ``` Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-linux native hosts, the server might take a few minutes to start after installation completes. @@ -104,6 +104,7 @@ Getting started with Appwrite is as easy as creating a new project, choosing you * [**Teams**](https://appwrite.io/docs/client/teams) - Manage and group users in teams. Manage memberships, invites, and user roles within a team. * [**Database**](https://appwrite.io/docs/client/database) - Manage database collections and documents. Read, create, update, and delete documents and filter lists of document collections using advanced filters. * [**Storage**](https://appwrite.io/docs/client/storage) - Manage storage files. Read, create, delete, and preview files. Manipulate the preview of your files to fit your app perfectly. All files are scanned by ClamAV and stored in a secure and encrypted way. +* [**Functions**](https://appwrite.io/docs/server/functions) - Customize your Appwrite server by executing your custom code in a secure, isolated environment. You can trigger your code on any Appwrite system event, manually or using a CRON schedule. * [**Locale**](https://appwrite.io/docs/client/locale) - Track your user's location, and manage your app locale-based data. * [**Avatars**](https://appwrite.io/docs/client/avatars) - Manage your users' avatars, countries' flags, browser icons, credit card symbols, and generate QR codes. @@ -114,7 +115,7 @@ For the complete API documentation, visit [https://appwrite.io/docs](https://app Below is a list of currently supported platforms and languages. If you wish to help us add support to your platform of choice, you can go over to our [SDK Generator](https://github.com/appwrite/sdk-generator) project and view our [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md). #### Client -* ✅   [Web](https://github.com/appwrite/sdk-for-js) (Maintained by the Appwrite Team) +* ✅   [Web](https://github.com/appwrite/sdk-for-web) (Maintained by the Appwrite Team) * ✅   [Flutter](https://github.com/appwrite/sdk-for-flutter) (Maintained by the Appwrite Team) #### Server @@ -123,8 +124,9 @@ Below is a list of currently supported platforms and languages. If you wish to h * ✅   [Deno](https://github.com/appwrite/sdk-for-deno) - **Beta** (Maintained by the Appwrite Team) * ✅   [Ruby](https://github.com/appwrite/sdk-for-ruby) - **Beta** (Maintained by the Appwrite Team) * ✅   [Python](https://github.com/appwrite/sdk-for-python) - **Beta** (Maintained by the Appwrite Team) +* ✅   [.NET](https://github.com/appwrite/sdk-for-dotnet) - **Experimental** (Maintained by the Appwrite Team) +* ✅   [Dart](https://github.com/appwrite/sdk-for-dart) **Experimental** (Maintained by the Appwrite Team) * ✅   [Go](https://github.com/appwrite/sdk-for-go) **Work in progress** (Maintained by the Appwrite Team) -* ✅   [Dart](https://github.com/appwrite/sdk-for-dart) **Work in progress** (Maintained by the Appwrite Team) Looking for more SDKs? - Help us by contributing a pull request to our [SDK Generator](https://github.com/appwrite/sdk-generator)! diff --git a/app/app.php b/app/app.php deleted file mode 100644 index 3f6735fdbb..0000000000 --- a/app/app.php +++ /dev/null @@ -1,433 +0,0 @@ -getAttribute('platforms', []), function ($node) { - if (isset($node['type']) && $node['type'] === 'web' && isset($node['hostname']) && !empty($node['hostname'])) { - return true; - } - - return false; - })); - -$clients = \array_unique(\array_merge($clientsConsole, \array_map(function ($node) { - return $node['hostname']; - }, \array_filter($project->getAttribute('platforms', []), function ($node) { - if (isset($node['type']) && $node['type'] === 'web' && isset($node['hostname']) && !empty($node['hostname'])) { - return true; - } - - return false; - })))); - -$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $console, $webhook, $mail, $audit, $usage, $clients) { - - $route = $utopia->match($request); - - if(!empty($route->getLabel('sdk.platform', [])) && empty($project->getId()) && ($route->getLabel('scope', '') !== 'public')) { - throw new Exception('Missing or unknown project ID', 400); - } - - $referrer = $request->getServer('HTTP_REFERER', ''); - $origin = \parse_url($request->getServer('HTTP_ORIGIN', $referrer), PHP_URL_HOST); - $protocol = \parse_url($request->getServer('HTTP_ORIGIN', $referrer), PHP_URL_SCHEME); - $port = \parse_url($request->getServer('HTTP_ORIGIN', $referrer), PHP_URL_PORT); - - $refDomain = $protocol.'://'.((\in_array($origin, $clients)) - ? $origin : 'localhost') . (!empty($port) ? ':'.$port : ''); - - $selfDomain = new Domain(Config::getParam('hostname')); - $endDomain = new Domain((string)$origin); - - Config::setParam('domainVerification', - ($selfDomain->getRegisterable() === $endDomain->getRegisterable()) && - $endDomain->getRegisterable() !== ''); - - /* - * Security Headers - * - * As recommended at: - * @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers - */ - if ($utopia->getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS - if(Config::getParam('protocol') !== 'https') { - return $response->redirect('https://' . Config::getParam('domain').$request->getServer('REQUEST_URI')); - } - - $response->addHeader('Strict-Transport-Security', 'max-age='.(60 * 60 * 24 * 126)); // 126 days - } - - $response - ->addHeader('Server', 'Appwrite') - ->addHeader('X-XSS-Protection', '1; mode=block; report=/v1/xss?url='.\urlencode($request->getServer('REQUEST_URI'))) - //->addHeader('X-Frame-Options', ($refDomain == 'http://localhost') ? 'SAMEORIGIN' : 'ALLOW-FROM ' . $refDomain) - ->addHeader('X-Content-Type-Options', 'nosniff') - ->addHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE') - ->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-SDK-Version, Cache-Control, Expires, Pragma') - ->addHeader('Access-Control-Expose-Headers', 'X-Fallback-Cookies') - ->addHeader('Access-Control-Allow-Origin', $refDomain) - ->addHeader('Access-Control-Allow-Credentials', 'true') - ; - - /* - * Validate Client Domain - Check to avoid CSRF attack - * Adding Appwrite API domains to allow XDOMAIN communication - * Skip this check for non-web platforms which are not requiredto send an origin header - */ - $origin = $request->getServer('HTTP_ORIGIN', $request->getServer('HTTP_REFERER', '')); - $originValidator = new Origin(\array_merge($project->getAttribute('platforms', []), $console->getAttribute('platforms', []))); - - if(!$originValidator->isValid($origin) - && \in_array($request->getMethod(), [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE]) - && $route->getLabel('origin', false) !== '*' - && empty($request->getHeader('X-Appwrite-Key', ''))) { - throw new Exception($originValidator->getDescription(), 403); - } - - /* - * ACL Check - */ - $role = ($user->isEmpty()) ? Auth::USER_ROLE_GUEST : Auth::USER_ROLE_MEMBER; - - // Add user roles - $membership = $user->search('teamId', $project->getAttribute('teamId', null), $user->getAttribute('memberships', [])); - - if ($membership) { - foreach ($membership->getAttribute('roles', []) as $memberRole) { - switch ($memberRole) { - case 'owner': - $role = Auth::USER_ROLE_OWNER; - break; - case 'admin': - $role = Auth::USER_ROLE_ADMIN; - break; - case 'developer': - $role = Auth::USER_ROLE_DEVELOPER; - break; - } - } - } - - $roles = Config::getParam('roles', []); - $scope = $route->getLabel('scope', 'none'); // Allowed scope for chosen route - $scopes = $roles[$role]['scopes']; // Allowed scopes for user role - - // Check if given key match project API keys - $key = $project->search('secret', $request->getHeader('X-Appwrite-Key', ''), $project->getAttribute('keys', [])); - - /* - * Try app auth when we have project key and no user - * Mock user to app and grant API key scopes in addition to default app scopes - */ - if (null !== $key && $user->isEmpty()) { - $user = new Document([ - '$id' => 0, - 'status' => Auth::USER_STATUS_ACTIVATED, - 'email' => 'app.'.$project->getId().'@service.'.Config::getParam('domain'), - 'password' => '', - 'name' => $project->getAttribute('name', 'Untitled'), - ]); - - $role = Auth::USER_ROLE_APP; - $scopes = \array_merge($roles[$role]['scopes'], $key->getAttribute('scopes', [])); - - Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys. - } - - Authorization::setRole('user:'.$user->getId()); - Authorization::setRole('role:'.$role); - - \array_map(function ($node) { - if (isset($node['teamId']) && isset($node['roles'])) { - Authorization::setRole('team:'.$node['teamId']); - - foreach ($node['roles'] as $nodeRole) { // Set all team roles - Authorization::setRole('team:'.$node['teamId'].'/'.$nodeRole); - } - } - }, $user->getAttribute('memberships', [])); - - // TDOO Check if user is god - - if (!\in_array($scope, $scopes)) { - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) { // Check if permission is denied because project is missing - throw new Exception('Project not found', 404); - } - - throw new Exception($user->getAttribute('email', 'User').' (role: '.\strtolower($roles[$role]['label']).') missing scope ('.$scope.')', 401); - } - - if (Auth::USER_STATUS_BLOCKED == $user->getAttribute('status')) { // Account has not been activated - throw new Exception('Invalid credentials. User is blocked', 401); // User is in status blocked - } - - if ($user->getAttribute('reset')) { - throw new Exception('Password reset is required', 412); - } - - /* - * Background Jobs - */ - $webhook - ->setParam('projectId', $project->getId()) - ->setParam('event', $route->getLabel('webhook', '')) - ->setParam('payload', []) - ; - - $audit - ->setParam('projectId', $project->getId()) - ->setParam('userId', $user->getId()) - ->setParam('event', '') - ->setParam('resource', '') - ->setParam('userAgent', $request->getServer('HTTP_USER_AGENT', '')) - ->setParam('ip', $request->getIP()) - ->setParam('data', []) - ; - - $usage - ->setParam('projectId', $project->getId()) - ->setParam('url', $request->getServer('HTTP_HOST', '').$request->getServer('REQUEST_URI', '')) - ->setParam('method', $request->getServer('REQUEST_METHOD', 'UNKNOWN')) - ->setParam('request', 0) - ->setParam('response', 0) - ->setParam('storage', 0) - ; -}); - -$utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage, $deletes, $mode, $project, $utopia) { - - /* - * Trigger events for background workers - */ - if (!empty($webhook->getParam('event'))) { - $webhook->trigger(); - } - - if (!empty($audit->getParam('event'))) { - $audit->trigger(); - } - - if (!empty($deletes->getParam('document'))) { - $deletes->trigger(); - } - - $route = $utopia->match($request); - - if($project->getId() - && $mode !== APP_MODE_ADMIN - && !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage and admin mode - $usage - ->setParam('request', $request->getSize() + $usage->getParam('storage')) - ->setParam('response', $response->getSize()) - ->trigger() - ; - } -}); - -$utopia->options(function () use ($request, $response) { - $origin = $request->getServer('HTTP_ORIGIN'); - - $response - ->addHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE') - ->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-SDK-Version, Cache-Control, Expires, Pragma, X-Fallback-Cookies') - ->addHeader('Access-Control-Expose-Headers', 'X-Fallback-Cookies') - ->addHeader('Access-Control-Allow-Origin', $origin) - ->addHeader('Access-Control-Allow-Credentials', 'true') - ->send(); -}); - -$utopia->error(function ($error /* @var $error Exception */) use ($request, $response, $utopia, $project) { - $env = Config::getParam('env'); - $version = Config::getParam('version'); - - switch ($error->getCode()) { - case 400: // Error allowed publicly - case 401: // Error allowed publicly - case 402: // Error allowed publicly - case 403: // Error allowed publicly - case 404: // Error allowed publicly - case 409: // Error allowed publicly - case 412: // Error allowed publicly - case 429: // Error allowed publicly - $code = $error->getCode(); - $message = $error->getMessage(); - break; - default: - $code = 500; // All other errors get the generic 500 server error status code - $message = 'Server Error'; - } - - $_SERVER = []; // Reset before reporting to error log to avoid keys being compromised - - $output = ((App::MODE_TYPE_DEVELOPMENT == $env)) ? [ - 'message' => $error->getMessage(), - 'code' => $error->getCode(), - 'file' => $error->getFile(), - 'line' => $error->getLine(), - 'trace' => $error->getTrace(), - 'version' => $version, - ] : [ - 'message' => $message, - 'code' => $code, - 'version' => $version, - ]; - - $response - ->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate') - ->addHeader('Expires', '0') - ->addHeader('Pragma', 'no-cache') - ->setStatusCode($code) - ; - - $route = $utopia->match($request); - $template = ($route) ? $route->getLabel('error', null) : null; - - if ($template) { - $layout = new View(__DIR__.'/views/layouts/default.phtml'); - $comp = new View($template); - - $comp - ->setParam('projectName', $project->getAttribute('name')) - ->setParam('projectURL', $project->getAttribute('url')) - ->setParam('message', $error->getMessage()) - ->setParam('code', $code) - ; - - $layout - ->setParam('title', $project->getAttribute('name').' - Error') - ->setParam('description', 'No Description') - ->setParam('body', $comp) - ->setParam('version', $version) - ->setParam('litespeed', false) - ; - - $response->send($layout->render()); - } - - $response - ->json($output) - ; -}); - -$utopia->get('/manifest.json') - ->desc('Progressive app manifest file') - ->label('scope', 'public') - ->label('docs', false) - ->action( - function () use ($response) { - $response->json([ - 'name' => APP_NAME, - 'short_name' => APP_NAME, - 'start_url' => '.', - 'url' => 'https://appwrite.io/', - 'display' => 'standalone', - 'background_color' => '#fff', - 'theme_color' => '#f02e65', - 'description' => 'End to end backend server for frontend and mobile apps. 👩‍💻👨‍💻', - 'icons' => [ - [ - 'src' => 'images/favicon.png', - 'sizes' => '256x256', - 'type' => 'image/png', - ], - ], - ]); - } - ); - -$utopia->get('/robots.txt') - ->desc('Robots.txt File') - ->label('scope', 'public') - ->label('docs', false) - ->action( - function () use ($response) { - $template = new View(__DIR__.'/views/general/robots.phtml'); - $response->text($template->render(false)); - } - ); - -$utopia->get('/humans.txt') - ->desc('Humans.txt File') - ->label('scope', 'public') - ->label('docs', false) - ->action( - function () use ($response) { - $template = new View(__DIR__.'/views/general/humans.phtml'); - $response->text($template->render(false)); - } - ); - -$utopia->get('/.well-known/acme-challenge') - ->desc('SSL Verification') - ->label('scope', 'public') - ->label('docs', false) - ->action( - function () use ($request, $response) { - $base = \realpath(APP_STORAGE_CERTIFICATES); - $path = \str_replace('/.well-known/acme-challenge/', '', $request->getParam('q')); - $absolute = \realpath($base.'/.well-known/acme-challenge/'.$path); - - if(!$base) { - throw new Exception('Storage error', 500); - } - - if(!$absolute) { - throw new Exception('Unknown path', 404); - } - - if(!\substr($absolute, 0, \strlen($base)) === $base) { - throw new Exception('Invalid path', 401); - } - - if(!\file_exists($absolute)) { - throw new Exception('Unknown path', 404); - } - - $content = @\file_get_contents($absolute); - - if(!$content) { - throw new Exception('Failed to get contents', 500); - } - - $response->text($content); - } - ); - -include_once __DIR__ . '/controllers/shared/api.php'; -include_once __DIR__ . '/controllers/shared/web.php'; - -foreach(Config::getParam('services', []) as $service) { - include_once $service['controller']; -} - -$utopia->run($request, $response); \ No newline at end of file diff --git a/app/cli.php b/app/cli.php new file mode 100644 index 0000000000..ced2fb8da4 --- /dev/null +++ b/app/cli.php @@ -0,0 +1,26 @@ +task('version') + ->desc('Get the server version') + ->action(function () { + Console::log(App::getEnv('_APP_VERSION', 'UNKNOWN')); + }); + +$cli->run(); \ No newline at end of file diff --git a/app/config/collections.php b/app/config/collections.php index 3141419c1b..9170b07573 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1,11 +1,10 @@ [ @@ -36,13 +35,7 @@ $collections = [ 'name' => 'Localhost', 'type' => 'web', 'hostname' => 'localhost', - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, - 'name' => 'Current Host', - 'type' => 'web', - 'hostname' => \parse_url('https://'.$request->getServer('HTTP_HOST'), PHP_URL_HOST), - ], + ], // Current host is added on app init ], 'legalName' => '', 'legalCountry' => '', @@ -50,9 +43,9 @@ $collections = [ 'legalCity' => '', 'legalAddress' => '', 'legalTaxId' => '', - 'authWhitelistEmails' => (!empty($request->getServer('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', $request->getServer('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], - 'authWhitelistIPs' => (!empty($request->getServer('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', $request->getServer('_APP_CONSOLE_WHITELIST_IPS', null)) : [], - 'authWhitelistDomains' => (!empty($request->getServer('_APP_CONSOLE_WHITELIST_DOMAINS', null))) ? \explode(',', $request->getServer('_APP_CONSOLE_WHITELIST_DOMAINS', null)) : [], + 'authWhitelistEmails' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], + 'authWhitelistIPs' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [], + 'authWhitelistDomains' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_DOMAINS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_DOMAINS', null)) : [], ], Database::SYSTEM_COLLECTION_COLLECTIONS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, @@ -65,7 +58,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Name', 'key' => 'name', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -74,7 +67,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Date Created', 'key' => 'dateCreated', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, 'array' => false, @@ -83,7 +76,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Date Updated', 'key' => 'dateUpdated', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, 'array' => false, @@ -92,7 +85,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Structure', 'key' => 'structure', - 'type' => 'boolean', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, 'default' => false, 'required' => true, 'array' => false, @@ -101,7 +94,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Rules', 'key' => 'rules', - 'type' => 'document', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, 'default' => [], 'required' => true, 'array' => true, @@ -120,7 +113,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Label', 'key' => 'label', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -129,7 +122,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Key', 'key' => 'key', - 'type' => 'key', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, 'default' => '', 'required' => true, 'array' => false, @@ -138,7 +131,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Type', 'key' => 'type', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -147,7 +140,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Default', 'key' => 'default', - 'type' => 'wildcard', + 'type' => Database::SYSTEM_VAR_TYPE_WILDCARD, 'default' => '', 'required' => false, 'array' => false, @@ -156,7 +149,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Required', 'key' => 'required', - 'type' => 'boolean', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, 'default' => true, 'required' => true, 'array' => false, @@ -165,7 +158,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Array', 'key' => 'array', - 'type' => 'boolean', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, 'default' => true, 'required' => true, 'array' => false, @@ -174,11 +167,19 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'list', 'key' => 'list', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, //'default' => '', 'required' => false, 'array' => true, ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Filter', + 'key' => 'filter', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'required' => false, + 'array' => true, + ], ], ], Database::SYSTEM_COLLECTION_USERS => [ @@ -192,7 +193,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Name', 'key' => 'name', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -201,7 +202,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Email', 'key' => 'email', - 'type' => 'email', + 'type' => Database::SYSTEM_VAR_TYPE_EMAIL, 'default' => '', 'required' => true, 'array' => false, @@ -210,7 +211,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Status', 'key' => 'status', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => true, 'array' => false, @@ -219,7 +220,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Password', 'key' => 'password', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -227,8 +228,8 @@ $collections = [ [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Password Update Date', - 'key' => 'password-update', - 'type' => 'numeric', + 'key' => 'passwordUpdate', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => true, 'array' => false, @@ -237,16 +238,17 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Prefs', 'key' => 'prefs', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, + 'filter' => ['json'] ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Registration Date', 'key' => 'registration', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => true, 'array' => false, @@ -255,7 +257,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Email Verification Status', 'key' => 'emailVerification', - 'type' => 'boolean', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, 'default' => '', 'required' => true, 'array' => false, @@ -264,7 +266,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Reset', 'key' => 'reset', - 'type' => 'boolean', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, 'default' => '', 'required' => true, 'array' => false, @@ -273,7 +275,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Tokens', 'key' => 'tokens', - 'type' => 'document', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, 'default' => [], 'required' => false, 'array' => true, @@ -283,7 +285,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Memberships', 'key' => 'memberships', - 'type' => 'document', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, 'default' => [], 'required' => false, 'array' => true, @@ -298,11 +300,20 @@ $collections = [ 'name' => 'Token', 'structure' => true, 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'User ID', + 'key' => 'userId', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => false, + 'array' => false, + ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Type', 'key' => 'type', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => null, 'required' => true, 'array' => false, @@ -311,7 +322,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Secret', 'key' => 'secret', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -320,7 +331,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Expire', 'key' => 'expire', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => true, 'array' => false, @@ -329,7 +340,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'User Agent', 'key' => 'userAgent', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -338,11 +349,128 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'IP', 'key' => 'ip', - 'type' => 'ip', + 'type' => Database::SYSTEM_VAR_TYPE_IP, 'default' => '', 'required' => true, 'array' => false, ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'OS Code', + 'key' => 'osCode', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'OS Name', + 'key' => 'osName', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'OS Version', + 'key' => 'osVersion', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Type', + 'key' => 'clientType', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Code', + 'key' => 'clientCode', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Name', + 'key' => 'clientName', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Version', + 'key' => 'clientVersion', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Engine', + 'key' => 'clientEngine', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Engine Version', + 'key' => 'clientEngineVersion', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Device Name', + 'key' => 'deviceName', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Device Brand', + 'key' => 'deviceBrand', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Device Model', + 'key' => 'deviceModel', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Country Code', + 'key' => 'countryCode', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], ], ], Database::SYSTEM_COLLECTION_MEMBERSHIPS => [ @@ -356,7 +484,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Team ID', 'key' => 'teamId', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -365,7 +493,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'User ID', 'key' => 'userId', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -374,7 +502,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Roles', 'key' => 'roles', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => true, @@ -383,7 +511,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Invited', 'key' => 'invited', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, //FIXME SHOULD BE REQUIRED 'array' => false, @@ -392,7 +520,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Joined', 'key' => 'joined', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => true, 'array' => false, @@ -401,7 +529,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Confirm', 'key' => 'confirm', - 'type' => 'boolean', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, 'default' => '', 'required' => true, 'array' => false, @@ -410,7 +538,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Secret', 'key' => 'secret', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -428,7 +556,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Name', 'key' => 'name', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -437,7 +565,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Date Created', 'key' => 'dateCreated', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => false, 'array' => false, @@ -446,7 +574,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Sum', 'key' => 'sum', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => false, 'array' => false, @@ -464,7 +592,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Name', 'key' => 'name', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -473,7 +601,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Description', 'key' => 'description', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => false, 'array' => false, @@ -482,7 +610,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Logo', 'key' => 'logo', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, ], @@ -490,7 +618,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'URL', 'key' => 'url', - 'type' => 'url', + 'type' => Database::SYSTEM_VAR_TYPE_URL, 'default' => '', 'required' => false, ], @@ -498,7 +626,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Team ID', 'key' => 'teamId', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => 0, 'required' => true, 'array' => false, @@ -507,7 +635,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Legal Name', 'key' => 'legalName', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, ], @@ -515,7 +643,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Legal Country', 'key' => 'legalCountry', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, ], @@ -523,7 +651,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Legal State', 'key' => 'legalState', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, ], @@ -531,7 +659,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Legal City', 'key' => 'legalCity', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, ], @@ -539,7 +667,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Legal Address', 'key' => 'legalAddress', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, ], @@ -547,7 +675,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Legal Tax ID', 'key' => 'legalTaxId', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, ], @@ -555,7 +683,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Webhooks', 'key' => 'webhooks', - 'type' => 'document', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, 'default' => [], 'required' => false, 'array' => true, @@ -565,7 +693,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'API Keys', 'key' => 'keys', - 'type' => 'document', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, 'default' => [], 'required' => false, 'array' => true, @@ -575,7 +703,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Tasks', 'key' => 'tasks', - 'type' => 'document', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, 'default' => [], 'required' => false, 'array' => true, @@ -585,7 +713,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Platforms', 'key' => 'platforms', - 'type' => 'document', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, 'default' => [], 'required' => false, 'array' => true, @@ -595,7 +723,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Domains', 'key' => 'domains', - 'type' => 'document', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, 'default' => [], 'required' => false, 'array' => true, @@ -614,7 +742,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Name', 'key' => 'name', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -623,7 +751,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Events', 'key' => 'events', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => false, 'array' => true, @@ -632,7 +760,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'URL', 'key' => 'url', - 'type' => 'url', + 'type' => Database::SYSTEM_VAR_TYPE_URL, 'default' => '', 'required' => false, 'array' => false, @@ -641,7 +769,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Security', 'key' => 'security', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, 'default' => '', 'required' => false, 'array' => false, @@ -650,7 +778,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'HTTP User', 'key' => 'httpUser', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -659,10 +787,11 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'HTTP Password', 'key' => 'httpPass', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, + 'filter' => ['encrypt'], ], ], ], @@ -677,7 +806,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Name', 'key' => 'name', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -686,7 +815,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Scopes', 'key' => 'scopes', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => false, 'array' => true, @@ -695,9 +824,10 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Secret', 'key' => 'secret', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, + 'filter' => ['encrypt'], ], ], ], @@ -712,7 +842,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Name', 'key' => 'name', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -721,7 +851,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Status', 'key' => 'status', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -730,7 +860,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Updated', 'key' => 'updated', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => false, 'array' => false, @@ -739,7 +869,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Schedule', 'key' => 'schedule', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -748,7 +878,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Previous', 'key' => 'previous', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => false, 'array' => false, @@ -757,7 +887,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Next', 'key' => 'next', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => false, 'array' => false, @@ -766,7 +896,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Duration', 'key' => 'duration', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => false, 'array' => false, @@ -775,7 +905,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Delay', 'key' => 'delay', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => false, 'array' => false, @@ -784,7 +914,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Security', 'key' => 'security', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, 'default' => '', 'required' => false, 'array' => false, @@ -793,7 +923,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'HTTP Method', 'key' => 'httpMethod', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -802,7 +932,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'HTTP URL', 'key' => 'httpUrl', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -811,7 +941,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'HTTP Headers', 'key' => 'httpHeaders', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => false, 'array' => true, @@ -820,7 +950,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'HTTP User', 'key' => 'httpUser', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -829,16 +959,17 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'HTTP Password', 'key' => 'httpPass', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, + 'filter' => ['encrypt'], ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Log', 'key' => 'log', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -847,7 +978,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Failures', 'key' => 'failures', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => '', 'required' => false, 'array' => false, @@ -865,7 +996,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Type', 'key' => 'type', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -874,7 +1005,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Name', 'key' => 'name', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -883,7 +1014,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Date Created', 'key' => 'dateCreated', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, 'array' => false, @@ -892,7 +1023,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Date Updated', 'key' => 'dateUpdated', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, 'array' => false, @@ -901,7 +1032,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Key', 'key' => 'key', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -910,7 +1041,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Store', 'key' => 'store', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -919,7 +1050,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Hostname', 'key' => 'hostname', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -937,7 +1068,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Domain', 'key' => 'domain', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -946,7 +1077,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Updated', 'key' => 'updated', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, 'array' => false, @@ -955,7 +1086,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Top Level Domain', 'key' => 'tld', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -964,7 +1095,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Registerable Domain', 'key' => 'registerable', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -973,7 +1104,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Verification', 'key' => 'verification', - 'type' => 'boolean', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, 'default' => false, 'required' => true, 'array' => false, @@ -982,7 +1113,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Certificate ID', 'key' => 'certificateId', - 'type' => 'key', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, 'default' => '', 'required' => false, 'array' => false, @@ -1000,7 +1131,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Domain', 'key' => 'domain', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, 'required' => true, 'array' => false, @@ -1009,7 +1140,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Issue Date', 'key' => 'issueDate', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, 'array' => false, @@ -1018,7 +1149,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Renew Date', 'key' => 'renewDate', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, 'array' => false, @@ -1027,7 +1158,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Attempts', 'key' => 'attempts', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, 'array' => false, @@ -1036,7 +1167,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Log', 'key' => 'log', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -1054,7 +1185,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Date Created', 'key' => 'dateCreated', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => false, 'array' => false, @@ -1063,7 +1194,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Folder ID', 'key' => 'folderId', - 'type' => 'key', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, 'default' => 0, 'required' => false, 'array' => false, @@ -1072,7 +1203,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Name', 'key' => 'name', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -1081,7 +1212,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Path', 'key' => 'path', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -1090,7 +1221,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Signature', 'key' => 'signature', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -1099,7 +1230,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Mime Type', 'key' => 'mimeType', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -1108,7 +1239,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Original Size', 'key' => 'sizeOriginal', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => true, 'array' => false, @@ -1117,7 +1248,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Actual Size', 'key' => 'sizeActual', - 'type' => 'numeric', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => 0, 'required' => true, 'array' => false, @@ -1126,7 +1257,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Algorithm', 'key' => 'algorithm', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -1135,7 +1266,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Token', 'key' => 'token', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => true, 'array' => false, @@ -1144,7 +1275,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Comment', 'key' => 'comment', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -1153,7 +1284,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'File OpenSSL Version', 'key' => 'fileOpenSSLVersion', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -1162,7 +1293,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'File OpenSSL Cipher', 'key' => 'fileOpenSSLCipher', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -1171,7 +1302,7 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'File OpenSSL Tag', 'key' => 'fileOpenSSLTag', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -1180,13 +1311,282 @@ $collections = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'File OpenSSL IV', 'key' => 'fileOpenSSLIV', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, ], ], ], + Database::SYSTEM_COLLECTION_FUNCTIONS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_FUNCTIONS, + '$permissions' => ['read' => ['*']], + 'name' => 'Functions', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Updated', + 'key' => 'dateUpdated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Status', + 'key' => 'status', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Env', + 'key' => 'env', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Tag', + 'key' => 'tag', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Vars', + 'key' => 'vars', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + 'filter' => ['json', 'encrypt'] + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Events', + 'key' => 'events', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => true, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Schedule', + 'key' => 'schedule', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Schedule Previous Run', + 'key' => 'schedulePrevious', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Schedule Next Run', + 'key' => 'scheduleNext', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Timeout', + 'key' => 'timeout', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_TAGS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_TAGS, + '$permissions' => ['read' => ['*']], + 'name' => 'Tags', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Function ID', + 'key' => 'functionId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Command', + 'key' => 'command', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Code Path', + 'key' => 'path', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Code Size', + 'key' => 'size', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_EXECUTIONS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_EXECUTIONS, + '$permissions' => ['read' => ['*']], + 'name' => 'Executions', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Function ID', + 'key' => 'functionId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Tag ID', + 'key' => 'tagId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Trigger', + 'key' => 'trigger', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Status', + 'key' => 'status', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Exit Code', + 'key' => 'exitCode', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Stdout', + 'key' => 'stdout', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Stderr', + 'key' => 'stderr', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Time', + 'key' => 'time', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_RESERVED => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_RESERVED, + '$permissions' => ['read' => ['*']], + 'name' => 'Reserved', + 'structure' => true, + ], ]; /* @@ -1201,7 +1601,7 @@ foreach ($providers as $index => $provider) { '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'OAuth2 '.\ucfirst($index).' ID', 'key' => 'usersOauth2'.\ucfirst($index).'Appid', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -1211,17 +1611,18 @@ foreach ($providers as $index => $provider) { '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'OAuth2 '.\ucfirst($index).' Secret', 'key' => 'usersOauth2'.\ucfirst($index).'Secret', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, + 'filter' => ['encrypt'], ]; $collections[Database::SYSTEM_COLLECTION_USERS]['rules'][] = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'OAuth2 '.\ucfirst($index).' ID', 'key' => 'oauth2'.\ucfirst($index), - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, @@ -1231,7 +1632,7 @@ foreach ($providers as $index => $provider) { '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'OAuth2 '.\ucfirst($index).' Access Token', 'key' => 'oauth2'.\ucfirst($index).'AccessToken', - 'type' => 'text', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', 'required' => false, 'array' => false, diff --git a/app/config/environments.php b/app/config/environments.php new file mode 100644 index 0000000000..9f1c5638e1 --- /dev/null +++ b/app/config/environments.php @@ -0,0 +1,138 @@ + [ + 'name' => 'Node.js', + 'version' => '14.5', + 'base' => 'node:14.5-alpine', + 'image' => 'appwrite/env-node-14.5:1.0.0', + 'build' => '/usr/src/code/docker/environments/node-14.5', + 'logo' => 'node.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'node-15.5' => [ + 'name' => 'Node.js', + 'version' => '15.5', + 'base' => 'node:15.5-alpine', + 'image' => 'appwrite/env-node-15.5:1.0.0', + 'build' => '/usr/src/code/docker/environments/node-15.5', + 'logo' => 'node.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'php-7.4' => [ + 'name' => 'PHP', + 'version' => '7.4', + 'base' => 'php:7.4-cli-alpine', + 'image' => 'appwrite/env-php-7.4:1.0.0', + 'build' => '/usr/src/code/docker/environments/php-7.4', + 'logo' => 'php.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'php-8.0' => [ + 'name' => 'PHP', + 'version' => '8.0', + 'base' => 'php:8.0-cli-alpine', + 'image' => 'appwrite/env-php-8.0:1.0.0', + 'build' => '/usr/src/code/docker/environments/php-8.0', + 'logo' => 'php.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'ruby-2.7' => [ + 'name' => 'Ruby', + 'version' => '2.7', + 'base' => 'ruby:2.7-alpine', + 'image' => 'appwrite/env-ruby-2.7:1.0.2', + 'build' => '/usr/src/code/docker/environments/ruby-2.7', + 'logo' => 'ruby.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'ruby-3.0' => [ + 'name' => 'Ruby', + 'version' => '3.0', + 'base' => 'ruby:3.0-alpine', + 'image' => 'appwrite/env-ruby-3.0:1.0.0', + 'build' => '/usr/src/code/docker/environments/ruby-3.0', + 'logo' => 'ruby.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'python-3.8' => [ + 'name' => 'Python', + 'version' => '3.8', + 'base' => 'python:3.8-alpine', + 'image' => 'appwrite/env-python-3.8:1.0.0', + 'build' => '/usr/src/code/docker/environments/python-3.8', + 'logo' => 'python.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'deno-1.2' => [ + 'name' => 'Deno', + 'version' => '1.2', + 'base' => 'hayd/deno:alpine-1.2.0', + 'image' => 'appwrite/env-deno-1.2:1.0.0', + 'build' => '/usr/src/code/docker/environments/deno-1.2', + 'logo' => 'deno.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'deno-1.5' => [ + 'name' => 'Deno', + 'version' => '1.5', + 'base' => 'hayd/deno:alpine-1.5.0', + 'image' => 'appwrite/env-deno-1.5:1.0.0', + 'build' => '/usr/src/code/docker/environments/deno-1.5', + 'logo' => 'deno.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'deno-1.6' => [ + 'name' => 'Deno', + 'version' => '1.6', + 'base' => 'hayd/deno:alpine-1.6.0', + 'image' => 'appwrite/env-deno-1.6:1.0.0', + 'build' => '/usr/src/code/docker/environments/deno-1.6', + 'logo' => 'deno.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], + 'dart-2.10' => [ + 'name' => 'Dart', + 'version' => '2.10', + 'base' => 'google/dart:2.10', + 'image' => 'appwrite/env-dart-2.10:1.0.0', + 'build' => '/usr/src/code/docker/environments/dart-2.10', + 'logo' => 'dart.png', + 'supports' => [System::X86], + ], + 'dotnet-3.1' => [ + 'name' => '.NET', + 'version' => '3.1', + 'base' => 'mcr.microsoft.com/dotnet/runtime:3.1-alpine', + 'image' => 'appwrite/env-dotnet-3.1:1.0.0', + 'build' => '/usr/src/code/docker/environments/dotnet-3.1', + 'logo' => 'dotnet.png', + 'supports' => [System::X86, System::ARM], + ], + 'dotnet-5.0' => [ + 'name' => '.NET', + 'version' => '5.0', + 'base' => 'mcr.microsoft.com/dotnet/runtime:5.0-alpine', + 'image' => 'appwrite/env-dotnet-5.0:1.0.0', + 'build' => '/usr/src/code/docker/environments/dotnet-5.0', + 'logo' => 'dotnet.png', + 'supports' => [System::X86, System::ARM], + ], +]; + +$allowList = empty(App::getEnv('_APP_FUNCTIONS_ENVS', null)) ? false : \explode(',', App::getEnv('_APP_FUNCTIONS_ENVS', null)); + +$environments = array_filter($environments, function ($environment, $key) use ($allowList) { + $isAllowed = $allowList && in_array($key, $allowList); + $isSupported = in_array(System::getArchEnum(), $environment["supports"]); + + return $allowList ? ($isAllowed && $isSupported) : $isSupported; +}, ARRAY_FILTER_USE_BOTH); + +return $environments; \ No newline at end of file diff --git a/app/config/events.php b/app/config/events.php index aeee6849f2..2bb3862fdf 100644 --- a/app/config/events.php +++ b/app/config/events.php @@ -3,56 +3,163 @@ /** * List of publicly accessiable system events */ + +use Appwrite\Utopia\Response; + return [ 'account.create' => [ 'description' => 'This event triggers when the account is created.', + 'model' => Response::MODEL_USER, + 'note' => '', ], 'account.update.email' => [ 'description' => 'This event triggers when the account email address is updated.', + 'model' => Response::MODEL_USER, + 'note' => '', ], 'account.update.name' => [ 'description' => 'This event triggers when the account name is updated.', + 'model' => Response::MODEL_USER, + 'note' => '', ], 'account.update.password' => [ 'description' => 'This event triggers when the account password is updated.', + 'model' => Response::MODEL_USER, + 'note' => '', ], 'account.update.prefs' => [ 'description' => 'This event triggers when the account preferences are updated.', + 'model' => Response::MODEL_USER, + 'note' => '', + ], + 'account.recovery.create' => [ + 'description' => 'This event triggers when the account recovery token is created.', + 'model' => Response::MODEL_TOKEN, + 'note' => 'version >= 0.7', + ], + 'account.recovery.update' => [ + 'description' => 'This event triggers when the account recovery token is validated.', + 'model' => Response::MODEL_TOKEN, + 'note' => 'version >= 0.7', + ], + 'account.verification.create' => [ + 'description' => 'This event triggers when the account verification token is created.', + 'model' => Response::MODEL_TOKEN, + 'note' => 'version >= 0.7', + ], + 'account.verification.update' => [ + 'description' => 'This event triggers when the account verification token is validated.', + 'model' => Response::MODEL_TOKEN, + 'note' => 'version >= 0.7', ], 'account.delete' => [ 'description' => 'This event triggers when the account is deleted.', + 'model' => Response::MODEL_USER, + 'note' => '', ], 'account.sessions.create' => [ 'description' => 'This event triggers when the account session is created.', + 'model' => Response::MODEL_SESSION, + 'note' => '', ], 'account.sessions.delete' => [ 'description' => 'This event triggers when the account session is deleted.', + 'model' => Response::MODEL_SESSION, + 'note' => '', ], 'database.collections.create' => [ 'description' => 'This event triggers when a database collection is created.', + 'model' => Response::MODEL_COLLECTION, + 'note' => '', ], 'database.collections.update' => [ 'description' => 'This event triggers when a database collection is updated.', + 'model' => Response::MODEL_COLLECTION, + 'note' => '', ], 'database.collections.delete' => [ 'description' => 'This event triggers when a database collection is deleted.', + 'model' => Response::MODEL_COLLECTION, + 'note' => '', ], 'database.documents.create' => [ 'description' => 'This event triggers when a database document is created.', + 'model' => Response::MODEL_ANY, + 'note' => '', ], - 'database.documents.patch' => [ - 'description' => 'This event triggers when a database document is patched.', + 'database.documents.update' => [ + 'description' => 'This event triggers when a database document is updated.', + 'model' => Response::MODEL_ANY, + 'note' => '', ], 'database.documents.delete' => [ 'description' => 'This event triggers when a database document is deleted.', + 'model' => Response::MODEL_ANY, + 'note' => '', ], 'storage.files.create' => [ 'description' => 'This event triggers when a storage file is created.', + 'model' => Response::MODEL_FILE, + 'note' => '', ], 'storage.files.update' => [ 'description' => 'This event triggers when a storage file is updated.', + 'model' => Response::MODEL_FILE, + 'note' => '', ], 'storage.files.delete' => [ 'description' => 'This event triggers when a storage file is deleted.', + 'model' => Response::MODEL_FILE, + 'note' => '', + ], + 'users.create' => [ + 'description' => 'This event triggers when a user is created from the users API.', + 'model' => Response::MODEL_USER, + 'note' => 'version >= 0.7', + ], + 'users.update.status' => [ + 'description' => 'This event triggers when a user status is updated from the users API.', + 'model' => Response::MODEL_USER, + 'note' => 'version >= 0.7', + ], + 'users.delete' => [ + 'description' => 'This event triggers when a user is deleted from users API.', + 'model' => Response::MODEL_USER, + 'note' => 'version >= 0.7', + ], + 'users.sessions.delete' => [ + 'description' => 'This event triggers when a user session is deleted from users API.', + 'model' => Response::MODEL_SESSION, + 'note' => 'version >= 0.7', + ], + 'teams.create' => [ + 'description' => 'This event triggers when a team is created.', + 'model' => Response::MODEL_TEAM, + 'note' => 'version >= 0.7', + ], + 'teams.update' => [ + 'description' => 'This event triggers when a team is updated.', + 'model' => Response::MODEL_TEAM, + 'note' => 'version >= 0.7', + ], + 'teams.delete' => [ + 'description' => 'This event triggers when a team is deleted.', + 'model' => Response::MODEL_TEAM, + 'note' => 'version >= 0.7', + ], + 'teams.memberships.create' => [ + 'description' => 'This event triggers when a team memberships is created.', + 'model' => Response::MODEL_MEMBERSHIP, + 'note' => 'version >= 0.7', + ], + 'teams.memberships.update.status' => [ + 'description' => 'This event triggers when a team memberships status is updated.', + 'model' => Response::MODEL_MEMBERSHIP, + 'note' => 'version >= 0.7', + ], + 'teams.memberships.delete' => [ + 'description' => 'This event triggers when a team memberships is deleted.', + 'model' => Response::MODEL_MEMBERSHIP, + 'note' => 'version >= 0.7', ], ]; \ No newline at end of file diff --git a/app/config/locales.php b/app/config/locale/codes.php similarity index 81% rename from app/config/locales.php rename to app/config/locale/codes.php index 84738367be..d3f289576c 100644 --- a/app/config/locales.php +++ b/app/config/locale/codes.php @@ -3,16 +3,21 @@ return [ 'af', // Afrikaans 'ar', // Arabic + 'ba', //Bosnian + 'be', // Belarusian + 'bg', // Bulgarian 'bn', // Bengali 'cat', // Catalan 'cz', // Czech 'de', // German 'en', // English 'es', // Spanish + 'fa', // Farsi/Persian 'fi', // Finnish 'fo', // Faroese 'fr', // French 'gr', // Greek + 'gu', //Gujrati 'he', // Hebrew 'hi', // Hindi 'hu', // Hungarian @@ -22,17 +27,22 @@ return [ 'it', // Italian 'ja', // Japanese 'jv', // Javanese + 'ka', // Kannada 'km', // Khmer 'ko', // Korean 'lt', // Lithuanian 'ml', // Malayalam + 'mr', // Marathi 'ms', // Malay 'nl', // Dutch 'no', // Norwegian + 'np', // Nepali + 'od', // Odia 'ph', // Filipino 'pl', // Polish 'pt-br', // Portuguese - Brazil 'pt-pt', // Portuguese - Portugal + 'pa', //Punjabi 'ro', // Romanian 'ru', // Russian 'si', // Sinhala @@ -43,7 +53,8 @@ return [ 'th', // Thai 'tr', // Turkish 'ua', // Ukrainian + 'ur', //Urdu 'vi', // Vietnamese 'zh-cn', // Chinese - China 'zh-tw', // Chinese - Taiwan -]; \ No newline at end of file +]; diff --git a/app/config/currencies.php b/app/config/locale/currencies.php similarity index 100% rename from app/config/currencies.php rename to app/config/locale/currencies.php diff --git a/app/config/eu.php b/app/config/locale/eu.php similarity index 82% rename from app/config/eu.php rename to app/config/locale/eu.php index fbefd23694..3db5b8773c 100644 --- a/app/config/eu.php +++ b/app/config/locale/eu.php @@ -30,8 +30,4 @@ $list = [ 'SE', // Sweden ]; -if (\time() < \strtotime('2020-01-31')) { // @see https://en.wikipedia.org/wiki/Brexit - $list[] = 'GB'; // // United Kingdom -} - return $list; diff --git a/app/config/languages.php b/app/config/locale/languages.php similarity index 100% rename from app/config/languages.php rename to app/config/locale/languages.php diff --git a/app/config/phones.php b/app/config/locale/phones.php similarity index 100% rename from app/config/phones.php rename to app/config/locale/phones.php diff --git a/app/config/locales/templates/_base.tpl b/app/config/locale/templates/email-base.tpl similarity index 100% rename from app/config/locales/templates/_base.tpl rename to app/config/locale/templates/email-base.tpl diff --git a/app/config/locales/templates/_cta.tpl b/app/config/locale/templates/email-cta.tpl similarity index 100% rename from app/config/locales/templates/_cta.tpl rename to app/config/locale/templates/email-cta.tpl diff --git a/app/config/locales/af.continents.php b/app/config/locale/translations/af.continents.php similarity index 100% rename from app/config/locales/af.continents.php rename to app/config/locale/translations/af.continents.php diff --git a/app/config/locales/af.countries.php b/app/config/locale/translations/af.countries.php similarity index 100% rename from app/config/locales/af.countries.php rename to app/config/locale/translations/af.countries.php diff --git a/app/config/locales/af.php b/app/config/locale/translations/af.php similarity index 100% rename from app/config/locales/af.php rename to app/config/locale/translations/af.php diff --git a/app/config/locales/ar.continents.php b/app/config/locale/translations/ar.continents.php similarity index 100% rename from app/config/locales/ar.continents.php rename to app/config/locale/translations/ar.continents.php diff --git a/app/config/locales/ar.countries.php b/app/config/locale/translations/ar.countries.php similarity index 100% rename from app/config/locales/ar.countries.php rename to app/config/locale/translations/ar.countries.php diff --git a/app/config/locales/ar.php b/app/config/locale/translations/ar.php similarity index 100% rename from app/config/locales/ar.php rename to app/config/locale/translations/ar.php diff --git a/app/config/locale/translations/ba.continents.php b/app/config/locale/translations/ba.continents.php new file mode 100644 index 0000000000..881de56f58 --- /dev/null +++ b/app/config/locale/translations/ba.continents.php @@ -0,0 +1,11 @@ + 'Afrika', + 'AN' => 'Antartika', + 'AS' => 'Azija', + 'EU' => 'Europa', + 'NA' => 'Sjeverna Amerika', + 'OC' => 'Okeanija', + 'SA' => 'Južna Amerika', +]; diff --git a/app/config/locale/translations/ba.countries.php b/app/config/locale/translations/ba.countries.php new file mode 100644 index 0000000000..84ca85a4b9 --- /dev/null +++ b/app/config/locale/translations/ba.countries.php @@ -0,0 +1,198 @@ + 'Afganistan', + 'AO' => 'Angola', + 'AL' => 'Albanija', + 'AD' => 'Andora', + 'AE' => 'Ujedinjeni Arapski Emirati', + 'AR' => 'Argentina', + 'AM' => 'Armenija', + 'AG' => 'Antigua i Barbuda', + 'AU' => 'Australija', + 'AT' => 'Austria', + 'AZ' => 'Azerbejdžan', + 'BI' => 'Burundi', + 'BE' => 'Belgija', + 'BJ' => 'Benin', + 'BF' => 'Burkina Faso', + 'BD' => 'Bangladeš', + 'BG' => 'Bugarska', + 'BH' => 'Bahrein', + 'BS' => 'Bahami', + 'BA' => 'Bosna i Hercegovina', + 'BY' => 'Bjelorusija', + 'BZ' => 'Belize', + 'BO' => 'Bolivija', + 'BR' => 'Brazil', + 'BB' => 'Barbados', + 'BN' => 'Brineji', + 'BT' => 'Butan', + 'BW' => 'Bocvanija', + 'CF' => 'Centralna Afrička Republika', + 'CA' => 'Kanada', + 'CH' => 'Švicarska', + 'CL' => 'Čile', + 'CN' => 'Kina', + 'CI' => 'Obala Slonovače', + 'CM' => 'Kameron', + 'CD' => 'DR Kongo', + 'CG' => 'Republika Kongo', + 'CO' => 'Kolumbija', + 'KM' => 'Komori', + 'CV' => 'Zelenortska Ostrva', + 'CR' => 'Kostarika', + 'CU' => 'Kuba', + 'CY' => 'Kipar', + 'CZ' => 'Češka', + 'DE' => 'Njemačka', + 'DJ' => 'Džibuti', + 'DM' => 'Dominika', + 'DK' => 'Danska', + 'DO' => 'Dominikanska Republika', + 'DZ' => 'Alžir', + 'EC' => 'Ekvador', + 'EG' => 'Egipt', + 'ER' => 'Eritreja', + 'ES' => 'Španija', + 'EE' => 'Estonija', + 'ET' => 'Etiopija', + 'FI' => 'Finska', + 'FJ' => 'Fidži', + 'FR' => 'Francuska', + 'FM' => 'Mikronezija', + 'GA' => 'Gabon', + 'GB' => 'Ujedinjeno Kraljevstvo', + 'GE' => 'Gruzija', + 'GH' => 'Gana', + 'GN' => 'Gvineja', + 'GM' => 'Gambia', + 'GW' => 'Gvineja Bisau', + 'GQ' => 'Ekvatorijalna Gvineja', + 'GR' => 'Grčka', + 'GD' => 'Grenada', + 'GT' => 'Guatemala', + 'GY' => 'Gvajana', + 'HN' => 'Honduras', + 'HR' => 'Hrvatska', + 'HT' => 'Haiti', + 'HU' => 'Mađarska', + 'ID' => 'Indonezija', + 'IN' => 'India', + 'IE' => 'Irska', + 'IR' => 'Iran', + 'IQ' => 'Irak', + 'IS' => 'Island', + 'IL' => 'Izrael', + 'IT' => 'Italija', + 'JM' => 'Jamajka', + 'JO' => 'Jordan', + 'JP' => 'Japan', + 'KZ' => 'Kazahstan', + 'KE' => 'Kenija', + 'KG' => 'Kirgistan', + 'KH' => 'Kambodža', + 'KI' => 'Kiribati', + 'KN' => 'Sveti Kitts i Nevis', + 'KR' => 'Južna Korea', + 'KW' => 'Kuvajt', + 'LA' => 'Laos', + 'LB' => 'Libanon', + 'LR' => 'Liberija', + 'LY' => 'Libija', + 'LC' => 'Sveta Lucija', + 'LI' => 'Lihtenštajn', + 'LK' => 'Šri Lanka', + 'LS' => 'Lesoto', + 'LT' => 'Litvanija', + 'LU' => 'Luksemburg', + 'LV' => 'Lavija', + 'MA' => 'Maroko', + 'MC' => 'Monako', + 'MD' => 'Moldavija', + 'MG' => 'Madagaskar', + 'MV' => 'Maldivi', + 'MX' => 'Meksiko', + 'MH' => 'Marshall Islands', + 'MK' => 'Makedonija', + 'ML' => 'Mali', + 'MT' => 'Malta', + 'MM' => 'Mijanmar', + 'ME' => 'Crna Gora', + 'MN' => 'Mongolia', + 'MZ' => 'Mozambik', + 'MR' => 'Mauritanija', + 'MU' => 'Mauricijus', + 'MW' => 'Malavi', + 'MY' => 'Malezija', + 'NA' => 'Namibia', + 'NE' => 'Niger', + 'NG' => 'Nigeria', + 'NI' => 'Nikaragva', + 'NL' => 'Holandija', + 'NO' => 'Norveška', + 'NP' => 'Nepal', + 'NR' => 'Nauru', + 'NZ' => 'Novi Zeland', + 'OM' => 'Oman', + 'PK' => 'Pakistan', + 'PA' => 'Panama', + 'PE' => 'Peru', + 'PH' => 'Filipini', + 'PW' => 'Palau', + 'PG' => 'Papua Nova Guinea', + 'PL' => 'Poljska', + 'KP' => 'Sjeverna Korea', + 'PT' => 'Portugal', + 'PY' => 'Paragvaj', + 'QA' => 'Katar', + 'RO' => 'Rumunija', + 'RU' => 'Rusija', + 'RW' => 'Ruanda', + 'SA' => 'Saudijska Arabija', + 'SD' => 'Sudan', + 'SN' => 'Senegal', + 'SG' => 'Singapur', + 'SB' => 'Solomonova Ostrva', + 'SL' => 'Sijera Leone', + 'SV' => 'Salvador', + 'SM' => 'San Marino', + 'SO' => 'Somalia', + 'RS' => 'Srbija', + 'SS' => 'Južni Sudan', + 'ST' => 'Sveti Toma i Prinsipe', + 'SR' => 'Surinam', + 'SK' => 'Slovačka', + 'SI' => 'Slovenija', + 'SE' => 'Švedska', + 'SZ' => 'Svazilend', + 'SC' => 'Sejšeli', + 'SY' => 'Sirija', + 'TD' => 'Čad', + 'TG' => 'Togo', + 'TH' => 'Tajland', + 'TJ' => 'Tajikistan', + 'TM' => 'Turkmenistan', + 'TL' => 'Timor-Leste', + 'TO' => 'Tonga', + 'TT' => 'Trinidad i Tobago', + 'TN' => 'Tunis', + 'TR' => 'Turska', + 'TV' => 'Tuvalu', + 'TZ' => 'Tanzania', + 'UG' => 'Uganda', + 'UA' => 'Ukrajina', + 'UY' => 'Urugvaj', + 'US' => 'Sjedinjene Američke Države', + 'UZ' => 'Uzbekistan', + 'VA' => 'Vatikan', + 'VC' => 'Sveti Vincent i Grenadini', + 'VE' => 'Venecuela', + 'VN' => 'Vijetnam', + 'VU' => 'Vanuatu', + 'WS' => 'Samoa', + 'YE' => 'Jemen', + 'ZA' => 'Južna Afrika', + 'ZM' => 'Zambia', + 'ZW' => 'Zimbabve', +]; diff --git a/app/config/locale/translations/ba.php b/app/config/locale/translations/ba.php new file mode 100644 index 0000000000..5eab8bc07c --- /dev/null +++ b/app/config/locale/translations/ba.php @@ -0,0 +1,21 @@ + '"Umjetnost mudrosti je umjetnost znanja o tome šta zanemariti."', // This is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'ba', + 'settings.direction' => 'ltr', + + // Service - Users + 'account.emails.team' => '%s Tim', + 'account.emails.verification.title' => 'Verifikacija računa', + 'account.emails.verification.body' => 'ba.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Reset lozinke', + 'account.emails.recovery.body' => 'ba.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Pozivnica za %s Team na %s', + 'account.emails.invitation.body' => 'ba.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'Nepoznat', + + 'countries' => include 'ba.countries.php', + 'continents' => include 'ba.continents.php', +]; diff --git a/app/config/locale/translations/be.continents.php b/app/config/locale/translations/be.continents.php new file mode 100644 index 0000000000..0d068d349a --- /dev/null +++ b/app/config/locale/translations/be.continents.php @@ -0,0 +1,11 @@ + 'Афрыка', + 'AN' => 'Антарктыда', + 'AS' => 'Азія', + 'EU' => 'Еўропа', + 'NA' => 'Паўночная Амерыка', + 'OC' => 'Акіянія', + 'SA' => 'Паўднёвая Амерыка', +]; diff --git a/app/config/locale/translations/be.countries.php b/app/config/locale/translations/be.countries.php new file mode 100644 index 0000000000..cb747327f4 --- /dev/null +++ b/app/config/locale/translations/be.countries.php @@ -0,0 +1,198 @@ + 'Афганістан', + 'AO' => 'Ангола', + 'AL' => 'Албанія', + 'AD' => 'Андора', + 'AE' => 'Аб\'яднаныя Арабскія Эміраты', + 'AR' => 'Аргентына', + 'AM' => 'Арменія', + 'AG' => 'Антыгуа і Барбуда', + 'AU' => 'Аўстралія', + 'AT' => 'Аўстрыя', + 'AZ' => 'Азербайджан', + 'BI' => 'Бурундзі', + 'BE' => 'Бельгія', + 'BJ' => 'Бенін', + 'BF' => 'Буркіна-Фасо', + 'BD' => 'Бангладэш', + 'BG' => 'Балгарыя', + 'BH' => 'Бахрэйн', + 'BS' => 'Багамскія астравы', + 'BA' => 'Боснія і Герцагавіна', + 'BY' => 'Беларусь', + 'BZ' => 'Беліз', + 'BO' => 'Балівія', + 'BR' => 'Бразілія', + 'BB' => 'Барбадас', + 'BN' => 'Бруней', + 'BT' => 'Бутан', + 'BW' => 'Батсвана', + 'CF' => 'Цэнтральна-Афрыканская Рэспубліка', + 'CA' => 'Канада', + 'CH' => 'Швейцарыя', + 'CL' => 'Чылі', + 'CN' => 'Кітай', + 'CI' => 'Бераг Слановай Косці', + 'CM' => 'Камерун', + 'CD' => 'ДР Конга', + 'CG' => 'Рэспубліка Конга', + 'CO' => 'Калумбія', + 'KM' => 'Каморскія выспы', + 'CV' => 'Каба-Вэрдэ', + 'CR' => 'Коста-Рыка', + 'CU' => 'Куба', + 'CY' => 'Кіпр', + 'CZ' => 'Чэхія', + 'DE' => 'Германія', + 'DJ' => 'Джыбуці', + 'DM' => 'Дамініка', + 'DK' => 'Данія', + 'DO' => 'Дамініканская Рэспубліка', + 'DZ' => 'Алжыр', + 'EC' => 'Эквадор', + 'EG' => 'Егіпет', + 'ER' => 'Эрытрэя', + 'ES' => 'Іспанія', + 'EE' => 'Эстонія', + 'ET' => 'Эфіопія', + 'FI' => 'Фінляндыя', + 'FJ' => 'Фіджы', + 'FR' => 'Францыя', + 'FM' => 'Мікранезія', + 'GA' => 'Габон', + 'GB' => 'Вялікабрытанія', + 'GE' => 'Грузія', + 'GH' => 'Гана', + 'GN' => 'Гвінея', + 'GM' => 'Гамбія', + 'GW' => 'Гвінея-Бісаў', + 'GQ' => 'Экватарыяльная Гвінея', + 'GR' => 'Грэцыя', + 'GD' => 'Грэнада', + 'GT' => 'Гватэмала', + 'GY' => 'Гаяна', + 'HN' => 'Гандурас', + 'HR' => 'Харватыя', + 'HT' => 'Гаіці', + 'HU' => 'Венгрыя', + 'ID' => 'Інданезія', + 'IN' => 'Індыя', + 'IE' => 'Ірландыя', + 'IR' => 'Іран', + 'IQ' => 'Ірак', + 'IS' => 'Ісландыя', + 'IL' => 'Ізраіль', + 'IT' => 'Італія', + 'JM' => 'Ямайка', + 'JO' => 'Іарданія', + 'JP' => 'Японія', + 'KZ' => 'Казахстан', + 'KE' => 'Кенія', + 'KG' => 'Кыргызстан', + 'KH' => 'Камбоджа', + 'KI' => 'Кірыбаці', + 'KN' => 'Сэнт-Кітс і Нэвіс', + 'KR' => 'Паўднёвая Карэя', + 'KW' => 'Кувейт', + 'LA' => 'Лаос', + 'LB' => 'Ліван', + 'LR' => 'Ліберыя', + 'LY' => 'Лівія', + 'LC' => 'Сент-Люсія', + 'LI' => 'Ліхтэнштэйн', + 'LK' => 'Шры-Ланка', + 'LS' => 'Лесота', + 'LT' => 'Літва', + 'LU' => 'Люксембург', + 'LV' => 'Латвія', + 'MA' => 'Марока', + 'MC' => 'Манака', + 'MD' => 'Малдова', + 'MG' => 'Мадагаскар', + 'MV' => 'Мальдывы', + 'MX' => 'Мексіка', + 'MH' => 'Маршалавы Астравы', + 'MK' => 'Македонія', + 'ML' => 'Малі', + 'MT' => 'Мальта', + 'MM' => 'М\'янма', + 'ME' => 'Чарнагорыя', + 'MN' => 'Манголія', + 'MZ' => 'Мазамбік', + 'MR' => 'Маўрытанія', + 'MU' => 'Маўрыкій', + 'MW' => 'Малаві', + 'MY' => 'Малайзія', + 'NA' => 'Намібія', + 'NE' => 'Нігер', + 'NG' => 'Нігерыя', + 'NI' => 'Нікарагуа', + 'NL' => 'Нідэрланды', + 'NO' => 'Нарвегія', + 'NP' => 'Непал', + 'NR' => 'Науру', + 'NZ' => 'Новая Зеландыя', + 'OM' => 'Аман', + 'PK' => 'Пакістан', + 'PA' => 'Панама', + 'PE' => 'Перу', + 'PH' => 'Філіпіны', + 'PW' => 'Палаў', + 'PG' => 'Папуа-Новая Гвінея', + 'PL' => 'Польшча', + 'KP' => 'Паўночная Карэя', + 'PT' => 'Партугалія', + 'PY' => 'Парагвай', + 'QA' => 'Катар', + 'RO' => 'Румынія', + 'RU' => 'Расія', + 'RW' => 'Руанда', + 'SA' => 'Саудаўская Аравія', + 'SD' => 'Судан', + 'SN' => 'Сенегал', + 'SG' => 'Сінгапур', + 'SB' => 'Саламонавы Астравы', + 'SL' => 'Сьера-Леонэ', + 'SV' => 'Сальвадор', + 'SM' => 'Сан-Марына', + 'SO' => 'Самалі', + 'RS' => 'Сербія', + 'SS' => 'Паўднёвы Судан', + 'ST' => 'Сан-Таме і Прынсіпі', + 'SR' => 'Сурынам', + 'SK' => 'Славакія', + 'SI' => 'Славенія', + 'SE' => 'Швецыя', + 'SZ' => 'Свазіленд', + 'SC' => 'Сейшэльскія астравы', + 'SY' => 'Сірыя', + 'TD' => 'Чад', + 'TG' => 'Таго', + 'TH' => 'Тайланд', + 'TJ' => 'Таджыкістан', + 'TM' => 'Туркменістан', + 'TL' => 'Востраў Тымор', + 'TO' => 'Тонга', + 'TT' => 'Трынідад і Табага', + 'TN' => 'Туніс', + 'TR' => 'Турцыя', + 'TV' => 'Тувалу', + 'TZ' => 'Танзанія', + 'UG' => 'Уганда', + 'UA' => 'Украіна', + 'UY' => 'Уругвай', + 'US' => 'Злучаныя Штаты', + 'UZ' => 'Узбекістан', + 'VA' => 'Ватыкан', + 'VC' => 'Сэнт-Вінсэнт і Грэнадыны', + 'VE' => 'Венесуэла', + 'VN' => 'В\'етнам', + 'VU' => 'Вануату', + 'WS' => 'Самоа', + 'YE' => 'Емен', + 'ZA' => 'Паўднёвая Афрыка', + 'ZM' => 'Замбія', + 'ZW' => 'Зімбабвэ', +]; diff --git a/app/config/locale/translations/be.php b/app/config/locale/translations/be.php new file mode 100644 index 0000000000..e7bf58840e --- /dev/null +++ b/app/config/locale/translations/be.php @@ -0,0 +1,21 @@ + '"Мастацтва быць мудрым - гэта мастацтва ведаць, на што нельга звярнуць увагу."', // This is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'be', + 'settings.direction' => 'ltr', + + // Service - Users + 'account.emails.team' => 'Каманда %s', + 'account.emails.verification.title' => 'Праверка ўліковага запісу', + 'account.emails.verification.body' => 'be.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Скід пароля', + 'account.emails.recovery.body' => 'be.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Запрашэнне да каманды %s y %s', + 'account.emails.invitation.body' => 'be.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'Невядомы', + + 'countries' => include 'be.countries.php', + 'continents' => include 'be.continents.php', +]; diff --git a/app/config/locale/translations/bg.continents.php b/app/config/locale/translations/bg.continents.php new file mode 100644 index 0000000000..ade83e0b98 --- /dev/null +++ b/app/config/locale/translations/bg.continents.php @@ -0,0 +1,11 @@ + 'Африка', + 'AN' => 'Антарктида', + 'AS' => 'Азия', + 'EU' => 'Европа', + 'NA' => 'Северна Америка', + 'OC' => 'Океания', + 'SA' => 'Южна Америка', +]; diff --git a/app/config/locale/translations/bg.countries.php b/app/config/locale/translations/bg.countries.php new file mode 100644 index 0000000000..f6ae739ca3 --- /dev/null +++ b/app/config/locale/translations/bg.countries.php @@ -0,0 +1,198 @@ + 'Афганистан', + 'AO' => 'Ангола', + 'AL' => 'Албания', + 'AD' => 'Андора', + 'AE' => 'Обединени арабски емирства', + 'AR' => 'Аржентина', + 'AM' => 'Армения', + 'AG' => 'Антигуа и Барбуда', + 'AU' => 'Австралия', + 'AT' => 'Австрия', + 'AZ' => 'Азербайджан', + 'BI' => 'Бурунди', + 'BE' => 'Белгия', + 'BJ' => 'Бенин', + 'BF' => 'Буркина Фасо', + 'BD' => 'Бангладеш', + 'BG' => 'България', + 'BH' => 'Бахрейн', + 'BS' => 'Бахамски острови', + 'BA' => 'Босна и Херцеговина', + 'BY' => 'Беларус', + 'BZ' => 'Белиз', + 'BO' => 'Боливия', + 'BR' => 'Бразилия', + 'BB' => 'Барбадос', + 'BN' => 'Бруней', + 'BT' => 'Бутан', + 'BW' => 'Ботсвана', + 'CF' => 'Централноафриканска република', + 'CA' => 'Канада', + 'CH' => 'Швейцария', + 'CL' => 'Чили', + 'CN' => 'Китай', + 'CI' => 'Кот д\'Ивоар', + 'CM' => 'Камерун', + 'CD' => 'ДР Конго', + 'CG' => 'Република Конго', + 'CO' => 'Колумбия', + 'KM' => 'Коморски острови', + 'CV' => 'Кабо Верде', + 'CR' => 'Коста Рика', + 'CU' => 'Куба', + 'CY' => 'Кипър', + 'CZ' => 'Чехия', + 'DE' => 'Германия', + 'DJ' => 'Джибути', + 'DM' => 'Доминика', + 'DK' => 'Дания', + 'DO' => 'Доминиканска република', + 'DZ' => 'Алжир', + 'EC' => 'Еквадор', + 'EG' => 'Египет', + 'ER' => 'Еритрея', + 'ES' => 'Испания', + 'EE' => 'Естония', + 'ET' => 'Етиопия', + 'FI' => 'Финландия', + 'FJ' => 'Фиджи', + 'FR' => 'Франция', + 'FM' => 'Микронезия', + 'GA' => 'Габон', + 'GB' => 'Обединеното кралство', + 'GE' => 'Джорджия', + 'GH' => 'Гана', + 'GN' => 'Гвинея', + 'GM' => 'Гамбия', + 'GW' => 'Гвинея-Бисау', + 'GQ' => 'Екваториална Гвинея', + 'GR' => 'Гърция', + 'GD' => 'Гренада', + 'GT' => 'Гватемала', + 'GY' => 'Гвиана', + 'HN' => 'Хондурас', + 'HR' => 'Хърватия', + 'HT' => 'Хаити', + 'HU' => 'Унгария', + 'ID' => 'Индонезия', + 'IN' => 'Индия', + 'IE' => 'Ирландия', + 'IR' => 'Иран', + 'IQ' => 'Ирак', + 'IS' => 'Исландия', + 'IL' => 'Израел', + 'IT' => 'Италия', + 'JM' => 'Ямайка', + 'JO' => 'Йордания', + 'JP' => 'Япония', + 'KZ' => 'Казахстан', + 'KE' => 'Кения', + 'KG' => 'Киргизстан', + 'KH' => 'Камбоджа', + 'KI' => 'Кирибати', + 'KN' => 'Сейнт Китс и Невис', + 'KR' => 'Южна Корея', + 'KW' => 'Кувейт', + 'LA' => 'Лаос', + 'LB' => 'Ливан', + 'LR' => 'Либерия', + 'LY' => 'Либия', + 'LC' => 'Сейнт Лусия', + 'LI' => 'Лихтенщайн', + 'LK' => 'Шри Ланка', + 'LS' => 'Лесото', + 'LT' => 'Литва', + 'LU' => 'Люксембург', + 'LV' => 'Латвия', + 'MA' => 'Мароко', + 'MC' => 'Монако', + 'MD' => 'Молдова', + 'MG' => 'Мадагаскар', + 'MV' => 'Малдиви', + 'MX' => 'Мексико', + 'MH' => 'Маршалови острови', + 'MK' => 'Македония', + 'ML' => 'Мали', + 'MT' => 'Малта', + 'MM' => 'Мианмар', + 'ME' => 'Черна гора', + 'MN' => 'Монголия', + 'MZ' => 'Мозамбик', + 'MR' => 'Мавритания', + 'MU' => 'Мавриций', + 'MW' => 'Малави', + 'MY' => 'Малайзия', + 'NA' => 'Намибия', + 'NE' => 'Нигер', + 'NG' => 'Нигерия', + 'NI' => 'Никарагуа', + 'NL' => 'Холандия', + 'NO' => 'Норвегия', + 'NP' => 'Непал', + 'NR' => 'Науру', + 'NZ' => 'Нова Зеландия', + 'OM' => 'Оман', + 'PK' => 'Пакистан', + 'PA' => 'Панама', + 'PE' => 'Перу', + 'PH' => 'Филипини', + 'PW' => 'Палау', + 'PG' => 'Папуа Нова Гвинея', + 'PL' => 'Полша', + 'KP' => 'Северна Корея', + 'PT' => 'Португалия', + 'PY' => 'Парагвай', + 'QA' => 'Катар', + 'RO' => 'Румъния', + 'RU' => 'Русия', + 'RW' => 'Руанда', + 'SA' => 'Саудитска Арабия', + 'SD' => 'Судан', + 'SN' => 'Сенегал', + 'SG' => 'Сингапур', + 'SB' => 'Соломонови острови', + 'SL' => 'Сиера Леоне', + 'SV' => 'Ел Салвадор', + 'SM' => 'Сан Марино', + 'SO' => 'Сомалия', + 'RS' => 'Сърбия', + 'SS' => 'Южен Судан', + 'ST' => 'Сао Томе и Принсипи', + 'SR' => 'Суринам', + 'SK' => 'Словакия', + 'SI' => 'Словения', + 'SE' => 'Швеция', + 'SZ' => 'Свазиленд', + 'SC' => 'Сейшели', + 'SY' => 'Сирия', + 'TD' => 'Чад', + 'TG' => 'Того', + 'TH' => 'Тайланд', + 'TJ' => 'Таджикистан', + 'TM' => 'Туркменистан', + 'TL' => 'Восточен Тимор', + 'TO' => 'Тонга', + 'TT' => 'Тринидад и Тобаго', + 'TN' => 'Тунис', + 'TR' => 'Турция', + 'TV' => 'Тувалу', + 'TZ' => 'Танзания', + 'UG' => 'Уганда', + 'UA' => 'Украйна', + 'UY' => 'Уругвай', + 'US' => 'Съединени американски щати', + 'UZ' => 'Узбекистан', + 'VA' => 'Ватикан', + 'VC' => 'Сейнт Винсент и Гренадини', + 'VE' => 'Венецуела', + 'VN' => 'Виетнам', + 'VU' => 'Вануату', + 'WS' => 'Самоа', + 'YE' => 'Йемен', + 'ZA' => 'Южна Африка', + 'ZM' => 'Замбия', + 'ZW' => 'Зимбабве', +]; diff --git a/app/config/locale/translations/bg.php b/app/config/locale/translations/bg.php new file mode 100644 index 0000000000..1e9cc51df7 --- /dev/null +++ b/app/config/locale/translations/bg.php @@ -0,0 +1,21 @@ + '"Изкуството да бъдеш мъдър е изкуството да знаеш какво да пренебрегнеш."', // This is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'bg', + 'settings.direction' => 'ltr', + + // Service - Users + 'account.emails.team' => '%s Екип', + 'account.emails.verification.title' => 'Потвърждаване на профила', + 'account.emails.verification.body' => 'bg.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'Възстановяване на парола', + 'account.emails.recovery.body' => 'bg.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'Покана към %s екипа при %s', + 'account.emails.invitation.body' => 'bg.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'Неизвестно', + + 'countries' => include 'bg.countries.php', + 'continents' => include 'bg.continents.php', +]; diff --git a/app/config/locales/bn.continents.php b/app/config/locale/translations/bn.continents.php similarity index 100% rename from app/config/locales/bn.continents.php rename to app/config/locale/translations/bn.continents.php diff --git a/app/config/locales/bn.countries.php b/app/config/locale/translations/bn.countries.php similarity index 100% rename from app/config/locales/bn.countries.php rename to app/config/locale/translations/bn.countries.php diff --git a/app/config/locales/bn.php b/app/config/locale/translations/bn.php similarity index 100% rename from app/config/locales/bn.php rename to app/config/locale/translations/bn.php diff --git a/app/config/locales/cat.continents.php b/app/config/locale/translations/cat.continents.php similarity index 100% rename from app/config/locales/cat.continents.php rename to app/config/locale/translations/cat.continents.php diff --git a/app/config/locales/cat.countries.php b/app/config/locale/translations/cat.countries.php similarity index 100% rename from app/config/locales/cat.countries.php rename to app/config/locale/translations/cat.countries.php diff --git a/app/config/locales/cat.php b/app/config/locale/translations/cat.php similarity index 100% rename from app/config/locales/cat.php rename to app/config/locale/translations/cat.php diff --git a/app/config/locales/cz.continents.php b/app/config/locale/translations/cz.continents.php similarity index 100% rename from app/config/locales/cz.continents.php rename to app/config/locale/translations/cz.continents.php diff --git a/app/config/locales/cz.countries.php b/app/config/locale/translations/cz.countries.php similarity index 100% rename from app/config/locales/cz.countries.php rename to app/config/locale/translations/cz.countries.php diff --git a/app/config/locales/cz.php b/app/config/locale/translations/cz.php similarity index 100% rename from app/config/locales/cz.php rename to app/config/locale/translations/cz.php diff --git a/app/config/locales/de.continents.php b/app/config/locale/translations/de.continents.php similarity index 100% rename from app/config/locales/de.continents.php rename to app/config/locale/translations/de.continents.php diff --git a/app/config/locales/de.countries.php b/app/config/locale/translations/de.countries.php similarity index 100% rename from app/config/locales/de.countries.php rename to app/config/locale/translations/de.countries.php diff --git a/app/config/locales/de.php b/app/config/locale/translations/de.php similarity index 100% rename from app/config/locales/de.php rename to app/config/locale/translations/de.php diff --git a/app/config/locales/en.continents.php b/app/config/locale/translations/en.continents.php similarity index 100% rename from app/config/locales/en.continents.php rename to app/config/locale/translations/en.continents.php diff --git a/app/config/locales/en.countries.php b/app/config/locale/translations/en.countries.php similarity index 100% rename from app/config/locales/en.countries.php rename to app/config/locale/translations/en.countries.php diff --git a/app/config/locales/en.php b/app/config/locale/translations/en.php similarity index 100% rename from app/config/locales/en.php rename to app/config/locale/translations/en.php diff --git a/app/config/locales/es.continents.php b/app/config/locale/translations/es.continents.php similarity index 100% rename from app/config/locales/es.continents.php rename to app/config/locale/translations/es.continents.php diff --git a/app/config/locales/es.countries.php b/app/config/locale/translations/es.countries.php similarity index 100% rename from app/config/locales/es.countries.php rename to app/config/locale/translations/es.countries.php diff --git a/app/config/locales/es.php b/app/config/locale/translations/es.php similarity index 92% rename from app/config/locales/es.php rename to app/config/locale/translations/es.php index efe6c53fa9..eec059533e 100644 --- a/app/config/locales/es.php +++ b/app/config/locale/translations/es.php @@ -9,7 +9,7 @@ return [ 'account.emails.team' => 'Equipo %s', 'account.emails.verification.title' => 'Confirmación de la cuenta', 'account.emails.verification.body' => 'es.email.auth.confirm.tpl', - 'account.emails.recovery.title' => 'Reestablecer contraseña', + 'account.emails.recovery.title' => 'Restablecer contraseña', 'account.emails.recovery.body' => 'es.email.auth.recovery.tpl', 'account.emails.invitation.title' => 'Invitación al Equipo %s en %s', 'account.emails.invitation.body' => 'es.email.auth.invitation.tpl', diff --git a/app/config/locale/translations/fa.continents.php b/app/config/locale/translations/fa.continents.php new file mode 100644 index 0000000000..e55e8f9f3c --- /dev/null +++ b/app/config/locale/translations/fa.continents.php @@ -0,0 +1,11 @@ + 'آفریقا', + 'AN' => 'قطب جنوب', + 'AS' => 'آسیا', + 'EU' => 'اروپا', + 'NA' => 'آمریکای شمالی', + 'OC' => 'اقیانوسیه', + 'SA' => 'آمریکای جنوبی', +]; diff --git a/app/config/locale/translations/fa.countries.php b/app/config/locale/translations/fa.countries.php new file mode 100644 index 0000000000..28a5ae0ae1 --- /dev/null +++ b/app/config/locale/translations/fa.countries.php @@ -0,0 +1,198 @@ + 'افقانستان', + 'AO' => 'آنگولا', + 'AL' => 'آلبانی', + 'AD' => 'آندورا', + 'AE' => 'امارات متحده عربی', + 'AR' => 'آرژانتین', + 'AM' => 'ارمنستان', + 'AG' => 'آنتیگوا و باربودا', + 'AU' => 'استرالیا', + 'AT' => 'اتریش', + 'AZ' => 'آذربایجان', + 'BI' => 'بوروندی', + 'BE' => 'بلژیک', + 'BJ' => 'بنین', + 'BF' => 'بورکینافاسو', + 'BD' => 'بنگلادش', + 'BG' => 'بلغارستان', + 'BH' => 'بحرین', + 'BS' => 'باهاما', + 'BA' => 'بوسنی و هرزگوین', + 'BY' => 'بلاروس', + 'BZ' => 'بلیز', + 'BO' => 'بولیوی', + 'BR' => 'برزیل', + 'BB' => 'باربادوس', + 'BN' => 'برونئی', + 'BT' => 'بوتان', + 'BW' => 'بوتسوانا', + 'CF' => 'جمهوری آفریقای مرکزی', + 'CA' => 'کانادا', + 'CH' => 'سوئیس', + 'CL' => 'شیلی', + 'CN' => 'چین', + 'CI' => 'ساحل عاج', + 'CM' => 'کامرون', + 'CD' => 'کنگو', + 'CG' => 'جمهوری کنگو', + 'CO' => 'کلمبیا', + 'KM' => 'کومور', + 'CV' => 'کیپ ورد', + 'CR' => 'کاستاریکا', + 'CU' => 'کوبا', + 'CY' => 'قبرس', + 'CZ' => 'جمهوری چک', + 'DE' => 'آلمان', + 'DJ' => 'جیبوتی', + 'DM' => 'دومینیکا', + 'DK' => 'دانمارک', + 'DO' => 'جمهوری دومینیکا', + 'DZ' => 'الجزیره', + 'EC' => 'اکوادور', + 'EG' => 'مصر', + 'ER' => 'اریتره', + 'ES' => 'اسپانیا', + 'EE' => 'استونی', + 'ET' => 'اتیوپی', + 'FI' => 'فنلاند', + 'FJ' => 'فیجی', + 'FR' => 'فرانسه', + 'FM' => 'میکرونزی', + 'GA' => 'گابن', + 'GB' => 'انگلستان', + 'GE' => 'گرجستان', + 'GH' => 'غنا', + 'GN' => 'گینه', + 'GM' => 'گامبیا', + 'GW' => 'گینه بیسائو', + 'GQ' => 'گینه استوایی', + 'GR' => 'یونان', + 'GD' => 'گرنادا', + 'GT' => 'گواتمالا', + 'GY' => 'گویان', + 'HN' => 'هندوراس', + 'HR' => 'کرواسی', + 'HT' => 'هائیتی', + 'HU' => 'مجارستان', + 'ID' => 'اندونزی', + 'IN' => 'هند', + 'IE' => 'ایرلند', + 'IR' => 'ایران', + 'IQ' => 'عراث', + 'IS' => 'ایسلند', + 'IL' => 'اسرائیل', + 'IT' => 'ایتالیا', + 'JM' => 'جاماییکا', + 'JO' => 'اردن', + 'JP' => 'جاپن', + 'KZ' => 'قزاقستان', + 'KE' => 'کنیا', + 'KG' => 'قرقیزستان', + 'KH' => 'کامبوج', + 'KI' => 'کیریباتی', + 'KN' => 'سنت کیتس و نویس', + 'KR' => 'کرخ جنوبی', + 'KW' => 'کویت', + 'LA' => 'لائوس', + 'LB' => 'لبنان', + 'LR' => 'لیبریا', + 'LY' => 'لیبی', + 'LC' => 'سنت لوسیا', + 'LI' => 'لیختن اشتاین', + 'LK' => 'سریلانکا', + 'LS' => 'لسوتو', + 'LT' => 'لیتوانی', + 'LU' => 'لوکزامبورگ', + 'LV' => 'لتونی', + 'MA' => 'مراکش', + 'MC' => 'موناکو', + 'MD' => 'مولداوی', + 'MG' => 'ماداگاسکار', + 'MV' => 'مالدیو', + 'MX' => 'مکزیک', + 'MH' => 'جزایر مارشال', + 'MK' => 'مقدونیه', + 'ML' => 'مالی', + 'MT' => 'مالتا', + 'MM' => 'میانمار', + 'ME' => 'مونته نگرو', + 'MN' => 'مغولستان', + 'MZ' => 'موزامبیک', + 'MR' => 'موریتانی', + 'MU' => 'موریس', + 'MW' => 'مالاوی', + 'MY' => 'مالزی', + 'NA' => 'نامیبیا', + 'NE' => 'نیجر', + 'NG' => 'نیجریه', + 'NI' => 'نیکاراگوئه', + 'NL' => 'هلند', + 'NO' => 'نروژ', + 'NP' => 'نپال', + 'NR' => 'نائورو', + 'NZ' => 'نیوزلند', + 'OM' => 'عمان', + 'PK' => 'پاکستان', + 'PA' => 'پاناما', + 'PE' => 'پرو', + 'PH' => 'فیلیپین', + 'PW' => 'پالائو', + 'PG' => 'پاپوآ گینه نو', + 'PL' => 'لهستان', + 'KP' => 'کره شمالی', + 'PT' => 'پرتغال', + 'PY' => 'پاراگوئه', + 'QA' => 'قطر', + 'RO' => 'رومانی', + 'RU' => 'روسیه', + 'RW' => 'رواندا', + 'SA' => 'عربستان سعودی', + 'SD' => 'سودان', + 'SN' => 'سنگال', + 'SG' => 'سنگاپور', + 'SB' => 'جزایر سلیمان', + 'SL' => 'سیرا لئون', + 'SV' => 'السالوادور', + 'SM' => 'سان مارینو', + 'SO' => 'سومالی', + 'RS' => 'صربستان', + 'SS' => 'سودان جنوبی', + 'ST' => 'سائو تومه و پرنسیپ', + 'SR' => 'سورینام', + 'SK' => 'اسلواکی', + 'SI' => 'اسلوونی', + 'SE' => 'سوئد', + 'SZ' => 'سوئیس', + 'SC' => 'سیشل', + 'SY' => 'سوریه', + 'TD' => 'چاد', + 'TG' => 'توگپ', + 'TH' => 'تایلند', + 'TJ' => 'تاجیکستان', + 'TM' => 'ترکمنستان', + 'TL' => 'تیمور-لسته', + 'TO' => 'تونگا', + 'TT' => 'ترینیداد و توباگو', + 'TN' => 'تونس', + 'TR' => 'ترکیه', + 'TV' => 'تووالو', + 'TZ' => 'تانزانیا', + 'UG' => 'اوگاندا', + 'UA' => 'اوکراین', + 'UY' => 'اوگوئه', + 'US' => 'ایالات متحده آمریکا', + 'UZ' => 'ازبکستان', + 'VA' => 'شهر واتیکان', + 'VC' => 'سنت وینسنت و گرنادین ها', + 'VE' => 'ونزوئلا', + 'VN' => 'ویتنام', + 'VU' => 'وانواتو', + 'WS' => 'ساموآ', + 'YE' => 'یمن', + 'ZA' => 'آفریقای جنوبی', + 'ZM' => 'زامبیا', + 'ZW' => 'زیمباوه', +]; diff --git a/app/config/locale/translations/fa.php b/app/config/locale/translations/fa.php new file mode 100644 index 0000000000..35fb30afc7 --- /dev/null +++ b/app/config/locale/translations/fa.php @@ -0,0 +1,21 @@ + '"هنر خردمند بودن، هنر دانستن چیزی است که باید از آن غافل شد."', // This is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'fa', + 'settings.direction' => 'rtl', + + // Service - Users + 'account.emails.team' => 'تیم %s', + 'account.emails.verification.title' => 'تایید حساب کاربری', + 'account.emails.verification.body' => 'fa.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'بازیابی رمز عبور', + 'account.emails.recovery.body' => 'fa.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'دعوتنامه به تیم %s در %s', + 'account.emails.invitation.body' => 'fa.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'ناشناخته', + + 'countries' => include 'fa.countries.php', + 'continents' => include 'fa.continents.php', +]; diff --git a/app/config/locales/fi.continents.php b/app/config/locale/translations/fi.continents.php similarity index 100% rename from app/config/locales/fi.continents.php rename to app/config/locale/translations/fi.continents.php diff --git a/app/config/locales/fi.countries.php b/app/config/locale/translations/fi.countries.php similarity index 100% rename from app/config/locales/fi.countries.php rename to app/config/locale/translations/fi.countries.php diff --git a/app/config/locales/fi.php b/app/config/locale/translations/fi.php similarity index 77% rename from app/config/locales/fi.php rename to app/config/locale/translations/fi.php index a39a830e72..c9e6c7eee9 100644 --- a/app/config/locales/fi.php +++ b/app/config/locale/translations/fi.php @@ -8,11 +8,11 @@ return [ // Service - Users 'account.emails.team' => '%s Tiimi', 'account.emails.verification.title' => 'Tilin Vahvistus', - 'account.emails.verification.body' => 'en.email.auth.confirm.tpl', + 'account.emails.verification.body' => 'fi.email.auth.confirm.tpl', 'account.emails.recovery.title' => 'Salasanan Nollaus', - 'account.emails.recovery.body' => 'en.email.auth.recovery.tpl', + 'account.emails.recovery.body' => 'fi.email.auth.recovery.tpl', 'account.emails.invitation.title' => 'Kutsu %s Tiimiin %s', - 'account.emails.invitation.body' => 'en.email.auth.invitation.tpl', + 'account.emails.invitation.body' => 'fi.email.auth.invitation.tpl', 'locale.country.unknown' => 'Unknown', diff --git a/app/config/locales/fo.continents.php b/app/config/locale/translations/fo.continents.php similarity index 100% rename from app/config/locales/fo.continents.php rename to app/config/locale/translations/fo.continents.php diff --git a/app/config/locales/fo.countries.php b/app/config/locale/translations/fo.countries.php similarity index 100% rename from app/config/locales/fo.countries.php rename to app/config/locale/translations/fo.countries.php diff --git a/app/config/locales/fo.php b/app/config/locale/translations/fo.php similarity index 100% rename from app/config/locales/fo.php rename to app/config/locale/translations/fo.php diff --git a/app/config/locales/fr.continents.php b/app/config/locale/translations/fr.continents.php similarity index 100% rename from app/config/locales/fr.continents.php rename to app/config/locale/translations/fr.continents.php diff --git a/app/config/locales/fr.countries.php b/app/config/locale/translations/fr.countries.php similarity index 100% rename from app/config/locales/fr.countries.php rename to app/config/locale/translations/fr.countries.php diff --git a/app/config/locales/fr.php b/app/config/locale/translations/fr.php similarity index 100% rename from app/config/locales/fr.php rename to app/config/locale/translations/fr.php diff --git a/app/config/locales/gr.continents.php b/app/config/locale/translations/gr.continents.php similarity index 100% rename from app/config/locales/gr.continents.php rename to app/config/locale/translations/gr.continents.php diff --git a/app/config/locales/gr.countries.php b/app/config/locale/translations/gr.countries.php similarity index 100% rename from app/config/locales/gr.countries.php rename to app/config/locale/translations/gr.countries.php diff --git a/app/config/locales/gr.php b/app/config/locale/translations/gr.php similarity index 100% rename from app/config/locales/gr.php rename to app/config/locale/translations/gr.php diff --git a/app/config/locale/translations/gu.continents.php b/app/config/locale/translations/gu.continents.php new file mode 100644 index 0000000000..a7dc5f7c63 --- /dev/null +++ b/app/config/locale/translations/gu.continents.php @@ -0,0 +1,11 @@ + 'આફ્રિકા', + 'AN' => 'એન્ટાર્કટિકા', + 'AS' => 'એશિયા', + 'EU' => 'યુરોપ', + 'NA' => 'ઉત્તર અમેરિકા', + 'OC' => 'ઓશનિયા', + 'SA' => 'દક્ષિણ અમેરિકા', +]; diff --git a/app/config/locale/translations/gu.countries.php b/app/config/locale/translations/gu.countries.php new file mode 100644 index 0000000000..aed6dc6c1f --- /dev/null +++ b/app/config/locale/translations/gu.countries.php @@ -0,0 +1,200 @@ + 'અફઘાનિસ્તાન', + 'AO' => 'અંગોલા', + 'AL' => 'અલ્બેનિયા', + 'AD' => 'એન્ડોરા', + 'AE' => 'સંયુક્ત આરબ અમીરાત', + 'AR' => 'આર્જેન્ટિના', + 'AM' => 'આર્મેનિયા', + 'AG' => 'એન્ટિગુઆ અને બાર્બુડા', + 'AU' => 'સ્ટ્રેલિયા', + 'AT' => 'ઑસ્ટ્રિયા', + 'AZ' => 'અઝરબૈજાન', + 'BI' => 'બરુંડી', + 'BE' => 'બેલ્જિયમ', + 'BJ' => 'બેનિન', + 'BF' => 'બુર્કિના ફાસો', + 'BD' => 'બાંગ્લાદેશ', + 'BG' => 'બલ્ગેરિયા', + 'BH' => 'બહરીન', + 'BS' => 'બહામાસ', + 'BA' => 'બોસ્નિયા અને હર્ઝેગોવિના', + 'BY' => 'બેલારુસ', + 'BZ' => 'બેલીઝ', + 'BO' => 'બોલિવિયા', + 'BR' => 'બ્રાઝિલ', + 'BB' => 'બાર્બાડોઝ', + 'BN' => 'બ્રુનેઇ', + 'BT' => 'ભૂટાન', + 'BW' => 'બોત્સ્વાના', + 'CF' => 'સેન્ટ્રલ આફ્રિકન રિપબ્લિક', + 'CA' => 'કેનેડા', + 'CH' => 'સ્વિટ્ઝર્લન્ડ', + 'CL' => 'ચિલી', + 'CN' => 'ચાઇના', + 'CI' => 'આઇવરી કોસ્ટ', + 'CM' => 'કેમરૂન', + 'CD' => 'ડીઆર કોંગો', + 'CG' => 'રિપબ્લિક ઓફ કોંગો', + 'CO' => 'કોલમ્બિયા', + 'KM' => 'કોમોરોઝ', + 'CV' => 'કેપ વર્ડે', + 'CR' => 'કોસ્ટા રિકા', + 'CU' => 'ક્યુબા', + 'CY' => 'સાયપ્રસ', + 'CZ' => 'ચેકિયા', + 'DE' => 'જર્મની', + 'DJ' => 'જીબુટી', + 'DM' => 'ડોમિનિકા', + 'DK' => 'ડેનમાર્ક', + 'DO' => 'ડોમિનિકન રિપબ્લિક', + 'DZ' => 'અલ્જેરિયા', + 'ER' => 'એરિટ્રીઆ', + 'EC' => 'એક્વાડોર', + 'EG' => 'ઇજિપ્ત', + 'IR' => 'એરિટ્રીઆ', + 'ES' => 'સ્પેન', + 'EE' => 'એસ્ટોનીયા', + 'ET' => 'ઇથોપિયા', + 'FI' => 'ફિનલેન્ડ', + 'FJ' => 'ફીજી', + 'FR' => 'ફ્રાંસ', + 'FM' => 'માઇક્રોનેસીયા', + 'GA' => 'ગેબોન', + 'GB' => 'યુનાઇટેડ કિંગડમ', + 'GE' => 'જ્યોર્જિયા', + 'GH' => 'ઘાના', + 'GN' => 'ગિની', + 'GM' => 'ગાંબિયા', + 'GW' => 'ગિની-બિસાઉ', + 'GQ' => 'ઇક્વેટોરિયલ ગિની', + 'GR' => 'ગ્રીસ', + 'GD' => 'ગ્રેનાડા', + 'GT' => 'ગ્વાટેમાલા', + 'GY' => 'ગુયાના', + 'HN' => 'હોન્ડુરાસ', + 'HR' => 'ક્રોએશિયા', + 'HT' => 'હૈતી', + 'HU' => 'હંગેરી', + 'ID' => 'ઇન્ડોનેશિયા', + 'IN' => 'ભારત', + 'IE' => 'આયર્લેન્ડ', + 'IR' => 'ઈરાન', + 'IQ' => 'ઇરાક', + 'IS' => 'આઇસલેન્ડ', + 'IL' => 'ઇઝરાઇલ', + 'IT' => 'ઇટાલી', + 'JM' => 'જમૈકા', + 'JO' => 'જોર્ડન', + 'JP' => 'જાપાન', + 'KZ' => 'કઝાકિસ્તાન', + 'KE' => 'કેન્યા', + 'KG' => 'કિર્ગીસ્તાન', + 'KH' => 'કંબોડિયા', + 'KI' => 'કિરીબતી', + 'KN' => 'સેન્ટ કિટ્સ એન્ડ નેવિસ', + 'KR' => 'દક્ષિણ કોરિયા', + 'KW' => 'કુવૈત', + 'LA' => 'લાઓસ', + 'LB' => 'લેબેનોન', + 'LR' => 'લાઇબેરિયા', + 'LY' => 'લિબિયા', + 'LC' => 'સેન્ટ લુસિયા', + 'LI' => 'લિક્ટેનસ્ટેઇન', + 'LK' => 'શ્રીલંકા', + 'LS' => 'લેસોથો', + 'LT' => 'લિથુનીયા', + 'LU' => 'લક્ઝમબર્ગ', + 'LV' => 'લાતવિયા', + 'MA' => 'મોરોક્કો', + 'MC' => 'મોનાકો', + 'MD' => 'મોલ્ડોવા', + 'MG' => 'મેડાગાસ્કર', + 'MV' => 'માલદીવ', + 'MX' => 'મેક્સિકો', + 'MH' => 'માર્શલ આઇલેન્ડ્સ', + 'MK' => 'મેસેડોનિયા', + 'ML' => 'લોહી', + 'MT' => 'માલ્ટા', + 'MM' => 'મ્યાનમાર', + 'ME' => 'મોન્ટેનેગ્રો', + 'MN' => 'મંગોલિયા', + 'MZ' => 'મોઝામ્બિક', + 'MR' => 'મૌરિટાનિયા', + 'MU' => 'મોરિશિયસ', + 'MW' => 'માલાવી', + 'MY' => 'મલેશિયા', + 'NA' => 'નમિબીઆ', + 'NE' => 'નાઇજર', + 'NG' => 'નાઇજીરીયા', + 'NI' => 'નિકારાગુઆ', + 'NL' => 'નેધરલેન્ડ', + 'NO' => 'નોર્વે', + 'NP' => 'નેપાળ', + 'NR' => 'નારુ', + 'NZ' => 'ન્યુઝીલેન્ડ', + 'OM' => 'ઓમાન', + 'PK' => 'પાકિસ્તાન', + 'PA' => 'પનામા', + 'PE' => 'પેરુ', + 'PH' => 'ફિલિપાઇન્સ', + 'PW' => 'પલાઉ', + 'PG' => 'પપુઆ ન્યુ ગિની', + 'PL' => 'પોલેન્ડ', + 'KP' => 'ઉત્તર કોરિયા', + 'PT' => 'પોર્ટુગલ', + 'PY' => 'પેરાગ્વે', + 'QA' => 'કતાર', + 'RO' => 'રોમાનિયા', + 'RU' => 'રશિયા', + 'RW' => 'રવાંડા', + 'SA' => 'સાઉદી અરેબિયા', + 'SD' => 'સુદાન', + 'SN' => 'સેનેગલ', + 'SG' => 'સિંગાપુર', + 'SB' => 'સોલોમન આઇલેન્ડ્સ', + 'SL' => 'સીએરા લિયોન', + 'SV' => 'અલ સાલ્વાડોર', + 'SM' => 'સાન મેરિનો', + 'SO' => 'સોમાલિયા', + 'RS' => 'સર્બિયા', + 'SS' => 'દક્ષિણ સુદાન', + 'ST' => 'સાઓ ટોમ અને પ્રિન્સિપેટ', + 'SR' => 'સુરીનામ', + 'SK' => 'સ્લોવાકિયા', + 'SI' => 'સ્લોવેનીયા', + 'SE' => 'સ્વીડન', + 'SZ' => 'સ્વાઝીલેન્ડ', + 'SC' => 'સેશેલ્સ', + 'SY' => 'સીરિયા', + 'TD' => 'ચાડ', + 'TG' => 'ટોગો', + 'TH' => 'થાઇલેન્ડ', + 'TJ' => 'તાજિકિસ્તાન', + 'TM' => 'તુર્કમેનિસ્તાન', + 'TL' => 'તિમોર-લેસ્ટે', + 'TO' => 'ટોંગા', + 'TT' => 'ત્રિનિદાદ અને ટોબેગો', + 'TN' => 'ટ્યુનિશિયા', + 'TR' => 'તુર્કી', + 'TV' => 'તુવાલુ', + 'TZ' => 'તાંઝાનિયા', + 'UG' => 'યુગાન્ડા', + 'UA' => 'યુક્રેન', + 'UY' => 'ઉરુગ્વે', + 'US' => 'યુનાઈટેડ સ્ટેટ્સ અમેરિકા', + 'UZ' => 'ઉઝબેકિસ્તાન', + 'VA' => 'વેટિકન સિટી', + 'VC' => 'સેન્ટ વિન્સેન્ટ એન્ડ ગ્રેનેડાઇન્સ', + 'VE' => 'વેનેઝુએલા', + 'VN' => 'વિયેટનામ', + 'VU' => 'વનુઆતુ', + 'WS' => 'સમોઆ', + 'YE' => 'યમન', + 'ZA' => 'દક્ષિણ આફ્રિકા', + 'ZM' => 'ઝામ્બિયા', + 'ZW' => 'ઝિમ્બાબ્વે', +]; diff --git a/app/config/locale/translations/gu.php b/app/config/locale/translations/gu.php new file mode 100644 index 0000000000..677c4827c6 --- /dev/null +++ b/app/config/locale/translations/gu.php @@ -0,0 +1,21 @@ + '"સ્માર્ટ બનવાની કળા એ છે કે શું અવગણવું તે જાણવાની કળા છે."', // Tmrs is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'gu', + 'settings.direction' => 'ltr', + + // Service - Users + 'account.emails.team' => '%s ટીમ', + 'account.emails.verification.title' => 'ખાતાની પુષ્ટિ ', + 'account.emails.verification.body' => 'gu.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'પાસવૉર્ડ રીસેટ ', + 'account.emails.recovery.body' => 'gu.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'આમંત્રણ %s ટીમ %s', + 'account.emails.invitation.body' => 'gu.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'अज्ञात', + + 'countries' => include 'gu.countries.php', + 'continents' => include 'gu.continents.php', +]; diff --git a/app/config/locales/he.continents.php b/app/config/locale/translations/he.continents.php similarity index 100% rename from app/config/locales/he.continents.php rename to app/config/locale/translations/he.continents.php diff --git a/app/config/locales/he.countries.php b/app/config/locale/translations/he.countries.php similarity index 100% rename from app/config/locales/he.countries.php rename to app/config/locale/translations/he.countries.php diff --git a/app/config/locales/he.php b/app/config/locale/translations/he.php similarity index 100% rename from app/config/locales/he.php rename to app/config/locale/translations/he.php diff --git a/app/config/locales/hi.continents.php b/app/config/locale/translations/hi.continents.php similarity index 100% rename from app/config/locales/hi.continents.php rename to app/config/locale/translations/hi.continents.php diff --git a/app/config/locale/translations/hi.countries.php b/app/config/locale/translations/hi.countries.php new file mode 100644 index 0000000000..c3e748492a --- /dev/null +++ b/app/config/locale/translations/hi.countries.php @@ -0,0 +1,199 @@ + 'अफ़ग़ानिस्तान', + 'AO' => 'अंगोला', + 'AL' => 'अल्बानिया', + 'AD' => 'अंडोरा', + 'AE' => 'संयुक्त अरब अमीरात', + 'AR' => 'अर्जेंटीना', + 'AM' => 'आर्मीनिया', + 'AG' => 'अंटीगुआ और बारबूडा', + 'AU' => 'ऑस्ट्रेलिया', + 'AT' => 'ऑस्ट्रिया', + 'AZ' => 'अज़रबैजान', + 'BI' => 'बुरुंडी', + 'BE' => 'बेल्जियम', + 'BJ' => 'बेनिन', + 'BF' => 'बुर्किना फासो', + 'BD' => 'बांग्लादेश', + 'BG' => 'बुल्गारिया', + 'BH' => 'बहरीन', + 'BS' => 'बहामास', + 'BA' => 'बॉस्निया और हर्ज़ेगोविना', + 'BY' => 'बेलारूस', + 'BZ' => 'बेलीज़', + 'BO' => 'बोलीविया', + 'BR' => 'ब्राज़ील', + 'BB' => 'बारबाडोस', + 'BN' => 'ब्रुनेई', + 'BT' => 'भूटान', + 'BW' => 'बोत्सवाना', + 'CF' => 'मध्य अफ्रीकी गणराज्य', + 'CA' => 'कनाडा', + 'CH' => 'स्विट्ज़रलैंड', + 'CL' => 'चिली', + 'CN' => 'चीन', + 'CI' => 'आइवरी कोस्ट', + 'CM' => 'कैमरून', + 'CD' => 'कांगो लोकतान्त्रिक गणराज्य', + 'CG' => 'कांगो गणराज्य', + 'CO' => 'कोलंबिया', + 'KM' => 'कोमोरोस', + 'CV' => 'केप वर्दे', + 'CR' => 'कोस्टा रीका', + 'CU' => 'क्यूबा', + 'CY' => 'साइप्रस', + 'CZ' => 'चेक गणराज्य', + 'DE' => 'जर्मनी', + 'DJ' => 'जिबूती', + 'DM' => 'डोमिनिका', + 'DK' => 'डेनमार्क', + 'DO' => 'डोमिनिकन रिपब्लिक', + 'DZ' => 'अल्जीरिया', + 'ER' => 'इरित्रिया', + 'EC' => 'ईक्वाडोर', + 'EG' => 'मिस्र', + 'ES' => 'स्पेन', + 'EE' => 'एस्टोनिया', + 'ET' => 'इथियोपिया', + 'FI' => 'फ़िनलैंड', + 'FJ' => 'फ़िजी', + 'FR' => 'फ्रांस', + 'FM' => 'माइक्रोनेशिया', + 'GA' => 'गबोन', + 'GB' => 'यूनाइटेड किंगडम', + 'GE' => 'जॉर्जिया', + 'GH' => 'घाना', + 'GN' => 'गिनी', + 'GM' => 'ज़ाम्बिया', + 'GW' => 'गिनी-बिसाऊ', + 'GQ' => 'इक्वेटोरियल गिनी', + 'GR' => 'यूनान', + 'GD' => 'ग्रेनाडा', + 'GT' => 'ग्वाटेमाला', + 'GY' => 'गयाना', + 'HN' => 'होंडुरस', + 'HR' => 'क्रोएशिया', + 'HT' => 'हैती', + 'HU' => 'हंगरी', + 'ID' => 'इंडोनेशिया', + 'IN' => 'भारत', + 'IE' => 'आयरलैंड', + 'IR' => 'ईरान', + 'IQ' => 'इराक', + 'IS' => 'आइसलैंड', + 'IL' => 'इज़राइल', + 'IT' => 'इटली', + 'JM' => 'जमैका', + 'JO' => 'जॉर्डन', + 'JP' => 'जापान', + 'KZ' => 'कज़ाख़िस्तान', + 'KE' => 'कीनियाा', + 'KG' => 'किर्गिज़स्तान', + 'KH' => 'कंबोडिया', + 'KI' => 'किरिबाती', + 'KN' => 'सेंट किट्स एंड नेविस', + 'KR' => 'दक्षिण कोरिया', + 'KW' => 'कुवैत', + 'LA' => 'लाओस', + 'LB' => 'लेबनान', + 'LR' => 'लाइबेरिया', + 'LY' => 'लीबिया', + 'LC' => 'सेंट लूसिया', + 'LI' => 'लिकटेंस्टीन', + 'LK' => 'श्रीलंका', + 'LS' => 'लेसोथो', + 'LT' => 'लिथुआनिया', + 'LU' => 'लक्ज़मबर्ग', + 'LV' => 'लातविया', + 'MA' => 'मोरक्को', + 'MC' => 'मोनैको', + 'MD' => 'मॉल्डोवा', + 'MG' => 'मेडागास्कर', + 'MV' => 'मालदीव', + 'MX' => 'मेक्सिको', + 'MH' => 'मार्शल द्वीपसमूह', + 'MK' => 'मैसिडोनिया', + 'ML' => 'माली', + 'MT' => 'माल्टा', + 'MM' => 'म्यांमार', + 'ME' => 'मोंटेनेग्रो', + 'MN' => 'मंगोलिया', + 'MZ' => 'मोज़ाम्बिक', + 'MR' => 'मॉरिटानिया', + 'MU' => 'मॉरिशस', + 'MW' => 'मलावी', + 'MY' => 'मलेशिया', + 'NA' => 'नामीबिया', + 'NE' => 'नाइजर', + 'NG' => 'नाईजीरिया', + 'NI' => 'निकारागुआ', + 'NL' => 'नीदरलैंड', + 'NO' => 'नॉर्वे', + 'NP' => 'नेपाल', + 'NR' => 'नाउरु', + 'NZ' => 'न्यूजीलैंड', + 'OM' => 'ओमान', + 'PK' => 'पाकिस्तान', + 'PA' => 'पनामा', + 'PE' => 'पेरू', + 'PH' => 'फिलीपींस', + 'PW' => 'पलाऊ', + 'PG' => 'पापुआ न्यू गिनी', + 'PL' => 'पोलैंड', + 'KP' => 'उत्तर कोरिया', + 'PT' => 'पुर्तगाल', + 'PY' => 'पैराग्वे', + 'QA' => 'क़तर', + 'RO' => 'रोमानिया', + 'RU' => 'रूस', + 'RW' => 'रवांडा', + 'SA' => 'सऊदी अरब', + 'SD' => 'सूडान', + 'SN' => 'सेनेगल', + 'SG' => 'सिंगापुर', + 'SB' => 'सोलोमन द्वीप', + 'SL' => 'सिएरा लियोन', + 'SV' => 'अल साल्वाडोर', + 'SM' => 'सैन मैरिनो', + 'SO' => 'सोमालिया', + 'RS' => 'सर्बिया', + 'SS' => 'दक्षिण सूडान', + 'ST' => 'साओ तोमे और प्रिंसिपी', + 'SR' => 'सूरीनाम', + 'SK' => 'स्लोवाकिया', + 'SI' => 'स्लोवेनिया', + 'SE' => 'स्वीडन', + 'SZ' => 'स्वाज़ीलैंड', + 'SC' => 'सेशेल्स', + 'SY' => 'सीरिया', + 'TD' => 'चाड', + 'TG' => 'टोगो', + 'TH' => 'थाईलैंड', + 'TJ' => 'ताजिकिस्तान', + 'TM' => 'तुर्कमेनिस्तान', + 'TL' => 'तिमोर-लेस्ते', + 'TO' => 'टोंगा', + 'TT' => 'त्रिनिदाद और टोबैगो', + 'TN' => 'ट्यूनीशिया', + 'TR' => 'तुर्की', + 'TV' => 'तुवालू', + 'TZ' => 'तंजानिया', + 'UG' => 'युगांडा', + 'UA' => 'यूक्रेन', + 'UY' => 'उरुग्वे', + 'US' => 'संयुक्त राज्य अमेरिका', + 'UZ' => 'उज़्बेकिस्तान', + 'VA' => 'वैटिकन सिटी', + 'VC' => 'सेंट विंसेंट एंड ग्रेनेडाइंस', + 'VE' => 'वेनेज़ुएला', + 'VN' => 'वियतनाम', + 'VU' => 'वानूआतू', + 'WS' => 'समोआ', + 'YE' => 'यमन', + 'ZA' => 'दक्षिण अफ्रीका', + 'ZM' => 'ज़ाम्बिया', + 'ZW' => 'ज़िम्बाब्वे', +]; diff --git a/app/config/locales/hi.php b/app/config/locale/translations/hi.php similarity index 100% rename from app/config/locales/hi.php rename to app/config/locale/translations/hi.php diff --git a/app/config/locales/hu.continents.php b/app/config/locale/translations/hu.continents.php similarity index 100% rename from app/config/locales/hu.continents.php rename to app/config/locale/translations/hu.continents.php diff --git a/app/config/locales/hu.countries.php b/app/config/locale/translations/hu.countries.php similarity index 91% rename from app/config/locales/hu.countries.php rename to app/config/locale/translations/hu.countries.php index 949313c35a..d7e9c7f877 100644 --- a/app/config/locales/hu.countries.php +++ b/app/config/locale/translations/hu.countries.php @@ -17,7 +17,7 @@ return [ 'BJ' => 'Benin', 'BF' => 'Burkina Faso', 'BD' => 'Banglades', - 'BG' => 'Bulgaria', + 'BG' => 'Bulgária', 'BH' => 'Bahrein', 'BS' => 'Bahamák', 'BA' => 'Bosznia-Hercegovina', @@ -50,7 +50,7 @@ return [ 'DM' => 'Dominika', 'DK' => 'Dánia', 'DO' => 'Dominikai Köztársaság', - 'DZ' => 'Algíria', + 'DZ' => 'Algéria', 'EC' => 'Ecuador', 'EG' => 'Egyiptom', 'ER' => 'Eritrea', @@ -67,7 +67,7 @@ return [ 'GH' => 'Ghána', 'GN' => 'Guinea', 'GM' => 'Gambia', - 'GW' => 'Guinea-Bissau', + 'GW' => 'Bissau-Guinea', 'GQ' => 'Egyenlítői-Guinea', 'GR' => 'Görögország', 'GD' => 'Grenada', @@ -88,24 +88,24 @@ return [ 'JM' => 'Jamaika', 'JO' => 'Jordánia', 'JP' => 'Japán', - 'KZ' => 'Kazakhsztán', + 'KZ' => 'Kazahsztán', 'KE' => 'Kenya', 'KG' => 'Kirgizisztán', 'KH' => 'Kambodzsa', 'KI' => 'Kiribati', 'KN' => 'Saint Kitts és Nevis', - 'KR' => 'Dél Korea', - 'KW' => 'Kuwait', + 'KR' => 'Dél-Korea', + 'KW' => 'Kuvait', 'LA' => 'Laosz', 'LB' => 'Libanon', 'LR' => 'Libéria', 'LY' => 'Líbia', 'LC' => 'Saint Lucia', 'LI' => 'Liechtenstein', - 'LK' => 'Sri Lanka', + 'LK' => 'Srí Lanka', 'LS' => 'Lesotho', 'LT' => 'Litvánia', - 'LU' => 'Luxembourg', + 'LU' => 'Luxemburg', 'LV' => 'Lettország', 'MA' => 'Marokkó', 'MC' => 'Monaco', @@ -127,8 +127,8 @@ return [ 'MY' => 'Malajzia', 'NA' => 'Namíbia', 'NE' => 'Niger', - 'NG' => 'Nigeria', - 'NI' => 'Nikaragua', + 'NG' => 'Nigéria', + 'NI' => 'Nicaragua', 'NL' => 'Hollandia', 'NO' => 'Norvégia', 'NP' => 'Nepál', @@ -145,10 +145,10 @@ return [ 'KP' => 'Észak-Korea', 'PT' => 'Portugália', 'PY' => 'Paraguay', - 'QA' => 'Qatar', + 'QA' => 'Katar', 'RO' => 'Románia', 'RU' => 'Oroszország', - 'RW' => 'Rwanda', + 'RW' => 'Ruanda', 'SA' => 'Szaúd-Arábia', 'SD' => 'Szudán', 'SN' => 'Szenegál', @@ -161,16 +161,16 @@ return [ 'RS' => 'Szerbia', 'SS' => 'Dél-Szudán', 'ST' => 'São Tomé és Príncipe', - 'SR' => 'Szurinám', + 'SR' => 'Suriname', 'SK' => 'Szlovákia', 'SI' => 'Szlovénia', 'SE' => 'Svédország', - 'SZ' => 'Swaziland', + 'SZ' => 'Szváziföld', 'SC' => 'Seychelles-szigetek', 'SY' => 'Szíria', 'TD' => 'Csád', 'TG' => 'Togo', - 'TH' => 'Tájföld', + 'TH' => 'Thaiföld', 'TJ' => 'Tádzsikisztán', 'TM' => 'Türkmenisztán', 'TL' => 'Timor-Leste', @@ -179,9 +179,9 @@ return [ 'TN' => 'Tunézia', 'TR' => 'Törökország', 'TV' => 'Tuvalu', - 'TZ' => 'Tanzania', + 'TZ' => 'Tanzánia', 'UG' => 'Uganda', - 'UA' => 'Ukraina', + 'UA' => 'Ukrajna', 'UY' => 'Uruguay', 'US' => 'Egyesült Államok', 'UZ' => 'Üzbegisztán', @@ -191,7 +191,7 @@ return [ 'VN' => 'Vietnám', 'VU' => 'Vanuatu', 'WS' => 'Szamoa', - 'YE' => 'Yemen', + 'YE' => 'Jemen', 'ZA' => 'Dél-Afrikai Köztársaság', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe', diff --git a/app/config/locales/hu.php b/app/config/locale/translations/hu.php similarity index 84% rename from app/config/locales/hu.php rename to app/config/locale/translations/hu.php index d5f1b7e684..87eed9c681 100644 --- a/app/config/locales/hu.php +++ b/app/config/locale/translations/hu.php @@ -7,11 +7,11 @@ return [ // Service - Users 'account.emails.team' => '%s Csapat', - 'account.emails.verification.title' => 'Fiók megerősítés', + 'account.emails.verification.title' => 'Fiók megerősítése', 'account.emails.verification.body' => 'hu.email.auth.confirm.tpl', - 'account.emails.recovery.title' => 'Jelszó Visszaállítás', + 'account.emails.recovery.title' => 'Jelszó-visszaállítás', 'account.emails.recovery.body' => 'hu.email.auth.recovery.tpl', - 'account.emails.invitation.title' => 'Meghívás a %s Csapathoz %s', + 'account.emails.invitation.title' => 'Meghívás a %s csapatba %s', 'account.emails.invitation.body' => 'hu.email.auth.invitation.tpl', 'locale.country.unknown' => 'Ismeretlen', diff --git a/app/config/locales/hy.continents.php b/app/config/locale/translations/hy.continents.php similarity index 100% rename from app/config/locales/hy.continents.php rename to app/config/locale/translations/hy.continents.php diff --git a/app/config/locales/hy.countries.php b/app/config/locale/translations/hy.countries.php similarity index 100% rename from app/config/locales/hy.countries.php rename to app/config/locale/translations/hy.countries.php diff --git a/app/config/locales/hy.php b/app/config/locale/translations/hy.php similarity index 100% rename from app/config/locales/hy.php rename to app/config/locale/translations/hy.php diff --git a/app/config/locales/id.continents.php b/app/config/locale/translations/id.continents.php similarity index 100% rename from app/config/locales/id.continents.php rename to app/config/locale/translations/id.continents.php diff --git a/app/config/locales/id.countries.php b/app/config/locale/translations/id.countries.php similarity index 93% rename from app/config/locales/id.countries.php rename to app/config/locale/translations/id.countries.php index 3f625140e3..049ae9c6c5 100644 --- a/app/config/locales/id.countries.php +++ b/app/config/locale/translations/id.countries.php @@ -13,7 +13,7 @@ return [ 'AT' => 'Austria', 'AZ' => 'Azerbaijan', 'BI' => 'Burundi', - 'BE' => 'Belgium', + 'BE' => 'Belgia', 'BJ' => 'Benin', 'BF' => 'Burkina Faso', 'BD' => 'Bangladesh', @@ -24,7 +24,7 @@ return [ 'BY' => 'Belarus', 'BZ' => 'Belize', 'BO' => 'Bolivia', - 'BR' => 'Brazil', + 'BR' => 'Brasil', 'BB' => 'Barbados', 'BN' => 'Brunei', 'BT' => 'Bhutan', @@ -36,15 +36,15 @@ return [ 'CN' => 'Cina', 'CI' => 'Pantai Gading', 'CM' => 'Kamerun', - 'CD' => 'DR Kongo', + 'CD' => 'Republik Demokratik Kongo', 'CG' => 'Republik Kongo', - 'CO' => 'Kolumbia', + 'CO' => 'Kolombia', 'KM' => 'Komoro', 'CV' => 'Tanjung Verde', 'CR' => 'Kosta Rika', 'CU' => 'Kuba', 'CY' => 'Siprus', - 'CZ' => 'Czechia', + 'CZ' => 'Ceko', 'DE' => 'Jerman', 'DJ' => 'Djibouti', 'DM' => 'Dominika', @@ -86,11 +86,11 @@ return [ 'IL' => 'Israel', 'IT' => 'Italia', 'JM' => 'Jamaika', - 'JO' => 'Jordan', + 'JO' => 'Yordania', 'JP' => 'Jepang', 'KZ' => 'Kazakhstan', 'KE' => 'Kenya', - 'KG' => 'Kirgistan', + 'KG' => 'Kirgizstan', 'KH' => 'Kamboja', 'KI' => 'Kiribati', 'KN' => 'Saint Kitts dan Nevis', @@ -113,7 +113,7 @@ return [ 'MG' => 'Madagaskar', 'MV' => 'Maladewa', 'MX' => 'Meksiko', - 'MH' => 'Pulau Marshall', + 'MH' => 'Kepulauan Marshall', 'MK' => 'Makedonia', 'ML' => 'Mali', 'MT' => 'Malta', @@ -153,7 +153,7 @@ return [ 'SD' => 'Sudan', 'SN' => 'Senegal', 'SG' => 'Singapura', - 'SB' => 'Pulau Solomon', + 'SB' => 'Kepulauan Solomon', 'SL' => 'Sierra Leone', 'SV' => 'El Salvador', 'SM' => 'San Marino', @@ -165,11 +165,11 @@ return [ 'SK' => 'Slovakia', 'SI' => 'Slovenia', 'SE' => 'Swedia', - 'SZ' => 'Swaziland', + 'SZ' => 'Eswatini', 'SC' => 'Seychelles', 'SY' => 'Suriah', 'TD' => 'Chad', - 'TG' => 'Untuk pergi', + 'TG' => 'Togo', 'TH' => 'Thailand', 'TJ' => 'Tajikistan', 'TM' => 'Turkmenistan', diff --git a/app/config/locales/id.php b/app/config/locale/translations/id.php similarity index 100% rename from app/config/locales/id.php rename to app/config/locale/translations/id.php diff --git a/app/config/locales/is.continents.php b/app/config/locale/translations/is.continents.php similarity index 100% rename from app/config/locales/is.continents.php rename to app/config/locale/translations/is.continents.php diff --git a/app/config/locales/is.countries.php b/app/config/locale/translations/is.countries.php similarity index 100% rename from app/config/locales/is.countries.php rename to app/config/locale/translations/is.countries.php diff --git a/app/config/locales/is.php b/app/config/locale/translations/is.php similarity index 100% rename from app/config/locales/is.php rename to app/config/locale/translations/is.php diff --git a/app/config/locales/it.continents.php b/app/config/locale/translations/it.continents.php similarity index 100% rename from app/config/locales/it.continents.php rename to app/config/locale/translations/it.continents.php diff --git a/app/config/locales/it.countries.php b/app/config/locale/translations/it.countries.php similarity index 99% rename from app/config/locales/it.countries.php rename to app/config/locale/translations/it.countries.php index 45851f6fcc..bb7869066e 100644 --- a/app/config/locales/it.countries.php +++ b/app/config/locale/translations/it.countries.php @@ -86,7 +86,7 @@ return [ 'IL' => 'Israele', 'IT' => 'Italia', 'JM' => 'Giamaica', - 'JO' => 'Jordan', + 'JO' => 'Giordania', 'JP' => 'Giappone', 'KZ' => 'Kazakistan', 'KE' => 'Kenya', diff --git a/app/config/locales/it.php b/app/config/locale/translations/it.php similarity index 100% rename from app/config/locales/it.php rename to app/config/locale/translations/it.php diff --git a/app/config/locales/ja.continents.php b/app/config/locale/translations/ja.continents.php similarity index 100% rename from app/config/locales/ja.continents.php rename to app/config/locale/translations/ja.continents.php diff --git a/app/config/locales/ja.countries.php b/app/config/locale/translations/ja.countries.php similarity index 100% rename from app/config/locales/ja.countries.php rename to app/config/locale/translations/ja.countries.php diff --git a/app/config/locales/ja.php b/app/config/locale/translations/ja.php similarity index 100% rename from app/config/locales/ja.php rename to app/config/locale/translations/ja.php diff --git a/app/config/locales/jv.continents.php b/app/config/locale/translations/jv.continents.php similarity index 100% rename from app/config/locales/jv.continents.php rename to app/config/locale/translations/jv.continents.php diff --git a/app/config/locales/jv.countries.php b/app/config/locale/translations/jv.countries.php similarity index 100% rename from app/config/locales/jv.countries.php rename to app/config/locale/translations/jv.countries.php diff --git a/app/config/locales/jv.php b/app/config/locale/translations/jv.php similarity index 100% rename from app/config/locales/jv.php rename to app/config/locale/translations/jv.php diff --git a/app/config/locale/translations/ka.continents.php b/app/config/locale/translations/ka.continents.php new file mode 100644 index 0000000000..a93d841957 --- /dev/null +++ b/app/config/locale/translations/ka.continents.php @@ -0,0 +1,11 @@ + 'ಆಫ್ರಿಕಾ', + 'AN' => 'ಅಂಟಾರ್ಕ್ಟಿಕಾ', + 'AS' => 'ಏಷ್ಯಾ', + 'EU' => 'ಯುರೋಪ್', + 'NA' => 'ಉತ್ತರ ಅಮೆರಿಕ', + 'OC' => 'ಓಷಿಯಾನಿಯಾ', + 'SA' => 'ದಕ್ಷಿಣ ಅಮೆರಿಕಾ', +]; \ No newline at end of file diff --git a/app/config/locale/translations/ka.countries.php b/app/config/locale/translations/ka.countries.php new file mode 100644 index 0000000000..048f49c1bf --- /dev/null +++ b/app/config/locale/translations/ka.countries.php @@ -0,0 +1,198 @@ + 'ಅಫ್ಘಾನಿಸ್ತಾನ', + 'AO' => 'ಅಂಗೋಲಾ', + 'AL' => 'ಅಲ್ಬೇನಿಯಾ', + 'AD' => 'ಅಂಡೋರಾ', + 'AE' => 'ಸಂಯುಕ್ತ ಅರಬ್ ಸಂಸ್ಥಾಪನೆಗಳು', + 'AR' => 'ಅರ್ಜೆಂಟೀನಾ', + 'AM' => 'ಅರ್ಮೇನಿಯಾ', + 'AG' => 'ಆಂಟಿಗುವಾ ಮತ್ತು ಬಾರ್ಬುಡಾ', + 'AU' => 'ಆಸ್ಟ್ರೇಲಿಯಾ', + 'AT' => 'ಆಸ್ಟ್ರಿಯಾ', + 'AZ' => 'ಅಜೆರ್ಬೈಜಾನ್', + 'BI' => 'ಬುರುಂಡಿ', + 'BE' => 'ಬೆಲ್ಜಿಯಂ', + 'BJ' => 'ಬೆನಿನ್', + 'BF' => 'ಬುರ್ಕಿನಾ ಫಾಸೊ', + 'BD' => 'ಬಾಂಗ್ಲಾದೇಶ', + 'BG' => 'ಬಲ್ಗೇರಿಯಾ', + 'BH' => 'ಬಹ್ರೇನ್', + 'BS' => 'ಬಹಾಮಾಸ್', + 'BA' => 'ಬೋಸ್ನಿಯಾ ಮತ್ತು ಹರ್ಜೆಗೋವಿನಾ', + 'BY' => 'ಬೆಲಾರಸ್', + 'BZ' => 'ಬೆಲೀಜ್', + 'BO' => 'ಬೊಲಿವಿಯಾ', + 'BR' => 'ಬ್ರೆಜಿಲ್', + 'BB' => 'ಬಾರ್ಬಡೋಸ್', + 'BN' => 'ಬ್ರೂನಿ', + 'BT' => 'ಭೂತಾನ್', + 'BW' => 'ಬೋಟ್ಸ್ವಾನ', + 'CF' => 'ಮಧ್ಯ ಆಫ್ರಿಕಾದ ಗಣರಾಜ್ಯ', + 'CA' => 'ಕೆನಡಾ', + 'CH' => 'ಸ್ವಿಟ್ಜರ್ಲೆಂಡ್', + 'CL' => 'ಚಿಲಿ', + 'CN' => 'ಚೀನಾ', + 'CI' => 'ಐವರಿ ಕೋಸ್ಟ್', + 'CM' => 'ಕ್ಯಾಮರೂನ್', + 'CD' => 'ಡಿಆರ್ ಕಾಂಗೋ', + 'CG' => 'ರಿಪಬ್ಲಿಕ್ ಆಫ್ ದಿ ಕಾಂಗೋ', + 'CO' => 'ಕೊಲಂಬಿಯಾ', + 'KM' => 'ಕೊಮೊರೊಸ್', + 'CV' => 'ಕೇಪ್ ವರ್ಡೆ', + 'CR' => 'ಕೋಸ್ಟ ರಿಕಾ', + 'CU' => 'ಕ್ಯೂಬಾ', + 'CY' => 'ಸೈಪ್ರಸ್', + 'CZ' => 'ಜೆಕಿಯಾ', + 'DE' => 'ಜರ್ಮನಿ', + 'DJ' => 'ಜಿಬೌಟಿ', + 'DM' => 'ಡೊಮಿನಿಕಾ', + 'DK' => 'ಡೆನ್ಮಾರ್ಕ್', + 'DO' => 'ಡೊಮಿನಿಕನ್ ರಿಪಬ್ಲಿಕ್', + 'DZ' => 'ಅಲ್ಜೀರಿಯಾ', + 'EC' => 'ಈಕ್ವೆಡಾರ್', + 'EG' => 'ಈಜಿಪ್ಟ್', + 'ER' => 'ಎರಿಟ್ರಿಯಾ', + 'ES' => 'ಸ್ಪೇನ್', + 'EE' => 'ಎಸ್ಟೋನಿಯಾ', + 'ET' => 'ಇಥಿಯೋಪಿಯಾ', + 'FI' => 'ಫಿನ್ಲ್ಯಾಂಡ್', + 'FJ' => 'ಫಿಜಿ', + 'FR' => 'ಫ್ರಾನ್ಸ್', + 'FM' => 'ಮೈಕ್ರೋನೇಶಿಯಾ', + 'GA' => 'ಗ್ಯಾಬೊನ್', + 'GB' => 'ಯುನೈಟೆಡ್ ಕಿಂಗ್ಡಮ್', + 'GE' => 'ಜಾರ್ಜಿಯಾ', + 'GH' => 'ಘಾನಾ', + 'GN' => 'ಗಿನಿಯಾ', + 'GM' => 'ಗ್ಯಾಂಬಿಯಾ', + 'GW' => 'ಗಿನಿಯಾ-ಬಿಸ್ಸೌ', + 'GQ' => 'ಈಕ್ವಟೋರಿಯಲ್ ಗಿನಿಯಾ', + 'GR' => 'ಗ್ರೀಸ್', + 'GD' => 'ಗ್ರೆನಡಾ', + 'GT' => 'ಗ್ವಾಟೆಮಾಲಾ', + 'GY' => 'ಗಯಾನಾ', + 'HN' => 'ಹೊಂಡುರಾಸ್', + 'HR' => 'ಕ್ರೊಯೇಷಿಯಾ', + 'HT' => 'ಹೈಟಿ', + 'HU' => 'ಹಂಗೇರಿ', + 'ID' => 'ಇಂಡೋನೇಷ್ಯಾ', + 'IN' => 'ಭಾರತ', + 'IE' => 'ಐರ್ಲೆಂಡ್', + 'IR' => 'ಇರಾನ್', + 'IQ' => 'ಇರಾಕ್', + 'IS' => 'ಐಸ್ಲ್ಯಾಂಡ್', + 'IL' => 'ಇಸ್ರೇಲ್', + 'IT' => 'ಇಟಲಿ', + 'JM' => 'ಜಮೈಕಾ', + 'JO' => 'ಜೋರ್ಡಾನ್', + 'JP' => 'ಜಪಾನ್', + 'KZ' => 'ಕಝಾಕಿಸ್ತಾನ್', + 'KE' => 'ಕೀನ್ಯಾ', + 'KG' => 'ಕಿರ್ಗಿಸ್ತಾನ್', + 'KH' => 'ಕಾಂಬೋಡಿಯಾ', + 'KI' => 'ಕಿರಿಬತಿ', + 'KN' => 'ಸೇಂಟ್ ಕಿಟ್ಸ್ ಮತ್ತು ನೆವಿಸ್', + 'KR' => 'ದಕ್ಷಿಣ ಕೊರಿಯಾ', + 'KW' => 'ಕುವೈತ್', + 'LA' => 'ಲಾವೋಸ್', + 'LB' => 'ಲೆಬನಾನ್', + 'LR' => 'ಲೈಬೀರಿಯಾ', + 'LY' => 'ಲಿಬಿಯಾ', + 'LC' => 'ಸೇಂಟ್ ಲೂಸಿಯಾ', + 'LI' => 'ಲಿಚ್ಟೆನ್‌ಸ್ಟೈನ್', + 'LK' => 'ಶ್ರೀಲಂಕಾ', + 'LS' => 'ಲೆಸೊಥೊ', + 'LT' => 'ಲಿಥುವೇನಿಯಾ', + 'LU' => 'ಲಕ್ಸೆಂಬರ್ಗ್', + 'LV' => 'ಲಾಟ್ವಿಯಾ', + 'MA' => 'ಮೊರಾಕೊ', + 'MC' => 'ಮೊನಾಕೊ', + 'MD' => 'ಮೊಲ್ಡೊವಾ', + 'MG' => 'ಮಡಗಾಸ್ಕರ್', + 'MV' => 'ಮಾಲ್ಡೀವ್ಸ್', + 'MX' => 'ಮೆಕ್ಸಿಕೊ', + 'MH' => 'ಮಾರ್ಷಲ್ ದ್ವೀಪಗಳು', + 'MK' => 'ಮ್ಯಾಸಿಡೋನಿಯಾ', + 'ML' => 'ಮಾಲಿ', + 'MT' => 'ಮಾಲ್ಟಾ', + 'MM' => 'ಮ್ಯಾನ್ಮಾರ್', + 'ME' => 'ಮಾಂಟೆನೆಗ್ರೊ', + 'MN' => 'ಮಂಗೋಲಿಯಾ', + 'MZ' => 'ಮೊಜಾಂಬಿಕ್', + 'MR' => 'ಮೌರಿಟಾನಿಯಾ', + 'MU' => 'ಮಾರಿಷಸ್', + 'MW' => 'ಮಲಾವಿ', + 'MY' => 'ಮಲೇಷ್ಯಾ', + 'NA' => 'ನಮೀಬಿಯಾ', + 'NE' => 'ನೈಜರ್', + 'NG' => 'ನೈಜೀರಿಯಾ', + 'NI' => 'ನಿಕರಾಗುವಾ', + 'NL' => 'ನೆದರ್ಲ್ಯಾಂಡ್ಸ್', + 'NO' => 'ನಾರ್ವೆ', + 'NP' => 'ನೇಪಾಳ', + 'NR' => 'ನೌರು', + 'NZ' => 'ನ್ಯೂಜಿಲ್ಯಾಂಡ್', + 'OM' => 'ಓಮನ್', + 'PK' => 'ಪಾಕಿಸ್ತಾನ', + 'PA' => 'ಪನಾಮ', + 'PE' => 'ಪೆರು', + 'PH' => 'ಫಿಲಿಪೈನ್ಸ್', + 'PW' => 'ಪಲಾವ್', + 'PG' => 'ಪಪುವಾ ನ್ಯೂಗಿನಿಯಾ', + 'PL' => 'ಪೋಲೆಂಡ್', + 'KP' => 'ಉತ್ತರ ಕೊರಿಯಾ', + 'PT' => 'ಪೋರ್ಚುಗಲ್', + 'PY' => 'ಪರಾಗ್ವೆ', + 'QA' => 'ಕತಾರ್', + 'RO' => 'ರೊಮೇನಿಯಾ', + 'RU' => 'ರಷ್ಯಾ', + 'RW' => 'ರುವಾಂಡಾ', + 'SA' => 'ಸೌದಿ ಅರೇಬಿಯಾ', + 'SD' => 'ಸುಡಾನ್', + 'SN' => 'ಸೆನೆಗಲ್', + 'SG' => 'ಸಿಂಗಾಪುರ್', + 'SB' => 'ಸೊಲೊಮನ್ ದ್ವೀಪಗಳು', + 'SL' => 'ಸಿಯೆರಾ ಲಿಯೋನ್', + 'SV' => 'ಎಲ್ ಸಾಲ್ವಡಾರ್', + 'SM' => 'ಸ್ಯಾನ್ ಮರಿನೋ', + 'SO' => 'ಸೊಮಾಲಿಯಾ', + 'RS' => 'ಸೆರ್ಬಿಯಾ', + 'SS' => 'ದಕ್ಷಿಣ ಸುಡಾನ್', + 'ST' => 'ಸಾವೊ ಟೋಮೆ ಮತ್ತು ಪ್ರಿನ್ಸಿಪೆ', + 'SR' => 'ಸುರಿನಾಮ್', + 'SK' => 'ಸ್ಲೋವಾಕಿಯಾ', + 'SI' => 'ಸ್ಲೊವೇನಿಯಾ', + 'SE' => 'ಸ್ವೀಡನ್', + 'SZ' => 'ಸ್ವಾಜಿಲ್ಯಾಂಡ್', + 'SC' => 'ಸೀಶೆಲ್ಸ್', + 'SY' => 'ಸಿರಿಯಾ', + 'TD' => 'ಚಾಡ್', + 'TG' => 'ಹೋಗಲು', + 'TH' => 'ಥೈಲ್ಯಾಂಡ್', + 'TJ' => 'ತಜಿಕಿಸ್ತಾನ್', + 'TM' => 'ತುರ್ಕಮೆನಿಸ್ತಾನ್', + 'TL' => 'ಟಿಮೋರ್-ಲೆಸ್ಟೆ', + 'TO' => 'ಟೋಂಗಾ', + 'TT' => 'ಟ್ರಿನಿಡಾಡ್ ಮತ್ತು ಟೊಬಾಗೊ', + 'TN' => 'ಟುನೀಶಿಯಾ', + 'TR' => 'ಟರ್ಕಿ', + 'TV' => 'ತುವಾಲು', + 'TZ' => 'ಟಾಂಜಾನಿಯಾ', + 'UG' => 'ಉಗಾಂಡಾ', + 'UA' => 'ಉಕ್ರೇನ್', + 'UY' => 'ಉರುಗ್ವೆ', + 'US' => 'ಯುನೈಟೆಡ್ ಸ್ಟೇಟ್ಸ್', + 'UZ' => 'ಉಜ್ಬೇಕಿಸ್ತಾನ್', + 'VA' => 'ವ್ಯಾಟಿಕನ್ ನಗರ', + 'VC' => 'ಸೇಂಟ್ ವಿನ್ಸೆಂಟ್ ಮತ್ತು ಗ್ರೆನಡೈನ್ಸ್', + 'VE' => 'ವೆನೆಜುವೆಲಾ', + 'VN' => 'ವಿಯೆಟ್ನಾಂ', + 'VU' => 'ವನವಾಟು', + 'WS' => 'ಸಮೋವಾ', + 'YE' => 'ಯೆಮೆನ್', + 'ZA' => 'ದಕ್ಷಿಣ ಆಫ್ರಿಕಾ', + 'ZM' => 'ಜಾಂಬಿಯಾ', + 'ZW' => 'ಜಿಂಬಾಬ್ವೆ', +]; \ No newline at end of file diff --git a/app/config/locale/translations/ka.php b/app/config/locale/translations/ka.php new file mode 100644 index 0000000000..5a06b1a75d --- /dev/null +++ b/app/config/locale/translations/ka.php @@ -0,0 +1,21 @@ + '"ಬುದ್ಧಿವಂತಿಕೆಯ ಕಲೆ ಏನು ಕಡೆಗಣಿಸಬೇಕೆಂದು ತಿಳಿಯುವ ಕಲೆ."', // This is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'ka', + 'settings.direction' => 'ltr', + + // Service - Users + 'account.emails.team' => '%s ತಂಡ', + 'account.emails.verification.title' => 'ಖಾತೆ ಪರಿಶೀಲನೆ', + 'account.emails.verification.body' => 'ka.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'ಪಾಸ್‌ವರ್ಡ್ ಮರುಹೊಂದಿಸು', + 'account.emails.recovery.body' => 'ka.email.auth.recovery.tpl', + 'account.emails.invitation.title' => '%s ತಂಡಕ್ಕೆ% %s ನಲ್ಲಿ ಆಹ್ವಾನ', + 'account.emails.invitation.body' => 'ka.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'Unknown', + + 'countries' => include 'ka.countries.php', + 'continents' => include 'ka.continents.php', +]; diff --git a/app/config/locales/km.continents.php b/app/config/locale/translations/km.continents.php similarity index 100% rename from app/config/locales/km.continents.php rename to app/config/locale/translations/km.continents.php diff --git a/app/config/locales/km.countries.php b/app/config/locale/translations/km.countries.php similarity index 100% rename from app/config/locales/km.countries.php rename to app/config/locale/translations/km.countries.php diff --git a/app/config/locales/km.php b/app/config/locale/translations/km.php similarity index 100% rename from app/config/locales/km.php rename to app/config/locale/translations/km.php diff --git a/app/config/locales/ko.continents.php b/app/config/locale/translations/ko.continents.php similarity index 100% rename from app/config/locales/ko.continents.php rename to app/config/locale/translations/ko.continents.php diff --git a/app/config/locales/ko.countries.php b/app/config/locale/translations/ko.countries.php similarity index 100% rename from app/config/locales/ko.countries.php rename to app/config/locale/translations/ko.countries.php diff --git a/app/config/locales/ko.php b/app/config/locale/translations/ko.php similarity index 100% rename from app/config/locales/ko.php rename to app/config/locale/translations/ko.php diff --git a/app/config/locales/lt.continents.php b/app/config/locale/translations/lt.continents.php similarity index 100% rename from app/config/locales/lt.continents.php rename to app/config/locale/translations/lt.continents.php diff --git a/app/config/locales/lt.countries.php b/app/config/locale/translations/lt.countries.php similarity index 100% rename from app/config/locales/lt.countries.php rename to app/config/locale/translations/lt.countries.php diff --git a/app/config/locales/lt.php b/app/config/locale/translations/lt.php similarity index 100% rename from app/config/locales/lt.php rename to app/config/locale/translations/lt.php diff --git a/app/config/locales/ml.continents.php b/app/config/locale/translations/ml.continents.php similarity index 100% rename from app/config/locales/ml.continents.php rename to app/config/locale/translations/ml.continents.php diff --git a/app/config/locales/ml.countries.php b/app/config/locale/translations/ml.countries.php similarity index 100% rename from app/config/locales/ml.countries.php rename to app/config/locale/translations/ml.countries.php diff --git a/app/config/locales/ml.php b/app/config/locale/translations/ml.php similarity index 100% rename from app/config/locales/ml.php rename to app/config/locale/translations/ml.php diff --git a/app/config/locale/translations/mr.continents.php b/app/config/locale/translations/mr.continents.php new file mode 100644 index 0000000000..70fc337ba3 --- /dev/null +++ b/app/config/locale/translations/mr.continents.php @@ -0,0 +1,11 @@ + 'अफ़्रीका', + 'AN' => 'अंटार्कटिका', + 'AS' => 'एशिया', + 'EU' => 'यूरोप', + 'NA' => 'उत्तर अमेरिका', + 'OC' => 'ओशिनिया', + 'SA' => 'दक्षिण अमेरिका', +]; diff --git a/app/config/locales/hi.countries.php b/app/config/locale/translations/mr.countries.php similarity index 100% rename from app/config/locales/hi.countries.php rename to app/config/locale/translations/mr.countries.php diff --git a/app/config/locale/translations/mr.php b/app/config/locale/translations/mr.php new file mode 100644 index 0000000000..bacc8ded84 --- /dev/null +++ b/app/config/locale/translations/mr.php @@ -0,0 +1,21 @@ + '"हुशार असण्याची कला म्हणजे कोणत्या गोष्टीकडे दुर्लक्ष करावे हे जाणून घेण्याची कला."', // Tmrs is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'mr', + 'settings.direction' => 'ltr', + + // Service - Users + 'account.emails.team' => '%s टीम', + 'account.emails.verification.title' => 'अकाउंट कन्फर्मेशन ', + 'account.emails.verification.body' => 'mr.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'पासवर्ड रिसेट ', + 'account.emails.recovery.body' => 'mr.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'इनविटेशन %s टीम %s', + 'account.emails.invitation.body' => 'mr.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'अज्ञात', + + 'countries' => include 'mr.countries.php', + 'continents' => include 'mr.continents.php', +]; diff --git a/app/config/locales/ms.continents.php b/app/config/locale/translations/ms.continents.php similarity index 100% rename from app/config/locales/ms.continents.php rename to app/config/locale/translations/ms.continents.php diff --git a/app/config/locales/ms.countries.php b/app/config/locale/translations/ms.countries.php similarity index 100% rename from app/config/locales/ms.countries.php rename to app/config/locale/translations/ms.countries.php diff --git a/app/config/locales/ms.php b/app/config/locale/translations/ms.php similarity index 100% rename from app/config/locales/ms.php rename to app/config/locale/translations/ms.php diff --git a/app/config/locales/nl.continents.php b/app/config/locale/translations/nl.continents.php similarity index 100% rename from app/config/locales/nl.continents.php rename to app/config/locale/translations/nl.continents.php diff --git a/app/config/locales/nl.countries.php b/app/config/locale/translations/nl.countries.php similarity index 100% rename from app/config/locales/nl.countries.php rename to app/config/locale/translations/nl.countries.php diff --git a/app/config/locales/nl.php b/app/config/locale/translations/nl.php similarity index 100% rename from app/config/locales/nl.php rename to app/config/locale/translations/nl.php diff --git a/app/config/locales/no.continents.php b/app/config/locale/translations/no.continents.php similarity index 100% rename from app/config/locales/no.continents.php rename to app/config/locale/translations/no.continents.php diff --git a/app/config/locales/no.countries.php b/app/config/locale/translations/no.countries.php similarity index 100% rename from app/config/locales/no.countries.php rename to app/config/locale/translations/no.countries.php diff --git a/app/config/locales/no.php b/app/config/locale/translations/no.php similarity index 100% rename from app/config/locales/no.php rename to app/config/locale/translations/no.php diff --git a/app/config/locale/translations/np.continents.php b/app/config/locale/translations/np.continents.php new file mode 100644 index 0000000000..e5f680393b --- /dev/null +++ b/app/config/locale/translations/np.continents.php @@ -0,0 +1,11 @@ + 'अफ्रीका', + 'AN' => 'एन्टार्टिका', + 'AS' => 'एशिया', + 'EU' => 'युरोप', + 'NA' => 'उत्तर अमेरिका', + 'OC' => 'ओसिआनिया', + 'SA' => 'दक्षिण अमेरिका', +]; diff --git a/app/config/locale/translations/np.countries.php b/app/config/locale/translations/np.countries.php new file mode 100644 index 0000000000..99b6e945ce --- /dev/null +++ b/app/config/locale/translations/np.countries.php @@ -0,0 +1,198 @@ + 'अफगानिस्तान', + 'AO' => 'अंगोला', + 'AL' => 'अल्बानिया', + 'AD' => 'अन्डोरा', + 'AE' => 'संयुक्त अरब एमिरेट्स', + 'AR' => 'अर्जेन्टिना', + 'AM' => 'आर्मेनिया', + 'AG' => 'एन्टिगुवा र बार्बुडा', + 'AU' => 'अष्ट्रेलिया', + 'AT' => 'अस्ट्रिया', + 'AZ' => 'अजरबैजान', + 'BI' => 'बुरुंडी', + 'BE' => 'बेल्जियम', + 'BJ' => 'बेनिन', + 'BF' => 'बुर्किना फासो', + 'BD' => 'बंगलादेश', + 'BG' => 'बुल्गारिया', + 'BH' => 'बहरेन', + 'BS' => 'बहामास', + 'BA' => 'बोस्निया र हेर्जेगोभिना', + 'BY' => 'बेलारुस', + 'BZ' => 'बेलिज', + 'BO' => 'बोलिभिया', + 'BR' => 'ब्राजिल', + 'BB' => 'बार्बाडोस', + 'BN' => 'ब्रुनेई', + 'BT' => 'भुटान', + 'BW' => 'बोत्सवाना', + 'CF' => 'मध्य अफ्रीकी गणराज्य', + 'CA' => 'क्यानडा', + 'CH' => 'स्विजरल्याण्ड', + 'CL' => 'चिली', + 'CN' => 'चीन', + 'CI' => 'आइवरी कोस्ट', + 'CM' => 'क्यामरून', + 'CD' => 'दि आर कांगो', + 'CG' => 'रिपब्लिक ओफ कंगो', + 'CO' => 'कोलम्बिया', + 'KM' => 'कोमोरोज', + 'CV' => 'केप भर्डे', + 'CR' => 'कोस्टा रिका', + 'CU' => 'क्युबा', + 'CY' => 'साइप्रस', + 'CZ' => 'चेकिया', + 'DE' => 'जर्मनी', + 'DJ' => 'जिबूउटी', + 'DM' => 'डोमिनिका', + 'DK' => 'डेनमार्क', + 'DO' => 'डोमिनिकन रिपब्लिक', + 'DZ' => 'अल्जेरिया', + 'EC' => 'इक्वेडर', + 'EG' => 'इजिप्ट', + 'ER' => 'इरिट्रिया', + 'ES' => 'स्पेन', + 'EE' => 'इस्टोनिया', + 'ET' => 'इथियोपिया', + 'FI' => 'फिनल्याण्ड', + 'FJ' => 'फिजी', + 'FR' => 'फ्रान्स', + 'FM' => 'माइक्रोनेसिया', + 'GA' => 'गेबन', + 'GB' => 'युनाइटेड किंगडम', + 'GE' => 'जर्जिया', + 'GH' => 'घाना', + 'GN' => 'गुयना', + 'GM' => 'गाम्बिया', + 'GW' => 'गुयना-बिसाउ', + 'GQ' => 'इक्वेटोरियल गुयना', + 'GR' => 'ग्रीस', + 'GD' => 'ग्रेनेडा', + 'GT' => 'ग्वाटेमाला', + 'GY' => 'गुयाना', + 'HN' => 'होन्डुरस', + 'HR' => 'क्रोएशिया', + 'HT' => 'हैती', + 'HU' => 'हंगेरी', + 'ID' => 'इन्डोनेसिया', + 'IN' => 'भारत', + 'IE' => 'आयरल्यान्ड', + 'IR' => 'ईरान', + 'IQ' => 'इराक', + 'IS' => 'आइसल्याण्ड', + 'IL' => 'इजरायल', + 'IT' => 'इटाली', + 'JM' => 'जमैका', + 'JO' => 'जोर्डन', + 'JP' => 'जापान', + 'KZ' => 'काजाकिस्तान', + 'KE' => 'केन्या', + 'KG' => 'किर्गिजस्तान', + 'KH' => 'कम्बोडिया', + 'KI' => 'किरिबाटी', + 'KN' => 'सेन्ट किट्स र नेविस', + 'KR' => 'दक्षिण कोरिया', + 'KW' => 'कुवेत', + 'LA' => 'लाओस', + 'LB' => 'लेबनान', + 'LR' => 'लाइबेरिया', + 'LY' => 'लिबिया', + 'LC' => 'सेन्ट लुसिया', + 'LI' => 'लिकस्टेन', + 'LK' => 'श्रीलंका', + 'LS' => 'लेसोथो', + 'LT' => 'लिथुआनिया', + 'LU' => 'लक्जमबर्ग', + 'LV' => 'लाटभिया', + 'MA' => 'मोरक्को', + 'MC' => 'मोरक्को', + 'MD' => 'मोल्डोभा', + 'MG' => 'मेडागास्कर', + 'MV' => 'माल्दिभ्स', + 'MX' => 'मेक्सिको', + 'MH' => 'मार्शल टापु', + 'MK' => 'म्यासेडोनिया', + 'ML' => 'माली', + 'MT' => 'माल्टा', + 'MM' => 'म्यानमार', + 'ME' => 'मोन्टेनेग्रो', + 'MN' => 'मंगोलिया', + 'MZ' => 'मोजाम्बिक', + 'MR' => 'मौरिटानिया', + 'MU' => 'मौरिसस', + 'MW' => 'मलावी', + 'MY' => 'मलेशिया', + 'NA' => 'नामिबिया', + 'NE' => 'नाइजर', + 'NG' => 'नाइजेरिया', + 'NI' => 'निकारागुआ', + 'NL' => 'नेदरल्याण्ड्स', + 'NO' => 'नर्वे', + 'NP' => 'नेपाल', + 'NR' => 'नउरु', + 'NZ' => 'न्युजिल्याण्ड', + 'OM' => 'ओमान', + 'PK' => 'पाकिस्तान', + 'PA' => 'पनामा', + 'PE' => 'पेरू', + 'PH' => 'फिलिपिन्स', + 'PW' => 'पलाउ', + 'PG' => 'पापुआ न्यू गुयना', + 'PL' => 'पोल्याण्ड', + 'KP' => 'उत्तर कोरिया', + 'PT' => 'पोर्तुगल', + 'PY' => 'पराग्वे', + 'QA' => 'कतार', + 'RO' => 'रोमानिया', + 'RU' => 'रसिया', + 'RW' => 'रुवाण्डा', + 'SA' => 'साउदी अरेबिया', + 'SD' => 'सुडान', + 'SN' => 'सेनेगल', + 'SG' => 'सिंगापुर', + 'SB' => 'सोलोमन टापु', + 'SL' => 'सिएरा लियोन', + 'SV' => 'एल साल्भाडोर', + 'SM' => 'सान मारिनो', + 'SO' => 'सोमालिया', + 'RS' => 'सर्बिया', + 'SS' => 'दक्षिण सुडान', + 'ST' => 'साओ टोमे र प्रिन्सिपे', + 'SR' => 'सुरिनाम', + 'SK' => 'स्लोभाकिया', + 'SI' => 'स्लोभेनिया', + 'SE' => 'स्वीडेन', + 'SZ' => 'एस्वातिनी', + 'SC' => 'सेशेल्स', + 'SY' => 'सिरिया', + 'TD' => 'चाड', + 'TG' => 'टोगो', + 'TH' => 'थाईल्यान्ड', + 'TJ' => 'ताजिकिस्तान', + 'TM' => 'तुर्कमेनिस्तान', + 'TL' => 'तिमोर-लेस्टे', + 'TO' => 'टोंगा', + 'TT' => 'ट्रिनिडाड र टोबागो', + 'TN' => 'ट्युनिसिया', + 'TR' => 'टर्की', + 'TV' => 'टुभालु', + 'TZ' => 'तान्जानिया', + 'UG' => 'युगान्डा', + 'UA' => 'युक्रेन', + 'UY' => 'उरुग्वे', + 'US' => 'युनाइटेड अमेरिका', + 'UZ' => 'उज्बेकिस्तान', + 'VA' => 'भ्याटिकन सिटी', + 'VC' => 'सेन्ट भिन्सेन्ट र ग्रेनाडाइन्स', + 'VE' => 'भेनेजुएला', + 'VN' => 'भियतनाम', + 'VU' => 'भानुआटु', + 'WS' => 'सामोआ', + 'YE' => 'यमन', + 'ZA' => 'दक्षिण अफ्रिका', + 'ZM' => 'जाम्बिया', + 'ZW' => 'जिम्बावे', +]; diff --git a/app/config/locale/translations/np.php b/app/config/locale/translations/np.php new file mode 100644 index 0000000000..e07c885c28 --- /dev/null +++ b/app/config/locale/translations/np.php @@ -0,0 +1,21 @@ + '"बुद्धिमान हुनु को कला के लाई बेवास्ता गर्न जान्ने को कला हो।"', // This is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'np', + 'settings.direction' => 'ltr', + + // Service - Users + 'account.emails.team' => '%s टीम', + 'account.emails.verification.title' => 'खाता प्रमाणीकरण', + 'account.emails.verification.body' => 'np.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'पासवर्ड रिसेट', + 'account.emails.recovery.body' => 'np.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'आमन्त्रित गर्न %s टीम मा %s', + 'account.emails.invitation.body' => 'np.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'अज्ञात', + + 'countries' => include 'np.countries.php', + 'continents' => include 'np.continents.php', +]; diff --git a/app/config/locale/translations/od.continents.php b/app/config/locale/translations/od.continents.php new file mode 100644 index 0000000000..d89addeefe --- /dev/null +++ b/app/config/locale/translations/od.continents.php @@ -0,0 +1,11 @@ + 'ଆଫ୍ରିକା', + 'AN' => 'ଆଣ୍ଟାର୍କଟିକା', + 'AS' => 'ଏସିଆ', + 'EU' => 'ଇଉରୋପ', + 'NA' => 'ନର୍ଥ ଆମେରିକା', + 'OC' => 'ଓସାନିଆ', + 'SA' => 'ସାଉଥ ଆମେରିକା', +]; diff --git a/app/config/locale/translations/od.countries.php b/app/config/locale/translations/od.countries.php new file mode 100644 index 0000000000..ca24130b4d --- /dev/null +++ b/app/config/locale/translations/od.countries.php @@ -0,0 +1,198 @@ + 'ଅଫଘନିସ୍ତାନ', + 'AO' => 'ଅଙ୍ଗୋଲା', + 'AL' => 'ଆଲବେନିଆ', + 'AD' => 'ଆଣ୍ଡୋରା', + 'AE' => 'ୟୁନାଇଟେଡ୍ ଆରବ ଏମିରେଟେସ୍', + 'AR' => 'ଆର୍ଜେଣ୍ଟିନା', + 'AM' => 'ଆର୍ମେନିଆ', + 'AG' => 'ଆଣ୍ଟିଗୁଆ ଏବଂ ବାରବୁଦା', + 'AU' => 'ଅଷ୍ଟ୍ରେଲିଆ', + 'AT' => 'ଅଷ୍ଟ୍ରିଆ', + 'AZ' => 'ଆଜେରବାଇଜାନ', + 'BI' => 'ବୁରୁଣ୍ଡି', + 'BE' => 'ବେଲଜିୟମ', + 'BJ' => 'ବେନିନ୍', + 'BF' => 'ବୁର୍କିନା ଫାସୋ', + 'BD' => 'ବାଂଲାଦେଶ', + 'BG' => 'ବୁଲଗେରିଆ', + 'BH' => 'ବହାରେନ', + 'BS' => 'ବାହାମା', + 'BA' => 'ବୋସନିଆ ଏବଂ ହେର୍ଜେଗୋଭିନା', + 'BY' => 'ବେଳରୁଷ', + 'BZ' => 'ବେଲିଜ଼ଏ', + 'BO' => 'ବୋଲିଭିଆ', + 'BR' => 'ବ୍ରାଜିଲ୍', + 'BB' => 'ବାରବାଡୋସ୍', + 'BN' => 'ବ୍ରୁନେଇ', + 'BT' => 'ଭୁଟାନ', + 'BW' => 'ବୋତସ୍ୱାନା', + 'CF' => 'କେନ୍ଦ୍ରୀୟ ଆଫ୍ରିକୀୟ ଗଣତନ୍ତ୍ର', + 'CA' => 'କାନାଡା', + 'CH' => 'ସ୍ୱିଜରଲ୍ୟାଣ୍ଡ', + 'CL' => 'ଚିଲି', + 'CN' => 'ଚୀନ୍', + 'CI' => 'ଆଇଭୋରୀ କୋଷ୍ଟ', + 'CM' => 'କାମେରୁନ୍', + 'CD' => 'ଡ଼ ର କଙ୍ଗୋ', + 'CG' => 'କଙ୍ଗୋ ଗଣତନ୍ତ୍ର', + 'CO' => 'କଲମ୍ବିଆ', + 'KM' => 'କୋମୋରସ୍', + 'CV' => 'କେପ୍ ଭର୍ଡେ', + 'CR' => 'କୋଷ୍ଟାରିକା', + 'CU' => 'କ୍ୟୁବା', + 'CY' => 'ସାଇପ୍ରସ୍', + 'CZ' => 'ଚେକିଆ', + 'DE' => 'ଜର୍ମାନୀ', + 'DJ' => 'ଜିବୁଟି', + 'DM' => 'ଡୋମିନିକା', + 'DK' => 'ଡେନମାର୍କ', + 'DO' => 'ଡୋମିନିକାନ୍ ରିପବ୍ଲିକ୍', + 'DZ' => 'ଆଲଜେରିଆ', + 'EC' => 'ଇକ୍ୟୁଏଡର୍', + 'EG' => 'ମିଶର', + 'ER' => 'ଇରିଟ୍ରିଆ', + 'ES' => 'ସ୍ପେନ୍', + 'EE' => 'ଇଷ୍ଟୋନିଆ', + 'ET' => 'ଇଥିଓପିଆ', + 'FI' => 'ଫିନଲ୍ୟାଣ୍ଡ', + 'FJ' => 'ଫିଜି', + 'FR' => 'ଫ୍ରାନ୍ସ', + 'FM' => 'ମାଇକ୍ରୋନେସିଆ', + 'GA' => 'ଗାବନ୍', + 'GB' => 'ୟୁନାଇଟେଡ୍ କିଙ୍ଗଡମ', + 'GE' => 'ଜର୍ଜିଆ', + 'GH' => 'ଘାନା', + 'GN' => 'ଗିନି', + 'GM' => 'ଗାମ୍ବିଆ', + 'GW' => 'ଗିନି-ବିସାଉ', + 'GQ' => 'ଏକ୍ୟୁଟୋରିଆଲ୍ ଗିନି', + 'GR' => 'ଗ୍ରୀସ୍', + 'GD' => 'ଗ୍ରେନାଡା', + 'GT' => 'ଗୁଆଟେମାଲା', + 'GY' => 'ଗୁଇନ୍ଦା', + 'HN' => 'ହୋଣ୍ଡୁରାସ୍', + 'HR' => 'କ୍ରୋଏସିଆ', + 'HT' => 'ହାଇତି', + 'HU' => 'ହଙ୍ଗେରୀ', + 'ID' => 'ଇଣ୍ଡୋନେସିଆ', + 'IN' => 'ଭାରତ', + 'IE' => 'ଆୟର୍ଲାଣ୍ଡ', + 'IR' => 'ଇରାନ', + 'IQ' => 'ଇରାକ', + 'IS' => 'ଆଇସଲ୍ୟାଣ୍ଡ', + 'IL' => 'ଇସ୍ରାଏଲ', + 'IT' => 'ଇଟାଲୀ', + 'JM' => 'ଜାମାଇକା', + 'JO' => 'ଜୋର୍ଡାନ', + 'JP' => 'ଜାପାନ', + 'KZ' => 'କାଜାଖସ୍ତାନ', + 'KE' => 'କେନିଆ', + 'KG' => 'କିର୍ଗିଜସ୍ଥାନ', + 'KH' => 'କାମ୍ବୋଡିଆ', + 'KI' => 'କିରିବାଟି', + 'KN' => 'ସେଣ୍ଟ କିଟ୍ସ ଏବଂ ନେଭିସ୍', + 'KR' => 'ଦକ୍ଷିଣ କୋରିଆ', + 'KW' => 'କୁଏତ', + 'LA' => 'ଲାଓସ୍', + 'LB' => 'ଲିବାନୋନ୍', + 'LR' => 'ଲାଇବେରିଆ', + 'LY' => 'ଲିବିଆ', + 'LC' => 'ସେଣ୍ଟ ଲୁସିଆ', + 'LI' => 'ଲିଚଟେଷ୍ଟାଇନ୍', + 'LK' => 'ଶ୍ରୀ ଲଙ୍କା', + 'LS' => 'ଲେସୋଥୋ', + 'LT' => 'ଲିଥୁଆନିଆ', + 'LU' => 'ଲକ୍ସେମବର୍ଗ', + 'LV' => 'ଲାଟଭିଆ', + 'MA' => 'ମୋରୋକୋ', + 'MC' => 'ମୋନାକୋ', + 'MD' => 'ମଲଡୋଭା', + 'MG' => 'ମାଡାଗାସ୍କର', + 'MV' => 'ମାଲଦ୍ୱୀପ', + 'MX' => 'ମେକ୍ସିକୋ', + 'MH' => 'ମାର୍ଶଲ ଦ୍ୱୀପପୁଞ୍ଜ', + 'MK' => 'ମାକେଡୋନିଆ', + 'ML' => 'ମାଲି', + 'MT' => 'ମାଲ୍ଟା', + 'MM' => 'ମିଆଁମାର', + 'ME' => 'ମୋଣ୍ଟେନେଗ୍ରୋ', + 'MN' => 'ମୋଙ୍ଗୋଲିଆ', + 'MZ' => 'ମୋଜାମ୍ବିକ୍', + 'MR' => 'ମରିସାନିଆ', + 'MU' => 'ମରିସସ୍', + 'MW' => 'ମଲାୱି', + 'MY' => 'ମାଲେସିଆ', + 'NA' => 'ନାମିବିଆ', + 'NE' => 'ନାଇଜର', + 'NG' => 'ନାଇଜେରିଆ', + 'NI' => 'ନିକାରାଗୁଆ', + 'NL' => 'ନେଦରଲ୍ୟାଣ୍ଡ', + 'NO' => 'ନରୱେ', + 'NP' => 'ନେପାଳ', + 'NR' => 'ନାଉରୁ', + 'NZ' => 'ନିଉଜିଲାଣ୍ଡ୍', + 'OM' => 'ଓମାନ', + 'PK' => 'ପାକିସ୍ତାନ', + 'PA' => 'ପାନାମା', + 'PE' => 'ପେରୁ', + 'PH' => 'ଫିଲିପାଇନ୍ସ', + 'PW' => 'ପାଲାଉ', + 'PG' => 'ପାପୁଆ ନ୍ୟୁ ଗିନି', + 'PL' => 'ପୋଲାଣ୍ଡ', + 'KP' => 'ଉତ୍ତର କୋରିଆ', + 'PT' => 'ପର୍ତ୍ତୁଗାଲ୍', + 'PY' => 'ପାରାଗୁଏ', + 'QA' => 'କାତାର', + 'RO' => 'ରୋମାନିଆ', + 'RU' => 'ୠଷ୍ସିଆ', + 'RW' => 'ରୁୱାଣ୍ଡା', + 'SA' => 'ସାଉଦି ଆରବ', + 'SD' => 'ସୁଦାନ', + 'SN' => 'ସେନେଗାଲ୍', + 'SG' => 'ସିଙ୍ଗାପୁର', + 'SB' => 'ଶଲୋମନ ଦ୍ୱୀପପୁ୍ଜ', + 'SL' => 'ସିଇରା ଲେଓନେ', + 'SV' => 'ଏଲ ସାଲଭାଡୋର', + 'SM' => 'ସାନ୍ ମାରିନୋ', + 'SO' => 'ସୋମାଲିଆ', + 'RS' => 'ସର୍ବିଆ', + 'SS' => 'ଦକ୍ଷିଣ ସୁଦାନ', + 'ST' => 'ସାଓ ଟୋମେ ଏବଂ ପ୍ରିନ୍ସିପି', + 'SR' => 'ସୁରିନାମ', + 'SK' => 'ସ୍ଲୋଭାକିଆ', + 'SI' => 'ସ୍ଲୋଭେନିଆ', + 'SE' => 'ସ୍ୱିଡେନ', + 'SZ' => 'ସ୍ୱେଜ଼ୀଲାଣ୍ଡ', + 'SC' => 'ସେଚେଲସ୍', + 'SY' => 'ସିରିଆ', + 'TD' => 'ଚାଡ', + 'TG' => 'ଟୋଗୋ', + 'TH' => 'ଥାଇଲ୍ୟାଣ୍ଡ', + 'TJ' => 'ତାଜିକିସ୍ତାନ', + 'TM' => 'ତୁର୍କମେନିସ୍ତାନ', + 'TL' => 'ତିମୋର-ଲେଷ୍ଟେ', + 'TO' => 'ଟୋଙ୍ଗା', + 'TT' => 'ତ୍ରିନିଦାଦ ଏବଂ ଟୋବାଗୋ', + 'TN' => 'ଟ୍ୟୁନିସିଆ', + 'TR' => 'ତୁର୍କୀ', + 'TV' => 'ତୁଭାଲୁ', + 'TZ' => 'ତାଞ୍ଜାନିଆ', + 'UG' => 'ଉଗାଣ୍ଡା', + 'UA' => 'ୟୁକ୍ରେନ', + 'UY' => 'ଉରୁଗୁଏ', + 'US' => 'ଯୁକ୍ତ ରାଷ୍ଟ୍ର', + 'UZ' => 'ଉଜବେକିସ୍ତାନ', + 'VA' => 'ଭାଟିକାନ୍ ସିଟି', + 'VC' => 'ସେଣ୍ଟ ଭିନ୍ସେଣ୍ଟ ଏବଂ ଗ୍ରେନାଡାଇନ୍ସ', + 'VE' => 'ଭେନେଜୁଏଲା', + 'VN' => 'ଭିଏତନାମ', + 'VU' => 'ଭାନୁୟୁଟୁ', + 'WS' => 'ସାମୋଆ', + 'YE' => 'ୟେମେନ', + 'ZA' => 'ଦକ୍ଷିଣ ଆଫ୍ରିକା', + 'ZM' => 'ଜାମ୍ବିଆ', + 'ZW' => 'ଜିମ୍ବାୱେ', +]; diff --git a/app/config/locale/translations/od.php b/app/config/locale/translations/od.php new file mode 100644 index 0000000000..6b6973da25 --- /dev/null +++ b/app/config/locale/translations/od.php @@ -0,0 +1,21 @@ + '"ଜ୍ଞାନୀ ହେବାର କଳା ହେଉଛି କ’ଣ ଅଣଦେଖା କରାଯିବ ଜାଣିବାର କଳା |"', // This is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'od', + 'settings.direction' => 'ltr', + + // Service - Users + 'account.emails.team' => '%s ଟିମ', + 'account.emails.verification.title' => 'ଏକାଉଣ୍ଟ ଭେରିଫିକେସନ', + 'account.emails.verification.body' => 'od.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'ପାସୱାର୍ଡ ରିସେଟ', + 'account.emails.recovery.body' => 'od.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'ଈଂଭିଟେସନ %s ଟିମ at %s', + 'account.emails.invitation.body' => 'od.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'ଅଜ୍ଞାତ', + + 'countries' => include 'od.countries.php', + 'continents' => include 'od.continents.php', +]; diff --git a/app/config/locale/translations/pa.continents.php b/app/config/locale/translations/pa.continents.php new file mode 100644 index 0000000000..07b6548b38 --- /dev/null +++ b/app/config/locale/translations/pa.continents.php @@ -0,0 +1,11 @@ + 'ਅਫਰੀਕਾ', + 'AN' => 'ਅੰਟਾਰਕਟਿਕਾ', + 'AS' => 'ਏਸ਼ੀਆ', + 'EU' => 'ਯੂਰਪ', + 'NA' => 'ਉੱਤਰ ਅਮਰੀਕਾ', + 'OC' => 'ਓਸੀਆਨੀਆ', + 'SA' => 'ਸਾਉਥ ਅਮਰੀਕਾ', +]; diff --git a/app/config/locale/translations/pa.countries.php b/app/config/locale/translations/pa.countries.php new file mode 100644 index 0000000000..1096d0a368 --- /dev/null +++ b/app/config/locale/translations/pa.countries.php @@ -0,0 +1,200 @@ + 'ਅਫਗਾਨਿਸਤਾਨ', + 'AO' => 'ਐਂਗੋਲਾ', + 'AL' => 'ਅਲਬਾਨੀਆ', + 'AD' => 'ਅੰਡੋਰਾ', + 'AE' => 'ਸੰਯੂਕਤ ਅਰਬ ਅਮੀਰਾਤ', + 'AR' => 'ਅਰਜਿੰਟੀਨਾ', + 'AM' => 'ਅਰਮੇਨੀਆ', + 'AG' => 'ਐਨੀਟਗੁਆ ਅਤੇ ਬਰਮੁਡਾ', + 'AU' => 'ਆਸਟਰੇਲੀਆ', + 'AT' => 'ਆਸਟਰੀਆ', + 'AZ' => 'ਅਜ਼ਰਬਾਈਜਾਨ', + 'BI' => 'ਬੁਰੂੰਡੀ', + 'BE' => 'ਬੈਲਜੀਅਮ', + 'BJ' => 'ਬੇਨਿਨ', + 'BF' => 'ਬੁਰਕੀਨਾ ਫਾਸੋ', + 'BD' => 'ਬੰਗਲਾਦੇਸ਼', + 'BG' => 'ਬੁਲਗਾਰੀਆ', + 'BH' => 'ਬਾਹਰੇਨ', + 'BS' => 'ਬਾਹਾਮਸ', + 'BA' => 'ਬੋਸਨੀਆ ਅਤੇ ਹਰਜ਼ੇਗੋਵਿਨਾ', + 'BY' => 'ਬੇਲਾਰੂਸ', + 'BZ' => 'ਬੇਲੀਜ਼', + 'BO' => 'ਬੋਲੀਵੀਆ', + 'BR' => 'ਬ੍ਰਾਜ਼ੀਲ', + 'BB' => 'ਬਾਰਬਾਡੋ', + 'BN' => 'ਬਰੂਨੇਈ ', + 'BT' => 'ਭੂਤਨ', + 'BW' => 'ਬੋਤਸਵਾਨਾ', + 'CF' => 'ਕੇਂਦਰੀ ਅਫ਼ਰੀਕੀ ਗਣਰਾਜ', + 'CA' => 'ਕੈਨਡਾ', + 'CH' => 'ਸਵਿੱਟਜਰਲੈਂਡ', + 'CL' => 'ਚਿਲੀ', + 'CN' => 'ਚੀਨ', + 'CI' => 'ਹਾਥੀ ਦੰਦ', + 'CM' => 'ਕੈਮਰੂਨ', + 'CD' => 'ਡੀ.ਆਰ. ਕੋਂਗੋ', + 'CG' => 'ਕੌਂਗੋ ਗਣਰਾਜ', + 'CO' => 'ਕੋਲੰਬੀਆ', + 'KM' => 'ਕੋਮੋਰੋਜ਼', + 'CV' => 'ਕੇਪ ਵਰਡ', + 'CR' => 'ਕੋਸਟਾਰੀਕਾ', + 'CU' => 'ਕਿ cਬਾ', + 'CY' => 'ਸਾਈਪ੍ਰਸ', + 'CZ' => 'ਚੇਕ ਗਣਤੰਤਰ', + 'DE' => 'ਜਰਮਨ', + 'DJ' => 'ਜਾਇਬੂਟੀ', + 'DM' => 'ਹਾਵੀਕਾ', + 'DK' => 'ਡੈਨਮਾਰਕ', + 'DO' => 'ਡੋਮਿਨਿੱਕ ਰਿਪਬਲਿਕ', + 'DZ' => 'ਅਲਜੀਰੀਆ', + 'ER' => 'ਇਰੀਟਰੀਆ', + 'EC' => 'ਇਕੂਏਟਰ', + 'EG' => 'ਮਿਸਰ', + 'IR' => 'ਇਰੀਟਰੀਆ', + 'ES' => 'ਸਪੇਨ', + 'EE' => 'ਈਸਟੋਨੀਆ', + 'ET' => 'ਈਥੋਪੀਆ', + 'FI' => 'ਫਿਨਲੈਂਡ', + 'FJ' => 'ਫਿਜੀ', + 'FR' => 'ਫ੍ਰਾਂਸ', + 'FM' => 'ਮਾਈਕਰੋਨੇਸ਼ੀਆ', + 'GA' => 'ਗੈਬਨ', + 'GB' => 'ਯੁਨਾਇਟੇਡ ਕਿਂਗਡਮ', + 'GE' => 'ਜਾਰਜੀਆ', + 'GH' => 'ਘਾਨਾ', + 'GN' => 'ਗਿੰਨੀ', + 'GM' => 'ਗੈਂਬੀਆ', + 'GW' => 'ਗਿੰਨੀ-ਬਿਸਾਉ', + 'GQ' => 'ਭੂਮੱਧ ਗਿੰਨੀ', + 'GR' => 'ਗ੍ਰੀਸ', + 'GD' => 'ਗ੍ਰੇਨਾਡਾ', + 'GT' => 'ਗੁਆਟੇਮਾਲਾ', + 'GY' => 'ਗੇਆਨਾ', + 'HN' => 'ਹੌਂਡੂਰਸ', + 'HR' => 'ਕਰੋਸ਼ੀਆ', + 'HT' => 'ਹੈਤੀ', + 'HU' => 'ਹੰਗਰੀਅਨ ਦੇਸ਼', + 'ID' => 'ਇੰਡੋਨੇਸ਼ੀਆ', + 'IN' => 'ਭਾਰਤ', + 'IE' => 'ਆਇਰਲੈਂਡ', + 'IR' => 'ਇਰਾਨ', + 'IQ' => 'ਇਰਾਕ', + 'IS' => 'ਆਈਸਲੈਂਡ', + 'IL' => 'ਇਸਰਾਇਲ', + 'IT' => 'ਇਟਲੀ', + 'JM' => 'ਜਮਾਏਕਾ', + 'JO' => 'ਜਾਰਡਨ', + 'JP' => 'ਜਪਾਨ', + 'KZ' => 'ਕਜ਼ਾਕਿਸਤਾਨ', + 'KE' => 'ਕੀਨੀਆ', + 'KG' => 'ਕਿਰਗਿਸਤਾਨ', + 'KH' => 'ਕੰਬੋਡੀਆ', + 'KI' => 'ਕਿਰੀਬਾਤੀ', + 'KN' => 'ਸੈਂਟ ਕਿੱਟਸ ਅਤੇ ਨੇਵਿਸ', + 'KR' => 'ਦੱਖਣੀ ਕੋਰੀਆ', + 'KW' => 'ਕੁਵੈਤ', + 'LA' => 'ਲਾਓਸ', + 'LB' => 'ਲੇਬਨਾਨ', + 'LR' => 'ਲਾਇਬੇਰੀਆ', + 'LY' => 'ਲਿਬੀਆ', + 'LC' => 'ਸ੍ਟ੍ਰੀਟ ਲੂਸੀਆ', + 'LI' => 'ਲੀਚਨਸਟਾਈਨ', + 'LK' => 'ਸ਼ਿਰੀਲੰਕਾ', + 'LS' => 'ਲੈਸੋਥੋ', + 'LT' => 'ਲਿਥੁਆਨੀਆ', + 'LU' => 'ਲਕਸਮਬਰਗ', + 'LV' => 'ਲਾਤਵੀਆ', + 'MA' => 'ਮੋਰੋਕੋ', + 'MC' => 'ਮੋਨਾਕੋ', + 'MD' => 'ਮੋਲਡੋਵਾ', + 'MG' => 'ਮੈਡਾਗਾਸਕਰ', + 'MV' => 'ਮਾਲਦੀਵ', + 'MX' => 'ਮੈਕਸੀਕੋ', + 'MH' => 'ਮਾਰਸ਼ਲ ਟਾਪੂ', + 'MK' => 'ਮੈਸੇਡੋਨੀਆ', + 'ML' => 'ਮਾਲੀ', + 'MT' => 'ਮਾਲਟਾ', + 'MM' => 'ਮਿਆਂਮਾਰ', + 'ME' => 'ਮੋਨਟੇਨੇਗਰੋ', + 'MN' => 'ਮੰਗੋਲੀਆ', + 'MZ' => 'ਮੋਜ਼ਰਬਿਕ', + 'MR' => 'ਮੌਰੀਟਾਨੀਆ', + 'MU' => 'ਮਾਰੀਸ਼ਸ', + 'MW' => 'ਮਾਲਾਵੀ', + 'MY' => 'ਮਲੇਸ਼ੀਆ', + 'NA' => 'ਨਾਮੀਬੀਆ', + 'NE' => 'ਨਾਈਜਰ', + 'NG' => 'ਨਾਈਜੀਰੀਆ', + 'NI' => 'ਨਿਕਾਰਾਗੁਆ', + 'NL' => 'ਨੈੱਟਲਰਲੈਂਡ', + 'NO' => 'ਨਾਰਵੇ', + 'NP' => 'ਨੇਪਾਲ', + 'NR' => 'ਨਾਰੂ', + 'NZ' => 'ਨਿਊਜ਼ੀਲੈਂਡ', + 'OM' => 'ਓਮਾਨ', + 'PK' => 'ਪਾਕਿਸਤਾਨ', + 'PA' => 'ਪਨਾਮਾ', + 'PE' => 'ਪੇਰੂ', + 'PH' => 'ਫਿਲਪੀਨਜ਼', + 'PW' => 'ਪਲਾਉ', + 'PG' => 'ਪਪੁਆ ਨਵਾਂ ਗਿੰਨੀ', + 'PL' => 'ਪੋਲੈਂਡ', + 'KP' => 'ਉੱਤਰੀ ਕੋਰਿਆ', + 'PT' => 'ਪੋਰਟੁਗਲ', + 'PY' => 'ਪੈਰਾਗੁਏ', + 'QA' => 'ਕਤਰ', + 'RO' => 'ਰੋਮਾਨੀਆ', + 'RU' => 'ਰੂਸ', + 'RW' => 'ਰੂਸ', + 'SA' => 'ਸੌਦੀ ਅਰਬ', + 'SD' => 'ਸੁਡਾਨ', + 'SN' => 'ਸੇਨੇਗਲ', + 'SG' => 'ਸਿੰਗਾਪੁਰ', + 'SB' => 'ਸੋਲੋਮੋਨ ਟਾਪੂ', + 'SL' => 'ਸੀਅਰਾ ਲਿਓਨ', + 'SV' => 'ਅਲ ਸਾਲਵਾਡੋਰ', + 'SM' => 'ਸੈਨ ਮਰੀਨੋ', + 'SO' => 'ਸੋਮਾਲੀਆ', + 'RS' => 'ਸਰਬੀਆ', + 'SS' => 'ਦੱਖਣੀ ਸੁਡਾਨ', + 'ST' => 'ਸਾਓ ਟੋਮ ਅਤੇ ਪ੍ਰਿੰਸੀਪਲ', + 'SR' => 'ਸੂਰੀਨਾਮ', + 'SK' => 'ਸਲਾਸਿਆ', + 'SI' => 'ਸਲੋਵੇਨੀਆ', + 'SE' => 'ਸਵੀਡਨ', + 'SZ' => 'ਸਵਾਜ਼ੀਲੈਂਡ', + 'SC' => 'ਸੇਸ਼ੇਲਸ', + 'SY' => 'ਸੀਰੀਆ', + 'TD' => 'ਚਾਡ', + 'TG' => 'ਹੁਣੇ ਜਾਣਾ', + 'TH' => 'ਥਾਈਲੈਂਡ', + 'TJ' => 'ਤਜਿਕਿਸਤਾਨ', + 'TM' => 'ਤੁਰਕਮੇਨਿਸਤਾਨ', + 'TL' => 'ਟਾਈਮਰ ਘੱਟ', + 'TO' => 'ਟੰਗਾ', + 'TT' => 'ਤ੍ਰਿਨੀਦਾਦ ਅਤੇ ਟੋਬਾਗੋ', + 'TN' => 'ਯੂਨਿਸੀਆ', + 'TR' => 'ਟਰਕੀ', + 'TV' => 'ਤੁਵਾਲੁ', + 'TZ' => 'ਤਨਜ਼ਾਨੀਆ', + 'UG' => 'ਯੂਗਾਂਡਾ', + 'UA' => 'ਯੂਕ੍ਰੇਨ', + 'UY' => 'ਉਰੁਗੁਏ', + 'US' => 'ਸੰਯੁਕਤ ਰਾਜ ਅਮਰੀਕਾ', + 'UZ' => 'ਉਜ਼ਬੇਕਿਸਤਾਨ', + 'VA' => 'ਵੈਟੀਕਨ ਸ਼ਹਿਰ', + 'VC' => 'ਸੈਂਟ ਵਿਨਸੈਂਟ ਅਤੇ ਗ੍ਰੇਨਾਡਾਈਨਜ਼', + 'VE' => 'ਵੈਨਜ਼ੂਏਲਾ', + 'VN' => 'ਵੀਅਤਨਾਮ', + 'VU' => 'ਵੈਨੂਆਟੂ', + 'WS' => 'ਸਮੋਆ', + 'YE' => 'ਯੀਮਨ', + 'ZA' => 'ਦੱਖਣੀ ਅਫਰੀਕਾ', + 'ZM' => 'ਜ਼ੈਂਬੀਆ', + 'ZW' => 'ਜ਼ਿੰਬਾਬਵੇ', +]; diff --git a/app/config/locale/translations/pa.php b/app/config/locale/translations/pa.php new file mode 100644 index 0000000000..6f1ffeeee4 --- /dev/null +++ b/app/config/locale/translations/pa.php @@ -0,0 +1,21 @@ + '"ਬੁੱਧੀਮਾਨ ਬਣਨ ਦੀ ਕਲਾ ਇਹ ਜਾਣਨ ਦੀ ਕਲਾ ਹੈ ਕਿ ਕਿਸ ਨੂੰ ਨਜ਼ਰਅੰਦਾਜ਼ ਕਰਨਾ ਹੈ."', // This is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'pa', + 'settings.direction' => 'ltr', + + // Service - Users + 'account.emails.team' => '%s ਟੀਮ', + 'account.emails.verification.title' => 'ਖਾਤਾ ਪੁਸ਼ਟੀਕਰਣ', + 'account.emails.verification.body' => 'pa.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'ਪਾਸਵਰਡ ਰੀਸੈੱਟ', + 'account.emails.recovery.body' => 'pa.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'ਸੱਦਾ %s ਟੀਮ %s', + 'account.emails.invitation.body' => 'pa.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'ਅਣਜਾਣ', + + 'countries' => include 'pa.countries.php', + 'continents' => include 'pa.continents.php', +]; diff --git a/app/config/locales/ph.continents.php b/app/config/locale/translations/ph.continents.php similarity index 100% rename from app/config/locales/ph.continents.php rename to app/config/locale/translations/ph.continents.php diff --git a/app/config/locales/ph.countries.php b/app/config/locale/translations/ph.countries.php similarity index 100% rename from app/config/locales/ph.countries.php rename to app/config/locale/translations/ph.countries.php diff --git a/app/config/locales/ph.php b/app/config/locale/translations/ph.php similarity index 100% rename from app/config/locales/ph.php rename to app/config/locale/translations/ph.php diff --git a/app/config/locales/pl.continents.php b/app/config/locale/translations/pl.continents.php similarity index 100% rename from app/config/locales/pl.continents.php rename to app/config/locale/translations/pl.continents.php diff --git a/app/config/locales/pl.countries.php b/app/config/locale/translations/pl.countries.php similarity index 100% rename from app/config/locales/pl.countries.php rename to app/config/locale/translations/pl.countries.php diff --git a/app/config/locales/pl.php b/app/config/locale/translations/pl.php similarity index 63% rename from app/config/locales/pl.php rename to app/config/locale/translations/pl.php index 7fc5875bf8..394072834d 100644 --- a/app/config/locales/pl.php +++ b/app/config/locale/translations/pl.php @@ -2,20 +2,20 @@ return [ 'settings.inspire' => '"Sztuka bycia mądrym to sztuka wiedzieć, co przeoczyć."', // This is the line printed in the homepage and console 'view-source' - 'settings.locale' => 'en', + 'settings.locale' => 'pl', 'settings.direction' => 'ltr', // Service - Users 'account.emails.team' => 'Zespół %s', 'account.emails.verification.title' => 'Potwierdzenie konta', - 'account.emails.verification.body' => 'en.email.auth.confirm.tpl', + 'account.emails.verification.body' => 'pl.email.auth.confirm.tpl', 'account.emails.recovery.title' => 'Zresetowanie hasła', - 'account.emails.recovery.body' => 'en.email.auth.recovery.tpl', + 'account.emails.recovery.body' => 'pl.email.auth.recovery.tpl', 'account.emails.invitation.title' => 'Zaproszenie do zespołu %s - %s', - 'account.emails.invitation.body' => 'en.email.auth.invitation.tpl', + 'account.emails.invitation.body' => 'pl.email.auth.invitation.tpl', 'locale.country.unknown' => 'Nieznany', - 'countries' => include 'en.countries.php', - 'continents' => include 'en.continents.php', + 'countries' => include 'pl.countries.php', + 'continents' => include 'pl.continents.php', ]; diff --git a/app/config/locales/pt-br.continents.php b/app/config/locale/translations/pt-br.continents.php similarity index 100% rename from app/config/locales/pt-br.continents.php rename to app/config/locale/translations/pt-br.continents.php diff --git a/app/config/locales/pt-br.countries.php b/app/config/locale/translations/pt-br.countries.php similarity index 100% rename from app/config/locales/pt-br.countries.php rename to app/config/locale/translations/pt-br.countries.php diff --git a/app/config/locales/pt-br.php b/app/config/locale/translations/pt-br.php similarity index 100% rename from app/config/locales/pt-br.php rename to app/config/locale/translations/pt-br.php diff --git a/app/config/locales/pt-pt.continents.php b/app/config/locale/translations/pt-pt.continents.php similarity index 100% rename from app/config/locales/pt-pt.continents.php rename to app/config/locale/translations/pt-pt.continents.php diff --git a/app/config/locales/pt-pt.countries.php b/app/config/locale/translations/pt-pt.countries.php similarity index 100% rename from app/config/locales/pt-pt.countries.php rename to app/config/locale/translations/pt-pt.countries.php diff --git a/app/config/locales/pt-pt.php b/app/config/locale/translations/pt-pt.php similarity index 100% rename from app/config/locales/pt-pt.php rename to app/config/locale/translations/pt-pt.php diff --git a/app/config/locales/ro.continents.php b/app/config/locale/translations/ro.continents.php similarity index 100% rename from app/config/locales/ro.continents.php rename to app/config/locale/translations/ro.continents.php diff --git a/app/config/locales/ro.countries.php b/app/config/locale/translations/ro.countries.php similarity index 100% rename from app/config/locales/ro.countries.php rename to app/config/locale/translations/ro.countries.php diff --git a/app/config/locales/ro.php b/app/config/locale/translations/ro.php similarity index 100% rename from app/config/locales/ro.php rename to app/config/locale/translations/ro.php diff --git a/app/config/locales/ru.continents.php b/app/config/locale/translations/ru.continents.php similarity index 100% rename from app/config/locales/ru.continents.php rename to app/config/locale/translations/ru.continents.php diff --git a/app/config/locales/ru.countries.php b/app/config/locale/translations/ru.countries.php similarity index 100% rename from app/config/locales/ru.countries.php rename to app/config/locale/translations/ru.countries.php diff --git a/app/config/locales/ru.php b/app/config/locale/translations/ru.php similarity index 100% rename from app/config/locales/ru.php rename to app/config/locale/translations/ru.php diff --git a/app/config/locales/si.continents.php b/app/config/locale/translations/si.continents.php similarity index 100% rename from app/config/locales/si.continents.php rename to app/config/locale/translations/si.continents.php diff --git a/app/config/locales/si.countries.php b/app/config/locale/translations/si.countries.php similarity index 100% rename from app/config/locales/si.countries.php rename to app/config/locale/translations/si.countries.php diff --git a/app/config/locales/si.php b/app/config/locale/translations/si.php similarity index 100% rename from app/config/locales/si.php rename to app/config/locale/translations/si.php diff --git a/app/config/locales/sl.continents.php b/app/config/locale/translations/sl.continents.php similarity index 100% rename from app/config/locales/sl.continents.php rename to app/config/locale/translations/sl.continents.php diff --git a/app/config/locales/sl.countries.php b/app/config/locale/translations/sl.countries.php similarity index 100% rename from app/config/locales/sl.countries.php rename to app/config/locale/translations/sl.countries.php diff --git a/app/config/locales/sl.php b/app/config/locale/translations/sl.php similarity index 100% rename from app/config/locales/sl.php rename to app/config/locale/translations/sl.php diff --git a/app/config/locales/sq.continents.php b/app/config/locale/translations/sq.continents.php similarity index 100% rename from app/config/locales/sq.continents.php rename to app/config/locale/translations/sq.continents.php diff --git a/app/config/locales/sq.countries.php b/app/config/locale/translations/sq.countries.php similarity index 100% rename from app/config/locales/sq.countries.php rename to app/config/locale/translations/sq.countries.php diff --git a/app/config/locales/sq.php b/app/config/locale/translations/sq.php similarity index 100% rename from app/config/locales/sq.php rename to app/config/locale/translations/sq.php diff --git a/app/config/locales/sv.continents.php b/app/config/locale/translations/sv.continents.php similarity index 100% rename from app/config/locales/sv.continents.php rename to app/config/locale/translations/sv.continents.php diff --git a/app/config/locales/sv.countries.php b/app/config/locale/translations/sv.countries.php similarity index 100% rename from app/config/locales/sv.countries.php rename to app/config/locale/translations/sv.countries.php diff --git a/app/config/locales/sv.php b/app/config/locale/translations/sv.php similarity index 100% rename from app/config/locales/sv.php rename to app/config/locale/translations/sv.php diff --git a/app/config/locales/ta.continents.php b/app/config/locale/translations/ta.continents.php similarity index 100% rename from app/config/locales/ta.continents.php rename to app/config/locale/translations/ta.continents.php diff --git a/app/config/locales/ta.countries.php b/app/config/locale/translations/ta.countries.php similarity index 100% rename from app/config/locales/ta.countries.php rename to app/config/locale/translations/ta.countries.php diff --git a/app/config/locales/ta.php b/app/config/locale/translations/ta.php similarity index 100% rename from app/config/locales/ta.php rename to app/config/locale/translations/ta.php diff --git a/app/config/locales/templates/af.email.auth.confirm.tpl b/app/config/locale/translations/templates/af.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/af.email.auth.confirm.tpl rename to app/config/locale/translations/templates/af.email.auth.confirm.tpl diff --git a/app/config/locales/templates/af.email.auth.invitation.tpl b/app/config/locale/translations/templates/af.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/af.email.auth.invitation.tpl rename to app/config/locale/translations/templates/af.email.auth.invitation.tpl diff --git a/app/config/locales/templates/af.email.auth.recovery.tpl b/app/config/locale/translations/templates/af.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/af.email.auth.recovery.tpl rename to app/config/locale/translations/templates/af.email.auth.recovery.tpl diff --git a/app/config/locales/templates/alb.email.auth.confirm.tpl b/app/config/locale/translations/templates/alb.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/alb.email.auth.confirm.tpl rename to app/config/locale/translations/templates/alb.email.auth.confirm.tpl diff --git a/app/config/locales/templates/alb.email.auth.invitation.tpl b/app/config/locale/translations/templates/alb.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/alb.email.auth.invitation.tpl rename to app/config/locale/translations/templates/alb.email.auth.invitation.tpl diff --git a/app/config/locales/templates/alb.email.auth.recovery.tpl b/app/config/locale/translations/templates/alb.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/alb.email.auth.recovery.tpl rename to app/config/locale/translations/templates/alb.email.auth.recovery.tpl diff --git a/app/config/locales/templates/ar.email.auth.confirm.tpl b/app/config/locale/translations/templates/ar.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/ar.email.auth.confirm.tpl rename to app/config/locale/translations/templates/ar.email.auth.confirm.tpl diff --git a/app/config/locales/templates/ar.email.auth.invitation.tpl b/app/config/locale/translations/templates/ar.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/ar.email.auth.invitation.tpl rename to app/config/locale/translations/templates/ar.email.auth.invitation.tpl diff --git a/app/config/locales/templates/ar.email.auth.recovery.tpl b/app/config/locale/translations/templates/ar.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/ar.email.auth.recovery.tpl rename to app/config/locale/translations/templates/ar.email.auth.recovery.tpl diff --git a/app/config/locale/translations/templates/ba.email.auth.confirm.tpl b/app/config/locale/translations/templates/ba.email.auth.confirm.tpl new file mode 100644 index 0000000000..33c325e32f --- /dev/null +++ b/app/config/locale/translations/templates/ba.email.auth.confirm.tpl @@ -0,0 +1,15 @@ +

+ Zdravo {{name}}, +

+

+ Kliknite na ovaj link da verifikujete vašu email adresu. +

+{{cta}} +

+ Ukoliko niste zatražili verifikaciju email adrese, ignorišite ovaj email. +

+

+ Hvala, +
+ {{project}} tim +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/ba.email.auth.invitation.tpl b/app/config/locale/translations/templates/ba.email.auth.invitation.tpl new file mode 100644 index 0000000000..ea22ec186a --- /dev/null +++ b/app/config/locale/translations/templates/ba.email.auth.invitation.tpl @@ -0,0 +1,14 @@ +

+ Zdravo, +

+

+ Dobili ste ovaj email jer {{owner}} vas poziva da postanete član {{team}} tima na {{project}}. +

+{{cta}} +

+ Ukoliko niste zainteresovani, ignorišite ovu poruku.

+

+ Hvala, +
+ {{project}} tim +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/ba.email.auth.recovery.tpl b/app/config/locale/translations/templates/ba.email.auth.recovery.tpl new file mode 100644 index 0000000000..368ab87475 --- /dev/null +++ b/app/config/locale/translations/templates/ba.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ Zdravo {{name}}, +

+

+ Kliknite na ovaj link da resetujete vašu {{project}} lozinku. +

+{{cta}} +

+ Ukoliko niste zatražili verifikaciju ove adrese, ignorišite ovaj email. +

+

+ Hvala, +
+ {{project}} tim +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/be.email.auth.confirm.tpl b/app/config/locale/translations/templates/be.email.auth.confirm.tpl new file mode 100644 index 0000000000..64ff468889 --- /dev/null +++ b/app/config/locale/translations/templates/be.email.auth.confirm.tpl @@ -0,0 +1,15 @@ +

+ Прывітанне {{name}}, +

+

+ Перайдзіце па гэтай спасылцы, каб пацвердзіць свой адрас электроннай пошты. +

+{{cta}} +

+ Калі вы не прасілі спраўдзіць гэты адрас, вы можаце праігнараваць гэтае паведамленне. +

+

+ Дзякуем, +
+ Каманда {{project}} +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/be.email.auth.invitation.tpl b/app/config/locale/translations/templates/be.email.auth.invitation.tpl new file mode 100644 index 0000000000..56319b1f91 --- /dev/null +++ b/app/config/locale/translations/templates/be.email.auth.invitation.tpl @@ -0,0 +1,15 @@ +

+ Прывітанне, +

+

+ Гэта паведамленне было адпраўлена вам, таму што {{owner}} хацеў запрасіць вас стаць членам каманды {{team}} у {{project}}. +

+{{cta}} +

+ Калі вам гэта не цікава, вы можаце праігнараваць гэтае паведамленне. +

+

+ Дзякуем, +
+ Каманда {{project}} +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/be.email.auth.recovery.tpl b/app/config/locale/translations/templates/be.email.auth.recovery.tpl new file mode 100644 index 0000000000..4e87165f28 --- /dev/null +++ b/app/config/locale/translations/templates/be.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ Прывітанне {{name}}, +

+

+ Перайдзіце па гэтай спасылцы, каб скінуць пароль для {{project}}. +

+{{cta}} +

+ Калі вы не прасілі скінуць пароль, вы можаце праігнараваць гэта паведамленне. +

+

+ Дзякуем, +
+ Каманда {{project}} +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/bg.email.auth.confirm.tpl b/app/config/locale/translations/templates/bg.email.auth.confirm.tpl new file mode 100644 index 0000000000..dc0c1df182 --- /dev/null +++ b/app/config/locale/translations/templates/bg.email.auth.confirm.tpl @@ -0,0 +1,15 @@ +

+ Здравейте {{name}}, +

+

+ Следвайте този линк, за да потвърдите имейл адреса си. +

+{{cta}} +

+ Ако не сте поискали да потвърдите този адрес, можете да игнорирате това съобщение. +

+

+ Поздрави, +
+ {{project}} екип +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/bg.email.auth.invitation.tpl b/app/config/locale/translations/templates/bg.email.auth.invitation.tpl new file mode 100644 index 0000000000..d5157f01c6 --- /dev/null +++ b/app/config/locale/translations/templates/bg.email.auth.invitation.tpl @@ -0,0 +1,14 @@ +

+ Здравейте, +

+

+ Този имейл Ви беше изпратен, защото {{owner}} искаше да Ви покани да станете член на {{team}} екип в {{project}}. +

+{{cta}} +

+ Ако не се интересувате, можете да игнорирате това съобщение.

+

+ Поздрави, +
+ {{project}} екип +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/bg.email.auth.recovery.tpl b/app/config/locale/translations/templates/bg.email.auth.recovery.tpl new file mode 100644 index 0000000000..007f7f05c3 --- /dev/null +++ b/app/config/locale/translations/templates/bg.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ Здравейте {{name}}, +

+

+ Последвайте този линк за да промените своята {{project}} парола. +

+{{cta}} +

+ Ако не сте поискали да потвърдите този адрес, можете да игнорирате това съобщение. +

+

+ Поздрави, +
+ {{project}} екип +

\ No newline at end of file diff --git a/app/config/locales/templates/bn.email.auth.confirm.tpl b/app/config/locale/translations/templates/bn.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/bn.email.auth.confirm.tpl rename to app/config/locale/translations/templates/bn.email.auth.confirm.tpl diff --git a/app/config/locales/templates/bn.email.auth.invitation.tpl b/app/config/locale/translations/templates/bn.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/bn.email.auth.invitation.tpl rename to app/config/locale/translations/templates/bn.email.auth.invitation.tpl diff --git a/app/config/locales/templates/bn.email.auth.recovery.tpl b/app/config/locale/translations/templates/bn.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/bn.email.auth.recovery.tpl rename to app/config/locale/translations/templates/bn.email.auth.recovery.tpl diff --git a/app/config/locales/templates/cat.email.auth.confirm.tpl b/app/config/locale/translations/templates/cat.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/cat.email.auth.confirm.tpl rename to app/config/locale/translations/templates/cat.email.auth.confirm.tpl diff --git a/app/config/locales/templates/cat.email.auth.invitation.tpl b/app/config/locale/translations/templates/cat.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/cat.email.auth.invitation.tpl rename to app/config/locale/translations/templates/cat.email.auth.invitation.tpl diff --git a/app/config/locales/templates/cat.email.auth.recovery.tpl b/app/config/locale/translations/templates/cat.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/cat.email.auth.recovery.tpl rename to app/config/locale/translations/templates/cat.email.auth.recovery.tpl diff --git a/app/config/locales/templates/cz.email.auth.confirm.tpl b/app/config/locale/translations/templates/cz.email.auth.confirm.tpl similarity index 71% rename from app/config/locales/templates/cz.email.auth.confirm.tpl rename to app/config/locale/translations/templates/cz.email.auth.confirm.tpl index e72b357a48..9e5fab32cc 100644 --- a/app/config/locales/templates/cz.email.auth.confirm.tpl +++ b/app/config/locale/translations/templates/cz.email.auth.confirm.tpl @@ -2,14 +2,14 @@ Ahoj {{name}},

- Kliknutím na tento odkaz ověřte svou e-mailovou adresu. + Klepnutím na tento odkaz ověřte svou e-mailovou adresu.

{{cta}}

Pokud jste nepožádali o ověření této adresy, můžete tuto zprávu ignorovat.

- dík, + Dík,
{{project}} tým

diff --git a/app/config/locales/templates/cz.email.auth.invitation.tpl b/app/config/locale/translations/templates/cz.email.auth.invitation.tpl similarity index 77% rename from app/config/locales/templates/cz.email.auth.invitation.tpl rename to app/config/locale/translations/templates/cz.email.auth.invitation.tpl index d5353e71cf..0dbfa6570b 100644 --- a/app/config/locales/templates/cz.email.auth.invitation.tpl +++ b/app/config/locale/translations/templates/cz.email.auth.invitation.tpl @@ -2,7 +2,7 @@ Ahoj,

- Tento e-mail vám byl zaslán, protože vás {{owner}} chtěl pozvat, abyste se stali členem týmu v týmu {{team}} v {{project}}. + Tento e-mail vám byl zaslán, protože vás {{owner}} chtěl pozvat, abyste se stali členem týmu {{team}} v {{project}}.

Klepnutím na tento odkaz se připojíte k týmu {{team}}: diff --git a/app/config/locales/templates/cz.email.auth.recovery.tpl b/app/config/locale/translations/templates/cz.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/cz.email.auth.recovery.tpl rename to app/config/locale/translations/templates/cz.email.auth.recovery.tpl diff --git a/app/config/locales/templates/de.email.auth.confirm.tpl b/app/config/locale/translations/templates/de.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/de.email.auth.confirm.tpl rename to app/config/locale/translations/templates/de.email.auth.confirm.tpl diff --git a/app/config/locales/templates/de.email.auth.invitation.tpl b/app/config/locale/translations/templates/de.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/de.email.auth.invitation.tpl rename to app/config/locale/translations/templates/de.email.auth.invitation.tpl diff --git a/app/config/locales/templates/de.email.auth.recovery.tpl b/app/config/locale/translations/templates/de.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/de.email.auth.recovery.tpl rename to app/config/locale/translations/templates/de.email.auth.recovery.tpl diff --git a/app/config/locales/templates/en.email.auth.confirm.tpl b/app/config/locale/translations/templates/en.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/en.email.auth.confirm.tpl rename to app/config/locale/translations/templates/en.email.auth.confirm.tpl diff --git a/app/config/locales/templates/en.email.auth.invitation.tpl b/app/config/locale/translations/templates/en.email.auth.invitation.tpl similarity index 70% rename from app/config/locales/templates/en.email.auth.invitation.tpl rename to app/config/locale/translations/templates/en.email.auth.invitation.tpl index 70ea922c0c..f801a5d3c0 100644 --- a/app/config/locales/templates/en.email.auth.invitation.tpl +++ b/app/config/locale/translations/templates/en.email.auth.invitation.tpl @@ -2,7 +2,7 @@ Hello,

- This mail was sent to you because {{owner}} wanted to invite you to become a team member at the {{team}} team over at {{project}}. + This mail was sent to you because {{owner}} wanted to invite you to become a member of the {{team}} team at {{project}}.

{{cta}}

@@ -11,4 +11,4 @@ Thanks,
{{project}} team -

\ No newline at end of file +

diff --git a/app/config/locales/templates/en.email.auth.recovery.tpl b/app/config/locale/translations/templates/en.email.auth.recovery.tpl similarity index 71% rename from app/config/locales/templates/en.email.auth.recovery.tpl rename to app/config/locale/translations/templates/en.email.auth.recovery.tpl index a4a982f46f..57bdeb18a5 100644 --- a/app/config/locales/templates/en.email.auth.recovery.tpl +++ b/app/config/locale/translations/templates/en.email.auth.recovery.tpl @@ -6,10 +6,10 @@

{{cta}}

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

Thanks,
{{project}} team -

\ No newline at end of file +

diff --git a/app/config/locales/templates/es.email.auth.confirm.tpl b/app/config/locale/translations/templates/es.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/es.email.auth.confirm.tpl rename to app/config/locale/translations/templates/es.email.auth.confirm.tpl diff --git a/app/config/locales/templates/es.email.auth.invitation.tpl b/app/config/locale/translations/templates/es.email.auth.invitation.tpl similarity index 63% rename from app/config/locales/templates/es.email.auth.invitation.tpl rename to app/config/locale/translations/templates/es.email.auth.invitation.tpl index d07b7ffb55..c1a8f81f11 100644 --- a/app/config/locales/templates/es.email.auth.invitation.tpl +++ b/app/config/locale/translations/templates/es.email.auth.invitation.tpl @@ -2,7 +2,7 @@ Hola,

- Te hemos enviamos este correo porque {{owner}} quiere invitarte a formar parte del equipo {{team}} en {{project}}. + Te hemos enviado este correo porque {{owner}} quiere invitarte a formar parte del equipo {{team}} en {{project}}.

Sigue este enlace para unirte al equipo {{team}}: diff --git a/app/config/locale/translations/templates/es.email.auth.recovery.tpl b/app/config/locale/translations/templates/es.email.auth.recovery.tpl new file mode 100644 index 0000000000..e498fd335c --- /dev/null +++ b/app/config/locale/translations/templates/es.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ Hola {{name}}, +

+

+ Sigue este enlace para restablecer tu contraseña de {{project}}. +

+{{cta}} +

+ Si no solicitaste restablecer tu contraseña, puedes ignorar este mensaje. +

+

+ Gracias, +
+ Equipo {{project}} +

diff --git a/app/config/locale/translations/templates/fa.email.auth.confirm.tpl b/app/config/locale/translations/templates/fa.email.auth.confirm.tpl new file mode 100644 index 0000000000..dcd33d88a8 --- /dev/null +++ b/app/config/locale/translations/templates/fa.email.auth.confirm.tpl @@ -0,0 +1,16 @@ +

+ +سلام {{name}}، +

+

+ برای تأیید آدرس ایمیل خود، روی این لینک کلیک کنید. +

+{{cta}} +

+اگر از شما خواسته نشده است این آدرس ایمیل را تأیید کنید، می توانید این پیام را نادیده بگیرید. +

+

+ متشکریم, +
+ تیم {{project}} +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/fa.email.auth.invitation.tpl b/app/config/locale/translations/templates/fa.email.auth.invitation.tpl new file mode 100644 index 0000000000..a89c7decc1 --- /dev/null +++ b/app/config/locale/translations/templates/fa.email.auth.invitation.tpl @@ -0,0 +1,18 @@ +

+ سلام، +

+

+ این نامه برای شما ارسال شد زیرا {{owner}} می‌خواهد شما را به عضویت تیم {{team}} در {{project}} دعوت کند. +

+

+ برای عضویت در تیم {{team}} بر روی لینک زیر کلیک کنید : +

+{{cta}} +

+اگر علاقه‌ای ندارید، می توانید این پیام را نادیده بگیرید. +

+

+ متشکریم, +
+ {{project}} تیم +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/fa.email.auth.recovery.tpl b/app/config/locale/translations/templates/fa.email.auth.recovery.tpl new file mode 100644 index 0000000000..b493d5e033 --- /dev/null +++ b/app/config/locale/translations/templates/fa.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ سلام {{name}}، +

+

+ لینک زیر را کلیک کنید تا رمز عبور {{project}} را بازیابی کنید. +

+{{cta}} +

+ اگر علاقه‌ای ندارید، می توانید این پیام را نادیده بگیرید. +

+

+ متشکریم، +
+ تیم {{project}} +

diff --git a/app/config/locales/templates/fi.email.auth.confirm.tpl b/app/config/locale/translations/templates/fi.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/fi.email.auth.confirm.tpl rename to app/config/locale/translations/templates/fi.email.auth.confirm.tpl diff --git a/app/config/locales/templates/fi.email.auth.invitation.tpl b/app/config/locale/translations/templates/fi.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/fi.email.auth.invitation.tpl rename to app/config/locale/translations/templates/fi.email.auth.invitation.tpl diff --git a/app/config/locales/templates/fi.email.auth.recovery.tpl b/app/config/locale/translations/templates/fi.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/fi.email.auth.recovery.tpl rename to app/config/locale/translations/templates/fi.email.auth.recovery.tpl diff --git a/app/config/locales/templates/fo.email.auth.confirm.tpl b/app/config/locale/translations/templates/fo.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/fo.email.auth.confirm.tpl rename to app/config/locale/translations/templates/fo.email.auth.confirm.tpl diff --git a/app/config/locales/templates/fo.email.auth.invitation.tpl b/app/config/locale/translations/templates/fo.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/fo.email.auth.invitation.tpl rename to app/config/locale/translations/templates/fo.email.auth.invitation.tpl diff --git a/app/config/locales/templates/fo.email.auth.recovery.tpl b/app/config/locale/translations/templates/fo.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/fo.email.auth.recovery.tpl rename to app/config/locale/translations/templates/fo.email.auth.recovery.tpl diff --git a/app/config/locales/templates/fr.email.auth.confirm.tpl b/app/config/locale/translations/templates/fr.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/fr.email.auth.confirm.tpl rename to app/config/locale/translations/templates/fr.email.auth.confirm.tpl diff --git a/app/config/locales/templates/fr.email.auth.invitation.tpl b/app/config/locale/translations/templates/fr.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/fr.email.auth.invitation.tpl rename to app/config/locale/translations/templates/fr.email.auth.invitation.tpl diff --git a/app/config/locales/templates/fr.email.auth.recovery.tpl b/app/config/locale/translations/templates/fr.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/fr.email.auth.recovery.tpl rename to app/config/locale/translations/templates/fr.email.auth.recovery.tpl diff --git a/app/config/locales/templates/gr.email.auth.confirm.tpl b/app/config/locale/translations/templates/gr.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/gr.email.auth.confirm.tpl rename to app/config/locale/translations/templates/gr.email.auth.confirm.tpl diff --git a/app/config/locales/templates/gr.email.auth.invitation.tpl b/app/config/locale/translations/templates/gr.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/gr.email.auth.invitation.tpl rename to app/config/locale/translations/templates/gr.email.auth.invitation.tpl diff --git a/app/config/locales/templates/gr.email.auth.recovery.tpl b/app/config/locale/translations/templates/gr.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/gr.email.auth.recovery.tpl rename to app/config/locale/translations/templates/gr.email.auth.recovery.tpl diff --git a/app/config/locale/translations/templates/gu.email.auth.confirm.tpl b/app/config/locale/translations/templates/gu.email.auth.confirm.tpl new file mode 100644 index 0000000000..d2223555d1 --- /dev/null +++ b/app/config/locale/translations/templates/gu.email.auth.confirm.tpl @@ -0,0 +1,16 @@ +

+ +નમસ્તે {{name}}, +

+

+ તમારા ઇમેઇલ સરનામાંને ચકાસવા માટે આ લિંક પર ક્લિક કરો. +

+{{cta}} +

+ જો તમને આ ઇમેઇલને ચકાસવા માટે પૂછવામાં નહીં આવે તો તમે આ સંદેશને અવગણી શકો છો. +

+

+ આભાર, +
+ {{project}} ટીમ +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/gu.email.auth.invitation.tpl b/app/config/locale/translations/templates/gu.email.auth.invitation.tpl new file mode 100644 index 0000000000..606dc25bb2 --- /dev/null +++ b/app/config/locale/translations/templates/gu.email.auth.invitation.tpl @@ -0,0 +1,18 @@ +

+ નમસ્તે, +

+

+ આ મેલ તમને મોકલ્યો હતો કારણ કે {{owner}} તને {{project}} આ કારણ થી {{team}} અહીં સભ્ય બનવા માટે આમંત્રણ આપવાની ઇચ્છા છે. +

+

+ ટીમ {{team}} જોડાવા માટે આ લિંક પર ક્લિક કરો : +

+{{cta}} +

+ જો તમને રુચિ ન હોય તો તમે આ સંદેશને અવગણી શકો છો. +

+

+ આભાર, +
+ {{project}} ટીમ +

diff --git a/app/config/locale/translations/templates/gu.email.auth.recovery.tpl b/app/config/locale/translations/templates/gu.email.auth.recovery.tpl new file mode 100644 index 0000000000..cdc4558de6 --- /dev/null +++ b/app/config/locale/translations/templates/gu.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ નમસ્તે {{name}}, +

+

+ {{project}} પાસવર્ડ ફરીથી સેટ કરવા માટે આ લિંક પર ક્લિક કરો. +

+{{cta}} +

+ જો તમને તમારો પાસવર્ડ ફરીથી સેટ કરવાનું કહેવામાં ન આવે, તો તમે આ સંદેશને અવગણી શકો છો. +

+

+ આભાર, +
+ {{project}} ટીમ +

diff --git a/app/config/locales/templates/he.email.auth.confirm.tpl b/app/config/locale/translations/templates/he.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/he.email.auth.confirm.tpl rename to app/config/locale/translations/templates/he.email.auth.confirm.tpl diff --git a/app/config/locales/templates/he.email.auth.invitation.tpl b/app/config/locale/translations/templates/he.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/he.email.auth.invitation.tpl rename to app/config/locale/translations/templates/he.email.auth.invitation.tpl diff --git a/app/config/locales/templates/he.email.auth.recovery.tpl b/app/config/locale/translations/templates/he.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/he.email.auth.recovery.tpl rename to app/config/locale/translations/templates/he.email.auth.recovery.tpl diff --git a/app/config/locales/templates/hi.email.auth.confirm.tpl b/app/config/locale/translations/templates/hi.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/hi.email.auth.confirm.tpl rename to app/config/locale/translations/templates/hi.email.auth.confirm.tpl diff --git a/app/config/locales/templates/hi.email.auth.invitation.tpl b/app/config/locale/translations/templates/hi.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/hi.email.auth.invitation.tpl rename to app/config/locale/translations/templates/hi.email.auth.invitation.tpl diff --git a/app/config/locales/templates/hi.email.auth.recovery.tpl b/app/config/locale/translations/templates/hi.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/hi.email.auth.recovery.tpl rename to app/config/locale/translations/templates/hi.email.auth.recovery.tpl diff --git a/app/config/locale/translations/templates/hu.email.auth.confirm.tpl b/app/config/locale/translations/templates/hu.email.auth.confirm.tpl new file mode 100644 index 0000000000..6aec157846 --- /dev/null +++ b/app/config/locale/translations/templates/hu.email.auth.confirm.tpl @@ -0,0 +1,15 @@ +

+ Kedves {{name}}! +

+

+ Kérjük, e-mail címe megerősítéséhez kattintson az alábbi hivatkozásra: +

+{{cta}} +

+ Ha nem kérte az e-mail cím megerősítését, kérjük, tekintse ezt az üzenetet tárgytalannak. +

+

+ Köszönettel: +
+ {{project}} csapat +

diff --git a/app/config/locale/translations/templates/hu.email.auth.invitation.tpl b/app/config/locale/translations/templates/hu.email.auth.invitation.tpl new file mode 100644 index 0000000000..0c07be924d --- /dev/null +++ b/app/config/locale/translations/templates/hu.email.auth.invitation.tpl @@ -0,0 +1,15 @@ +

+ Üdvözöljük! +

+

+ Azért küldtük ezt az e-mailt, mert {{owner}} szeretné meghívni Önt a {{team}} csapatba a {{project}} projektben. +

+{{cta}} +

+ Ha nem szeretne csatlakozni, kérjük, tekintse ezt az üzenetet tárgytalannak. +

+

+ Köszönettel: +
+ {{project}} csapat +

diff --git a/app/config/locale/translations/templates/hu.email.auth.recovery.tpl b/app/config/locale/translations/templates/hu.email.auth.recovery.tpl new file mode 100644 index 0000000000..2919b0ffcf --- /dev/null +++ b/app/config/locale/translations/templates/hu.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ Kedves {{name}}! +

+

+ {{project}} jelszava visszaállításához kérjük, kattintson az alábbi linkre: +

+{{cta}} +

+ Ha nem kérte jelszava visszaállítását, kérjük, tekintse ezt az üzenetet tárgytalannak. +

+

+ Köszönettel: +
+ {{project}} csapat +

diff --git a/app/config/locales/templates/hy.email.auth.confirm.tpl b/app/config/locale/translations/templates/hy.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/hy.email.auth.confirm.tpl rename to app/config/locale/translations/templates/hy.email.auth.confirm.tpl diff --git a/app/config/locales/templates/hy.email.auth.invitation.tpl b/app/config/locale/translations/templates/hy.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/hy.email.auth.invitation.tpl rename to app/config/locale/translations/templates/hy.email.auth.invitation.tpl diff --git a/app/config/locales/templates/hy.email.auth.recovery.tpl b/app/config/locale/translations/templates/hy.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/hy.email.auth.recovery.tpl rename to app/config/locale/translations/templates/hy.email.auth.recovery.tpl diff --git a/app/config/locales/templates/id.email.auth.confirm.tpl b/app/config/locale/translations/templates/id.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/id.email.auth.confirm.tpl rename to app/config/locale/translations/templates/id.email.auth.confirm.tpl diff --git a/app/config/locales/templates/id.email.auth.invitation.tpl b/app/config/locale/translations/templates/id.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/id.email.auth.invitation.tpl rename to app/config/locale/translations/templates/id.email.auth.invitation.tpl diff --git a/app/config/locales/templates/id.email.auth.recovery.tpl b/app/config/locale/translations/templates/id.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/id.email.auth.recovery.tpl rename to app/config/locale/translations/templates/id.email.auth.recovery.tpl diff --git a/app/config/locales/templates/is.email.auth.confirm.tpl b/app/config/locale/translations/templates/is.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/is.email.auth.confirm.tpl rename to app/config/locale/translations/templates/is.email.auth.confirm.tpl diff --git a/app/config/locales/templates/is.email.auth.invitation.tpl b/app/config/locale/translations/templates/is.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/is.email.auth.invitation.tpl rename to app/config/locale/translations/templates/is.email.auth.invitation.tpl diff --git a/app/config/locales/templates/is.email.auth.recovery.tpl b/app/config/locale/translations/templates/is.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/is.email.auth.recovery.tpl rename to app/config/locale/translations/templates/is.email.auth.recovery.tpl diff --git a/app/config/locales/templates/it.email.auth.confirm.tpl b/app/config/locale/translations/templates/it.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/it.email.auth.confirm.tpl rename to app/config/locale/translations/templates/it.email.auth.confirm.tpl diff --git a/app/config/locales/templates/it.email.auth.invitation.tpl b/app/config/locale/translations/templates/it.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/it.email.auth.invitation.tpl rename to app/config/locale/translations/templates/it.email.auth.invitation.tpl diff --git a/app/config/locales/templates/it.email.auth.recovery.tpl b/app/config/locale/translations/templates/it.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/it.email.auth.recovery.tpl rename to app/config/locale/translations/templates/it.email.auth.recovery.tpl diff --git a/app/config/locales/templates/ja.email.auth.confirm.tpl b/app/config/locale/translations/templates/ja.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/ja.email.auth.confirm.tpl rename to app/config/locale/translations/templates/ja.email.auth.confirm.tpl diff --git a/app/config/locales/templates/ja.email.auth.invitation.tpl b/app/config/locale/translations/templates/ja.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/ja.email.auth.invitation.tpl rename to app/config/locale/translations/templates/ja.email.auth.invitation.tpl diff --git a/app/config/locales/templates/ja.email.auth.recovery.tpl b/app/config/locale/translations/templates/ja.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/ja.email.auth.recovery.tpl rename to app/config/locale/translations/templates/ja.email.auth.recovery.tpl diff --git a/app/config/locales/templates/jv.email.auth.confirm.tpl b/app/config/locale/translations/templates/jv.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/jv.email.auth.confirm.tpl rename to app/config/locale/translations/templates/jv.email.auth.confirm.tpl diff --git a/app/config/locales/templates/jv.email.auth.invitation.tpl b/app/config/locale/translations/templates/jv.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/jv.email.auth.invitation.tpl rename to app/config/locale/translations/templates/jv.email.auth.invitation.tpl diff --git a/app/config/locales/templates/jv.email.auth.recovery.tpl b/app/config/locale/translations/templates/jv.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/jv.email.auth.recovery.tpl rename to app/config/locale/translations/templates/jv.email.auth.recovery.tpl diff --git a/app/config/locale/translations/templates/ka.email.auth.confirm.tpl b/app/config/locale/translations/templates/ka.email.auth.confirm.tpl new file mode 100644 index 0000000000..62ac8d924a --- /dev/null +++ b/app/config/locale/translations/templates/ka.email.auth.confirm.tpl @@ -0,0 +1,15 @@ +

+ ಹಲೋ {{name}}, +

+

+ ನಿಮ್ಮ ಇಮೇಲ್ ವಿಳಾಸವನ್ನು ಪರಿಶೀಲಿಸಲು ಈ ಲಿಂಕ್ ಅನ್ನು ಅನುಸರಿಸಿ. +

+{{cta}} +

+ ಈ ವಿಳಾಸವನ್ನು ಪರಿಶೀಲಿಸಲು ನೀವು ಕೇಳದಿದ್ದರೆ, ನೀವು ಈ ಸಂದೇಶವನ್ನು ನಿರ್ಲಕ್ಷಿಸಬಹುದು. +

+

+ ಧನ್ಯವಾದಗಳು, +
+ {{project}} ತಂಡ +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/ka.email.auth.invitation.tpl b/app/config/locale/translations/templates/ka.email.auth.invitation.tpl new file mode 100644 index 0000000000..86507a1d67 --- /dev/null +++ b/app/config/locale/translations/templates/ka.email.auth.invitation.tpl @@ -0,0 +1,14 @@ +

+ ಹಲೋ, +

+

+ {{project}} ಕ್ಕೆ {{team}} ತಂಡದ ಓವರ್‌ನಲ್ಲಿ ತಂಡದ ಸದಸ್ಯರಾಗಲು {{owner}} ನಿಮ್ಮನ್ನು ಆಹ್ವಾನಿಸಲು ಬಯಸಿದ್ದರಿಂದ ಈ ಮೇಲ್ ಅನ್ನು ನಿಮಗೆ ಕಳುಹಿಸಲಾಗಿದೆ. +

+{{cta}} +

+ ನಿಮಗೆ ಆಸಕ್ತಿ ಇಲ್ಲದಿದ್ದರೆ, ನೀವು ಈ ಸಂದೇಶವನ್ನು ನಿರ್ಲಕ್ಷಿಸಬಹುದು. +

+ ಧನ್ಯವಾದಗಳು, +
+ {{project}} ತಂಡ +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/ka.email.auth.recovery.tpl b/app/config/locale/translations/templates/ka.email.auth.recovery.tpl new file mode 100644 index 0000000000..9d90ffc10b --- /dev/null +++ b/app/config/locale/translations/templates/ka.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ ಹಲೋ {{name}}, +

+

+ ನಿಮ್ಮ {{project}} ಪಾಸ್‌ವರ್ಡ್ ಅನ್ನು ಮರುಹೊಂದಿಸಲು ಈ ಲಿಂಕ್ ಅನ್ನು ಅನುಸರಿಸಿ. +

+{{cta}} +

+ ಈ ವಿಳಾಸವನ್ನು ಪರಿಶೀಲಿಸಲು ನೀವು ಕೇಳದಿದ್ದರೆ, ನೀವು ಈ ಸಂದೇಶವನ್ನು ನಿರ್ಲಕ್ಷಿಸಬಹುದು. +

+

+ ಧನ್ಯವಾದಗಳು, +
+ {{project}} ತಂಡ +

\ No newline at end of file diff --git a/app/config/locales/templates/km.email.auth.confirm.tpl b/app/config/locale/translations/templates/km.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/km.email.auth.confirm.tpl rename to app/config/locale/translations/templates/km.email.auth.confirm.tpl diff --git a/app/config/locales/templates/km.email.auth.invitation.tpl b/app/config/locale/translations/templates/km.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/km.email.auth.invitation.tpl rename to app/config/locale/translations/templates/km.email.auth.invitation.tpl diff --git a/app/config/locales/templates/km.email.auth.recovery.tpl b/app/config/locale/translations/templates/km.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/km.email.auth.recovery.tpl rename to app/config/locale/translations/templates/km.email.auth.recovery.tpl diff --git a/app/config/locales/templates/ko.email.auth.confirm.tpl b/app/config/locale/translations/templates/ko.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/ko.email.auth.confirm.tpl rename to app/config/locale/translations/templates/ko.email.auth.confirm.tpl diff --git a/app/config/locales/templates/ko.email.auth.invitation.tpl b/app/config/locale/translations/templates/ko.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/ko.email.auth.invitation.tpl rename to app/config/locale/translations/templates/ko.email.auth.invitation.tpl diff --git a/app/config/locales/templates/ko.email.auth.recovery.tpl b/app/config/locale/translations/templates/ko.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/ko.email.auth.recovery.tpl rename to app/config/locale/translations/templates/ko.email.auth.recovery.tpl diff --git a/app/config/locales/templates/lt.email.auth.confirm.tpl b/app/config/locale/translations/templates/lt.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/lt.email.auth.confirm.tpl rename to app/config/locale/translations/templates/lt.email.auth.confirm.tpl diff --git a/app/config/locales/templates/lt.email.auth.invitation.tpl b/app/config/locale/translations/templates/lt.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/lt.email.auth.invitation.tpl rename to app/config/locale/translations/templates/lt.email.auth.invitation.tpl diff --git a/app/config/locales/templates/lt.email.auth.recovery.tpl b/app/config/locale/translations/templates/lt.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/lt.email.auth.recovery.tpl rename to app/config/locale/translations/templates/lt.email.auth.recovery.tpl diff --git a/app/config/locales/templates/ml.email.auth.confirm.tpl b/app/config/locale/translations/templates/ml.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/ml.email.auth.confirm.tpl rename to app/config/locale/translations/templates/ml.email.auth.confirm.tpl diff --git a/app/config/locales/templates/ml.email.auth.invitation.tpl b/app/config/locale/translations/templates/ml.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/ml.email.auth.invitation.tpl rename to app/config/locale/translations/templates/ml.email.auth.invitation.tpl diff --git a/app/config/locales/templates/ml.email.auth.recovery.tpl b/app/config/locale/translations/templates/ml.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/ml.email.auth.recovery.tpl rename to app/config/locale/translations/templates/ml.email.auth.recovery.tpl diff --git a/app/config/locale/translations/templates/mr.email.auth.confirm.tpl b/app/config/locale/translations/templates/mr.email.auth.confirm.tpl new file mode 100644 index 0000000000..9ca8e0a5b7 --- /dev/null +++ b/app/config/locale/translations/templates/mr.email.auth.confirm.tpl @@ -0,0 +1,16 @@ +

+ +नमस्कार {{name}}, +

+

+ आपला ईमेल पत्ता वेरीफाई करण्यासाठी या लिंक वर क्लिक करा. +

+{{cta}} +

+ आपण हे ईमेल वेरीफाई करण्यास सांगितले नसल्यास आपण या संदेशाकडे दुर्लक्ष करू शकता. +

+

+ धन्यवाद, +
+ {{project}} टीम +

diff --git a/app/config/locale/translations/templates/mr.email.auth.invitation.tpl b/app/config/locale/translations/templates/mr.email.auth.invitation.tpl new file mode 100644 index 0000000000..e9507ec409 --- /dev/null +++ b/app/config/locale/translations/templates/mr.email.auth.invitation.tpl @@ -0,0 +1,18 @@ +

+ नमस्कार, +

+

+ हा मेल आपल्‍याला पाठविला गेला कारण {{owner}} आपल्‍याला {{project}} या कारणास्तव {{team}} येथे सदस्य होण्यासाठी आमंत्रित करू इच्छित होते. +

+

+ टीम {{team}}मध्ये सामील होण्यासाठी या लिंक वर क्लिक करा : +

+{{cta}} +

+ आपल्याला स्वारस्य नसल्यास आपण या संदेशाकडे दुर्लक्ष करू शकता. +

+

+ धन्यवाद, +
+ {{project}} टीम +

diff --git a/app/config/locale/translations/templates/mr.email.auth.recovery.tpl b/app/config/locale/translations/templates/mr.email.auth.recovery.tpl new file mode 100644 index 0000000000..ea93107ea2 --- /dev/null +++ b/app/config/locale/translations/templates/mr.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ नमस्कार {{name}}, +

+

+ {{project}} पासवर्ड रीसेट करण्यासाठी या लिंक वर क्लिक करा. +

+{{cta}} +

+ आपण आपला पासवर्ड रीसेट करण्यास सांगितले नसेल तर, आपण हा संदेश दुर्लक्षित करू शकता. +

+

+ धन्यवाद, +
+ {{project}} टीम +

diff --git a/app/config/locales/templates/my.email.auth.confirm.tpl b/app/config/locale/translations/templates/my.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/my.email.auth.confirm.tpl rename to app/config/locale/translations/templates/my.email.auth.confirm.tpl diff --git a/app/config/locales/templates/my.email.auth.invitation.tpl b/app/config/locale/translations/templates/my.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/my.email.auth.invitation.tpl rename to app/config/locale/translations/templates/my.email.auth.invitation.tpl diff --git a/app/config/locales/templates/my.email.auth.recovery.tpl b/app/config/locale/translations/templates/my.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/my.email.auth.recovery.tpl rename to app/config/locale/translations/templates/my.email.auth.recovery.tpl diff --git a/app/config/locales/templates/nl.email.auth.confirm.tpl b/app/config/locale/translations/templates/nl.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/nl.email.auth.confirm.tpl rename to app/config/locale/translations/templates/nl.email.auth.confirm.tpl diff --git a/app/config/locales/templates/nl.email.auth.invitation.tpl b/app/config/locale/translations/templates/nl.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/nl.email.auth.invitation.tpl rename to app/config/locale/translations/templates/nl.email.auth.invitation.tpl diff --git a/app/config/locales/templates/nl.email.auth.recovery.tpl b/app/config/locale/translations/templates/nl.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/nl.email.auth.recovery.tpl rename to app/config/locale/translations/templates/nl.email.auth.recovery.tpl diff --git a/app/config/locales/templates/no.email.auth.confirm.tpl b/app/config/locale/translations/templates/no.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/no.email.auth.confirm.tpl rename to app/config/locale/translations/templates/no.email.auth.confirm.tpl diff --git a/app/config/locales/templates/no.email.auth.invitation.tpl b/app/config/locale/translations/templates/no.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/no.email.auth.invitation.tpl rename to app/config/locale/translations/templates/no.email.auth.invitation.tpl diff --git a/app/config/locales/templates/no.email.auth.recovery.tpl b/app/config/locale/translations/templates/no.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/no.email.auth.recovery.tpl rename to app/config/locale/translations/templates/no.email.auth.recovery.tpl diff --git a/app/config/locale/translations/templates/np.email.auth.confirm.tpl b/app/config/locale/translations/templates/np.email.auth.confirm.tpl new file mode 100644 index 0000000000..c782ae98e9 --- /dev/null +++ b/app/config/locale/translations/templates/np.email.auth.confirm.tpl @@ -0,0 +1,16 @@ +

+ नमस्कार {{name}}, +

+

+ तपाईंको ईमेल ठेगाना प्रमाणित गर्न यो लिंक अनुसरण गर्नुहोस्। +

+{{cta}} +

+ यदि तपाईंले यो ठेगाना प्रमाणित गर्न सोधेन भने, तपाईं यो सन्देशलाई वेवास्ता गर्न सक्नुहुनेछ। +

+

+ धन्यवाद, +
+ {{project}} टीम +

+ diff --git a/app/config/locale/translations/templates/np.email.auth.invitation.tpl b/app/config/locale/translations/templates/np.email.auth.invitation.tpl new file mode 100644 index 0000000000..65d555185a --- /dev/null +++ b/app/config/locale/translations/templates/np.email.auth.invitation.tpl @@ -0,0 +1,15 @@ +

+ नमस्कार {{name}}, +

+

+ यो मेल तपाईंलाई पठाइएको थियो किनभने {{owner}}ले तपाईंलाई {{team}} टीममा रहेको {{project}} प्रोजेक्टमा टीमको सदस्य बन्न आमन्त्रित गर्न चाहन्छ। +

+{{cta}} +

+ यदि तपाईं इच्छुक हुनुहुन्न भने, तपाईं यो सन्देशलाई वेवास्ता गर्न सक्नुहुनेछ। +

+

+ धन्यवाद, +
+ {{project}} टीम +

diff --git a/app/config/locale/translations/templates/np.email.auth.recovery.tpl b/app/config/locale/translations/templates/np.email.auth.recovery.tpl new file mode 100644 index 0000000000..a2f9bb97d6 --- /dev/null +++ b/app/config/locale/translations/templates/np.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ नमस्कार {{name}}, +

+

+ तपाईंको {{project}}को पासवर्ड रिसेट गर्नका लागि यो लिंक अनुसरण गर्नुहोस्। +

+{{cta}} +

+ यदि तपाईंले यो ठेगाना प्रमाणित गर्न सोधेन भने, तपाईं यो सन्देशलाई वेवास्ता गर्न सक्नुहुनेछ। +

+

+ धन्यवाद, +
+ {{project}} टीम +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/od.email.auth.confirm.tpl b/app/config/locale/translations/templates/od.email.auth.confirm.tpl new file mode 100644 index 0000000000..9453a2a35c --- /dev/null +++ b/app/config/locale/translations/templates/od.email.auth.confirm.tpl @@ -0,0 +1,16 @@ +

+ + ନମସ୍କାର {{name}}, +

+

+ ଆପଣଙ୍କର ଇମେଲ୍ ଠିକଣା ଯାଞ୍ଚ କରିବାକୁ ଏହି ଲିଙ୍କ୍ ଅନୁସରଣ କରନ୍ତୁ| +

+{{cta}} +

+ ଯଦି ଆପଣ ଏହି ଠିକଣା ଯାଞ୍ଚ କରିବାକୁ କହି ନାହାଁନ୍ତି, ଆପଣ ଏହି ସନ୍ଦେଶକୁ ଉପେକ୍ଷା କରିପାରିବେ| +

+

+ ଧନ୍ୟବାଦ, +
+ {{project}} ଟିମ +

diff --git a/app/config/locale/translations/templates/od.email.auth.invitation.tpl b/app/config/locale/translations/templates/od.email.auth.invitation.tpl new file mode 100644 index 0000000000..ea1bf636c4 --- /dev/null +++ b/app/config/locale/translations/templates/od.email.auth.invitation.tpl @@ -0,0 +1,14 @@ +

+ ନମସ୍କାର, +

+

+ ଏହି ମେଲ୍ ଆପଣଙ୍କୁ ପଠାଯାଇଥିଲା କାରଣ {{owner}} ଆପଣଙ୍କୁ {{project}} ପାଇଁ {{team}} ଦଳରେ ଦଳର ସଦସ୍ୟ ହେବାକୁ ଆମନ୍ତ୍ରିତ ହେବାକୁ ଚାହୁଁଥିଲେ| +

+{{cta}} +

+ ଯଦି ଆପଣ ଆଗ୍ରହୀ ନୁହଁନ୍ତି, ଆପଣ ଏହି ସନ୍ଦେଶକୁ ଅଣଦେଖା କରିପାରିବେ |

+

+ ଧନ୍ୟବାଦ, +
+ {{project}} ଟିମ +

diff --git a/app/config/locale/translations/templates/od.email.auth.recovery.tpl b/app/config/locale/translations/templates/od.email.auth.recovery.tpl new file mode 100644 index 0000000000..9a20751205 --- /dev/null +++ b/app/config/locale/translations/templates/od.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ ନମସ୍କାର {{name}}, +

+

+ {{project}} ପାସୱାର୍ଡ ରିସେଟ କରିବାକୁ ଏହି ଲିଙ୍କ୍ ଉପରେ କ୍ଲିକ୍ କରନ୍ତୁ | +

+{{cta}} +

+ ଯଦି ଆପଣ ଏହି ଠିକଣା ଯାଞ୍ଚ କରିବାକୁ କହି ନାହାଁନ୍ତି, ଆପଣ ଏହି ସନ୍ଦେଶକୁ ଉପେକ୍ଷା କରିପାରିବେ| +

+

+ ଧନ୍ୟବାଦ, +
+ {{project}} ଟିମ +

diff --git a/app/config/locale/translations/templates/pa.email.auth.confirm.tpl b/app/config/locale/translations/templates/pa.email.auth.confirm.tpl new file mode 100644 index 0000000000..b8dc31c467 --- /dev/null +++ b/app/config/locale/translations/templates/pa.email.auth.confirm.tpl @@ -0,0 +1,16 @@ +

+ +ਸਤ ਸ੍ਰੀ ਅਕਾਲ {{name}}, +

+

+ ਆਪਣੇ ਈਮੇਲ ਪਤੇ ਦੀ ਤਸਦੀਕ ਕਰਨ ਲਈ ਇਸ ਲਿੰਕ ਤੇ ਕਲਿਕ ਕਰੋ. +

+{{cta}} +

+ਜੇ ਤੁਸੀਂ ਇਸ ਈਮੇਲ ਦੀ ਪੁਸ਼ਟੀ ਕਰਨ ਲਈ ਨਹੀਂ ਪੁੱਛਿਆ ਜਾਂਦਾ ਤਾਂ ਤੁਸੀਂ ਇਸ ਸੁਨੇਹੇ ਨੂੰ ਨਜ਼ਰਅੰਦਾਜ਼ ਕਰ ਸਕਦੇ ਹੋ. +

+

+ ਤੁਹਾਡਾ ਧੰਨਵਾਦ, +
+ {{project}} ਟੀਮ +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/pa.email.auth.invitation.tpl b/app/config/locale/translations/templates/pa.email.auth.invitation.tpl new file mode 100644 index 0000000000..e7643abc17 --- /dev/null +++ b/app/config/locale/translations/templates/pa.email.auth.invitation.tpl @@ -0,0 +1,18 @@ +

+ ਸਤ ਸ੍ਰੀ ਅਕਾਲ, +

+

+ ਕਿਉਂਕਿ ਇਹ ਮੇਲ ਤੁਹਾਨੂੰ ਭੇਜਿਆ ਗਿਆ ਸੀ {{owner}} ਤੁਸੀਂ {{project}} ਇਸ ਕਰਕੇ {{team}} ਇੱਥੇ ਇੱਕ ਮੈਂਬਰ ਬਣਨ ਲਈ ਸੱਦਾ ਦੇਣ ਦੀ ਇੱਛਾ ਹੈ. +

+

+ ਟੀਮ {{team}} ਸ਼ਾਮਲ ਹੋਣ ਲਈ ਇਸ ਲਿੰਕ 'ਤੇ ਕਲਿੱਕ ਕਰੋ : +

+{{cta}} +

+ਜੇ ਤੁਸੀਂ ਦਿਲਚਸਪੀ ਨਹੀਂ ਰੱਖਦੇ ਹੋ ਤਾਂ ਤੁਸੀਂ ਇਸ ਸੰਦੇਸ਼ ਨੂੰ ਅਣਡਿੱਠ ਕਰ ਸਕਦੇ ਹੋ. +

+

+ ਤੁਹਾਡਾ ਧੰਨਵਾਦ, +
+ {{project}} ਟੀਮ +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/pa.email.auth.recovery.tpl b/app/config/locale/translations/templates/pa.email.auth.recovery.tpl new file mode 100644 index 0000000000..fab1d290f5 --- /dev/null +++ b/app/config/locale/translations/templates/pa.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ ਸਤ ਸ੍ਰੀ ਅਕਾਲ {{name}}, +

+

+ {{project}} ਆਪਣਾ ਪਾਸਵਰਡ ਰੀਸੈਟ ਕਰਨ ਲਈ ਇਸ ਲਿੰਕ ਤੇ ਕਲਿਕ ਕਰੋ. +

+{{cta}} +

+ਜੇ ਤੁਹਾਨੂੰ ਆਪਣਾ ਪਾਸਵਰਡ ਰੀਸੈਟ ਕਰਨ ਲਈ ਨਹੀਂ ਕਿਹਾ ਜਾਂਦਾ, ਤਾਂ ਤੁਸੀਂ ਇਸ ਸੁਨੇਹੇ ਨੂੰ ਨਜ਼ਰਅੰਦਾਜ਼ ਕਰ ਸਕਦੇ ਹੋ. +

+

+ ਤੁਹਾਡਾ ਧੰਨਵਾਦ, +
+ {{project}} ਟੀਮ +

\ No newline at end of file diff --git a/app/config/locales/templates/ph.email.auth.confirm.tpl b/app/config/locale/translations/templates/ph.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/ph.email.auth.confirm.tpl rename to app/config/locale/translations/templates/ph.email.auth.confirm.tpl diff --git a/app/config/locales/templates/ph.email.auth.invitation.tpl b/app/config/locale/translations/templates/ph.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/ph.email.auth.invitation.tpl rename to app/config/locale/translations/templates/ph.email.auth.invitation.tpl diff --git a/app/config/locales/templates/ph.email.auth.recovery.tpl b/app/config/locale/translations/templates/ph.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/ph.email.auth.recovery.tpl rename to app/config/locale/translations/templates/ph.email.auth.recovery.tpl diff --git a/app/config/locales/templates/pl.email.auth.confirm.tpl b/app/config/locale/translations/templates/pl.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/pl.email.auth.confirm.tpl rename to app/config/locale/translations/templates/pl.email.auth.confirm.tpl diff --git a/app/config/locales/templates/pl.email.auth.invitation.tpl b/app/config/locale/translations/templates/pl.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/pl.email.auth.invitation.tpl rename to app/config/locale/translations/templates/pl.email.auth.invitation.tpl diff --git a/app/config/locales/templates/pl.email.auth.recovery.tpl b/app/config/locale/translations/templates/pl.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/pl.email.auth.recovery.tpl rename to app/config/locale/translations/templates/pl.email.auth.recovery.tpl diff --git a/app/config/locales/templates/pt-br.email.auth.confirm.tpl b/app/config/locale/translations/templates/pt-br.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/pt-br.email.auth.confirm.tpl rename to app/config/locale/translations/templates/pt-br.email.auth.confirm.tpl diff --git a/app/config/locales/templates/pt-br.email.auth.invitation.tpl b/app/config/locale/translations/templates/pt-br.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/pt-br.email.auth.invitation.tpl rename to app/config/locale/translations/templates/pt-br.email.auth.invitation.tpl diff --git a/app/config/locales/templates/pt-br.email.auth.recovery.tpl b/app/config/locale/translations/templates/pt-br.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/pt-br.email.auth.recovery.tpl rename to app/config/locale/translations/templates/pt-br.email.auth.recovery.tpl diff --git a/app/config/locales/templates/pt-pt.email.auth.confirm.tpl b/app/config/locale/translations/templates/pt-pt.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/pt-pt.email.auth.confirm.tpl rename to app/config/locale/translations/templates/pt-pt.email.auth.confirm.tpl diff --git a/app/config/locales/templates/pt-pt.email.auth.invitation.tpl b/app/config/locale/translations/templates/pt-pt.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/pt-pt.email.auth.invitation.tpl rename to app/config/locale/translations/templates/pt-pt.email.auth.invitation.tpl diff --git a/app/config/locales/templates/pt-pt.email.auth.recovery.tpl b/app/config/locale/translations/templates/pt-pt.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/pt-pt.email.auth.recovery.tpl rename to app/config/locale/translations/templates/pt-pt.email.auth.recovery.tpl diff --git a/app/config/locales/templates/ro.email.auth.confirm.tpl b/app/config/locale/translations/templates/ro.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/ro.email.auth.confirm.tpl rename to app/config/locale/translations/templates/ro.email.auth.confirm.tpl diff --git a/app/config/locales/templates/ro.email.auth.invitation.tpl b/app/config/locale/translations/templates/ro.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/ro.email.auth.invitation.tpl rename to app/config/locale/translations/templates/ro.email.auth.invitation.tpl diff --git a/app/config/locales/templates/ro.email.auth.recovery.tpl b/app/config/locale/translations/templates/ro.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/ro.email.auth.recovery.tpl rename to app/config/locale/translations/templates/ro.email.auth.recovery.tpl diff --git a/app/config/locales/templates/ru.email.auth.confirm.tpl b/app/config/locale/translations/templates/ru.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/ru.email.auth.confirm.tpl rename to app/config/locale/translations/templates/ru.email.auth.confirm.tpl diff --git a/app/config/locales/templates/ru.email.auth.invitation.tpl b/app/config/locale/translations/templates/ru.email.auth.invitation.tpl similarity index 75% rename from app/config/locales/templates/ru.email.auth.invitation.tpl rename to app/config/locale/translations/templates/ru.email.auth.invitation.tpl index 7dc637a3de..8d90140c64 100644 --- a/app/config/locales/templates/ru.email.auth.invitation.tpl +++ b/app/config/locale/translations/templates/ru.email.auth.invitation.tpl @@ -2,7 +2,7 @@ Здравствуйте,

- Это письмо отправлено вам, потому что {{owner}} приглашает стать членом команды {{team}} в проекте {{project}}. + Это письмо отправлено вам, потому что {{owner}} приглашает вас стать членом команды {{team}} в проекте {{project}}.

Перейдите по ссылке, чтобы присоединиться к команде {{team}} : diff --git a/app/config/locales/templates/ru.email.auth.recovery.tpl b/app/config/locale/translations/templates/ru.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/ru.email.auth.recovery.tpl rename to app/config/locale/translations/templates/ru.email.auth.recovery.tpl diff --git a/app/config/locales/templates/si.email.auth.confirm.tpl b/app/config/locale/translations/templates/si.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/si.email.auth.confirm.tpl rename to app/config/locale/translations/templates/si.email.auth.confirm.tpl diff --git a/app/config/locales/templates/si.email.auth.invitation.tpl b/app/config/locale/translations/templates/si.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/si.email.auth.invitation.tpl rename to app/config/locale/translations/templates/si.email.auth.invitation.tpl diff --git a/app/config/locales/templates/si.email.auth.recovery.tpl b/app/config/locale/translations/templates/si.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/si.email.auth.recovery.tpl rename to app/config/locale/translations/templates/si.email.auth.recovery.tpl diff --git a/app/config/locales/templates/sl.email.auth.confirm.tpl b/app/config/locale/translations/templates/sl.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/sl.email.auth.confirm.tpl rename to app/config/locale/translations/templates/sl.email.auth.confirm.tpl diff --git a/app/config/locales/templates/sl.email.auth.invitation.tpl b/app/config/locale/translations/templates/sl.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/sl.email.auth.invitation.tpl rename to app/config/locale/translations/templates/sl.email.auth.invitation.tpl diff --git a/app/config/locales/templates/sl.email.auth.recovery.tpl b/app/config/locale/translations/templates/sl.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/sl.email.auth.recovery.tpl rename to app/config/locale/translations/templates/sl.email.auth.recovery.tpl diff --git a/app/config/locales/templates/sv.email.auth.confirm.tpl b/app/config/locale/translations/templates/sv.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/sv.email.auth.confirm.tpl rename to app/config/locale/translations/templates/sv.email.auth.confirm.tpl diff --git a/app/config/locales/templates/sv.email.auth.invitation.tpl b/app/config/locale/translations/templates/sv.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/sv.email.auth.invitation.tpl rename to app/config/locale/translations/templates/sv.email.auth.invitation.tpl diff --git a/app/config/locales/templates/sv.email.auth.recovery.tpl b/app/config/locale/translations/templates/sv.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/sv.email.auth.recovery.tpl rename to app/config/locale/translations/templates/sv.email.auth.recovery.tpl diff --git a/app/config/locales/templates/ta.email.auth.confirm.tpl b/app/config/locale/translations/templates/ta.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/ta.email.auth.confirm.tpl rename to app/config/locale/translations/templates/ta.email.auth.confirm.tpl diff --git a/app/config/locales/templates/ta.email.auth.invitation.tpl b/app/config/locale/translations/templates/ta.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/ta.email.auth.invitation.tpl rename to app/config/locale/translations/templates/ta.email.auth.invitation.tpl diff --git a/app/config/locales/templates/ta.email.auth.recovery.tpl b/app/config/locale/translations/templates/ta.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/ta.email.auth.recovery.tpl rename to app/config/locale/translations/templates/ta.email.auth.recovery.tpl diff --git a/app/config/locales/templates/th.email.auth.confirm.tpl b/app/config/locale/translations/templates/th.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/th.email.auth.confirm.tpl rename to app/config/locale/translations/templates/th.email.auth.confirm.tpl diff --git a/app/config/locales/templates/th.email.auth.invitation.tpl b/app/config/locale/translations/templates/th.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/th.email.auth.invitation.tpl rename to app/config/locale/translations/templates/th.email.auth.invitation.tpl diff --git a/app/config/locales/templates/th.email.auth.recovery.tpl b/app/config/locale/translations/templates/th.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/th.email.auth.recovery.tpl rename to app/config/locale/translations/templates/th.email.auth.recovery.tpl diff --git a/app/config/locales/templates/tr.email.auth.confirm.tpl b/app/config/locale/translations/templates/tr.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/tr.email.auth.confirm.tpl rename to app/config/locale/translations/templates/tr.email.auth.confirm.tpl diff --git a/app/config/locales/templates/tr.email.auth.invitation.tpl b/app/config/locale/translations/templates/tr.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/tr.email.auth.invitation.tpl rename to app/config/locale/translations/templates/tr.email.auth.invitation.tpl diff --git a/app/config/locales/templates/tr.email.auth.recovery.tpl b/app/config/locale/translations/templates/tr.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/tr.email.auth.recovery.tpl rename to app/config/locale/translations/templates/tr.email.auth.recovery.tpl diff --git a/app/config/locales/templates/ua.email.auth.confirm.tpl b/app/config/locale/translations/templates/ua.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/ua.email.auth.confirm.tpl rename to app/config/locale/translations/templates/ua.email.auth.confirm.tpl diff --git a/app/config/locales/templates/ua.email.auth.invitation.tpl b/app/config/locale/translations/templates/ua.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/ua.email.auth.invitation.tpl rename to app/config/locale/translations/templates/ua.email.auth.invitation.tpl diff --git a/app/config/locales/templates/ua.email.auth.recovery.tpl b/app/config/locale/translations/templates/ua.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/ua.email.auth.recovery.tpl rename to app/config/locale/translations/templates/ua.email.auth.recovery.tpl diff --git a/app/config/locale/translations/templates/ur.email.auth.confirm.tpl b/app/config/locale/translations/templates/ur.email.auth.confirm.tpl new file mode 100644 index 0000000000..c468415d42 --- /dev/null +++ b/app/config/locale/translations/templates/ur.email.auth.confirm.tpl @@ -0,0 +1,15 @@ +

+ ہیلو {{name}}, +

+

+ اپنے ای میل پتے کی تصدیق کے ل this اس لنک کی پیروی کریں۔ +

+{{cta}} +

+ اگر آپ نے اس پتے کی تصدیق کرنے کے لئے نہیں کہا تو آپ اس پیغام کو نظرانداز کرسکتے ہیں۔ +

+

+ شکریہ, +
+ {{project}} ٹیم +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/ur.email.auth.invitation.tpl b/app/config/locale/translations/templates/ur.email.auth.invitation.tpl new file mode 100644 index 0000000000..c1982cb97f --- /dev/null +++ b/app/config/locale/translations/templates/ur.email.auth.invitation.tpl @@ -0,0 +1,14 @@ +

+ ہیلو, +

+

+ یہ میل آپ کو اس لئے بھیجا گیا تھا کیونکہ {{owner}} میں آپ کو ٹیم کے ممبر بننے کے لئے مدعو کرنا چاہتا تھا {{team}} میں ٹیم ختم {{project}}. +

+{{cta}} +

+ اگر آپ دلچسپی نہیں رکھتے ہیں تو ، آپ اس پیغام کو نظرانداز کرسکتے ہیں۔

+

+ شکریہ, +
+ {{project}} ٹیم +

\ No newline at end of file diff --git a/app/config/locale/translations/templates/ur.email.auth.recovery.tpl b/app/config/locale/translations/templates/ur.email.auth.recovery.tpl new file mode 100644 index 0000000000..4c884ec9ce --- /dev/null +++ b/app/config/locale/translations/templates/ur.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ ہیلو {{name}}, +

+

+ اپنا دوبارہ ترتیب دینے کیلئے اس لنک پر عمل کریں {{project}} پاس ورڈ. +

+{{cta}} +

+ اگر آپ نے اس پتے کی تصدیق کرنے کے لئے نہیں کہا تو آپ اس پیغام کو نظرانداز کرسکتے ہیں۔ +

+

+ شکریہ, +
+ {{project}} ٹیم +

\ No newline at end of file diff --git a/app/config/locales/templates/vi.email.auth.confirm.tpl b/app/config/locale/translations/templates/vi.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/vi.email.auth.confirm.tpl rename to app/config/locale/translations/templates/vi.email.auth.confirm.tpl diff --git a/app/config/locales/templates/vi.email.auth.invitation.tpl b/app/config/locale/translations/templates/vi.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/vi.email.auth.invitation.tpl rename to app/config/locale/translations/templates/vi.email.auth.invitation.tpl diff --git a/app/config/locales/templates/vi.email.auth.recovery.tpl b/app/config/locale/translations/templates/vi.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/vi.email.auth.recovery.tpl rename to app/config/locale/translations/templates/vi.email.auth.recovery.tpl diff --git a/app/config/locales/templates/zh-cn.email.auth.confirm.tpl b/app/config/locale/translations/templates/zh-cn.email.auth.confirm.tpl similarity index 100% rename from app/config/locales/templates/zh-cn.email.auth.confirm.tpl rename to app/config/locale/translations/templates/zh-cn.email.auth.confirm.tpl diff --git a/app/config/locales/templates/zh-cn.email.auth.invitation.tpl b/app/config/locale/translations/templates/zh-cn.email.auth.invitation.tpl similarity index 100% rename from app/config/locales/templates/zh-cn.email.auth.invitation.tpl rename to app/config/locale/translations/templates/zh-cn.email.auth.invitation.tpl diff --git a/app/config/locales/templates/zh-cn.email.auth.recovery.tpl b/app/config/locale/translations/templates/zh-cn.email.auth.recovery.tpl similarity index 100% rename from app/config/locales/templates/zh-cn.email.auth.recovery.tpl rename to app/config/locale/translations/templates/zh-cn.email.auth.recovery.tpl diff --git a/app/config/locale/translations/templates/zh-tw.email.auth.confirm.tpl b/app/config/locale/translations/templates/zh-tw.email.auth.confirm.tpl new file mode 100644 index 0000000000..1cc03b1629 --- /dev/null +++ b/app/config/locale/translations/templates/zh-tw.email.auth.confirm.tpl @@ -0,0 +1,15 @@ +

+ {{name}} 你好, +

+

+ 請點擊下方的連結驗證你的電子郵箱地址。 +

+{{cta}} +

+ 如果你沒有請求驗證本電子信箱,請忽略這份信件。 +

+

+ 謝謝。 +
+ 來自 {{project}} +

diff --git a/app/config/locales/templates/zh-tw.email.auth.invitation.tpl b/app/config/locale/translations/templates/zh-tw.email.auth.invitation.tpl similarity index 57% rename from app/config/locales/templates/zh-tw.email.auth.invitation.tpl rename to app/config/locale/translations/templates/zh-tw.email.auth.invitation.tpl index b5e6cc8225..7c65d6bdb6 100644 --- a/app/config/locales/templates/zh-tw.email.auth.invitation.tpl +++ b/app/config/locale/translations/templates/zh-tw.email.auth.invitation.tpl @@ -2,17 +2,17 @@ 你好,

- {{owner}}邀請您加入{{project}}項目的{{team}}小組。 + {{owner}}邀請您加入{{project}}專案的{{team}}小組。

請點擊下方的鏈接加入{{team}}小組:

{{cta}}

- 如果您沒有加入該小組的計劃,請忽略本郵件。 + 如果您沒有加入該小組的計劃,請忽略本信件。

謝謝。
來自 {{project}} -

\ No newline at end of file +

diff --git a/app/config/locale/translations/templates/zh-tw.email.auth.recovery.tpl b/app/config/locale/translations/templates/zh-tw.email.auth.recovery.tpl new file mode 100644 index 0000000000..c141200dbe --- /dev/null +++ b/app/config/locale/translations/templates/zh-tw.email.auth.recovery.tpl @@ -0,0 +1,15 @@ +

+ {{name}} 你好, +

+

+ 請點擊下方的連結重設 {{project}} 的密碼。 +

+{{cta}} +

+ 如果你未曾申請重設密碼,請忽略本信件。 +

+

+ 謝謝。 +
+ 來自 {{project}} +

diff --git a/app/config/locales/th.continents.php b/app/config/locale/translations/th.continents.php similarity index 100% rename from app/config/locales/th.continents.php rename to app/config/locale/translations/th.continents.php diff --git a/app/config/locales/th.countries.php b/app/config/locale/translations/th.countries.php similarity index 100% rename from app/config/locales/th.countries.php rename to app/config/locale/translations/th.countries.php diff --git a/app/config/locales/th.php b/app/config/locale/translations/th.php similarity index 100% rename from app/config/locales/th.php rename to app/config/locale/translations/th.php diff --git a/app/config/locales/tr.continents.php b/app/config/locale/translations/tr.continents.php similarity index 100% rename from app/config/locales/tr.continents.php rename to app/config/locale/translations/tr.continents.php diff --git a/app/config/locales/tr.countries.php b/app/config/locale/translations/tr.countries.php similarity index 100% rename from app/config/locales/tr.countries.php rename to app/config/locale/translations/tr.countries.php diff --git a/app/config/locales/tr.php b/app/config/locale/translations/tr.php similarity index 100% rename from app/config/locales/tr.php rename to app/config/locale/translations/tr.php diff --git a/app/config/locales/ua.continents.php b/app/config/locale/translations/ua.continents.php similarity index 100% rename from app/config/locales/ua.continents.php rename to app/config/locale/translations/ua.continents.php diff --git a/app/config/locales/ua.countries.php b/app/config/locale/translations/ua.countries.php similarity index 100% rename from app/config/locales/ua.countries.php rename to app/config/locale/translations/ua.countries.php diff --git a/app/config/locales/ua.php b/app/config/locale/translations/ua.php similarity index 91% rename from app/config/locales/ua.php rename to app/config/locale/translations/ua.php index f1f251b67f..07efa73411 100644 --- a/app/config/locales/ua.php +++ b/app/config/locale/translations/ua.php @@ -5,12 +5,12 @@ return [ 'settings.locale' => 'ua', 'settings.direction' => 'ltr', - 'account.emails.team' => '%s Команда', + 'account.emails.team' => 'Команда %s', 'account.emails.verification.title' => 'Підтвердження Акаунту' , 'account.emails.verification.body' => 'ua.email.auth.confirm.tpl', 'account.emails.recovery.title' => 'Скидання пароля', 'account.emails.recovery.body' => 'ua.email.auth.recovery.tpl', - 'account.emails.invitation.title' => 'Запрошення до %s Команди у %s', + 'account.emails.invitation.title' => 'Запрошення до Команди %s у %s', 'account.emails.invitation.body' => 'ua.email.auth.invitation.tpl', 'locale.country.unknown' => 'Невідомо', diff --git a/app/config/locale/translations/ur.continents.php b/app/config/locale/translations/ur.continents.php new file mode 100644 index 0000000000..db0c9cdf56 --- /dev/null +++ b/app/config/locale/translations/ur.continents.php @@ -0,0 +1,11 @@ + 'افریقہ', + 'AN' => 'انٹارکٹیکا', + 'AS' => 'ایشیا', + 'EU' => 'یورپ', + 'NA' => 'شمالی امریکہ', + 'OC' => 'اوشینیا', + 'SA' => 'جنوبی امریکہ', +]; diff --git a/app/config/locale/translations/ur.countries.php b/app/config/locale/translations/ur.countries.php new file mode 100644 index 0000000000..8a8f95185b --- /dev/null +++ b/app/config/locale/translations/ur.countries.php @@ -0,0 +1,198 @@ + 'افغانستان', + 'AO' => 'انگولا', + 'AL' => 'البانیہ', + 'AD' => 'انڈورا', + 'AE' => 'متحدہ عرب امارات', + 'AR' => 'ارجنٹائن', + 'AM' => 'آرمینیا', + 'AG' => 'اینٹیگوا اور باربوڈا', + 'AU' => 'آسٹریلیا', + 'AT' => 'آسٹریا', + 'AZ' => 'آذربائیجان', + 'BI' => 'برونڈی', + 'BE' => 'بیلجیم', + 'BJ' => 'بینن', + 'BF' => 'برکینا فاسو', + 'BD' => 'بنگلہ دیش', + 'BG' => 'بلغاریہ', + 'BH' => 'بحرین', + 'BS' => 'بہاماس', + 'BA' => 'بوسنیا اور ہرزیگوینا', + 'BY' => 'بیلاروس', + 'BZ' => 'بیلیز', + 'BO' => 'بولیویا', + 'BR' => 'برازیل', + 'BB' => 'بارباڈوس', + 'BN' => 'برونائی', + 'BT' => 'بھوٹان', + 'BW' => 'بوٹسوانا', + 'CF' => 'مرکزی افریقی جمہوریت', + 'CA' => 'کینیڈا', + 'CH' => 'سوئٹزرلینڈ', + 'CL' => 'چلی', + 'CN' => 'چین', + 'CI' => 'آئیوری کوسٹ', + 'CM' => 'کیمرون', + 'CD' => 'جمہوری جمہوریہ کانگو', + 'CG' => 'جمہوریہ کانگو', + 'CO' => 'کولمبیا', + 'KM' => 'کوموروس', + 'CV' => 'کیپ وردے', + 'CR' => 'کوسٹا ریکا', + 'CU' => 'کیوبا', + 'CY' => 'قبرص', + 'CZ' => 'چیکیا', + 'DE' => 'جرمنی', + 'DJ' => 'جبوتی', + 'DM' => 'ڈومینیکا', + 'DK' => 'ڈنمارک', + 'DO' => 'ڈومینیکن ریپبلک', + 'DZ' => 'الجیریا', + 'EC' => 'ایکواڈور', + 'EG' => 'مصر', + 'ER' => 'اریٹیریا', + 'ES' => 'اسپین', + 'EE' => 'ایسٹونیا', + 'ET' => 'ایتھوپیا', + 'FI' => 'فن لینڈ', + 'FJ' => 'فجی', + 'FR' => 'فرانس', + 'FM' => 'مائکرونیشیا', + 'GA' => 'گبون', + 'GB' => 'متحدہ سلطنت یونائیٹڈ کنگڈم', + 'GE' => 'جارجیا', + 'GH' => 'گھانا', + 'GN' => 'گیانا', + 'GM' => 'گیمبیا', + 'GW' => 'گیانا - بساؤ', + 'GQ' => 'استوائی گنی', + 'GR' => 'یونان', + 'GD' => 'گریناڈا', + 'GT' => 'گوئٹے مالا', + 'GY' => 'گیانا', + 'HN' => 'ہونڈوراس', + 'HR' => 'کروشیا', + 'HT' => 'ہیٹی', + 'HU' => 'ہنگری', + 'ID' => 'انڈونیشیا', + 'IN' => 'ہندوستان', + 'IE' => 'آئرلینڈ', + 'IR' => 'ایران', + 'IQ' => 'عراق', + 'IS' => 'آئس لینڈ', + 'IL' => 'اسرا ییل', + 'IT' => 'اٹلی', + 'JM' => 'جمیکا', + 'JO' => 'اردن', + 'JP' => 'جاپان', + 'KZ' => 'قازقستان', + 'KE' => 'کینیا', + 'KG' => 'کرغزستان', + 'KH' => 'کمبوڈیا', + 'KI' => 'کیریباتی', + 'KN' => 'سینٹ کٹس اینڈ نیوس', + 'KR' => 'جنوبی کوریا', + 'KW' => 'کویت', + 'LA' => 'لاؤس', + 'LB' => 'لبنان', + 'LR' => 'لائبیریا', + 'LY' => 'لیبیا', + 'LC' => 'سینٹ لوسیا', + 'LI' => 'لیچسٹین', + 'LK' => 'سری لنکا', + 'LS' => 'لیسوتھو', + 'LT' => 'لتھوانیا', + 'LU' => 'لکسمبرگ', + 'LV' => 'لٹویا', + 'MA' => 'مراکش', + 'MC' => 'موناکو', + 'MD' => 'مالڈووا', + 'MG' => 'مڈغاسکر', + 'MV' => 'مالدیپ', + 'MX' => 'میکسیکو', + 'MH' => 'جزائر مارشل', + 'MK' => 'میسیڈونیا', + 'ML' => 'مالی', + 'MT' => 'مالٹا', + 'MM' => 'میانمار', + 'ME' => 'مونٹی نیگرو', + 'MN' => 'منگولیا', + 'MZ' => 'موزمبیق', + 'MR' => 'موریتانیا', + 'MU' => 'ماریشیس', + 'MW' => 'ملاوی', + 'MY' => 'ملائیشیا', + 'NA' => 'نمیبیا', + 'NE' => 'نائجر', + 'NG' => 'نائیجیریا', + 'NI' => 'نکاراگوا', + 'NL' => 'نیدرلینڈز', + 'NO' => 'ناروے', + 'NP' => 'نیپال', + 'NR' => 'نورو', + 'NZ' => 'نیوزی لینڈ', + 'OM' => 'عمان', + 'PK' => 'پاکستان', + 'PA' => 'پانامہ', + 'PE' => 'پیرو', + 'PH' => 'فلپائن', + 'PW' => 'پلاؤ', + 'PG' => 'پاپوا نیو گنی', + 'PL' => 'پولینڈ', + 'KP' => 'شمالی کوریا', + 'PT' => 'پرتگال', + 'PY' => 'پیراگوئے', + 'QA' => 'قطر', + 'RO' => 'رومانیہ', + 'RU' => 'روس', + 'RW' => '', + 'SA' => 'روانڈا', + 'SD' => 'سوڈان', + 'SN' => 'سینیگال', + 'SG' => 'سنگاپور', + 'SB' => 'جزائر سلیمان', + 'SL' => 'سیرا لیون', + 'SV' => 'ال سلواڈور', + 'SM' => 'سان مارینو', + 'SO' => 'صومالیہ', + 'RS' => 'سربیا', + 'SS' => 'جنوبی سوڈان', + 'ST' => 'ساؤ ٹومے اور پرنسیپی', + 'SR' => 'سورینام', + 'SK' => 'سلوواکیا', + 'SI' => 'سلووینیا', + 'SE' => 'سویڈن', + 'SZ' => 'سوازیلینڈ', + 'SC' => 'سیچلز', + 'SY' => 'شام', + 'TD' => 'چاڈ', + 'TG' => 'جانے کے لئے', + 'TH' => 'تھائی لینڈ', + 'TJ' => 'تاجکستان', + 'TM' => 'ترکمانستان', + 'TL' => 'تیمور لیسی', + 'TO' => 'ٹونگا', + 'TT' => 'ٹرینیڈاڈ اور ٹوباگو', + 'TN' => 'تیونس', + 'TR' => 'ترکی', + 'TV' => 'ٹوالو', + 'TZ' => 'تنزانیہ', + 'UG' => 'یوگنڈا', + 'UA' => 'یوکرائن', + 'UY' => 'یوراگوئے', + 'US' => 'ریاستہائے متحدہ', + 'UZ' => 'ازبکستان', + 'VA' => 'ویٹیکن سٹی', + 'VC' => 'سینٹ ونسنٹ اور گریناڈائنز', + 'VE' => 'وینزویلا', + 'VN' => 'ویتنام', + 'VU' => 'وانواتو', + 'WS' => 'ساموا', + 'YE' => 'یمن', + 'ZA' => 'جنوبی افریقہ', + 'ZM' => 'زیمبیا', + 'ZW' => 'زمبابوے', +]; diff --git a/app/config/locale/translations/ur.php b/app/config/locale/translations/ur.php new file mode 100644 index 0000000000..770e25f4df --- /dev/null +++ b/app/config/locale/translations/ur.php @@ -0,0 +1,21 @@ + '"عقلمند ہونے کا فن یہ جاننے کا فن ہے کہ کیا نظرانداز کیا جائے۔"', // This is the line printed in the homepage and console 'view-source' + 'settings.locale' => 'ur', + 'settings.direction' => 'rtl', + + // Service - Users + 'account.emails.team' => '%s ٹیم', + 'account.emails.verification.title' => 'اکاؤنٹ کی توثیق', + 'account.emails.verification.body' => 'ur.email.auth.confirm.tpl', + 'account.emails.recovery.title' => 'پاس ورڈ دوبارہ ترتیب دیں', + 'account.emails.recovery.body' => 'ur.email.auth.recovery.tpl', + 'account.emails.invitation.title' => 'کی دعوت %s میں ٹیم %s', + 'account.emails.invitation.body' => 'ur.email.auth.invitation.tpl', + + 'locale.country.unknown' => 'نامعلوم', + + 'countries' => include 'ur.countries.php', + 'continents' => include 'ur.continents.php', +]; diff --git a/app/config/locales/vi.continents.php b/app/config/locale/translations/vi.continents.php similarity index 100% rename from app/config/locales/vi.continents.php rename to app/config/locale/translations/vi.continents.php diff --git a/app/config/locales/vi.countries.php b/app/config/locale/translations/vi.countries.php similarity index 100% rename from app/config/locales/vi.countries.php rename to app/config/locale/translations/vi.countries.php diff --git a/app/config/locales/vi.php b/app/config/locale/translations/vi.php similarity index 100% rename from app/config/locales/vi.php rename to app/config/locale/translations/vi.php diff --git a/app/config/locales/zh-cn.continents.php b/app/config/locale/translations/zh-cn.continents.php similarity index 100% rename from app/config/locales/zh-cn.continents.php rename to app/config/locale/translations/zh-cn.continents.php diff --git a/app/config/locales/zh-cn.countries.php b/app/config/locale/translations/zh-cn.countries.php similarity index 100% rename from app/config/locales/zh-cn.countries.php rename to app/config/locale/translations/zh-cn.countries.php diff --git a/app/config/locales/zh-cn.php b/app/config/locale/translations/zh-cn.php similarity index 100% rename from app/config/locales/zh-cn.php rename to app/config/locale/translations/zh-cn.php diff --git a/app/config/locales/zh-tw.continents.php b/app/config/locale/translations/zh-tw.continents.php similarity index 100% rename from app/config/locales/zh-tw.continents.php rename to app/config/locale/translations/zh-tw.continents.php diff --git a/app/config/locales/zh-tw.countries.php b/app/config/locale/translations/zh-tw.countries.php similarity index 100% rename from app/config/locales/zh-tw.countries.php rename to app/config/locale/translations/zh-tw.countries.php diff --git a/app/config/locales/zh-tw.php b/app/config/locale/translations/zh-tw.php similarity index 84% rename from app/config/locales/zh-tw.php rename to app/config/locale/translations/zh-tw.php index c77c6245fe..be4f79df95 100644 --- a/app/config/locales/zh-tw.php +++ b/app/config/locale/translations/zh-tw.php @@ -1,13 +1,13 @@ '"懂得取舍,方顯睿智。"', // This is the line printed in the homepage and console 'view-source' + 'settings.inspire' => '"懂得取捨,方顯睿智。"', // This is the line printed in the homepage and console 'view-source' 'settings.locale' => 'zh-tw', 'settings.direction' => 'ltr', // Service - Users 'account.emails.team' => '%s 小組', - 'account.emails.verification.title' => '賬戶確認', + 'account.emails.verification.title' => '帳戶確認', 'account.emails.verification.body' => 'zh-tw.email.auth.confirm.tpl', 'account.emails.recovery.title' => '重設密碼', 'account.emails.recovery.body' => 'zh.email.auth.recovery.tpl', @@ -16,4 +16,4 @@ return [ 'locale.country.unknown' => '未知', 'countries' => include 'zh-tw.countries.php', 'continents' => include 'zh-tw.continents.php', -]; \ No newline at end of file +]; diff --git a/app/config/locales/templates/es.email.auth.recovery.tpl b/app/config/locales/templates/es.email.auth.recovery.tpl deleted file mode 100644 index 0f1cfaa434..0000000000 --- a/app/config/locales/templates/es.email.auth.recovery.tpl +++ /dev/null @@ -1,15 +0,0 @@ -

- Hola {{name}}, -

-

- Sigue este enlace para reestablecer tu contraseña de {{project}}. -

-{{cta}} -

- Si no has pedido reestablecer tu contraseña, puedes ignorar este mensaje. -

-

- Gracias, -
- Equipo {{project}} -

diff --git a/app/config/locales/templates/hu.email.auth.confirm.tpl b/app/config/locales/templates/hu.email.auth.confirm.tpl deleted file mode 100644 index 259c7ceb9b..0000000000 --- a/app/config/locales/templates/hu.email.auth.confirm.tpl +++ /dev/null @@ -1,15 +0,0 @@ -

- Szia {{name}}, -

-

- Kattints erre a linkre, hogy megerősítsd az e-mail címed. -

-{{cta}} -

- Ha nem kérelmezted, hogy megerősítsük ezt a címet, ignoráld ezt a levelet. -

-

- Köszönettel, -
- {{project}} csapat -

diff --git a/app/config/locales/templates/hu.email.auth.invitation.tpl b/app/config/locales/templates/hu.email.auth.invitation.tpl deleted file mode 100644 index 5c8d90b86a..0000000000 --- a/app/config/locales/templates/hu.email.auth.invitation.tpl +++ /dev/null @@ -1,18 +0,0 @@ -

- Szia, -

-

- Azért küldtük ezt az e-mailt {{owner}} mert meg szeretnénk hívni a {{team}} csapatba a következő projektre {{project}}. -

-

- Kattints erre a linkre, hogy a {{team}} csapat tagja legyél: -

-{{cta}} -

- Ha nem vegy ebben érdekelt ignoráld ezt az üzenetet. -

-

- Köszönettel, -
- {{project}} csapat -

diff --git a/app/config/locales/templates/hu.email.auth.recovery.tpl b/app/config/locales/templates/hu.email.auth.recovery.tpl deleted file mode 100644 index b5e915516a..0000000000 --- a/app/config/locales/templates/hu.email.auth.recovery.tpl +++ /dev/null @@ -1,15 +0,0 @@ -

- Szia {{name}}, -

-

- Kattints erre a linkre, hogy visszaállítsuk a {{project}} jelszavad. -

-{{cta}} -

- Ha nem kérvényezted, hogy visszaállítsuk a jelszavad ignoráld ezt a levelet. -

-

- Köszönettel, -
- {{project}} csapat -

diff --git a/app/config/locales/templates/zh-tw.email.auth.confirm.tpl b/app/config/locales/templates/zh-tw.email.auth.confirm.tpl deleted file mode 100644 index 7a19636dbb..0000000000 --- a/app/config/locales/templates/zh-tw.email.auth.confirm.tpl +++ /dev/null @@ -1,15 +0,0 @@ -

- {{name}} 你好, -

-

- 請點擊下方的鏈接驗證你的電子郵箱地址。 -

-{{cta}} -

- 如果你沒有請求驗證本郵箱,請忽略這份郵件。 -

-

- 謝謝。 -
- 來自 {{project}} -

\ No newline at end of file diff --git a/app/config/locales/templates/zh-tw.email.auth.recovery.tpl b/app/config/locales/templates/zh-tw.email.auth.recovery.tpl deleted file mode 100644 index 1144b36b3c..0000000000 --- a/app/config/locales/templates/zh-tw.email.auth.recovery.tpl +++ /dev/null @@ -1,16 +0,0 @@ -

- {{name}} 你好, -

-

- 请点击下方的链接重新设置{{project}}的密码。 - Follow this link to reset your {{project}} password. -

-{{cta}} -

- 如果您未曾申请重设密码,请忽略本邮件。 -

-

- 谢谢。 -
- 来自 {{project}} -

diff --git a/app/config/platforms.php b/app/config/platforms.php index 35e03c7a44..f9756d1ae6 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -15,26 +15,30 @@ return [ [ 'key' => 'web', 'name' => 'Web', - 'version' => '1.1.0', - 'url' => 'https://github.com/appwrite/sdk-for-js', + 'version' => '2.0.0', + 'url' => 'https://github.com/appwrite/sdk-for-web', + 'package' => 'https://www.npmjs.com/package/appwrite', 'enabled' => true, 'beta' => false, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'javascript', 'source' => \realpath(__DIR__ . '/../sdks/client-web'), - 'gitUrl' => 'git@github.com:appwrite/sdk-for-js.git', - 'gitRepoName' => 'sdk-for-js', + 'gitUrl' => 'git@github.com:appwrite/sdk-for-web.git', + 'gitRepoName' => 'sdk-for-web', 'gitUserName' => 'appwrite', ], [ 'key' => 'flutter', 'name' => 'Flutter', - 'version' => '0.3.0-dev.1', + 'version' => '0.3.0', 'url' => 'https://github.com/appwrite/sdk-for-flutter', + 'package' => 'https://pub.dev/packages/appwrite', 'enabled' => true, 'beta' => true, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'dart', 'source' => \realpath(__DIR__ . '/../sdks/client-flutter'), @@ -42,28 +46,15 @@ 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', - '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', 'url' => '', + 'package' => '', 'enabled' => false, 'beta' => false, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'swift', 'source' => false, @@ -75,9 +66,11 @@ return [ 'key' => 'objective-c', 'name' => 'Objective C', 'url' => '', + 'package' => '', 'enabled' => false, 'beta' => false, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => '', 'source' => false, @@ -89,9 +82,11 @@ return [ 'key' => 'kotlin', 'name' => 'Kotlin', 'url' => '', + 'package' => '', 'enabled' => false, 'beta' => false, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'kotlin', 'source' => false, @@ -104,8 +99,9 @@ return [ // 'name' => 'Java', // 'url' => '', // 'enabled' => false, - // 'dev' => false, // 'beta' => false, + // 'dev' => false, + // 'hidden' => false, // 'family' => APP_PLATFORM_CLIENT, // 'prism' => 'java', // 'source' => false, @@ -127,9 +123,11 @@ return [ 'name' => 'Console', 'version' => '1.0.0', 'url' => 'https://github.com/appwrite/sdk-for-console', + 'package' => '', 'enabled' => true, 'beta' => false, 'dev' => false, + 'hidden' => true, 'family' => APP_PLATFORM_CONSOLE, 'prism' => 'console', 'source' => \realpath(__DIR__ . '/../sdks/console-web'), @@ -150,11 +148,13 @@ return [ [ 'key' => 'nodejs', 'name' => 'Node.js', - 'version' => '1.1.0', + 'version' => '2.0.0', 'url' => 'https://github.com/appwrite/sdk-for-node', + 'package' => 'https://www.npmjs.com/package/node-appwrite', 'enabled' => true, 'beta' => false, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'javascript', 'source' => \realpath(__DIR__ . '/../sdks/server-nodejs'), @@ -165,11 +165,13 @@ return [ [ 'key' => 'deno', 'name' => 'Deno', - 'version' => '0.0.2', + 'version' => '0.1.0', 'url' => 'https://github.com/appwrite/sdk-for-deno', + 'package' => 'https://deno.land/x/appwrite', 'enabled' => true, 'beta' => true, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'typescript', 'source' => \realpath(__DIR__ . '/../sdks/server-deno'), @@ -180,11 +182,13 @@ return [ [ 'key' => 'php', 'name' => 'PHP', - 'version' => '1.1.0', + 'version' => '2.0.0', 'url' => 'https://github.com/appwrite/sdk-for-php', + 'package' => 'https://packagist.org/packages/appwrite/appwrite', 'enabled' => true, 'beta' => false, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'php', 'source' => \realpath(__DIR__ . '/../sdks/server-php'), @@ -195,11 +199,13 @@ return [ [ 'key' => 'python', 'name' => 'Python', - 'version' => '0.0.6', + 'version' => '0.1.0', 'url' => 'https://github.com/appwrite/sdk-for-python', + 'package' => 'https://pypi.org/project/appwrite/', 'enabled' => true, - 'beta' => true, + 'beta' => false, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'python', 'source' => \realpath(__DIR__ . '/../sdks/server-python'), @@ -210,11 +216,13 @@ return [ [ 'key' => 'ruby', 'name' => 'Ruby', - 'version' => '1.0.11', + 'version' => '2.0.0', 'url' => 'https://github.com/appwrite/sdk-for-ruby', + 'package' => 'https://rubygems.org/gems/appwrite', 'enabled' => true, - 'beta' => true, + 'beta' => false, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'ruby', 'source' => \realpath(__DIR__ . '/../sdks/server-ruby'), @@ -227,9 +235,11 @@ return [ 'name' => 'Go', 'version' => '0.0.7', 'url' => 'https://github.com/appwrite/sdk-for-go', + 'package' => '', 'enabled' => false, 'beta' => true, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'go', 'source' => \realpath(__DIR__ . '/../sdks/server-go'), @@ -242,9 +252,11 @@ return [ 'name' => 'Java', 'version' => '0.0.2', 'url' => 'https://github.com/appwrite/sdk-for-java', + 'package' => '', 'enabled' => false, 'beta' => true, 'dev' => false, + 'hidden' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'java', 'source' => \realpath(__DIR__ . '/../sdks/server-java'), @@ -252,21 +264,57 @@ return [ 'gitRepoName' => 'sdk-for-java', 'gitUserName' => 'appwrite', ], + [ + 'key' => 'dotnet', + 'name' => '.NET', + 'version' => '0.1.0', + 'url' => 'https://github.com/appwrite/sdk-for-dotnet', + 'package' => 'https://www.nuget.org/packages/Appwrite', + 'enabled' => true, + 'beta' => true, + 'dev' => true, + 'hidden' => false, + 'family' => APP_PLATFORM_SERVER, + 'prism' => 'csharp', + 'source' => \realpath(__DIR__ . '/../sdks/server-dotnet'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-dotnet.git', + 'gitRepoName' => 'sdk-for-dotnet', + 'gitUserName' => 'appwrite', + ], [ 'key' => 'dart', 'name' => 'Dart', - 'version' => '0.0.1', + 'version' => '0.2.0', 'url' => 'https://github.com/appwrite/sdk-for-dart', - 'enabled' => false, + 'package' => 'https://pub.dev/packages/dart_appwrite', + 'enabled' => true, 'beta' => true, - 'dev' => false, + 'dev' => true, + 'hidden' => false, 'family' => APP_PLATFORM_SERVER, - 'prism' => 'java', + 'prism' => 'dart', 'source' => \realpath(__DIR__ . '/../sdks/server-dart'), 'gitUrl' => 'git@github.com:appwrite/sdk-for-dart.git', 'gitRepoName' => 'sdk-for-dart', 'gitUserName' => 'appwrite', ], + [ + 'key' => 'cli', + 'name' => 'Command Line', + 'version' => '0.4.0', + 'url' => 'https://github.com/appwrite/sdk-for-cli', + 'package' => 'https://github.com/appwrite/sdk-for-cli', + 'enabled' => true, + 'beta' => true, + 'dev' => false, + 'hidden' => true, + 'family' => APP_PLATFORM_SERVER, + 'prism' => 'bash', + 'source' => \realpath(__DIR__ . '/../sdks/server-cli'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-cli.git', + 'gitRepoName' => 'sdk-for-cli', + 'gitUserName' => 'appwrite', + ], ], ], ]; diff --git a/app/config/roles.php b/app/config/roles.php index 4d2420ec58..78dd24ad45 100644 --- a/app/config/roles.php +++ b/app/config/roles.php @@ -1,15 +1,8 @@ [ + Auth::USER_ROLE_GUEST => [ 'label' => 'Guest', 'scopes' => [ 'public', @@ -61,25 +60,27 @@ return [ 'files.read', 'locale.read', 'avatars.read', + 'execution.read', + 'execution.write', ], ], - ROLE_MEMBER => [ + Auth::USER_ROLE_MEMBER => [ 'label' => 'Member', - 'scopes' => \array_merge($logged, []), + 'scopes' => \array_merge($member, []), ], - ROLE_ADMIN => [ + Auth::USER_ROLE_ADMIN => [ 'label' => 'Admin', 'scopes' => \array_merge($admins, []), ], - ROLE_DEVELOPER => [ + Auth::USER_ROLE_DEVELOPER => [ 'label' => 'Developer', 'scopes' => \array_merge($admins, []), ], - ROLE_OWNER => [ + Auth::USER_ROLE_OWNER => [ 'label' => 'Owner', - 'scopes' => \array_merge($logged, $admins, []), + 'scopes' => \array_merge($member, $admins, []), ], - ROLE_APP => [ + Auth::USER_ROLE_APP => [ 'label' => 'Application', 'scopes' => ['health.read'], ], diff --git a/app/config/scopes.php b/app/config/scopes.php index 59ad2a0859..088502c5d8 100644 --- a/app/config/scopes.php +++ b/app/config/scopes.php @@ -1,25 +1,55 @@ [ + 'description' => 'Access to read your project\'s users', + ], + 'users.write' => [ + 'description' => 'Access to create, update, and delete your project\'s users', + ], + 'teams.read' => [ + 'description' => 'Access to read your project\'s teams', + ], + 'teams.write' => [ + 'description' => 'Access to create, update, and delete your project\'s teams', + ], + 'collections.read' => [ + 'description' => 'Access to read your project\'s database collections', + ], + 'collections.write' => [ + 'description' => 'Access to create, update, and delete your project\'s database collections', + ], + 'documents.read' => [ + 'description' => 'Access to read your project\'s database documents', + ], + 'documents.write' => [ + 'description' => 'Access to create, update, and delete your project\'s database documents', + ], + 'files.read' => [ + 'description' => 'Access to read your project\'s storage files and preview images', + ], + 'files.write' => [ + 'description' => 'Access to create, update, and delete your project\'s storage files', + ], + 'functions.read' => [ + 'description' => 'Access to read your project\'s functions and code tags', + ], + 'functions.write' => [ + 'description' => 'Access to create, update, and delete your project\'s functions and code tags', + ], + 'execution.read' => [ + 'description' => 'Access to read your project\'s execution logs', + ], + 'execution.write' => [ + 'description' => 'Access to execute your project\'s functions', + ], + 'locale.read' => [ + 'description' => 'Access to access your project\'s Locale service', + ], + 'avatars.read' => [ + 'description' => 'Access to access your project\'s Avatars service', + ], + 'health.read' => [ + 'description' => 'Access to read your project\'s health status', + ], ];; \ No newline at end of file diff --git a/app/config/services.php b/app/config/services.php index cc5df8c8e2..af55d0d6ea 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -2,91 +2,139 @@ return [ '/' => [ + 'key' => 'homepage', 'name' => 'Homepage', - 'controller' => 'controllers/web/home.php', + 'subtitle' => '', + 'controller' => 'web/home.php', 'sdk' => false, + 'docs' => false, 'tests' => false, ], 'console/' => [ + 'key' => 'console', 'name' => 'Console', - 'controller' => 'controllers/web/console.php', + 'controller' => 'web/console.php', 'sdk' => false, + 'docs' => false, 'tests' => false, ], 'v1/account' => [ + 'key' => 'account', 'name' => 'Account', + 'subtitle' => 'The Account service allows you to authenticate and manage a user account.', 'description' => '/docs/services/account.md', - 'controller' => 'controllers/api/account.php', + 'controller' => 'api/account.php', 'sdk' => true, + 'docs' => true, 'tests' => false, ], 'v1/avatars' => [ + 'key' => 'avatars', 'name' => 'Avatars', + 'subtitle'=> 'The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars.', 'description' => '/docs/services/avatars.md', - 'controller' => 'controllers/api/avatars.php', + 'controller' => 'api/avatars.php', 'sdk' => true, + 'docs' => true, 'tests' => false, ], 'v1/database' => [ + 'key' => 'database', 'name' => 'Database', + 'subtitle' => 'The Database service allows you to create structured collections of documents, query and filter lists of documents', 'description' => '/docs/services/database.md', - 'controller' => 'controllers/api/database.php', + 'controller' => 'api/database.php', 'sdk' => true, + 'docs' => true, 'tests' => false, ], 'v1/locale' => [ + 'key' => 'locale', 'name' => 'Locale', + 'subtitle' => 'The Locale service allows you to customize your app based on your users\' location.', 'description' => '/docs/services/locale.md', - 'controller' => 'controllers/api/locale.php', + 'controller' => 'api/locale.php', 'sdk' => true, + 'docs' => true, 'tests' => false, ], 'v1/health' => [ + 'key' => 'health', 'name' => 'Health', + 'subtitle' => 'The Health service allows you to both validate and monitor your Appwrite server\'s health.', 'description' => '/docs/services/health.md', - 'controller' => 'controllers/api/health.php', + 'controller' => 'api/health.php', 'sdk' => true, + 'docs' => true, 'tests' => false, ], 'v1/projects' => [ + 'key' => 'projects', 'name' => 'Projects', - 'controller' => 'controllers/api/projects.php', + 'subtitle' => 'The Project service allows you to manage all the projects in your Appwrite server.', + 'controller' => 'api/projects.php', 'sdk' => true, + 'docs' => true, 'tests' => false, ], 'v1/storage' => [ + 'key' => 'storage', 'name' => 'Storage', + 'subtitle' => 'The Storage service allows you to manage your project files.', 'description' => '/docs/services/storage.md', - 'controller' => 'controllers/api/storage.php', + 'controller' => 'api/storage.php', 'sdk' => true, + 'docs' => true, 'tests' => false, ], 'v1/teams' => [ + 'key' => 'teams', 'name' => 'Teams', + 'subtitle' => 'The Teams service allows you to group users of your project and to enable them to share read and write access to your project resources', 'description' => '/docs/services/teams.md', - 'controller' => 'controllers/api/teams.php', + 'controller' => 'api/teams.php', 'sdk' => true, + 'docs' => true, 'tests' => false, ], 'v1/users' => [ + 'key' => 'users', 'name' => 'Users', + 'subtitle' => 'The Users service allows you to manage your project users.', 'description' => '/docs/services/users.md', - 'controller' => 'controllers/api/users.php', + 'controller' => 'api/users.php', 'sdk' => true, + 'docs' => true, + 'tests' => false, + ], + 'v1/functions' => [ + 'key' => 'functions', + 'name' => 'Functions', + 'subtitle' => 'The Functions Service allows you view, create and manage your Cloud Functions.', + 'description' => '/docs/services/functions.md', + 'controller' => 'api/functions.php', + 'sdk' => true, + 'docs' => true, 'tests' => false, ], 'v1/mock' => [ + 'key' => 'mock', 'name' => 'Mock', + 'subtitle' => '', 'description' => '', - 'controller' => 'controllers/mock.php', + 'controller' => 'mock.php', 'sdk' => false, + 'docs' => false, 'tests' => true, ], 'v1/graphql' => [ + 'key' => 'graphql', 'name' => 'GraphQL', + 'subtitle' => 'Appwrite\'s GraphQL Endpoint', 'description' => 'GraphQL Endpoint', - 'controller' => 'controllers/api/graphql.php', + 'controller' => 'api/graphql.php', 'sdk' => false, + 'docs' => false, 'tests' => false, ], ]; diff --git a/app/config/specs/0.6.2.client.json b/app/config/specs/0.6.2.client.json index 6524743bca..6132b76ba1 100644 --- a/app/config/specs/0.6.2.client.json +++ b/app/config/specs/0.6.2.client.json @@ -1,2 +1,2 @@ -{"swagger":"2.0","info":{"version":"0.6.2","title":"Appwrite","description":"Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)","termsOfService":"https:\/\/appwrite.io\/policy\/terms","contact":{"name":"Appwrite Team","url":"https:\/\/appwrite.io\/support","email":"team@localhost.test"},"license":{"name":"BSD-3-Clause","url":"https:\/\/raw.githubusercontent.com\/appwrite\/appwrite\/master\/LICENSE"}},"host":"appwrite.io","basePath":"\/v1","schemes":["https"],"consumes":["application\/json","multipart\/form-data"],"produces":["application\/json"],"securityDefinitions":{"Project":{"type":"apiKey","name":"X-Appwrite-Project","description":"Your project ID","in":"header","extensions":{"demo":"5df5acd0d48c2"}},"Locale":{"type":"apiKey","name":"X-Appwrite-Locale","description":"","in":"header","extensions":{"demo":"en"}}},"paths":{"\/account":{"get":{"summary":"Get Account","operationId":"get","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user data as JSON object.","extensions":{"weight":38,"cookies":false,"type":"","demo":"docs\/examples\/account\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]},"post":{"summary":"Create Account","operationId":"create","consumes":["application\/json"],"tags":["account"],"description":"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).","extensions":{"weight":32,"cookies":false,"type":"","demo":"docs\/examples\/account\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"name","description":"User name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"}]},"delete":{"summary":"Delete Account","operationId":"delete","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":46,"cookies":false,"type":"","demo":"docs\/examples\/account\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]}},"\/account\/email":{"patch":{"summary":"Update Account Email","operationId":"updateEmail","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":44,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-email.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-email.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/logs":{"get":{"summary":"Get Account Logs","operationId":"getLogs","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.","extensions":{"weight":41,"cookies":false,"type":"","demo":"docs\/examples\/account\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]}},"\/account\/name":{"patch":{"summary":"Update Account Name","operationId":"updateName","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user account name.","extensions":{"weight":42,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-name.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-name.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"name","description":"User name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]}},"\/account\/password":{"patch":{"summary":"Update Account Password","operationId":"updatePassword","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user password. For validation, user is required to pass the password twice.","extensions":{"weight":43,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-password.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-password.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"password","description":"New user password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"oldPassword","description":"Old user password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/prefs":{"get":{"summary":"Get Account Preferences","operationId":"getPrefs","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user preferences as a key-value object.","extensions":{"weight":39,"cookies":false,"type":"","demo":"docs\/examples\/account\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]},"patch":{"summary":"Update Account Preferences","operationId":"updatePrefs","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user account preferences. You can pass only the specific settings you wish to update.","extensions":{"weight":45,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"prefs","description":"Prefs key-value JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"}]}},"\/account\/recovery":{"post":{"summary":"Create Password Recovery","operationId":"createRecovery","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":49,"cookies":false,"type":"","demo":"docs\/examples\/account\/create-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]},"put":{"summary":"Complete Password Recovery","operationId":"updateRecovery","consumes":["application\/json"],"tags":["account"],"description":"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.\n\nPlease 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.","extensions":{"weight":50,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"userId","description":"User account UID address.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Valid reset token.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"},{"name":"password","description":"New password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"passwordAgain","description":"New password again. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/sessions":{"get":{"summary":"Get Account Sessions","operationId":"getSessions","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of active sessions across different devices.","extensions":{"weight":40,"cookies":false,"type":"","demo":"docs\/examples\/account\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]},"post":{"summary":"Create Account Session","operationId":"createSession","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":33,"cookies":false,"type":"","demo":"docs\/examples\/account\/create-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]},"delete":{"summary":"Delete All Account Sessions","operationId":"deleteSessions","consumes":["application\/json"],"tags":["account"],"description":"Delete all sessions from the user account and remove any sessions cookies from the end client.","extensions":{"weight":48,"cookies":false,"type":"","demo":"docs\/examples\/account\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]}},"\/account\/sessions\/oauth2\/{provider}":{"get":{"summary":"Create Account Session with OAuth2","operationId":"createOAuth2Session","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":34,"cookies":false,"type":"webAuth","demo":"docs\/examples\/account\/create-o-auth2session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session-oauth2.md","rate-limit":50,"rate-time":3600,"rate-key":"ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"provider","description":"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.","required":true,"type":"string","x-example":"amazon","in":"path"},{"name":"success","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"\/auth\/oauth2\/success","in":"query"},{"name":"failure","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"\/auth\/oauth2\/failure","in":"query"},{"name":"scopes","description":"A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"}]}},"\/account\/sessions\/{sessionId}":{"delete":{"summary":"Delete Account Session","operationId":"deleteSession","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":47,"cookies":false,"type":"","demo":"docs\/examples\/account\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"sessionId","description":"Session unique ID. Use the string 'current' to delete the current device session.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/account\/verification":{"post":{"summary":"Create Email Verification","operationId":"createVerification","consumes":["application\/json"],"tags":["account"],"description":"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). \n\nPlease 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.\n","extensions":{"weight":51,"cookies":false,"type":"","demo":"docs\/examples\/account\/create-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]},"put":{"summary":"Complete Email Verification","operationId":"updateVerification","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":52,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Valid verification token.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"}]}},"\/avatars\/browsers\/{code}":{"get":{"summary":"Get Browser Icon","operationId":"getBrowser","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":54,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-browser.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-browser.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"code","description":"Browser Code.","required":true,"type":"string","x-example":"aa","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/credit-cards\/{code}":{"get":{"summary":"Get Credit Card Icon","operationId":"getCreditCard","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":53,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-credit-card.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-credit-card.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"code","description":"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa.","required":true,"type":"string","x-example":"amex","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/favicon":{"get":{"summary":"Get Favicon","operationId":"getFavicon","consumes":["application\/json"],"tags":["avatars"],"description":"Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote website URL.","extensions":{"weight":57,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-favicon.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-favicon.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"url","description":"Website URL which you want to fetch the favicon from.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"}]}},"\/avatars\/flags\/{code}":{"get":{"summary":"Get Country Flag","operationId":"getFlag","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":55,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-flag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-flag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"code","description":"Country Code. ISO Alpha-2 country code format.","required":true,"type":"string","x-example":"af","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/image":{"get":{"summary":"Get Image from URL","operationId":"getImage","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":56,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-image.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-image.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"url","description":"Image URL which you want to crop.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"}]}},"\/avatars\/initials":{"get":{"summary":"Get User Initials","operationId":"getInitials","consumes":["application\/json"],"tags":["avatars"],"description":"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.\n\nYou 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.","extensions":{"weight":59,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-initials.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-initials.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"name","description":"Full Name. When empty, current user name or email will be used.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"query"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"color","description":"Changes text color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"},{"name":"background","description":"Changes background color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"}]}},"\/avatars\/qr":{"get":{"summary":"Get QR Code","operationId":"getQR","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":58,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-q-r.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-qr.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"text","description":"Plain text to be converted to QR code image.","required":true,"type":"string","x-example":"[TEXT]","in":"query"},{"name":"size","description":"QR code size. Pass an integer between 0 to 1000. Defaults to 400.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"margin","description":"Margin from edge. Pass an integer between 0 to 10. Defaults to 1.","required":false,"type":"integer","format":"int32","x-example":0,"default":1,"in":"query"},{"name":"download","description":"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.","required":false,"type":"boolean","x-example":false,"default":false,"in":"query"}]}},"\/database\/collections\/{collectionId}\/documents":{"get":{"summary":"List Documents","operationId":"listDocuments","consumes":["application\/json"],"tags":["database"],"description":"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).","extensions":{"weight":66,"cookies":false,"type":"","demo":"docs\/examples\/database\/list-documents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-documents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"filters","description":"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'.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"},{"name":"offset","description":"Offset value. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"limit","description":"Maximum number of documents to return in response. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":50,"in":"query"},{"name":"orderField","description":"Document field that results will be sorted by.","required":false,"type":"string","x-example":"[ORDER_FIELD]","default":"$id","in":"query"},{"name":"orderType","description":"Order direction. Possible values are DESC for descending order, or ASC for ascending order.","required":false,"type":"string","x-example":"DESC","default":"ASC","in":"query"},{"name":"orderCast","description":"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.","required":false,"type":"string","x-example":"int","default":"string","in":"query"},{"name":"search","description":"Search query. Enter any free text search. The database will try to find a match against all document attributes and children.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"}]},"post":{"summary":"Create Document","operationId":"createDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","extensions":{"weight":65,"cookies":false,"type":"","demo":"docs\/examples\/database\/create-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"parentDocument","description":"Parent document unique ID. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","x-example":"[PARENT_DOCUMENT]","default":"","in":"formData"},{"name":"parentProperty","description":"Parent document property name. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","default":"","in":"formData"},{"name":"parentPropertyType","description":"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.","required":false,"type":"string","x-example":"assign","default":"assign","in":"formData"}]}},"\/database\/collections\/{collectionId}\/documents\/{documentId}":{"get":{"summary":"Get Document","operationId":"getDocument","consumes":["application\/json"],"tags":["database"],"description":"Get document by its unique ID. This endpoint response returns a JSON object with the document data.","extensions":{"weight":67,"cookies":false,"type":"","demo":"docs\/examples\/database\/get-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]},"patch":{"summary":"Update Document","operationId":"updateDocument","consumes":["application\/json"],"tags":["database"],"description":"","extensions":{"weight":68,"cookies":false,"type":"","demo":"docs\/examples\/database\/update-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete Document","operationId":"deleteDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","extensions":{"weight":69,"cookies":false,"type":"","demo":"docs\/examples\/database\/delete-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]}},"\/locale":{"get":{"summary":"Get User Locale","operationId":"get","consumes":["application\/json"],"tags":["locale"],"description":"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.\n\n([IP Geolocation by DB-IP](https:\/\/db-ip.com))","extensions":{"weight":70,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-locale.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/continents":{"get":{"summary":"List Continents","operationId":"getContinents","consumes":["application\/json"],"tags":["locale"],"description":"List of all continents. You can use the locale header to get the data in a supported language.","extensions":{"weight":74,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-continents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-continents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/countries":{"get":{"summary":"List Countries","operationId":"getCountries","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries. You can use the locale header to get the data in a supported language.","extensions":{"weight":71,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-countries.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/countries\/eu":{"get":{"summary":"List EU Countries","operationId":"getCountriesEU","consumes":["application\/json"],"tags":["locale"],"description":"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.","extensions":{"weight":72,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-countries-e-u.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-eu.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/countries\/phones":{"get":{"summary":"List Countries Phone Codes","operationId":"getCountriesPhones","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries phone codes. You can use the locale header to get the data in a supported language.","extensions":{"weight":73,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-countries-phones.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-phones.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/currencies":{"get":{"summary":"List Currencies","operationId":"getCurrencies","consumes":["application\/json"],"tags":["locale"],"description":"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.","extensions":{"weight":75,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-currencies.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-currencies.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/languages":{"get":{"summary":"List Languages","operationId":"getLanguages","consumes":["application\/json"],"tags":["locale"],"description":"List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.","extensions":{"weight":76,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-languages.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-languages.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/storage\/files":{"get":{"summary":"List Files","operationId":"listFiles","consumes":["application\/json"],"tags":["storage"],"description":"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).","extensions":{"weight":124,"cookies":false,"type":"","demo":"docs\/examples\/storage\/list-files.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/list-files.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create File","operationId":"createFile","consumes":["multipart\/form-data"],"tags":["storage"],"description":"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.","extensions":{"weight":123,"cookies":false,"type":"upload","demo":"docs\/examples\/storage\/create-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/create-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"file","description":"Binary File.","required":true,"type":"file","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/storage\/files\/{fileId}":{"get":{"summary":"Get File","operationId":"getFile","consumes":["application\/json"],"tags":["storage"],"description":"Get file by its unique ID. This endpoint response returns a JSON object with the file metadata.","extensions":{"weight":125,"cookies":false,"type":"","demo":"docs\/examples\/storage\/get-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]},"put":{"summary":"Update File","operationId":"updateFile","consumes":["application\/json"],"tags":["storage"],"description":"Update file by its unique ID. Only users with write permissions have access to update this resource.","extensions":{"weight":129,"cookies":false,"type":"","demo":"docs\/examples\/storage\/update-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/update-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete File","operationId":"deleteFile","consumes":["application\/json"],"tags":["storage"],"description":"Delete a file by its unique ID. Only users with write permissions have access to delete this resource.","extensions":{"weight":130,"cookies":false,"type":"","demo":"docs\/examples\/storage\/delete-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/delete-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/download":{"get":{"summary":"Get File for Download","operationId":"getFileDownload","consumes":["application\/json"],"tags":["storage"],"description":"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.","extensions":{"weight":127,"cookies":false,"type":"location","demo":"docs\/examples\/storage\/get-file-download.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-download.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/preview":{"get":{"summary":"Get File Preview","operationId":"getFilePreview","consumes":["application\/json"],"tags":["storage"],"description":"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.","extensions":{"weight":126,"cookies":false,"type":"location","demo":"docs\/examples\/storage\/get-file-preview.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-preview.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"quality","description":"Preview image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"background","description":"Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.","required":false,"type":"string","default":"","in":"query"},{"name":"output","description":"Output format type (jpeg, jpg, png, gif and webp).","required":false,"type":"string","x-example":"jpg","in":"query"}]}},"\/storage\/files\/{fileId}\/view":{"get":{"summary":"Get File for View","operationId":"getFileView","consumes":["application\/json"],"tags":["storage"],"description":"Get file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.","extensions":{"weight":128,"cookies":false,"type":"location","demo":"docs\/examples\/storage\/get-file-view.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-view.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"as","description":"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.","required":false,"type":"string","x-example":"pdf","default":"","in":"query"}]}},"\/teams":{"get":{"summary":"List Teams","operationId":"list","consumes":["application\/json"],"tags":["teams"],"description":"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).","extensions":{"weight":132,"cookies":false,"type":"","demo":"docs\/examples\/teams\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/list-teams.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team","operationId":"create","consumes":["application\/json"],"tags":["teams"],"description":"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.","extensions":{"weight":131,"cookies":false,"type":"","demo":"docs\/examples\/teams\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"roles","description":"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).","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":["owner"],"in":"formData"}]}},"\/teams\/{teamId}":{"get":{"summary":"Get Team","operationId":"get","consumes":["application\/json"],"tags":["teams"],"description":"Get team by its unique ID. All team members have read access for this resource.","extensions":{"weight":133,"cookies":false,"type":"","demo":"docs\/examples\/teams\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]},"put":{"summary":"Update Team","operationId":"update","consumes":["application\/json"],"tags":["teams"],"description":"Update team by its unique ID. Only team owners have write access for this resource.","extensions":{"weight":134,"cookies":false,"type":"","demo":"docs\/examples\/teams\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]},"delete":{"summary":"Delete Team","operationId":"delete","consumes":["application\/json"],"tags":["teams"],"description":"Delete team by its unique ID. Only team owners have write access for this resource.","extensions":{"weight":135,"cookies":false,"type":"","demo":"docs\/examples\/teams\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships":{"get":{"summary":"Get Team Memberships","operationId":"getMemberships","consumes":["application\/json"],"tags":["teams"],"description":"Get team members by the team unique ID. All team members have read access for this list of resources.","extensions":{"weight":137,"cookies":false,"type":"","demo":"docs\/examples\/teams\/get-memberships.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team-members.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team Membership","operationId":"createMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.\n\nUse 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.\n\nPlease 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.","extensions":{"weight":136,"cookies":false,"type":"","demo":"docs\/examples\/teams\/create-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"email","description":"New team member email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"name","description":"New team member name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"},{"name":"roles","description":"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).","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}":{"delete":{"summary":"Delete Team Membership","operationId":"deleteMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.","extensions":{"weight":139,"cookies":false,"type":"","demo":"docs\/examples\/teams\/delete-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}\/status":{"patch":{"summary":"Update Team Membership Status","operationId":"updateMembershipStatus","consumes":["application\/json"],"tags":["teams"],"description":"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.","extensions":{"weight":138,"cookies":false,"type":"","demo":"docs\/examples\/teams\/update-membership-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team-membership-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"},{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Secret key.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"}]}}},"definitions":{"Error":{"required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"externalDocs":{"description":"Full API docs, specs and tutorials","url":"https:\/\/localhost\/docs"}} \ No newline at end of file +{"swagger":"2.0","info":{"version":"0.6.2","title":"Appwrite","description":"Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)","termsOfService":"https:\/\/appwrite.io\/policy\/terms","contact":{"name":"Appwrite Team","url":"https:\/\/appwrite.io\/support","email":"team@localhost.test"},"license":{"name":"BSD-3-Clause","url":"https:\/\/raw.githubusercontent.com\/appwrite\/appwrite\/master\/LICENSE"}},"host":"appwrite.io","basePath":"\/v1","schemes":["https"],"consumes":["application\/json","multipart\/form-data"],"produces":["application\/json"],"securityDefinitions":{"Project":{"type":"apiKey","name":"X-Appwrite-Project","description":"Your project ID","in":"header","x-appwrite":{"demo":"5df5acd0d48c2"}},"Locale":{"type":"apiKey","name":"X-Appwrite-Locale","description":"","in":"header","x-appwrite":{"demo":"en"}}},"paths":{"\/account":{"get":{"summary":"Get Account","operationId":"get","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user data as JSON object.","x-appwrite":{"weight":38,"cookies":false,"type":"","demo":"account\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]},"post":{"summary":"Create Account","operationId":"create","consumes":["application\/json"],"tags":["account"],"description":"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).","x-appwrite":{"weight":32,"cookies":false,"type":"","demo":"account\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"name","description":"User name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"}]},"delete":{"summary":"Delete Account","operationId":"delete","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":46,"cookies":false,"type":"","demo":"account\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]}},"\/account\/email":{"patch":{"summary":"Update Account Email","operationId":"updateEmail","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":44,"cookies":false,"type":"","demo":"account\/update-email.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-email.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/logs":{"get":{"summary":"Get Account Logs","operationId":"getLogs","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.","x-appwrite":{"weight":41,"cookies":false,"type":"","demo":"account\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]}},"\/account\/name":{"patch":{"summary":"Update Account Name","operationId":"updateName","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user account name.","x-appwrite":{"weight":42,"cookies":false,"type":"","demo":"account\/update-name.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-name.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"name","description":"User name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]}},"\/account\/password":{"patch":{"summary":"Update Account Password","operationId":"updatePassword","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user password. For validation, user is required to pass the password twice.","x-appwrite":{"weight":43,"cookies":false,"type":"","demo":"account\/update-password.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-password.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"password","description":"New user password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"oldPassword","description":"Old user password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/prefs":{"get":{"summary":"Get Account Preferences","operationId":"getPrefs","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user preferences as a key-value object.","x-appwrite":{"weight":39,"cookies":false,"type":"","demo":"account\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]},"patch":{"summary":"Update Account Preferences","operationId":"updatePrefs","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user account preferences. You can pass only the specific settings you wish to update.","x-appwrite":{"weight":45,"cookies":false,"type":"","demo":"account\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"prefs","description":"Prefs key-value JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"}]}},"\/account\/recovery":{"post":{"summary":"Create Password Recovery","operationId":"createRecovery","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":49,"cookies":false,"type":"","demo":"account\/create-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]},"put":{"summary":"Complete Password Recovery","operationId":"updateRecovery","consumes":["application\/json"],"tags":["account"],"description":"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.\n\nPlease 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.","x-appwrite":{"weight":50,"cookies":false,"type":"","demo":"account\/update-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"userId","description":"User account UID address.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Valid reset token.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"},{"name":"password","description":"New password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"passwordAgain","description":"New password again. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/sessions":{"get":{"summary":"Get Account Sessions","operationId":"getSessions","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of active sessions across different devices.","x-appwrite":{"weight":40,"cookies":false,"type":"","demo":"account\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]},"post":{"summary":"Create Account Session","operationId":"createSession","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":33,"cookies":false,"type":"","demo":"account\/create-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]},"delete":{"summary":"Delete All Account Sessions","operationId":"deleteSessions","consumes":["application\/json"],"tags":["account"],"description":"Delete all sessions from the user account and remove any sessions cookies from the end client.","x-appwrite":{"weight":48,"cookies":false,"type":"","demo":"account\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}]}},"\/account\/sessions\/oauth2\/{provider}":{"get":{"summary":"Create Account Session with OAuth2","operationId":"createOAuth2Session","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":34,"cookies":false,"type":"webAuth","demo":"account\/create-o-auth2session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session-oauth2.md","rate-limit":50,"rate-time":3600,"rate-key":"ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"provider","description":"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.","required":true,"type":"string","x-example":"amazon","in":"path"},{"name":"success","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"https:\/\/appwrite.io\/auth\/oauth2\/success","in":"query"},{"name":"failure","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"https:\/\/appwrite.io\/auth\/oauth2\/failure","in":"query"},{"name":"scopes","description":"A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"}]}},"\/account\/sessions\/{sessionId}":{"delete":{"summary":"Delete Account Session","operationId":"deleteSession","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":47,"cookies":false,"type":"","demo":"account\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"sessionId","description":"Session unique ID. Use the string 'current' to delete the current device session.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/account\/verification":{"post":{"summary":"Create Email Verification","operationId":"createVerification","consumes":["application\/json"],"tags":["account"],"description":"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). \n\nPlease 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.\n","x-appwrite":{"weight":51,"cookies":false,"type":"","demo":"account\/create-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"account","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]},"put":{"summary":"Complete Email Verification","operationId":"updateVerification","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":52,"cookies":false,"type":"","demo":"account\/update-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Valid verification token.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"}]}},"\/avatars\/browsers\/{code}":{"get":{"summary":"Get Browser Icon","operationId":"getBrowser","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":54,"cookies":false,"type":"location","demo":"avatars\/get-browser.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-browser.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"code","description":"Browser Code.","required":true,"type":"string","x-example":"aa","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/credit-cards\/{code}":{"get":{"summary":"Get Credit Card Icon","operationId":"getCreditCard","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":53,"cookies":false,"type":"location","demo":"avatars\/get-credit-card.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-credit-card.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"code","description":"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa.","required":true,"type":"string","x-example":"amex","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/favicon":{"get":{"summary":"Get Favicon","operationId":"getFavicon","consumes":["application\/json"],"tags":["avatars"],"description":"Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote website URL.","x-appwrite":{"weight":57,"cookies":false,"type":"location","demo":"avatars\/get-favicon.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-favicon.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"url","description":"Website URL which you want to fetch the favicon from.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"}]}},"\/avatars\/flags\/{code}":{"get":{"summary":"Get Country Flag","operationId":"getFlag","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":55,"cookies":false,"type":"location","demo":"avatars\/get-flag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-flag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"code","description":"Country Code. ISO Alpha-2 country code format.","required":true,"type":"string","x-example":"af","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/image":{"get":{"summary":"Get Image from URL","operationId":"getImage","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":56,"cookies":false,"type":"location","demo":"avatars\/get-image.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-image.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"url","description":"Image URL which you want to crop.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"}]}},"\/avatars\/initials":{"get":{"summary":"Get User Initials","operationId":"getInitials","consumes":["application\/json"],"tags":["avatars"],"description":"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.\n\nYou 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.","x-appwrite":{"weight":59,"cookies":false,"type":"location","demo":"avatars\/get-initials.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-initials.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"name","description":"Full Name. When empty, current user name or email will be used.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"query"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"color","description":"Changes text color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"},{"name":"background","description":"Changes background color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"}]}},"\/avatars\/qr":{"get":{"summary":"Get QR Code","operationId":"getQR","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":58,"cookies":false,"type":"location","demo":"avatars\/get-q-r.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-qr.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"text","description":"Plain text to be converted to QR code image.","required":true,"type":"string","x-example":"[TEXT]","in":"query"},{"name":"size","description":"QR code size. Pass an integer between 0 to 1000. Defaults to 400.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"margin","description":"Margin from edge. Pass an integer between 0 to 10. Defaults to 1.","required":false,"type":"integer","format":"int32","x-example":0,"default":1,"in":"query"},{"name":"download","description":"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.","required":false,"type":"boolean","x-example":false,"default":false,"in":"query"}]}},"\/database\/collections\/{collectionId}\/documents":{"get":{"summary":"List Documents","operationId":"listDocuments","consumes":["application\/json"],"tags":["database"],"description":"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).","x-appwrite":{"weight":66,"cookies":false,"type":"","demo":"database\/list-documents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-documents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"filters","description":"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'.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"},{"name":"offset","description":"Offset value. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"limit","description":"Maximum number of documents to return in response. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":50,"in":"query"},{"name":"orderField","description":"Document field that results will be sorted by.","required":false,"type":"string","x-example":"[ORDER_FIELD]","default":"$id","in":"query"},{"name":"orderType","description":"Order direction. Possible values are DESC for descending order, or ASC for ascending order.","required":false,"type":"string","x-example":"DESC","default":"ASC","in":"query"},{"name":"orderCast","description":"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.","required":false,"type":"string","x-example":"int","default":"string","in":"query"},{"name":"search","description":"Search query. Enter any free text search. The database will try to find a match against all document attributes and children.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"}]},"post":{"summary":"Create Document","operationId":"createDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","x-appwrite":{"weight":65,"cookies":false,"type":"","demo":"database\/create-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"parentDocument","description":"Parent document unique ID. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","x-example":"[PARENT_DOCUMENT]","default":"","in":"formData"},{"name":"parentProperty","description":"Parent document property name. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","default":"","in":"formData"},{"name":"parentPropertyType","description":"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.","required":false,"type":"string","x-example":"assign","default":"assign","in":"formData"}]}},"\/database\/collections\/{collectionId}\/documents\/{documentId}":{"get":{"summary":"Get Document","operationId":"getDocument","consumes":["application\/json"],"tags":["database"],"description":"Get document by its unique ID. This endpoint response returns a JSON object with the document data.","x-appwrite":{"weight":67,"cookies":false,"type":"","demo":"database\/get-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]},"patch":{"summary":"Update Document","operationId":"updateDocument","consumes":["application\/json"],"tags":["database"],"description":"","x-appwrite":{"weight":68,"cookies":false,"type":"","demo":"database\/update-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete Document","operationId":"deleteDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","x-appwrite":{"weight":69,"cookies":false,"type":"","demo":"database\/delete-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]}},"\/locale":{"get":{"summary":"Get User Locale","operationId":"get","consumes":["application\/json"],"tags":["locale"],"description":"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.\n\n([IP Geolocation by DB-IP](https:\/\/db-ip.com))","x-appwrite":{"weight":70,"cookies":false,"type":"","demo":"locale\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-locale.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/continents":{"get":{"summary":"List Continents","operationId":"getContinents","consumes":["application\/json"],"tags":["locale"],"description":"List of all continents. You can use the locale header to get the data in a supported language.","x-appwrite":{"weight":74,"cookies":false,"type":"","demo":"locale\/get-continents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-continents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/countries":{"get":{"summary":"List Countries","operationId":"getCountries","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries. You can use the locale header to get the data in a supported language.","x-appwrite":{"weight":71,"cookies":false,"type":"","demo":"locale\/get-countries.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/countries\/eu":{"get":{"summary":"List EU Countries","operationId":"getCountriesEU","consumes":["application\/json"],"tags":["locale"],"description":"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.","x-appwrite":{"weight":72,"cookies":false,"type":"","demo":"locale\/get-countries-e-u.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-eu.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/countries\/phones":{"get":{"summary":"List Countries Phone Codes","operationId":"getCountriesPhones","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries phone codes. You can use the locale header to get the data in a supported language.","x-appwrite":{"weight":73,"cookies":false,"type":"","demo":"locale\/get-countries-phones.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-phones.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/currencies":{"get":{"summary":"List Currencies","operationId":"getCurrencies","consumes":["application\/json"],"tags":["locale"],"description":"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.","x-appwrite":{"weight":75,"cookies":false,"type":"","demo":"locale\/get-currencies.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-currencies.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/locale\/languages":{"get":{"summary":"List Languages","operationId":"getLanguages","consumes":["application\/json"],"tags":["locale"],"description":"List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.","x-appwrite":{"weight":76,"cookies":false,"type":"","demo":"locale\/get-languages.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-languages.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[]}]}},"\/storage\/files":{"get":{"summary":"List Files","operationId":"listFiles","consumes":["application\/json"],"tags":["storage"],"description":"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).","x-appwrite":{"weight":124,"cookies":false,"type":"","demo":"storage\/list-files.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/list-files.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create File","operationId":"createFile","consumes":["multipart\/form-data"],"tags":["storage"],"description":"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.","x-appwrite":{"weight":123,"cookies":false,"type":"upload","demo":"storage\/create-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/create-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"file","description":"Binary File.","required":true,"type":"file","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/storage\/files\/{fileId}":{"get":{"summary":"Get File","operationId":"getFile","consumes":["application\/json"],"tags":["storage"],"description":"Get file by its unique ID. This endpoint response returns a JSON object with the file metadata.","x-appwrite":{"weight":125,"cookies":false,"type":"","demo":"storage\/get-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]},"put":{"summary":"Update File","operationId":"updateFile","consumes":["application\/json"],"tags":["storage"],"description":"Update file by its unique ID. Only users with write permissions have access to update this resource.","x-appwrite":{"weight":129,"cookies":false,"type":"","demo":"storage\/update-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/update-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete File","operationId":"deleteFile","consumes":["application\/json"],"tags":["storage"],"description":"Delete a file by its unique ID. Only users with write permissions have access to delete this resource.","x-appwrite":{"weight":130,"cookies":false,"type":"","demo":"storage\/delete-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/delete-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/download":{"get":{"summary":"Get File for Download","operationId":"getFileDownload","consumes":["application\/json"],"tags":["storage"],"description":"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.","x-appwrite":{"weight":127,"cookies":false,"type":"location","demo":"storage\/get-file-download.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-download.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/preview":{"get":{"summary":"Get File Preview","operationId":"getFilePreview","consumes":["application\/json"],"tags":["storage"],"description":"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.","x-appwrite":{"weight":126,"cookies":false,"type":"location","demo":"storage\/get-file-preview.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-preview.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"quality","description":"Preview image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"background","description":"Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.","required":false,"type":"string","default":"","in":"query"},{"name":"output","description":"Output format type (jpeg, jpg, png, gif and webp).","required":false,"type":"string","x-example":"jpg","in":"query"}]}},"\/storage\/files\/{fileId}\/view":{"get":{"summary":"Get File for View","operationId":"getFileView","consumes":["application\/json"],"tags":["storage"],"description":"Get file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.","x-appwrite":{"weight":128,"cookies":false,"type":"location","demo":"storage\/get-file-view.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-view.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"as","description":"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.","required":false,"type":"string","x-example":"pdf","default":"","in":"query"}]}},"\/teams":{"get":{"summary":"List Teams","operationId":"list","consumes":["application\/json"],"tags":["teams"],"description":"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).","x-appwrite":{"weight":132,"cookies":false,"type":"","demo":"teams\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/list-teams.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team","operationId":"create","consumes":["application\/json"],"tags":["teams"],"description":"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.","x-appwrite":{"weight":131,"cookies":false,"type":"","demo":"teams\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"roles","description":"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).","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":["owner"],"in":"formData"}]}},"\/teams\/{teamId}":{"get":{"summary":"Get Team","operationId":"get","consumes":["application\/json"],"tags":["teams"],"description":"Get team by its unique ID. All team members have read access for this resource.","x-appwrite":{"weight":133,"cookies":false,"type":"","demo":"teams\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]},"put":{"summary":"Update Team","operationId":"update","consumes":["application\/json"],"tags":["teams"],"description":"Update team by its unique ID. Only team owners have write access for this resource.","x-appwrite":{"weight":134,"cookies":false,"type":"","demo":"teams\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]},"delete":{"summary":"Delete Team","operationId":"delete","consumes":["application\/json"],"tags":["teams"],"description":"Delete team by its unique ID. Only team owners have write access for this resource.","x-appwrite":{"weight":135,"cookies":false,"type":"","demo":"teams\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships":{"get":{"summary":"Get Team Memberships","operationId":"getMemberships","consumes":["application\/json"],"tags":["teams"],"description":"Get team members by the team unique ID. All team members have read access for this list of resources.","x-appwrite":{"weight":137,"cookies":false,"type":"","demo":"teams\/get-memberships.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team-members.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team Membership","operationId":"createMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.\n\nUse 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.\n\nPlease 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.","x-appwrite":{"weight":136,"cookies":false,"type":"","demo":"teams\/create-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"email","description":"New team member email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"name","description":"New team member name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"},{"name":"roles","description":"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).","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}":{"delete":{"summary":"Delete Team Membership","operationId":"deleteMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.","x-appwrite":{"weight":139,"cookies":false,"type":"","demo":"teams\/delete-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}\/status":{"patch":{"summary":"Update Team Membership Status","operationId":"updateMembershipStatus","consumes":["application\/json"],"tags":["teams"],"description":"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.","x-appwrite":{"weight":138,"cookies":false,"type":"","demo":"teams\/update-membership-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team-membership-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"},{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Secret key.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"}]}}},"definitions":{"Error":{"required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"externalDocs":{"description":"Full API docs, specs and tutorials","url":"https:\/\/localhost\/docs"}} \ No newline at end of file diff --git a/app/config/specs/0.6.2.console.json b/app/config/specs/0.6.2.console.json index 8963e9ef3a..73205ca7c8 100644 --- a/app/config/specs/0.6.2.console.json +++ b/app/config/specs/0.6.2.console.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"version":"0.6.2","title":"Appwrite","description":"Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)","termsOfService":"https:\/\/appwrite.io\/policy\/terms","contact":{"name":"Appwrite Team","url":"https:\/\/appwrite.io\/support","email":"team@localhost.test"},"license":{"name":"BSD-3-Clause","url":"https:\/\/raw.githubusercontent.com\/appwrite\/appwrite\/master\/LICENSE"}},"host":"appwrite.io","basePath":"\/v1","schemes":["https"],"consumes":["application\/json","multipart\/form-data"],"produces":["application\/json"],"securityDefinitions":{"Project":{"type":"apiKey","name":"X-Appwrite-Project","description":"Your project ID","in":"header","extensions":{"demo":"5df5acd0d48c2"}},"Key":{"type":"apiKey","name":"X-Appwrite-Key","description":"Your secret API key","in":"header","extensions":{"demo":"919c2d18fb5d4...a2ae413da83346ad2"}},"Locale":{"type":"apiKey","name":"X-Appwrite-Locale","description":"","in":"header","extensions":{"demo":"en"}},"Mode":{"type":"apiKey","name":"X-Appwrite-Mode","description":"","in":"header","extensions":{"demo":""}}},"paths":{"\/account":{"get":{"summary":"Get Account","operationId":"get","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user data as JSON object.","extensions":{"weight":38,"cookies":false,"type":"","demo":"docs\/examples\/account\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]},"post":{"summary":"Create Account","operationId":"create","consumes":["application\/json"],"tags":["account"],"description":"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).","extensions":{"weight":32,"cookies":false,"type":"","demo":"docs\/examples\/account\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"name","description":"User name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"}]},"delete":{"summary":"Delete Account","operationId":"delete","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":46,"cookies":false,"type":"","demo":"docs\/examples\/account\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]}},"\/account\/email":{"patch":{"summary":"Update Account Email","operationId":"updateEmail","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":44,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-email.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-email.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/logs":{"get":{"summary":"Get Account Logs","operationId":"getLogs","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.","extensions":{"weight":41,"cookies":false,"type":"","demo":"docs\/examples\/account\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]}},"\/account\/name":{"patch":{"summary":"Update Account Name","operationId":"updateName","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user account name.","extensions":{"weight":42,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-name.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-name.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"User name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]}},"\/account\/password":{"patch":{"summary":"Update Account Password","operationId":"updatePassword","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user password. For validation, user is required to pass the password twice.","extensions":{"weight":43,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-password.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-password.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"password","description":"New user password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"oldPassword","description":"Old user password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/prefs":{"get":{"summary":"Get Account Preferences","operationId":"getPrefs","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user preferences as a key-value object.","extensions":{"weight":39,"cookies":false,"type":"","demo":"docs\/examples\/account\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]},"patch":{"summary":"Update Account Preferences","operationId":"updatePrefs","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user account preferences. You can pass only the specific settings you wish to update.","extensions":{"weight":45,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"prefs","description":"Prefs key-value JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"}]}},"\/account\/recovery":{"post":{"summary":"Create Password Recovery","operationId":"createRecovery","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":49,"cookies":false,"type":"","demo":"docs\/examples\/account\/create-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]},"put":{"summary":"Complete Password Recovery","operationId":"updateRecovery","consumes":["application\/json"],"tags":["account"],"description":"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.\n\nPlease 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.","extensions":{"weight":50,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User account UID address.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Valid reset token.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"},{"name":"password","description":"New password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"passwordAgain","description":"New password again. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/sessions":{"get":{"summary":"Get Account Sessions","operationId":"getSessions","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of active sessions across different devices.","extensions":{"weight":40,"cookies":false,"type":"","demo":"docs\/examples\/account\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]},"post":{"summary":"Create Account Session","operationId":"createSession","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":33,"cookies":false,"type":"","demo":"docs\/examples\/account\/create-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]},"delete":{"summary":"Delete All Account Sessions","operationId":"deleteSessions","consumes":["application\/json"],"tags":["account"],"description":"Delete all sessions from the user account and remove any sessions cookies from the end client.","extensions":{"weight":48,"cookies":false,"type":"","demo":"docs\/examples\/account\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]}},"\/account\/sessions\/oauth2\/{provider}":{"get":{"summary":"Create Account Session with OAuth2","operationId":"createOAuth2Session","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":34,"cookies":false,"type":"webAuth","demo":"docs\/examples\/account\/create-o-auth2session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session-oauth2.md","rate-limit":50,"rate-time":3600,"rate-key":"ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"provider","description":"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.","required":true,"type":"string","x-example":"amazon","in":"path"},{"name":"success","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"\/auth\/oauth2\/success","in":"query"},{"name":"failure","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"\/auth\/oauth2\/failure","in":"query"},{"name":"scopes","description":"A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"}]}},"\/account\/sessions\/{sessionId}":{"delete":{"summary":"Delete Account Session","operationId":"deleteSession","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":47,"cookies":false,"type":"","demo":"docs\/examples\/account\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"sessionId","description":"Session unique ID. Use the string 'current' to delete the current device session.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/account\/verification":{"post":{"summary":"Create Email Verification","operationId":"createVerification","consumes":["application\/json"],"tags":["account"],"description":"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). \n\nPlease 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.\n","extensions":{"weight":51,"cookies":false,"type":"","demo":"docs\/examples\/account\/create-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]},"put":{"summary":"Complete Email Verification","operationId":"updateVerification","consumes":["application\/json"],"tags":["account"],"description":"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.","extensions":{"weight":52,"cookies":false,"type":"","demo":"docs\/examples\/account\/update-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Valid verification token.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"}]}},"\/avatars\/browsers\/{code}":{"get":{"summary":"Get Browser Icon","operationId":"getBrowser","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":54,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-browser.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-browser.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Browser Code.","required":true,"type":"string","x-example":"aa","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/credit-cards\/{code}":{"get":{"summary":"Get Credit Card Icon","operationId":"getCreditCard","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":53,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-credit-card.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-credit-card.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa.","required":true,"type":"string","x-example":"amex","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/favicon":{"get":{"summary":"Get Favicon","operationId":"getFavicon","consumes":["application\/json"],"tags":["avatars"],"description":"Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote website URL.","extensions":{"weight":57,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-favicon.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-favicon.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Website URL which you want to fetch the favicon from.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"}]}},"\/avatars\/flags\/{code}":{"get":{"summary":"Get Country Flag","operationId":"getFlag","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":55,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-flag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-flag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Country Code. ISO Alpha-2 country code format.","required":true,"type":"string","x-example":"af","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/image":{"get":{"summary":"Get Image from URL","operationId":"getImage","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":56,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-image.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-image.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Image URL which you want to crop.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"}]}},"\/avatars\/initials":{"get":{"summary":"Get User Initials","operationId":"getInitials","consumes":["application\/json"],"tags":["avatars"],"description":"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.\n\nYou 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.","extensions":{"weight":59,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-initials.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-initials.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Full Name. When empty, current user name or email will be used.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"query"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"color","description":"Changes text color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"},{"name":"background","description":"Changes background color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"}]}},"\/avatars\/qr":{"get":{"summary":"Get QR Code","operationId":"getQR","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":58,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-q-r.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-qr.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"text","description":"Plain text to be converted to QR code image.","required":true,"type":"string","x-example":"[TEXT]","in":"query"},{"name":"size","description":"QR code size. Pass an integer between 0 to 1000. Defaults to 400.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"margin","description":"Margin from edge. Pass an integer between 0 to 10. Defaults to 1.","required":false,"type":"integer","format":"int32","x-example":0,"default":1,"in":"query"},{"name":"download","description":"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.","required":false,"type":"boolean","x-example":false,"default":false,"in":"query"}]}},"\/database\/collections":{"get":{"summary":"List Collections","operationId":"listCollections","consumes":["application\/json"],"tags":["database"],"description":"Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project collections. [Learn more about different API modes](\/docs\/admin).","extensions":{"weight":61,"cookies":false,"type":"","demo":"docs\/examples\/database\/list-collections.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-collections.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Collection","operationId":"createCollection","consumes":["application\/json"],"tags":["database"],"description":"Create a new Collection.","extensions":{"weight":60,"cookies":false,"type":"","demo":"docs\/examples\/database\/create-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Collection name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"rules","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/database\/collections\/{collectionId}":{"get":{"summary":"Get Collection","operationId":"getCollection","consumes":["application\/json"],"tags":["database"],"description":"Get collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.","extensions":{"weight":62,"cookies":false,"type":"","demo":"docs\/examples\/database\/get-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]},"put":{"summary":"Update Collection","operationId":"updateCollection","consumes":["application\/json"],"tags":["database"],"description":"Update collection by its unique ID.","extensions":{"weight":63,"cookies":false,"type":"","demo":"docs\/examples\/database\/update-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"name","description":"Collection name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"rules","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"formData"}]},"delete":{"summary":"Delete Collection","operationId":"deleteCollection","consumes":["application\/json"],"tags":["database"],"description":"Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.","extensions":{"weight":64,"cookies":false,"type":"","demo":"docs\/examples\/database\/delete-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]}},"\/database\/collections\/{collectionId}\/documents":{"get":{"summary":"List Documents","operationId":"listDocuments","consumes":["application\/json"],"tags":["database"],"description":"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).","extensions":{"weight":66,"cookies":false,"type":"","demo":"docs\/examples\/database\/list-documents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-documents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"filters","description":"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'.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"},{"name":"offset","description":"Offset value. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"limit","description":"Maximum number of documents to return in response. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":50,"in":"query"},{"name":"orderField","description":"Document field that results will be sorted by.","required":false,"type":"string","x-example":"[ORDER_FIELD]","default":"$id","in":"query"},{"name":"orderType","description":"Order direction. Possible values are DESC for descending order, or ASC for ascending order.","required":false,"type":"string","x-example":"DESC","default":"ASC","in":"query"},{"name":"orderCast","description":"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.","required":false,"type":"string","x-example":"int","default":"string","in":"query"},{"name":"search","description":"Search query. Enter any free text search. The database will try to find a match against all document attributes and children.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"}]},"post":{"summary":"Create Document","operationId":"createDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","extensions":{"weight":65,"cookies":false,"type":"","demo":"docs\/examples\/database\/create-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"parentDocument","description":"Parent document unique ID. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","x-example":"[PARENT_DOCUMENT]","default":"","in":"formData"},{"name":"parentProperty","description":"Parent document property name. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","default":"","in":"formData"},{"name":"parentPropertyType","description":"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.","required":false,"type":"string","x-example":"assign","default":"assign","in":"formData"}]}},"\/database\/collections\/{collectionId}\/documents\/{documentId}":{"get":{"summary":"Get Document","operationId":"getDocument","consumes":["application\/json"],"tags":["database"],"description":"Get document by its unique ID. This endpoint response returns a JSON object with the document data.","extensions":{"weight":67,"cookies":false,"type":"","demo":"docs\/examples\/database\/get-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]},"patch":{"summary":"Update Document","operationId":"updateDocument","consumes":["application\/json"],"tags":["database"],"description":"","extensions":{"weight":68,"cookies":false,"type":"","demo":"docs\/examples\/database\/update-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete Document","operationId":"deleteDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","extensions":{"weight":69,"cookies":false,"type":"","demo":"docs\/examples\/database\/delete-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]}},"\/health":{"get":{"summary":"Get HTTP","operationId":"get","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite HTTP server is up and responsive.","extensions":{"weight":77,"cookies":false,"type":"","demo":"docs\/examples\/health\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/anti-virus":{"get":{"summary":"Get Anti virus","operationId":"getAntiVirus","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite Anti Virus server is up and connection is successful.","extensions":{"weight":89,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-anti-virus.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-anti-virus.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/cache":{"get":{"summary":"Get Cache","operationId":"getCache","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite in-memory cache server is up and connection is successful.","extensions":{"weight":80,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-cache.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-cache.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/db":{"get":{"summary":"Get DB","operationId":"getDB","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite database server is up and connection is successful.","extensions":{"weight":79,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-d-b.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-db.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/certificates":{"get":{"summary":"Get Certificate Queue","operationId":"getQueueCertificates","consumes":["application\/json"],"tags":["health"],"description":"Get the number of certificates that are waiting to be issued against [Letsencrypt](https:\/\/letsencrypt.org\/) in the Appwrite internal queue server.","extensions":{"weight":86,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-certificates.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-certificates.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/functions":{"get":{"summary":"Get Functions Queue","operationId":"getQueueFunctions","consumes":["application\/json"],"tags":["health"],"description":"","extensions":{"weight":87,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-functions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-functions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/logs":{"get":{"summary":"Get Logs Queue","operationId":"getQueueLogs","consumes":["application\/json"],"tags":["health"],"description":"Get the number of logs that are waiting to be processed in the Appwrite internal queue server.","extensions":{"weight":84,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/tasks":{"get":{"summary":"Get Tasks Queue","operationId":"getQueueTasks","consumes":["application\/json"],"tags":["health"],"description":"Get the number of tasks that are waiting to be processed in the Appwrite internal queue server.","extensions":{"weight":83,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-tasks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-tasks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/usage":{"get":{"summary":"Get Usage Queue","operationId":"getQueueUsage","consumes":["application\/json"],"tags":["health"],"description":"Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server.","extensions":{"weight":85,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-usage.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/webhooks":{"get":{"summary":"Get Webhooks Queue","operationId":"getQueueWebhooks","consumes":["application\/json"],"tags":["health"],"description":"Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server.","extensions":{"weight":82,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-webhooks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-webhooks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/storage\/local":{"get":{"summary":"Get Local Storage","operationId":"getStorageLocal","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite local storage device is up and connection is successful.","extensions":{"weight":88,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-storage-local.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-local.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/time":{"get":{"summary":"Get Time","operationId":"getTime","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https:\/\/en.wikipedia.org\/wiki\/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP.","extensions":{"weight":81,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-time.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-time.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale":{"get":{"summary":"Get User Locale","operationId":"get","consumes":["application\/json"],"tags":["locale"],"description":"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.\n\n([IP Geolocation by DB-IP](https:\/\/db-ip.com))","extensions":{"weight":70,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-locale.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/continents":{"get":{"summary":"List Continents","operationId":"getContinents","consumes":["application\/json"],"tags":["locale"],"description":"List of all continents. You can use the locale header to get the data in a supported language.","extensions":{"weight":74,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-continents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-continents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries":{"get":{"summary":"List Countries","operationId":"getCountries","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries. You can use the locale header to get the data in a supported language.","extensions":{"weight":71,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-countries.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/eu":{"get":{"summary":"List EU Countries","operationId":"getCountriesEU","consumes":["application\/json"],"tags":["locale"],"description":"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.","extensions":{"weight":72,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-countries-e-u.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-eu.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/phones":{"get":{"summary":"List Countries Phone Codes","operationId":"getCountriesPhones","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries phone codes. You can use the locale header to get the data in a supported language.","extensions":{"weight":73,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-countries-phones.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-phones.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/currencies":{"get":{"summary":"List Currencies","operationId":"getCurrencies","consumes":["application\/json"],"tags":["locale"],"description":"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.","extensions":{"weight":75,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-currencies.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-currencies.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/languages":{"get":{"summary":"List Languages","operationId":"getLanguages","consumes":["application\/json"],"tags":["locale"],"description":"List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.","extensions":{"weight":76,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-languages.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-languages.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/bar":{"get":{"summary":"Mock a get request for SDK tests","operationId":"get","consumes":["application\/json"],"tags":["bar"],"description":"","extensions":{"weight":155,"cookies":false,"type":"","demo":"docs\/examples\/bar\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"query"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"query"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"query"}]},"post":{"summary":"Mock a post request for SDK tests","operationId":"post","consumes":["application\/json"],"tags":["bar"],"description":"","extensions":{"weight":156,"cookies":false,"type":"","demo":"docs\/examples\/bar\/post.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a post request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"put":{"summary":"Mock a put request for SDK tests","operationId":"put","consumes":["application\/json"],"tags":["bar"],"description":"","extensions":{"weight":158,"cookies":false,"type":"","demo":"docs\/examples\/bar\/put.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a put request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"patch":{"summary":"Mock a patch request for SDK tests","operationId":"patch","consumes":["application\/json"],"tags":["bar"],"description":"","extensions":{"weight":157,"cookies":false,"type":"","demo":"docs\/examples\/bar\/patch.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Mock a delete request for SDK tests","operationId":"delete","consumes":["application\/json"],"tags":["bar"],"description":"","extensions":{"weight":159,"cookies":false,"type":"","demo":"docs\/examples\/bar\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a delete request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/mock\/tests\/foo":{"get":{"summary":"Mock a get request for SDK tests","operationId":"get","consumes":["application\/json"],"tags":["foo"],"description":"","extensions":{"weight":150,"cookies":false,"type":"","demo":"docs\/examples\/foo\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"query"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"query"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"query"}]},"post":{"summary":"Mock a post request for SDK tests","operationId":"post","consumes":["application\/json"],"tags":["foo"],"description":"","extensions":{"weight":151,"cookies":false,"type":"","demo":"docs\/examples\/foo\/post.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a post request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"put":{"summary":"Mock a put request for SDK tests","operationId":"put","consumes":["application\/json"],"tags":["foo"],"description":"","extensions":{"weight":153,"cookies":false,"type":"","demo":"docs\/examples\/foo\/put.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a put request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"patch":{"summary":"Mock a patch request for SDK tests","operationId":"patch","consumes":["application\/json"],"tags":["foo"],"description":"","extensions":{"weight":152,"cookies":false,"type":"","demo":"docs\/examples\/foo\/patch.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Mock a delete request for SDK tests","operationId":"delete","consumes":["application\/json"],"tags":["foo"],"description":"","extensions":{"weight":154,"cookies":false,"type":"","demo":"docs\/examples\/foo\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a delete request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/mock\/tests\/general\/empty":{"get":{"summary":"Mock a post request for SDK tests","operationId":"empty","consumes":["application\/json"],"tags":["general"],"description":"","extensions":{"weight":165,"cookies":false,"type":"","demo":"docs\/examples\/general\/empty.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a redirected request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/get-cookie":{"get":{"summary":"Mock a cookie request for SDK tests","operationId":"getCookie","consumes":["application\/json"],"tags":["general"],"description":"","extensions":{"weight":164,"cookies":false,"type":"","demo":"docs\/examples\/general\/get-cookie.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get cookie request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/redirect":{"get":{"summary":"Mock a post request for SDK tests","operationId":"redirect","consumes":["application\/json"],"tags":["general"],"description":"","extensions":{"weight":161,"cookies":false,"type":"","demo":"docs\/examples\/general\/redirect.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a redirect request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/redirected":{"get":{"summary":"Mock a post request for SDK tests","operationId":"redirected","consumes":["application\/json"],"tags":["general"],"description":"","extensions":{"weight":162,"cookies":false,"type":"","demo":"docs\/examples\/general\/redirected.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a redirected request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/set-cookie":{"get":{"summary":"Mock a cookie request for SDK tests","operationId":"setCookie","consumes":["application\/json"],"tags":["general"],"description":"","extensions":{"weight":163,"cookies":false,"type":"","demo":"docs\/examples\/general\/set-cookie.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a set cookie request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/upload":{"post":{"summary":"Mock a post request for SDK tests","operationId":"upload","consumes":["multipart\/form-data"],"tags":["general"],"description":"","extensions":{"weight":160,"cookies":false,"type":"","demo":"docs\/examples\/general\/upload.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a delete request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"file","description":"Sample file param","required":true,"type":"file","in":"formData"}]}},"\/projects":{"get":{"summary":"List Projects","operationId":"list","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":92,"cookies":false,"type":"","demo":"docs\/examples\/projects\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}]},"post":{"summary":"Create Project","operationId":"create","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":91,"cookies":false,"type":"","demo":"docs\/examples\/projects\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Project name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"formData"},{"name":"description","description":"Project description.","required":false,"type":"string","x-example":"[DESCRIPTION]","default":"","in":"formData"},{"name":"logo","description":"Project logo.","required":false,"type":"string","x-example":"[LOGO]","default":"","in":"formData"},{"name":"url","description":"Project URL.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"","in":"formData"},{"name":"legalName","description":"Project legal Name.","required":false,"type":"string","x-example":"[LEGAL_NAME]","default":"","in":"formData"},{"name":"legalCountry","description":"Project legal Country.","required":false,"type":"string","x-example":"[LEGAL_COUNTRY]","default":"","in":"formData"},{"name":"legalState","description":"Project legal State.","required":false,"type":"string","x-example":"[LEGAL_STATE]","default":"","in":"formData"},{"name":"legalCity","description":"Project legal City.","required":false,"type":"string","x-example":"[LEGAL_CITY]","default":"","in":"formData"},{"name":"legalAddress","description":"Project legal Address.","required":false,"type":"string","x-example":"[LEGAL_ADDRESS]","default":"","in":"formData"},{"name":"legalTaxId","description":"Project legal Tax ID.","required":false,"type":"string","x-example":"[LEGAL_TAX_ID]","default":"","in":"formData"}]}},"\/projects\/{projectId}":{"get":{"summary":"Get Project","operationId":"get","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":93,"cookies":false,"type":"","demo":"docs\/examples\/projects\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"patch":{"summary":"Update Project","operationId":"update","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":95,"cookies":false,"type":"","demo":"docs\/examples\/projects\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"name","description":"Project name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"description","description":"Project description.","required":false,"type":"string","x-example":"[DESCRIPTION]","default":"","in":"formData"},{"name":"logo","description":"Project logo.","required":false,"type":"string","x-example":"[LOGO]","default":"","in":"formData"},{"name":"url","description":"Project URL.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"","in":"formData"},{"name":"legalName","description":"Project legal name.","required":false,"type":"string","x-example":"[LEGAL_NAME]","default":"","in":"formData"},{"name":"legalCountry","description":"Project legal country..","required":false,"type":"string","x-example":"[LEGAL_COUNTRY]","default":"","in":"formData"},{"name":"legalState","description":"Project legal state.","required":false,"type":"string","x-example":"[LEGAL_STATE]","default":"","in":"formData"},{"name":"legalCity","description":"Project legal city.","required":false,"type":"string","x-example":"[LEGAL_CITY]","default":"","in":"formData"},{"name":"legalAddress","description":"Project legal address.","required":false,"type":"string","x-example":"[LEGAL_ADDRESS]","default":"","in":"formData"},{"name":"legalTaxId","description":"Project legal tax ID.","required":false,"type":"string","x-example":"[LEGAL_TAX_ID]","default":"","in":"formData"}]},"delete":{"summary":"Delete Project","operationId":"delete","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":97,"cookies":false,"type":"","demo":"docs\/examples\/projects\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"password","description":"Your user password for confirmation. Must be between 6 to 32 chars.","required":true,"type":"string","x-example":"[PASSWORD]","in":"formData"}]}},"\/projects\/{projectId}\/domains":{"get":{"summary":"List Domains","operationId":"listDomains","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":119,"cookies":false,"type":"","demo":"docs\/examples\/projects\/list-domains.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Domain","operationId":"createDomain","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":118,"cookies":false,"type":"","demo":"docs\/examples\/projects\/create-domain.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domain","description":"Domain name.","required":true,"type":"string","in":"formData"}]}},"\/projects\/{projectId}\/domains\/{domainId}":{"get":{"summary":"Get Domain","operationId":"getDomain","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":120,"cookies":false,"type":"","demo":"docs\/examples\/projects\/get-domain.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domainId","description":"Domain unique ID.","required":true,"type":"string","x-example":"[DOMAIN_ID]","in":"path"}]},"delete":{"summary":"Delete Domain","operationId":"deleteDomain","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":122,"cookies":false,"type":"","demo":"docs\/examples\/projects\/delete-domain.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domainId","description":"Domain unique ID.","required":true,"type":"string","x-example":"[DOMAIN_ID]","in":"path"}]}},"\/projects\/{projectId}\/domains\/{domainId}\/verification":{"patch":{"summary":"Update Domain Verification Status","operationId":"updateDomainVerification","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":121,"cookies":false,"type":"","demo":"docs\/examples\/projects\/update-domain-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domainId","description":"Domain unique ID.","required":true,"type":"string","x-example":"[DOMAIN_ID]","in":"path"}]}},"\/projects\/{projectId}\/keys":{"get":{"summary":"List Keys","operationId":"listKeys","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":104,"cookies":false,"type":"","demo":"docs\/examples\/projects\/list-keys.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Key","operationId":"createKey","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":103,"cookies":false,"type":"","demo":"docs\/examples\/projects\/create-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"name","description":"Key name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"scopes","description":"Key scopes list.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/projects\/{projectId}\/keys\/{keyId}":{"get":{"summary":"Get Key","operationId":"getKey","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":105,"cookies":false,"type":"","demo":"docs\/examples\/projects\/get-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"keyId","description":"Key unique ID.","required":true,"type":"string","x-example":"[KEY_ID]","in":"path"}]},"put":{"summary":"Update Key","operationId":"updateKey","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":106,"cookies":false,"type":"","demo":"docs\/examples\/projects\/update-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"keyId","description":"Key unique ID.","required":true,"type":"string","x-example":"[KEY_ID]","in":"path"},{"name":"name","description":"Key name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"scopes","description":"Key scopes list","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete Key","operationId":"deleteKey","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":107,"cookies":false,"type":"","demo":"docs\/examples\/projects\/delete-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"keyId","description":"Key unique ID.","required":true,"type":"string","x-example":"[KEY_ID]","in":"path"}]}},"\/projects\/{projectId}\/oauth2":{"patch":{"summary":"Update Project OAuth2","operationId":"updateOAuth2","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":96,"cookies":false,"type":"","demo":"docs\/examples\/projects\/update-o-auth2.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"provider","description":"Provider Name","required":true,"type":"string","x-example":"amazon","in":"formData"},{"name":"appId","description":"Provider app ID.","required":false,"type":"string","x-example":"[APP_ID]","default":"","in":"formData"},{"name":"secret","description":"Provider secret key.","required":false,"type":"string","x-example":"[SECRET]","default":"","in":"formData"}]}},"\/projects\/{projectId}\/platforms":{"get":{"summary":"List Platforms","operationId":"listPlatforms","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":114,"cookies":false,"type":"","demo":"docs\/examples\/projects\/list-platforms.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Platform","operationId":"createPlatform","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":113,"cookies":false,"type":"","demo":"docs\/examples\/projects\/create-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"type","description":"Platform type.","required":true,"type":"string","x-example":"web","in":"formData"},{"name":"name","description":"Platform name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"key","description":"Package name for android or bundle ID for iOS.","required":false,"type":"string","x-example":"[KEY]","default":"","in":"formData"},{"name":"store","description":"App store or Google Play store ID.","required":false,"type":"string","x-example":"[STORE]","default":"","in":"formData"},{"name":"hostname","description":"Platform client hostname.","required":false,"type":"string","x-example":"[HOSTNAME]","default":"","in":"formData"}]}},"\/projects\/{projectId}\/platforms\/{platformId}":{"get":{"summary":"Get Platform","operationId":"getPlatform","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":115,"cookies":false,"type":"","demo":"docs\/examples\/projects\/get-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"platformId","description":"Platform unique ID.","required":true,"type":"string","x-example":"[PLATFORM_ID]","in":"path"}]},"put":{"summary":"Update Platform","operationId":"updatePlatform","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":116,"cookies":false,"type":"","demo":"docs\/examples\/projects\/update-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"platformId","description":"Platform unique ID.","required":true,"type":"string","x-example":"[PLATFORM_ID]","in":"path"},{"name":"name","description":"Platform name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"key","description":"Package name for android or bundle ID for iOS.","required":false,"type":"string","x-example":"[KEY]","default":"","in":"formData"},{"name":"store","description":"App store or Google Play store ID.","required":false,"type":"string","x-example":"[STORE]","default":"","in":"formData"},{"name":"hostname","description":"Platform client URL.","required":false,"type":"string","x-example":"[HOSTNAME]","default":"","in":"formData"}]},"delete":{"summary":"Delete Platform","operationId":"deletePlatform","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":117,"cookies":false,"type":"","demo":"docs\/examples\/projects\/delete-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"platformId","description":"Platform unique ID.","required":true,"type":"string","x-example":"[PLATFORM_ID]","in":"path"}]}},"\/projects\/{projectId}\/tasks":{"get":{"summary":"List Tasks","operationId":"listTasks","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":109,"cookies":false,"type":"","demo":"docs\/examples\/projects\/list-tasks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Task","operationId":"createTask","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":108,"cookies":false,"type":"","demo":"docs\/examples\/projects\/create-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"name","description":"Task name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"status","description":"Task status.","required":true,"type":"string","x-example":"play","in":"formData"},{"name":"schedule","description":"Task schedule CRON syntax.","required":true,"type":"string","in":"formData"},{"name":"security","description":"Certificate verification, false for disabled or true for enabled.","required":true,"type":"boolean","x-example":false,"in":"formData"},{"name":"httpMethod","description":"Task HTTP method.","required":true,"type":"string","x-example":"GET","in":"formData"},{"name":"httpUrl","description":"Task HTTP URL","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"},{"name":"httpHeaders","description":"Task HTTP headers list.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"httpUser","description":"Task HTTP user.","required":false,"type":"string","x-example":"[HTTP_USER]","default":"","in":"formData"},{"name":"httpPass","description":"Task HTTP password.","required":false,"type":"string","x-example":"[HTTP_PASS]","default":"","in":"formData"}]}},"\/projects\/{projectId}\/tasks\/{taskId}":{"get":{"summary":"Get Task","operationId":"getTask","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":110,"cookies":false,"type":"","demo":"docs\/examples\/projects\/get-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"taskId","description":"Task unique ID.","required":true,"type":"string","x-example":"[TASK_ID]","in":"path"}]},"put":{"summary":"Update Task","operationId":"updateTask","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":111,"cookies":false,"type":"","demo":"docs\/examples\/projects\/update-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"taskId","description":"Task unique ID.","required":true,"type":"string","x-example":"[TASK_ID]","in":"path"},{"name":"name","description":"Task name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"status","description":"Task status.","required":true,"type":"string","x-example":"play","in":"formData"},{"name":"schedule","description":"Task schedule CRON syntax.","required":true,"type":"string","in":"formData"},{"name":"security","description":"Certificate verification, false for disabled or true for enabled.","required":true,"type":"boolean","x-example":false,"in":"formData"},{"name":"httpMethod","description":"Task HTTP method.","required":true,"type":"string","x-example":"GET","in":"formData"},{"name":"httpUrl","description":"Task HTTP URL.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"},{"name":"httpHeaders","description":"Task HTTP headers list.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"httpUser","description":"Task HTTP user.","required":false,"type":"string","x-example":"[HTTP_USER]","default":"","in":"formData"},{"name":"httpPass","description":"Task HTTP password.","required":false,"type":"string","x-example":"[HTTP_PASS]","default":"","in":"formData"}]},"delete":{"summary":"Delete Task","operationId":"deleteTask","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":112,"cookies":false,"type":"","demo":"docs\/examples\/projects\/delete-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"taskId","description":"Task unique ID.","required":true,"type":"string","x-example":"[TASK_ID]","in":"path"}]}},"\/projects\/{projectId}\/usage":{"get":{"summary":"Get Project","operationId":"getUsage","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":94,"cookies":false,"type":"","demo":"docs\/examples\/projects\/get-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"range","description":"Date range.","required":false,"type":"string","x-example":"daily","default":"last30","in":"query"}]}},"\/projects\/{projectId}\/webhooks":{"get":{"summary":"List Webhooks","operationId":"listWebhooks","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":99,"cookies":false,"type":"","demo":"docs\/examples\/projects\/list-webhooks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Webhook","operationId":"createWebhook","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":98,"cookies":false,"type":"","demo":"docs\/examples\/projects\/create-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"name","description":"Webhook name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"events","description":"Webhook events list.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"Webhook URL.","required":true,"type":"string","x-example":"[URL]","in":"formData"},{"name":"security","description":"Certificate verification, false for disabled or true for enabled.","required":true,"type":"boolean","x-example":false,"in":"formData"},{"name":"httpUser","description":"Webhook HTTP user.","required":false,"type":"string","x-example":"[HTTP_USER]","default":"","in":"formData"},{"name":"httpPass","description":"Webhook HTTP password.","required":false,"type":"string","x-example":"[HTTP_PASS]","default":"","in":"formData"}]}},"\/projects\/{projectId}\/webhooks\/{webhookId}":{"get":{"summary":"Get Webhook","operationId":"getWebhook","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":100,"cookies":false,"type":"","demo":"docs\/examples\/projects\/get-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"webhookId","description":"Webhook unique ID.","required":true,"type":"string","x-example":"[WEBHOOK_ID]","in":"path"}]},"put":{"summary":"Update Webhook","operationId":"updateWebhook","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":101,"cookies":false,"type":"","demo":"docs\/examples\/projects\/update-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"webhookId","description":"Webhook unique ID.","required":true,"type":"string","x-example":"[WEBHOOK_ID]","in":"path"},{"name":"name","description":"Webhook name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"events","description":"Webhook events list.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"Webhook URL.","required":true,"type":"string","x-example":"[URL]","in":"formData"},{"name":"security","description":"Certificate verification, false for disabled or true for enabled.","required":true,"type":"boolean","x-example":false,"in":"formData"},{"name":"httpUser","description":"Webhook HTTP user.","required":false,"type":"string","x-example":"[HTTP_USER]","default":"","in":"formData"},{"name":"httpPass","description":"Webhook HTTP password.","required":false,"type":"string","x-example":"[HTTP_PASS]","default":"","in":"formData"}]},"delete":{"summary":"Delete Webhook","operationId":"deleteWebhook","consumes":["application\/json"],"tags":["projects"],"description":"","extensions":{"weight":102,"cookies":false,"type":"","demo":"docs\/examples\/projects\/delete-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"webhookId","description":"Webhook unique ID.","required":true,"type":"string","x-example":"[WEBHOOK_ID]","in":"path"}]}},"\/storage\/files":{"get":{"summary":"List Files","operationId":"listFiles","consumes":["application\/json"],"tags":["storage"],"description":"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).","extensions":{"weight":124,"cookies":false,"type":"","demo":"docs\/examples\/storage\/list-files.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/list-files.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create File","operationId":"createFile","consumes":["multipart\/form-data"],"tags":["storage"],"description":"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.","extensions":{"weight":123,"cookies":false,"type":"upload","demo":"docs\/examples\/storage\/create-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/create-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"file","description":"Binary File.","required":true,"type":"file","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/storage\/files\/{fileId}":{"get":{"summary":"Get File","operationId":"getFile","consumes":["application\/json"],"tags":["storage"],"description":"Get file by its unique ID. This endpoint response returns a JSON object with the file metadata.","extensions":{"weight":125,"cookies":false,"type":"","demo":"docs\/examples\/storage\/get-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]},"put":{"summary":"Update File","operationId":"updateFile","consumes":["application\/json"],"tags":["storage"],"description":"Update file by its unique ID. Only users with write permissions have access to update this resource.","extensions":{"weight":129,"cookies":false,"type":"","demo":"docs\/examples\/storage\/update-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/update-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete File","operationId":"deleteFile","consumes":["application\/json"],"tags":["storage"],"description":"Delete a file by its unique ID. Only users with write permissions have access to delete this resource.","extensions":{"weight":130,"cookies":false,"type":"","demo":"docs\/examples\/storage\/delete-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/delete-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/download":{"get":{"summary":"Get File for Download","operationId":"getFileDownload","consumes":["application\/json"],"tags":["storage"],"description":"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.","extensions":{"weight":127,"cookies":false,"type":"location","demo":"docs\/examples\/storage\/get-file-download.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-download.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/preview":{"get":{"summary":"Get File Preview","operationId":"getFilePreview","consumes":["application\/json"],"tags":["storage"],"description":"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.","extensions":{"weight":126,"cookies":false,"type":"location","demo":"docs\/examples\/storage\/get-file-preview.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-preview.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"quality","description":"Preview image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"background","description":"Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.","required":false,"type":"string","default":"","in":"query"},{"name":"output","description":"Output format type (jpeg, jpg, png, gif and webp).","required":false,"type":"string","x-example":"jpg","in":"query"}]}},"\/storage\/files\/{fileId}\/view":{"get":{"summary":"Get File for View","operationId":"getFileView","consumes":["application\/json"],"tags":["storage"],"description":"Get file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.","extensions":{"weight":128,"cookies":false,"type":"location","demo":"docs\/examples\/storage\/get-file-view.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-view.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"as","description":"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.","required":false,"type":"string","x-example":"pdf","default":"","in":"query"}]}},"\/teams":{"get":{"summary":"List Teams","operationId":"list","consumes":["application\/json"],"tags":["teams"],"description":"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).","extensions":{"weight":132,"cookies":false,"type":"","demo":"docs\/examples\/teams\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/list-teams.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team","operationId":"create","consumes":["application\/json"],"tags":["teams"],"description":"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.","extensions":{"weight":131,"cookies":false,"type":"","demo":"docs\/examples\/teams\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"roles","description":"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).","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":["owner"],"in":"formData"}]}},"\/teams\/{teamId}":{"get":{"summary":"Get Team","operationId":"get","consumes":["application\/json"],"tags":["teams"],"description":"Get team by its unique ID. All team members have read access for this resource.","extensions":{"weight":133,"cookies":false,"type":"","demo":"docs\/examples\/teams\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]},"put":{"summary":"Update Team","operationId":"update","consumes":["application\/json"],"tags":["teams"],"description":"Update team by its unique ID. Only team owners have write access for this resource.","extensions":{"weight":134,"cookies":false,"type":"","demo":"docs\/examples\/teams\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]},"delete":{"summary":"Delete Team","operationId":"delete","consumes":["application\/json"],"tags":["teams"],"description":"Delete team by its unique ID. Only team owners have write access for this resource.","extensions":{"weight":135,"cookies":false,"type":"","demo":"docs\/examples\/teams\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships":{"get":{"summary":"Get Team Memberships","operationId":"getMemberships","consumes":["application\/json"],"tags":["teams"],"description":"Get team members by the team unique ID. All team members have read access for this list of resources.","extensions":{"weight":137,"cookies":false,"type":"","demo":"docs\/examples\/teams\/get-memberships.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team-members.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team Membership","operationId":"createMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.\n\nUse 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.\n\nPlease 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.","extensions":{"weight":136,"cookies":false,"type":"","demo":"docs\/examples\/teams\/create-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"email","description":"New team member email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"name","description":"New team member name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"},{"name":"roles","description":"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).","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}":{"delete":{"summary":"Delete Team Membership","operationId":"deleteMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.","extensions":{"weight":139,"cookies":false,"type":"","demo":"docs\/examples\/teams\/delete-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}\/status":{"patch":{"summary":"Update Team Membership Status","operationId":"updateMembershipStatus","consumes":["application\/json"],"tags":["teams"],"description":"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.","extensions":{"weight":138,"cookies":false,"type":"","demo":"docs\/examples\/teams\/update-membership-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team-membership-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"},{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Secret key.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"}]}},"\/users":{"get":{"summary":"List Users","operationId":"list","consumes":["application\/json"],"tags":["users"],"description":"Get a list of all the project users. You can use the query params to filter your results.","extensions":{"weight":141,"cookies":false,"type":"","demo":"docs\/examples\/users\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/list-users.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create User","operationId":"create","consumes":["application\/json"],"tags":["users"],"description":"Create a new user.","extensions":{"weight":140,"cookies":false,"type":"","demo":"docs\/examples\/users\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/create-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"name","description":"User name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"}]}},"\/users\/{userId}":{"get":{"summary":"Get User","operationId":"get","consumes":["application\/json"],"tags":["users"],"description":"Get user by its unique ID.","extensions":{"weight":142,"cookies":false,"type":"","demo":"docs\/examples\/users\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/logs":{"get":{"summary":"Get User Logs","operationId":"getLogs","consumes":["application\/json"],"tags":["users"],"description":"Get user activity logs list by its unique ID.","extensions":{"weight":145,"cookies":false,"type":"","demo":"docs\/examples\/users\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/prefs":{"get":{"summary":"Get User Preferences","operationId":"getPrefs","consumes":["application\/json"],"tags":["users"],"description":"Get user preferences by its unique ID.","extensions":{"weight":143,"cookies":false,"type":"","demo":"docs\/examples\/users\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"patch":{"summary":"Update User Preferences","operationId":"updatePrefs","consumes":["application\/json"],"tags":["users"],"description":"Update user preferences by its unique ID. You can pass only the specific settings you wish to update.","extensions":{"weight":147,"cookies":false,"type":"","demo":"docs\/examples\/users\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"prefs","description":"Prefs key-value JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"}]}},"\/users\/{userId}\/sessions":{"get":{"summary":"Get User Sessions","operationId":"getSessions","consumes":["application\/json"],"tags":["users"],"description":"Get user sessions list by its unique ID.","extensions":{"weight":144,"cookies":false,"type":"","demo":"docs\/examples\/users\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"delete":{"summary":"Delete User Sessions","operationId":"deleteSessions","consumes":["application\/json"],"tags":["users"],"description":"Delete all user sessions by its unique ID.","extensions":{"weight":149,"cookies":false,"type":"","demo":"docs\/examples\/users\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/sessions\/{sessionId}":{"delete":{"summary":"Delete User Session","operationId":"deleteSession","consumes":["application\/json"],"tags":["users"],"description":"Delete user sessions by its unique ID.","extensions":{"weight":148,"cookies":false,"type":"","demo":"docs\/examples\/users\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"sessionId","description":"User unique session ID.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/users\/{userId}\/status":{"patch":{"summary":"Update User Status","operationId":"updateStatus","consumes":["application\/json"],"tags":["users"],"description":"Update user status by its unique ID.","extensions":{"weight":146,"cookies":false,"type":"","demo":"docs\/examples\/users\/update-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"status","description":"User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0","required":true,"type":"string","x-example":1,"in":"formData"}]}}},"definitions":{"Error":{"required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"externalDocs":{"description":"Full API docs, specs and tutorials","url":"https:\/\/localhost\/docs"}} \ No newline at end of file +{"swagger":"2.0","info":{"version":"0.6.2","title":"Appwrite","description":"Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)","termsOfService":"https:\/\/appwrite.io\/policy\/terms","contact":{"name":"Appwrite Team","url":"https:\/\/appwrite.io\/support","email":"team@localhost.test"},"license":{"name":"BSD-3-Clause","url":"https:\/\/raw.githubusercontent.com\/appwrite\/appwrite\/master\/LICENSE"}},"host":"appwrite.io","basePath":"\/v1","schemes":["https"],"consumes":["application\/json","multipart\/form-data"],"produces":["application\/json"],"securityDefinitions":{"Project":{"type":"apiKey","name":"X-Appwrite-Project","description":"Your project ID","in":"header","x-appwrite":{"demo":"5df5acd0d48c2"}},"Key":{"type":"apiKey","name":"X-Appwrite-Key","description":"Your secret API key","in":"header","x-appwrite":{"demo":"919c2d18fb5d4...a2ae413da83346ad2"}},"Locale":{"type":"apiKey","name":"X-Appwrite-Locale","description":"","in":"header","x-appwrite":{"demo":"en"}},"Mode":{"type":"apiKey","name":"X-Appwrite-Mode","description":"","in":"header","x-appwrite":{"demo":""}}},"paths":{"\/account":{"get":{"summary":"Get Account","operationId":"get","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user data as JSON object.","x-appwrite":{"weight":38,"cookies":false,"type":"","demo":"account\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]},"post":{"summary":"Create Account","operationId":"create","consumes":["application\/json"],"tags":["account"],"description":"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).","x-appwrite":{"weight":32,"cookies":false,"type":"","demo":"account\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"name","description":"User name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"}]},"delete":{"summary":"Delete Account","operationId":"delete","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":46,"cookies":false,"type":"","demo":"account\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]}},"\/account\/email":{"patch":{"summary":"Update Account Email","operationId":"updateEmail","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":44,"cookies":false,"type":"","demo":"account\/update-email.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-email.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/logs":{"get":{"summary":"Get Account Logs","operationId":"getLogs","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.","x-appwrite":{"weight":41,"cookies":false,"type":"","demo":"account\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]}},"\/account\/name":{"patch":{"summary":"Update Account Name","operationId":"updateName","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user account name.","x-appwrite":{"weight":42,"cookies":false,"type":"","demo":"account\/update-name.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-name.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"User name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]}},"\/account\/password":{"patch":{"summary":"Update Account Password","operationId":"updatePassword","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user password. For validation, user is required to pass the password twice.","x-appwrite":{"weight":43,"cookies":false,"type":"","demo":"account\/update-password.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-password.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"password","description":"New user password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"oldPassword","description":"Old user password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/prefs":{"get":{"summary":"Get Account Preferences","operationId":"getPrefs","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user preferences as a key-value object.","x-appwrite":{"weight":39,"cookies":false,"type":"","demo":"account\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]},"patch":{"summary":"Update Account Preferences","operationId":"updatePrefs","consumes":["application\/json"],"tags":["account"],"description":"Update currently logged in user account preferences. You can pass only the specific settings you wish to update.","x-appwrite":{"weight":45,"cookies":false,"type":"","demo":"account\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"prefs","description":"Prefs key-value JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"}]}},"\/account\/recovery":{"post":{"summary":"Create Password Recovery","operationId":"createRecovery","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":49,"cookies":false,"type":"","demo":"account\/create-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]},"put":{"summary":"Complete Password Recovery","operationId":"updateRecovery","consumes":["application\/json"],"tags":["account"],"description":"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.\n\nPlease 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.","x-appwrite":{"weight":50,"cookies":false,"type":"","demo":"account\/update-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User account UID address.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Valid reset token.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"},{"name":"password","description":"New password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"passwordAgain","description":"New password again. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]}},"\/account\/sessions":{"get":{"summary":"Get Account Sessions","operationId":"getSessions","consumes":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of active sessions across different devices.","x-appwrite":{"weight":40,"cookies":false,"type":"","demo":"account\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]},"post":{"summary":"Create Account Session","operationId":"createSession","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":33,"cookies":false,"type":"","demo":"account\/create-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"}]},"delete":{"summary":"Delete All Account Sessions","operationId":"deleteSessions","consumes":["application\/json"],"tags":["account"],"description":"Delete all sessions from the user account and remove any sessions cookies from the end client.","x-appwrite":{"weight":48,"cookies":false,"type":"","demo":"account\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}]}},"\/account\/sessions\/oauth2\/{provider}":{"get":{"summary":"Create Account Session with OAuth2","operationId":"createOAuth2Session","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":34,"cookies":false,"type":"webAuth","demo":"account\/create-o-auth2session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session-oauth2.md","rate-limit":50,"rate-time":3600,"rate-key":"ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"provider","description":"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.","required":true,"type":"string","x-example":"amazon","in":"path"},{"name":"success","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"\/auth\/oauth2\/success","in":"query"},{"name":"failure","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"\/auth\/oauth2\/failure","in":"query"},{"name":"scopes","description":"A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"}]}},"\/account\/sessions\/{sessionId}":{"delete":{"summary":"Delete Account Session","operationId":"deleteSession","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":47,"cookies":false,"type":"","demo":"account\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"sessionId","description":"Session unique ID. Use the string 'current' to delete the current device session.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/account\/verification":{"post":{"summary":"Create Email Verification","operationId":"createVerification","consumes":["application\/json"],"tags":["account"],"description":"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). \n\nPlease 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.\n","x-appwrite":{"weight":51,"cookies":false,"type":"","demo":"account\/create-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"account","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]},"put":{"summary":"Complete Email Verification","operationId":"updateVerification","consumes":["application\/json"],"tags":["account"],"description":"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.","x-appwrite":{"weight":52,"cookies":false,"type":"","demo":"account\/update-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Valid verification token.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"}]}},"\/avatars\/browsers\/{code}":{"get":{"summary":"Get Browser Icon","operationId":"getBrowser","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":54,"cookies":false,"type":"location","demo":"avatars\/get-browser.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-browser.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Browser Code.","required":true,"type":"string","x-example":"aa","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/credit-cards\/{code}":{"get":{"summary":"Get Credit Card Icon","operationId":"getCreditCard","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":53,"cookies":false,"type":"location","demo":"avatars\/get-credit-card.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-credit-card.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa.","required":true,"type":"string","x-example":"amex","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/favicon":{"get":{"summary":"Get Favicon","operationId":"getFavicon","consumes":["application\/json"],"tags":["avatars"],"description":"Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote website URL.","x-appwrite":{"weight":57,"cookies":false,"type":"location","demo":"avatars\/get-favicon.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-favicon.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Website URL which you want to fetch the favicon from.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"}]}},"\/avatars\/flags\/{code}":{"get":{"summary":"Get Country Flag","operationId":"getFlag","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":55,"cookies":false,"type":"location","demo":"avatars\/get-flag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-flag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Country Code. ISO Alpha-2 country code format.","required":true,"type":"string","x-example":"af","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/image":{"get":{"summary":"Get Image from URL","operationId":"getImage","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":56,"cookies":false,"type":"location","demo":"avatars\/get-image.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-image.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Image URL which you want to crop.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"}]}},"\/avatars\/initials":{"get":{"summary":"Get User Initials","operationId":"getInitials","consumes":["application\/json"],"tags":["avatars"],"description":"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.\n\nYou 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.","x-appwrite":{"weight":59,"cookies":false,"type":"location","demo":"avatars\/get-initials.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-initials.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Full Name. When empty, current user name or email will be used.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"query"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"color","description":"Changes text color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"},{"name":"background","description":"Changes background color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"}]}},"\/avatars\/qr":{"get":{"summary":"Get QR Code","operationId":"getQR","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":58,"cookies":false,"type":"location","demo":"avatars\/get-q-r.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-qr.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"text","description":"Plain text to be converted to QR code image.","required":true,"type":"string","x-example":"[TEXT]","in":"query"},{"name":"size","description":"QR code size. Pass an integer between 0 to 1000. Defaults to 400.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"margin","description":"Margin from edge. Pass an integer between 0 to 10. Defaults to 1.","required":false,"type":"integer","format":"int32","x-example":0,"default":1,"in":"query"},{"name":"download","description":"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.","required":false,"type":"boolean","x-example":false,"default":false,"in":"query"}]}},"\/database\/collections":{"get":{"summary":"List Collections","operationId":"listCollections","consumes":["application\/json"],"tags":["database"],"description":"Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project collections. [Learn more about different API modes](\/docs\/admin).","x-appwrite":{"weight":61,"cookies":false,"type":"","demo":"database\/list-collections.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-collections.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Collection","operationId":"createCollection","consumes":["application\/json"],"tags":["database"],"description":"Create a new Collection.","x-appwrite":{"weight":60,"cookies":false,"type":"","demo":"database\/create-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Collection name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"rules","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/database\/collections\/{collectionId}":{"get":{"summary":"Get Collection","operationId":"getCollection","consumes":["application\/json"],"tags":["database"],"description":"Get collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.","x-appwrite":{"weight":62,"cookies":false,"type":"","demo":"database\/get-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]},"put":{"summary":"Update Collection","operationId":"updateCollection","consumes":["application\/json"],"tags":["database"],"description":"Update collection by its unique ID.","x-appwrite":{"weight":63,"cookies":false,"type":"","demo":"database\/update-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"name","description":"Collection name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"rules","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"formData"}]},"delete":{"summary":"Delete Collection","operationId":"deleteCollection","consumes":["application\/json"],"tags":["database"],"description":"Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.","x-appwrite":{"weight":64,"cookies":false,"type":"","demo":"database\/delete-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]}},"\/database\/collections\/{collectionId}\/documents":{"get":{"summary":"List Documents","operationId":"listDocuments","consumes":["application\/json"],"tags":["database"],"description":"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).","x-appwrite":{"weight":66,"cookies":false,"type":"","demo":"database\/list-documents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-documents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"filters","description":"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'.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"},{"name":"offset","description":"Offset value. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"limit","description":"Maximum number of documents to return in response. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":50,"in":"query"},{"name":"orderField","description":"Document field that results will be sorted by.","required":false,"type":"string","x-example":"[ORDER_FIELD]","default":"$id","in":"query"},{"name":"orderType","description":"Order direction. Possible values are DESC for descending order, or ASC for ascending order.","required":false,"type":"string","x-example":"DESC","default":"ASC","in":"query"},{"name":"orderCast","description":"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.","required":false,"type":"string","x-example":"int","default":"string","in":"query"},{"name":"search","description":"Search query. Enter any free text search. The database will try to find a match against all document attributes and children.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"}]},"post":{"summary":"Create Document","operationId":"createDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","x-appwrite":{"weight":65,"cookies":false,"type":"","demo":"database\/create-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"parentDocument","description":"Parent document unique ID. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","x-example":"[PARENT_DOCUMENT]","default":"","in":"formData"},{"name":"parentProperty","description":"Parent document property name. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","default":"","in":"formData"},{"name":"parentPropertyType","description":"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.","required":false,"type":"string","x-example":"assign","default":"assign","in":"formData"}]}},"\/database\/collections\/{collectionId}\/documents\/{documentId}":{"get":{"summary":"Get Document","operationId":"getDocument","consumes":["application\/json"],"tags":["database"],"description":"Get document by its unique ID. This endpoint response returns a JSON object with the document data.","x-appwrite":{"weight":67,"cookies":false,"type":"","demo":"database\/get-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]},"patch":{"summary":"Update Document","operationId":"updateDocument","consumes":["application\/json"],"tags":["database"],"description":"","x-appwrite":{"weight":68,"cookies":false,"type":"","demo":"database\/update-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete Document","operationId":"deleteDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","x-appwrite":{"weight":69,"cookies":false,"type":"","demo":"database\/delete-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]}},"\/health":{"get":{"summary":"Get HTTP","operationId":"get","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite HTTP server is up and responsive.","x-appwrite":{"weight":77,"cookies":false,"type":"","demo":"health\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/anti-virus":{"get":{"summary":"Get Anti virus","operationId":"getAntiVirus","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite Anti Virus server is up and connection is successful.","x-appwrite":{"weight":89,"cookies":false,"type":"","demo":"health\/get-anti-virus.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-anti-virus.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/cache":{"get":{"summary":"Get Cache","operationId":"getCache","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite in-memory cache server is up and connection is successful.","x-appwrite":{"weight":80,"cookies":false,"type":"","demo":"health\/get-cache.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-cache.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/db":{"get":{"summary":"Get DB","operationId":"getDB","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite database server is up and connection is successful.","x-appwrite":{"weight":79,"cookies":false,"type":"","demo":"health\/get-d-b.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-db.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/certificates":{"get":{"summary":"Get Certificate Queue","operationId":"getQueueCertificates","consumes":["application\/json"],"tags":["health"],"description":"Get the number of certificates that are waiting to be issued against [Letsencrypt](https:\/\/letsencrypt.org\/) in the Appwrite internal queue server.","x-appwrite":{"weight":86,"cookies":false,"type":"","demo":"health\/get-queue-certificates.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-certificates.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/functions":{"get":{"summary":"Get Functions Queue","operationId":"getQueueFunctions","consumes":["application\/json"],"tags":["health"],"description":"","x-appwrite":{"weight":87,"cookies":false,"type":"","demo":"health\/get-queue-functions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-functions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/logs":{"get":{"summary":"Get Logs Queue","operationId":"getQueueLogs","consumes":["application\/json"],"tags":["health"],"description":"Get the number of logs that are waiting to be processed in the Appwrite internal queue server.","x-appwrite":{"weight":84,"cookies":false,"type":"","demo":"health\/get-queue-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/tasks":{"get":{"summary":"Get Tasks Queue","operationId":"getQueueTasks","consumes":["application\/json"],"tags":["health"],"description":"Get the number of tasks that are waiting to be processed in the Appwrite internal queue server.","x-appwrite":{"weight":83,"cookies":false,"type":"","demo":"health\/get-queue-tasks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-tasks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/usage":{"get":{"summary":"Get Usage Queue","operationId":"getQueueUsage","consumes":["application\/json"],"tags":["health"],"description":"Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server.","x-appwrite":{"weight":85,"cookies":false,"type":"","demo":"health\/get-queue-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-usage.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/webhooks":{"get":{"summary":"Get Webhooks Queue","operationId":"getQueueWebhooks","consumes":["application\/json"],"tags":["health"],"description":"Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server.","x-appwrite":{"weight":82,"cookies":false,"type":"","demo":"health\/get-queue-webhooks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-webhooks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/storage\/local":{"get":{"summary":"Get Local Storage","operationId":"getStorageLocal","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite local storage device is up and connection is successful.","x-appwrite":{"weight":88,"cookies":false,"type":"","demo":"health\/get-storage-local.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-local.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/time":{"get":{"summary":"Get Time","operationId":"getTime","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https:\/\/en.wikipedia.org\/wiki\/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP.","x-appwrite":{"weight":81,"cookies":false,"type":"","demo":"health\/get-time.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-time.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale":{"get":{"summary":"Get User Locale","operationId":"get","consumes":["application\/json"],"tags":["locale"],"description":"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.\n\n([IP Geolocation by DB-IP](https:\/\/db-ip.com))","x-appwrite":{"weight":70,"cookies":false,"type":"","demo":"locale\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-locale.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/continents":{"get":{"summary":"List Continents","operationId":"getContinents","consumes":["application\/json"],"tags":["locale"],"description":"List of all continents. You can use the locale header to get the data in a supported language.","x-appwrite":{"weight":74,"cookies":false,"type":"","demo":"locale\/get-continents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-continents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries":{"get":{"summary":"List Countries","operationId":"getCountries","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries. You can use the locale header to get the data in a supported language.","x-appwrite":{"weight":71,"cookies":false,"type":"","demo":"locale\/get-countries.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/eu":{"get":{"summary":"List EU Countries","operationId":"getCountriesEU","consumes":["application\/json"],"tags":["locale"],"description":"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.","x-appwrite":{"weight":72,"cookies":false,"type":"","demo":"locale\/get-countries-e-u.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-eu.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/phones":{"get":{"summary":"List Countries Phone Codes","operationId":"getCountriesPhones","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries phone codes. You can use the locale header to get the data in a supported language.","x-appwrite":{"weight":73,"cookies":false,"type":"","demo":"locale\/get-countries-phones.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-phones.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/currencies":{"get":{"summary":"List Currencies","operationId":"getCurrencies","consumes":["application\/json"],"tags":["locale"],"description":"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.","x-appwrite":{"weight":75,"cookies":false,"type":"","demo":"locale\/get-currencies.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-currencies.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/languages":{"get":{"summary":"List Languages","operationId":"getLanguages","consumes":["application\/json"],"tags":["locale"],"description":"List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.","x-appwrite":{"weight":76,"cookies":false,"type":"","demo":"locale\/get-languages.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-languages.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/bar":{"get":{"summary":"Mock a get request for SDK tests","operationId":"get","consumes":["application\/json"],"tags":["bar"],"description":"","x-appwrite":{"weight":155,"cookies":false,"type":"","demo":"bar\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"query"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"query"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"query"}]},"post":{"summary":"Mock a post request for SDK tests","operationId":"post","consumes":["application\/json"],"tags":["bar"],"description":"","x-appwrite":{"weight":156,"cookies":false,"type":"","demo":"bar\/post.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a post request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"put":{"summary":"Mock a put request for SDK tests","operationId":"put","consumes":["application\/json"],"tags":["bar"],"description":"","x-appwrite":{"weight":158,"cookies":false,"type":"","demo":"bar\/put.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a put request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"patch":{"summary":"Mock a patch request for SDK tests","operationId":"patch","consumes":["application\/json"],"tags":["bar"],"description":"","x-appwrite":{"weight":157,"cookies":false,"type":"","demo":"bar\/patch.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Mock a delete request for SDK tests","operationId":"delete","consumes":["application\/json"],"tags":["bar"],"description":"","x-appwrite":{"weight":159,"cookies":false,"type":"","demo":"bar\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a delete request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/mock\/tests\/foo":{"get":{"summary":"Mock a get request for SDK tests","operationId":"get","consumes":["application\/json"],"tags":["foo"],"description":"","x-appwrite":{"weight":150,"cookies":false,"type":"","demo":"foo\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"query"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"query"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"query"}]},"post":{"summary":"Mock a post request for SDK tests","operationId":"post","consumes":["application\/json"],"tags":["foo"],"description":"","x-appwrite":{"weight":151,"cookies":false,"type":"","demo":"foo\/post.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a post request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"put":{"summary":"Mock a put request for SDK tests","operationId":"put","consumes":["application\/json"],"tags":["foo"],"description":"","x-appwrite":{"weight":153,"cookies":false,"type":"","demo":"foo\/put.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a put request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"patch":{"summary":"Mock a patch request for SDK tests","operationId":"patch","consumes":["application\/json"],"tags":["foo"],"description":"","x-appwrite":{"weight":152,"cookies":false,"type":"","demo":"foo\/patch.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Mock a delete request for SDK tests","operationId":"delete","consumes":["application\/json"],"tags":["foo"],"description":"","x-appwrite":{"weight":154,"cookies":false,"type":"","demo":"foo\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a delete request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/mock\/tests\/general\/empty":{"get":{"summary":"Mock a post request for SDK tests","operationId":"empty","consumes":["application\/json"],"tags":["general"],"description":"","x-appwrite":{"weight":165,"cookies":false,"type":"","demo":"general\/empty.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a redirected request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/get-cookie":{"get":{"summary":"Mock a cookie request for SDK tests","operationId":"getCookie","consumes":["application\/json"],"tags":["general"],"description":"","x-appwrite":{"weight":164,"cookies":false,"type":"","demo":"general\/get-cookie.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a get cookie request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/redirect":{"get":{"summary":"Mock a post request for SDK tests","operationId":"redirect","consumes":["application\/json"],"tags":["general"],"description":"","x-appwrite":{"weight":161,"cookies":false,"type":"","demo":"general\/redirect.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a redirect request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/redirected":{"get":{"summary":"Mock a post request for SDK tests","operationId":"redirected","consumes":["application\/json"],"tags":["general"],"description":"","x-appwrite":{"weight":162,"cookies":false,"type":"","demo":"general\/redirected.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a redirected request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/set-cookie":{"get":{"summary":"Mock a cookie request for SDK tests","operationId":"setCookie","consumes":["application\/json"],"tags":["general"],"description":"","x-appwrite":{"weight":163,"cookies":false,"type":"","demo":"general\/set-cookie.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a set cookie request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}]}},"\/mock\/tests\/general\/upload":{"post":{"summary":"Mock a post request for SDK tests","operationId":"upload","consumes":["multipart\/form-data"],"tags":["general"],"description":"","x-appwrite":{"weight":160,"cookies":false,"type":"","demo":"general\/upload.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/masterMock a delete request for SDK tests","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"x","description":"Sample string param","required":true,"type":"string","x-example":"[]","in":"formData"},{"name":"y","description":"Sample numeric param","required":true,"type":"integer","format":"int32","in":"formData"},{"name":"z","description":"Sample array param","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"file","description":"Sample file param","required":true,"type":"file","in":"formData"}]}},"\/projects":{"get":{"summary":"List Projects","operationId":"list","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":92,"cookies":false,"type":"","demo":"projects\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}]},"post":{"summary":"Create Project","operationId":"create","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":91,"cookies":false,"type":"","demo":"projects\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Project name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"formData"},{"name":"description","description":"Project description.","required":false,"type":"string","x-example":"[DESCRIPTION]","default":"","in":"formData"},{"name":"logo","description":"Project logo.","required":false,"type":"string","x-example":"[LOGO]","default":"","in":"formData"},{"name":"url","description":"Project URL.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"","in":"formData"},{"name":"legalName","description":"Project legal Name.","required":false,"type":"string","x-example":"[LEGAL_NAME]","default":"","in":"formData"},{"name":"legalCountry","description":"Project legal Country.","required":false,"type":"string","x-example":"[LEGAL_COUNTRY]","default":"","in":"formData"},{"name":"legalState","description":"Project legal State.","required":false,"type":"string","x-example":"[LEGAL_STATE]","default":"","in":"formData"},{"name":"legalCity","description":"Project legal City.","required":false,"type":"string","x-example":"[LEGAL_CITY]","default":"","in":"formData"},{"name":"legalAddress","description":"Project legal Address.","required":false,"type":"string","x-example":"[LEGAL_ADDRESS]","default":"","in":"formData"},{"name":"legalTaxId","description":"Project legal Tax ID.","required":false,"type":"string","x-example":"[LEGAL_TAX_ID]","default":"","in":"formData"}]}},"\/projects\/{projectId}":{"get":{"summary":"Get Project","operationId":"get","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":93,"cookies":false,"type":"","demo":"projects\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"patch":{"summary":"Update Project","operationId":"update","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":95,"cookies":false,"type":"","demo":"projects\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"name","description":"Project name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"description","description":"Project description.","required":false,"type":"string","x-example":"[DESCRIPTION]","default":"","in":"formData"},{"name":"logo","description":"Project logo.","required":false,"type":"string","x-example":"[LOGO]","default":"","in":"formData"},{"name":"url","description":"Project URL.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"","in":"formData"},{"name":"legalName","description":"Project legal name.","required":false,"type":"string","x-example":"[LEGAL_NAME]","default":"","in":"formData"},{"name":"legalCountry","description":"Project legal country..","required":false,"type":"string","x-example":"[LEGAL_COUNTRY]","default":"","in":"formData"},{"name":"legalState","description":"Project legal state.","required":false,"type":"string","x-example":"[LEGAL_STATE]","default":"","in":"formData"},{"name":"legalCity","description":"Project legal city.","required":false,"type":"string","x-example":"[LEGAL_CITY]","default":"","in":"formData"},{"name":"legalAddress","description":"Project legal address.","required":false,"type":"string","x-example":"[LEGAL_ADDRESS]","default":"","in":"formData"},{"name":"legalTaxId","description":"Project legal tax ID.","required":false,"type":"string","x-example":"[LEGAL_TAX_ID]","default":"","in":"formData"}]},"delete":{"summary":"Delete Project","operationId":"delete","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":97,"cookies":false,"type":"","demo":"projects\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"password","description":"Your user password for confirmation. Must be between 6 to 32 chars.","required":true,"type":"string","x-example":"[PASSWORD]","in":"formData"}]}},"\/projects\/{projectId}\/domains":{"get":{"summary":"List Domains","operationId":"listDomains","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":119,"cookies":false,"type":"","demo":"projects\/list-domains.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Domain","operationId":"createDomain","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":118,"cookies":false,"type":"","demo":"projects\/create-domain.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domain","description":"Domain name.","required":true,"type":"string","in":"formData"}]}},"\/projects\/{projectId}\/domains\/{domainId}":{"get":{"summary":"Get Domain","operationId":"getDomain","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":120,"cookies":false,"type":"","demo":"projects\/get-domain.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domainId","description":"Domain unique ID.","required":true,"type":"string","x-example":"[DOMAIN_ID]","in":"path"}]},"delete":{"summary":"Delete Domain","operationId":"deleteDomain","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":122,"cookies":false,"type":"","demo":"projects\/delete-domain.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domainId","description":"Domain unique ID.","required":true,"type":"string","x-example":"[DOMAIN_ID]","in":"path"}]}},"\/projects\/{projectId}\/domains\/{domainId}\/verification":{"patch":{"summary":"Update Domain Verification Status","operationId":"updateDomainVerification","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":121,"cookies":false,"type":"","demo":"projects\/update-domain-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domainId","description":"Domain unique ID.","required":true,"type":"string","x-example":"[DOMAIN_ID]","in":"path"}]}},"\/projects\/{projectId}\/keys":{"get":{"summary":"List Keys","operationId":"listKeys","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":104,"cookies":false,"type":"","demo":"projects\/list-keys.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Key","operationId":"createKey","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":103,"cookies":false,"type":"","demo":"projects\/create-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"name","description":"Key name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"scopes","description":"Key scopes list.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/projects\/{projectId}\/keys\/{keyId}":{"get":{"summary":"Get Key","operationId":"getKey","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":105,"cookies":false,"type":"","demo":"projects\/get-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"keyId","description":"Key unique ID.","required":true,"type":"string","x-example":"[KEY_ID]","in":"path"}]},"put":{"summary":"Update Key","operationId":"updateKey","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":106,"cookies":false,"type":"","demo":"projects\/update-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"keyId","description":"Key unique ID.","required":true,"type":"string","x-example":"[KEY_ID]","in":"path"},{"name":"name","description":"Key name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"scopes","description":"Key scopes list","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete Key","operationId":"deleteKey","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":107,"cookies":false,"type":"","demo":"projects\/delete-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"keyId","description":"Key unique ID.","required":true,"type":"string","x-example":"[KEY_ID]","in":"path"}]}},"\/projects\/{projectId}\/oauth2":{"patch":{"summary":"Update Project OAuth2","operationId":"updateOAuth2","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":96,"cookies":false,"type":"","demo":"projects\/update-o-auth2.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"provider","description":"Provider Name","required":true,"type":"string","x-example":"amazon","in":"formData"},{"name":"appId","description":"Provider app ID.","required":false,"type":"string","x-example":"[APP_ID]","default":"","in":"formData"},{"name":"secret","description":"Provider secret key.","required":false,"type":"string","x-example":"[SECRET]","default":"","in":"formData"}]}},"\/projects\/{projectId}\/platforms":{"get":{"summary":"List Platforms","operationId":"listPlatforms","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":114,"cookies":false,"type":"","demo":"projects\/list-platforms.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Platform","operationId":"createPlatform","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":113,"cookies":false,"type":"","demo":"projects\/create-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"type","description":"Platform type.","required":true,"type":"string","x-example":"web","in":"formData"},{"name":"name","description":"Platform name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"key","description":"Package name for android or bundle ID for iOS.","required":false,"type":"string","x-example":"[KEY]","default":"","in":"formData"},{"name":"store","description":"App store or Google Play store ID.","required":false,"type":"string","x-example":"[STORE]","default":"","in":"formData"},{"name":"hostname","description":"Platform client hostname.","required":false,"type":"string","x-example":"[HOSTNAME]","default":"","in":"formData"}]}},"\/projects\/{projectId}\/platforms\/{platformId}":{"get":{"summary":"Get Platform","operationId":"getPlatform","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":115,"cookies":false,"type":"","demo":"projects\/get-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"platformId","description":"Platform unique ID.","required":true,"type":"string","x-example":"[PLATFORM_ID]","in":"path"}]},"put":{"summary":"Update Platform","operationId":"updatePlatform","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":116,"cookies":false,"type":"","demo":"projects\/update-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"platformId","description":"Platform unique ID.","required":true,"type":"string","x-example":"[PLATFORM_ID]","in":"path"},{"name":"name","description":"Platform name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"key","description":"Package name for android or bundle ID for iOS.","required":false,"type":"string","x-example":"[KEY]","default":"","in":"formData"},{"name":"store","description":"App store or Google Play store ID.","required":false,"type":"string","x-example":"[STORE]","default":"","in":"formData"},{"name":"hostname","description":"Platform client URL.","required":false,"type":"string","x-example":"[HOSTNAME]","default":"","in":"formData"}]},"delete":{"summary":"Delete Platform","operationId":"deletePlatform","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":117,"cookies":false,"type":"","demo":"projects\/delete-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"platformId","description":"Platform unique ID.","required":true,"type":"string","x-example":"[PLATFORM_ID]","in":"path"}]}},"\/projects\/{projectId}\/tasks":{"get":{"summary":"List Tasks","operationId":"listTasks","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":109,"cookies":false,"type":"","demo":"projects\/list-tasks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Task","operationId":"createTask","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":108,"cookies":false,"type":"","demo":"projects\/create-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"name","description":"Task name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"status","description":"Task status.","required":true,"type":"string","x-example":"play","in":"formData"},{"name":"schedule","description":"Task schedule CRON syntax.","required":true,"type":"string","in":"formData"},{"name":"security","description":"Certificate verification, false for disabled or true for enabled.","required":true,"type":"boolean","x-example":false,"in":"formData"},{"name":"httpMethod","description":"Task HTTP method.","required":true,"type":"string","x-example":"GET","in":"formData"},{"name":"httpUrl","description":"Task HTTP URL","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"},{"name":"httpHeaders","description":"Task HTTP headers list.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"httpUser","description":"Task HTTP user.","required":false,"type":"string","x-example":"[HTTP_USER]","default":"","in":"formData"},{"name":"httpPass","description":"Task HTTP password.","required":false,"type":"string","x-example":"[HTTP_PASS]","default":"","in":"formData"}]}},"\/projects\/{projectId}\/tasks\/{taskId}":{"get":{"summary":"Get Task","operationId":"getTask","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":110,"cookies":false,"type":"","demo":"projects\/get-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"taskId","description":"Task unique ID.","required":true,"type":"string","x-example":"[TASK_ID]","in":"path"}]},"put":{"summary":"Update Task","operationId":"updateTask","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":111,"cookies":false,"type":"","demo":"projects\/update-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"taskId","description":"Task unique ID.","required":true,"type":"string","x-example":"[TASK_ID]","in":"path"},{"name":"name","description":"Task name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"status","description":"Task status.","required":true,"type":"string","x-example":"play","in":"formData"},{"name":"schedule","description":"Task schedule CRON syntax.","required":true,"type":"string","in":"formData"},{"name":"security","description":"Certificate verification, false for disabled or true for enabled.","required":true,"type":"boolean","x-example":false,"in":"formData"},{"name":"httpMethod","description":"Task HTTP method.","required":true,"type":"string","x-example":"GET","in":"formData"},{"name":"httpUrl","description":"Task HTTP URL.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"},{"name":"httpHeaders","description":"Task HTTP headers list.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"httpUser","description":"Task HTTP user.","required":false,"type":"string","x-example":"[HTTP_USER]","default":"","in":"formData"},{"name":"httpPass","description":"Task HTTP password.","required":false,"type":"string","x-example":"[HTTP_PASS]","default":"","in":"formData"}]},"delete":{"summary":"Delete Task","operationId":"deleteTask","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":112,"cookies":false,"type":"","demo":"projects\/delete-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"taskId","description":"Task unique ID.","required":true,"type":"string","x-example":"[TASK_ID]","in":"path"}]}},"\/projects\/{projectId}\/usage":{"get":{"summary":"Get Project","operationId":"getUsage","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":94,"cookies":false,"type":"","demo":"projects\/get-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"range","description":"Date range.","required":false,"type":"string","x-example":"daily","default":"last30","in":"query"}]}},"\/projects\/{projectId}\/webhooks":{"get":{"summary":"List Webhooks","operationId":"listWebhooks","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":99,"cookies":false,"type":"","demo":"projects\/list-webhooks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Webhook","operationId":"createWebhook","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":98,"cookies":false,"type":"","demo":"projects\/create-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"name","description":"Webhook name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"events","description":"Webhook events list.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"Webhook URL.","required":true,"type":"string","x-example":"[URL]","in":"formData"},{"name":"security","description":"Certificate verification, false for disabled or true for enabled.","required":true,"type":"boolean","x-example":false,"in":"formData"},{"name":"httpUser","description":"Webhook HTTP user.","required":false,"type":"string","x-example":"[HTTP_USER]","default":"","in":"formData"},{"name":"httpPass","description":"Webhook HTTP password.","required":false,"type":"string","x-example":"[HTTP_PASS]","default":"","in":"formData"}]}},"\/projects\/{projectId}\/webhooks\/{webhookId}":{"get":{"summary":"Get Webhook","operationId":"getWebhook","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":100,"cookies":false,"type":"","demo":"projects\/get-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"webhookId","description":"Webhook unique ID.","required":true,"type":"string","x-example":"[WEBHOOK_ID]","in":"path"}]},"put":{"summary":"Update Webhook","operationId":"updateWebhook","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":101,"cookies":false,"type":"","demo":"projects\/update-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"webhookId","description":"Webhook unique ID.","required":true,"type":"string","x-example":"[WEBHOOK_ID]","in":"path"},{"name":"name","description":"Webhook name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"events","description":"Webhook events list.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"Webhook URL.","required":true,"type":"string","x-example":"[URL]","in":"formData"},{"name":"security","description":"Certificate verification, false for disabled or true for enabled.","required":true,"type":"boolean","x-example":false,"in":"formData"},{"name":"httpUser","description":"Webhook HTTP user.","required":false,"type":"string","x-example":"[HTTP_USER]","default":"","in":"formData"},{"name":"httpPass","description":"Webhook HTTP password.","required":false,"type":"string","x-example":"[HTTP_PASS]","default":"","in":"formData"}]},"delete":{"summary":"Delete Webhook","operationId":"deleteWebhook","consumes":["application\/json"],"tags":["projects"],"description":"","x-appwrite":{"weight":102,"cookies":false,"type":"","demo":"projects\/delete-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"webhookId","description":"Webhook unique ID.","required":true,"type":"string","x-example":"[WEBHOOK_ID]","in":"path"}]}},"\/storage\/files":{"get":{"summary":"List Files","operationId":"listFiles","consumes":["application\/json"],"tags":["storage"],"description":"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).","x-appwrite":{"weight":124,"cookies":false,"type":"","demo":"storage\/list-files.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/list-files.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create File","operationId":"createFile","consumes":["multipart\/form-data"],"tags":["storage"],"description":"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.","x-appwrite":{"weight":123,"cookies":false,"type":"upload","demo":"storage\/create-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/create-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"file","description":"Binary File.","required":true,"type":"file","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/storage\/files\/{fileId}":{"get":{"summary":"Get File","operationId":"getFile","consumes":["application\/json"],"tags":["storage"],"description":"Get file by its unique ID. This endpoint response returns a JSON object with the file metadata.","x-appwrite":{"weight":125,"cookies":false,"type":"","demo":"storage\/get-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]},"put":{"summary":"Update File","operationId":"updateFile","consumes":["application\/json"],"tags":["storage"],"description":"Update file by its unique ID. Only users with write permissions have access to update this resource.","x-appwrite":{"weight":129,"cookies":false,"type":"","demo":"storage\/update-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/update-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete File","operationId":"deleteFile","consumes":["application\/json"],"tags":["storage"],"description":"Delete a file by its unique ID. Only users with write permissions have access to delete this resource.","x-appwrite":{"weight":130,"cookies":false,"type":"","demo":"storage\/delete-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/delete-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/download":{"get":{"summary":"Get File for Download","operationId":"getFileDownload","consumes":["application\/json"],"tags":["storage"],"description":"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.","x-appwrite":{"weight":127,"cookies":false,"type":"location","demo":"storage\/get-file-download.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-download.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/preview":{"get":{"summary":"Get File Preview","operationId":"getFilePreview","consumes":["application\/json"],"tags":["storage"],"description":"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.","x-appwrite":{"weight":126,"cookies":false,"type":"location","demo":"storage\/get-file-preview.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-preview.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"quality","description":"Preview image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"background","description":"Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.","required":false,"type":"string","default":"","in":"query"},{"name":"output","description":"Output format type (jpeg, jpg, png, gif and webp).","required":false,"type":"string","x-example":"jpg","in":"query"}]}},"\/storage\/files\/{fileId}\/view":{"get":{"summary":"Get File for View","operationId":"getFileView","consumes":["application\/json"],"tags":["storage"],"description":"Get file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.","x-appwrite":{"weight":128,"cookies":false,"type":"location","demo":"storage\/get-file-view.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-view.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"as","description":"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.","required":false,"type":"string","x-example":"pdf","default":"","in":"query"}]}},"\/teams":{"get":{"summary":"List Teams","operationId":"list","consumes":["application\/json"],"tags":["teams"],"description":"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).","x-appwrite":{"weight":132,"cookies":false,"type":"","demo":"teams\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/list-teams.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team","operationId":"create","consumes":["application\/json"],"tags":["teams"],"description":"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.","x-appwrite":{"weight":131,"cookies":false,"type":"","demo":"teams\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"roles","description":"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).","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":["owner"],"in":"formData"}]}},"\/teams\/{teamId}":{"get":{"summary":"Get Team","operationId":"get","consumes":["application\/json"],"tags":["teams"],"description":"Get team by its unique ID. All team members have read access for this resource.","x-appwrite":{"weight":133,"cookies":false,"type":"","demo":"teams\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]},"put":{"summary":"Update Team","operationId":"update","consumes":["application\/json"],"tags":["teams"],"description":"Update team by its unique ID. Only team owners have write access for this resource.","x-appwrite":{"weight":134,"cookies":false,"type":"","demo":"teams\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]},"delete":{"summary":"Delete Team","operationId":"delete","consumes":["application\/json"],"tags":["teams"],"description":"Delete team by its unique ID. Only team owners have write access for this resource.","x-appwrite":{"weight":135,"cookies":false,"type":"","demo":"teams\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships":{"get":{"summary":"Get Team Memberships","operationId":"getMemberships","consumes":["application\/json"],"tags":["teams"],"description":"Get team members by the team unique ID. All team members have read access for this list of resources.","x-appwrite":{"weight":137,"cookies":false,"type":"","demo":"teams\/get-memberships.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team-members.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team Membership","operationId":"createMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.\n\nUse 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.\n\nPlease 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.","x-appwrite":{"weight":136,"cookies":false,"type":"","demo":"teams\/create-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"email","description":"New team member email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"name","description":"New team member name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"},{"name":"roles","description":"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).","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}":{"delete":{"summary":"Delete Team Membership","operationId":"deleteMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.","x-appwrite":{"weight":139,"cookies":false,"type":"","demo":"teams\/delete-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}\/status":{"patch":{"summary":"Update Team Membership Status","operationId":"updateMembershipStatus","consumes":["application\/json"],"tags":["teams"],"description":"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.","x-appwrite":{"weight":138,"cookies":false,"type":"","demo":"teams\/update-membership-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team-membership-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"},{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"formData"},{"name":"secret","description":"Secret key.","required":true,"type":"string","x-example":"[SECRET]","in":"formData"}]}},"\/users":{"get":{"summary":"List Users","operationId":"list","consumes":["application\/json"],"tags":["users"],"description":"Get a list of all the project users. You can use the query params to filter your results.","x-appwrite":{"weight":141,"cookies":false,"type":"","demo":"users\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/list-users.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create User","operationId":"create","consumes":["application\/json"],"tags":["users"],"description":"Create a new user.","x-appwrite":{"weight":140,"cookies":false,"type":"","demo":"users\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/create-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"name","description":"User name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"}]}},"\/users\/{userId}":{"get":{"summary":"Get User","operationId":"get","consumes":["application\/json"],"tags":["users"],"description":"Get user by its unique ID.","x-appwrite":{"weight":142,"cookies":false,"type":"","demo":"users\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/logs":{"get":{"summary":"Get User Logs","operationId":"getLogs","consumes":["application\/json"],"tags":["users"],"description":"Get user activity logs list by its unique ID.","x-appwrite":{"weight":145,"cookies":false,"type":"","demo":"users\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/prefs":{"get":{"summary":"Get User Preferences","operationId":"getPrefs","consumes":["application\/json"],"tags":["users"],"description":"Get user preferences by its unique ID.","x-appwrite":{"weight":143,"cookies":false,"type":"","demo":"users\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"patch":{"summary":"Update User Preferences","operationId":"updatePrefs","consumes":["application\/json"],"tags":["users"],"description":"Update user preferences by its unique ID. You can pass only the specific settings you wish to update.","x-appwrite":{"weight":147,"cookies":false,"type":"","demo":"users\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"prefs","description":"Prefs key-value JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"}]}},"\/users\/{userId}\/sessions":{"get":{"summary":"Get User Sessions","operationId":"getSessions","consumes":["application\/json"],"tags":["users"],"description":"Get user sessions list by its unique ID.","x-appwrite":{"weight":144,"cookies":false,"type":"","demo":"users\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"delete":{"summary":"Delete User Sessions","operationId":"deleteSessions","consumes":["application\/json"],"tags":["users"],"description":"Delete all user sessions by its unique ID.","x-appwrite":{"weight":149,"cookies":false,"type":"","demo":"users\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/sessions\/{sessionId}":{"delete":{"summary":"Delete User Session","operationId":"deleteSession","consumes":["application\/json"],"tags":["users"],"description":"Delete user sessions by its unique ID.","x-appwrite":{"weight":148,"cookies":false,"type":"","demo":"users\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"sessionId","description":"User unique session ID.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/users\/{userId}\/status":{"patch":{"summary":"Update User Status","operationId":"updateStatus","consumes":["application\/json"],"tags":["users"],"description":"Update user status by its unique ID.","x-appwrite":{"weight":146,"cookies":false,"type":"","demo":"users\/update-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"status","description":"User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0","required":true,"type":"string","x-example":1,"in":"formData"}]}}},"definitions":{"Error":{"required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"externalDocs":{"description":"Full API docs, specs and tutorials","url":"https:\/\/localhost\/docs"}} \ No newline at end of file diff --git a/app/config/specs/0.6.2.server.json b/app/config/specs/0.6.2.server.json index c13f492351..6186f78a4c 100644 --- a/app/config/specs/0.6.2.server.json +++ b/app/config/specs/0.6.2.server.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"version":"0.6.2","title":"Appwrite","description":"Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)","termsOfService":"https:\/\/appwrite.io\/policy\/terms","contact":{"name":"Appwrite Team","url":"https:\/\/appwrite.io\/support","email":"team@localhost.test"},"license":{"name":"BSD-3-Clause","url":"https:\/\/raw.githubusercontent.com\/appwrite\/appwrite\/master\/LICENSE"}},"host":"appwrite.io","basePath":"\/v1","schemes":["https"],"consumes":["application\/json","multipart\/form-data"],"produces":["application\/json"],"securityDefinitions":{"Project":{"type":"apiKey","name":"X-Appwrite-Project","description":"Your project ID","in":"header","extensions":{"demo":"5df5acd0d48c2"}},"Key":{"type":"apiKey","name":"X-Appwrite-Key","description":"Your secret API key","in":"header","extensions":{"demo":"919c2d18fb5d4...a2ae413da83346ad2"}},"Locale":{"type":"apiKey","name":"X-Appwrite-Locale","description":"","in":"header","extensions":{"demo":"en"}}},"paths":{"\/avatars\/browsers\/{code}":{"get":{"summary":"Get Browser Icon","operationId":"getBrowser","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":54,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-browser.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-browser.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Browser Code.","required":true,"type":"string","x-example":"aa","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/credit-cards\/{code}":{"get":{"summary":"Get Credit Card Icon","operationId":"getCreditCard","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":53,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-credit-card.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-credit-card.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa.","required":true,"type":"string","x-example":"amex","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/favicon":{"get":{"summary":"Get Favicon","operationId":"getFavicon","consumes":["application\/json"],"tags":["avatars"],"description":"Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote website URL.","extensions":{"weight":57,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-favicon.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-favicon.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Website URL which you want to fetch the favicon from.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"}]}},"\/avatars\/flags\/{code}":{"get":{"summary":"Get Country Flag","operationId":"getFlag","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":55,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-flag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-flag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Country Code. ISO Alpha-2 country code format.","required":true,"type":"string","x-example":"af","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/image":{"get":{"summary":"Get Image from URL","operationId":"getImage","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":56,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-image.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-image.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Image URL which you want to crop.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"}]}},"\/avatars\/initials":{"get":{"summary":"Get User Initials","operationId":"getInitials","consumes":["application\/json"],"tags":["avatars"],"description":"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.\n\nYou 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.","extensions":{"weight":59,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-initials.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-initials.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Full Name. When empty, current user name or email will be used.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"query"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"color","description":"Changes text color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"},{"name":"background","description":"Changes background color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"}]}},"\/avatars\/qr":{"get":{"summary":"Get QR Code","operationId":"getQR","consumes":["application\/json"],"tags":["avatars"],"description":"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.","extensions":{"weight":58,"cookies":false,"type":"location","demo":"docs\/examples\/avatars\/get-q-r.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-qr.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"text","description":"Plain text to be converted to QR code image.","required":true,"type":"string","x-example":"[TEXT]","in":"query"},{"name":"size","description":"QR code size. Pass an integer between 0 to 1000. Defaults to 400.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"margin","description":"Margin from edge. Pass an integer between 0 to 10. Defaults to 1.","required":false,"type":"integer","format":"int32","x-example":0,"default":1,"in":"query"},{"name":"download","description":"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.","required":false,"type":"boolean","x-example":false,"default":false,"in":"query"}]}},"\/database\/collections":{"get":{"summary":"List Collections","operationId":"listCollections","consumes":["application\/json"],"tags":["database"],"description":"Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project collections. [Learn more about different API modes](\/docs\/admin).","extensions":{"weight":61,"cookies":false,"type":"","demo":"docs\/examples\/database\/list-collections.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-collections.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Collection","operationId":"createCollection","consumes":["application\/json"],"tags":["database"],"description":"Create a new Collection.","extensions":{"weight":60,"cookies":false,"type":"","demo":"docs\/examples\/database\/create-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Collection name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"rules","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/database\/collections\/{collectionId}":{"get":{"summary":"Get Collection","operationId":"getCollection","consumes":["application\/json"],"tags":["database"],"description":"Get collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.","extensions":{"weight":62,"cookies":false,"type":"","demo":"docs\/examples\/database\/get-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]},"put":{"summary":"Update Collection","operationId":"updateCollection","consumes":["application\/json"],"tags":["database"],"description":"Update collection by its unique ID.","extensions":{"weight":63,"cookies":false,"type":"","demo":"docs\/examples\/database\/update-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"name","description":"Collection name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"rules","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"formData"}]},"delete":{"summary":"Delete Collection","operationId":"deleteCollection","consumes":["application\/json"],"tags":["database"],"description":"Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.","extensions":{"weight":64,"cookies":false,"type":"","demo":"docs\/examples\/database\/delete-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]}},"\/database\/collections\/{collectionId}\/documents":{"get":{"summary":"List Documents","operationId":"listDocuments","consumes":["application\/json"],"tags":["database"],"description":"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).","extensions":{"weight":66,"cookies":false,"type":"","demo":"docs\/examples\/database\/list-documents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-documents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"filters","description":"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'.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"},{"name":"offset","description":"Offset value. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"limit","description":"Maximum number of documents to return in response. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":50,"in":"query"},{"name":"orderField","description":"Document field that results will be sorted by.","required":false,"type":"string","x-example":"[ORDER_FIELD]","default":"$id","in":"query"},{"name":"orderType","description":"Order direction. Possible values are DESC for descending order, or ASC for ascending order.","required":false,"type":"string","x-example":"DESC","default":"ASC","in":"query"},{"name":"orderCast","description":"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.","required":false,"type":"string","x-example":"int","default":"string","in":"query"},{"name":"search","description":"Search query. Enter any free text search. The database will try to find a match against all document attributes and children.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"}]},"post":{"summary":"Create Document","operationId":"createDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","extensions":{"weight":65,"cookies":false,"type":"","demo":"docs\/examples\/database\/create-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"parentDocument","description":"Parent document unique ID. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","x-example":"[PARENT_DOCUMENT]","default":"","in":"formData"},{"name":"parentProperty","description":"Parent document property name. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","default":"","in":"formData"},{"name":"parentPropertyType","description":"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.","required":false,"type":"string","x-example":"assign","default":"assign","in":"formData"}]}},"\/database\/collections\/{collectionId}\/documents\/{documentId}":{"get":{"summary":"Get Document","operationId":"getDocument","consumes":["application\/json"],"tags":["database"],"description":"Get document by its unique ID. This endpoint response returns a JSON object with the document data.","extensions":{"weight":67,"cookies":false,"type":"","demo":"docs\/examples\/database\/get-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]},"patch":{"summary":"Update Document","operationId":"updateDocument","consumes":["application\/json"],"tags":["database"],"description":"","extensions":{"weight":68,"cookies":false,"type":"","demo":"docs\/examples\/database\/update-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete Document","operationId":"deleteDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","extensions":{"weight":69,"cookies":false,"type":"","demo":"docs\/examples\/database\/delete-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]}},"\/health":{"get":{"summary":"Get HTTP","operationId":"get","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite HTTP server is up and responsive.","extensions":{"weight":77,"cookies":false,"type":"","demo":"docs\/examples\/health\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/anti-virus":{"get":{"summary":"Get Anti virus","operationId":"getAntiVirus","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite Anti Virus server is up and connection is successful.","extensions":{"weight":89,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-anti-virus.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-anti-virus.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/cache":{"get":{"summary":"Get Cache","operationId":"getCache","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite in-memory cache server is up and connection is successful.","extensions":{"weight":80,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-cache.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-cache.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/db":{"get":{"summary":"Get DB","operationId":"getDB","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite database server is up and connection is successful.","extensions":{"weight":79,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-d-b.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-db.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/certificates":{"get":{"summary":"Get Certificate Queue","operationId":"getQueueCertificates","consumes":["application\/json"],"tags":["health"],"description":"Get the number of certificates that are waiting to be issued against [Letsencrypt](https:\/\/letsencrypt.org\/) in the Appwrite internal queue server.","extensions":{"weight":86,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-certificates.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-certificates.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/functions":{"get":{"summary":"Get Functions Queue","operationId":"getQueueFunctions","consumes":["application\/json"],"tags":["health"],"description":"","extensions":{"weight":87,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-functions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-functions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/logs":{"get":{"summary":"Get Logs Queue","operationId":"getQueueLogs","consumes":["application\/json"],"tags":["health"],"description":"Get the number of logs that are waiting to be processed in the Appwrite internal queue server.","extensions":{"weight":84,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/tasks":{"get":{"summary":"Get Tasks Queue","operationId":"getQueueTasks","consumes":["application\/json"],"tags":["health"],"description":"Get the number of tasks that are waiting to be processed in the Appwrite internal queue server.","extensions":{"weight":83,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-tasks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-tasks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/usage":{"get":{"summary":"Get Usage Queue","operationId":"getQueueUsage","consumes":["application\/json"],"tags":["health"],"description":"Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server.","extensions":{"weight":85,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-usage.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/webhooks":{"get":{"summary":"Get Webhooks Queue","operationId":"getQueueWebhooks","consumes":["application\/json"],"tags":["health"],"description":"Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server.","extensions":{"weight":82,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-queue-webhooks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-webhooks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/storage\/local":{"get":{"summary":"Get Local Storage","operationId":"getStorageLocal","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite local storage device is up and connection is successful.","extensions":{"weight":88,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-storage-local.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-local.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/time":{"get":{"summary":"Get Time","operationId":"getTime","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https:\/\/en.wikipedia.org\/wiki\/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP.","extensions":{"weight":81,"cookies":false,"type":"","demo":"docs\/examples\/health\/get-time.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-time.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale":{"get":{"summary":"Get User Locale","operationId":"get","consumes":["application\/json"],"tags":["locale"],"description":"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.\n\n([IP Geolocation by DB-IP](https:\/\/db-ip.com))","extensions":{"weight":70,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-locale.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/continents":{"get":{"summary":"List Continents","operationId":"getContinents","consumes":["application\/json"],"tags":["locale"],"description":"List of all continents. You can use the locale header to get the data in a supported language.","extensions":{"weight":74,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-continents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-continents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries":{"get":{"summary":"List Countries","operationId":"getCountries","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries. You can use the locale header to get the data in a supported language.","extensions":{"weight":71,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-countries.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/eu":{"get":{"summary":"List EU Countries","operationId":"getCountriesEU","consumes":["application\/json"],"tags":["locale"],"description":"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.","extensions":{"weight":72,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-countries-e-u.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-eu.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/phones":{"get":{"summary":"List Countries Phone Codes","operationId":"getCountriesPhones","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries phone codes. You can use the locale header to get the data in a supported language.","extensions":{"weight":73,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-countries-phones.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-phones.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/currencies":{"get":{"summary":"List Currencies","operationId":"getCurrencies","consumes":["application\/json"],"tags":["locale"],"description":"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.","extensions":{"weight":75,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-currencies.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-currencies.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/languages":{"get":{"summary":"List Languages","operationId":"getLanguages","consumes":["application\/json"],"tags":["locale"],"description":"List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.","extensions":{"weight":76,"cookies":false,"type":"","demo":"docs\/examples\/locale\/get-languages.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-languages.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/storage\/files":{"get":{"summary":"List Files","operationId":"listFiles","consumes":["application\/json"],"tags":["storage"],"description":"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).","extensions":{"weight":124,"cookies":false,"type":"","demo":"docs\/examples\/storage\/list-files.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/list-files.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create File","operationId":"createFile","consumes":["multipart\/form-data"],"tags":["storage"],"description":"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.","extensions":{"weight":123,"cookies":false,"type":"upload","demo":"docs\/examples\/storage\/create-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/create-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"file","description":"Binary File.","required":true,"type":"file","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/storage\/files\/{fileId}":{"get":{"summary":"Get File","operationId":"getFile","consumes":["application\/json"],"tags":["storage"],"description":"Get file by its unique ID. This endpoint response returns a JSON object with the file metadata.","extensions":{"weight":125,"cookies":false,"type":"","demo":"docs\/examples\/storage\/get-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]},"put":{"summary":"Update File","operationId":"updateFile","consumes":["application\/json"],"tags":["storage"],"description":"Update file by its unique ID. Only users with write permissions have access to update this resource.","extensions":{"weight":129,"cookies":false,"type":"","demo":"docs\/examples\/storage\/update-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/update-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete File","operationId":"deleteFile","consumes":["application\/json"],"tags":["storage"],"description":"Delete a file by its unique ID. Only users with write permissions have access to delete this resource.","extensions":{"weight":130,"cookies":false,"type":"","demo":"docs\/examples\/storage\/delete-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/delete-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/download":{"get":{"summary":"Get File for Download","operationId":"getFileDownload","consumes":["application\/json"],"tags":["storage"],"description":"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.","extensions":{"weight":127,"cookies":false,"type":"location","demo":"docs\/examples\/storage\/get-file-download.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-download.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/preview":{"get":{"summary":"Get File Preview","operationId":"getFilePreview","consumes":["application\/json"],"tags":["storage"],"description":"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.","extensions":{"weight":126,"cookies":false,"type":"location","demo":"docs\/examples\/storage\/get-file-preview.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-preview.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"quality","description":"Preview image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"background","description":"Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.","required":false,"type":"string","default":"","in":"query"},{"name":"output","description":"Output format type (jpeg, jpg, png, gif and webp).","required":false,"type":"string","x-example":"jpg","in":"query"}]}},"\/storage\/files\/{fileId}\/view":{"get":{"summary":"Get File for View","operationId":"getFileView","consumes":["application\/json"],"tags":["storage"],"description":"Get file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.","extensions":{"weight":128,"cookies":false,"type":"location","demo":"docs\/examples\/storage\/get-file-view.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-view.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"as","description":"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.","required":false,"type":"string","x-example":"pdf","default":"","in":"query"}]}},"\/teams":{"get":{"summary":"List Teams","operationId":"list","consumes":["application\/json"],"tags":["teams"],"description":"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).","extensions":{"weight":132,"cookies":false,"type":"","demo":"docs\/examples\/teams\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/list-teams.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team","operationId":"create","consumes":["application\/json"],"tags":["teams"],"description":"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.","extensions":{"weight":131,"cookies":false,"type":"","demo":"docs\/examples\/teams\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"roles","description":"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).","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":["owner"],"in":"formData"}]}},"\/teams\/{teamId}":{"get":{"summary":"Get Team","operationId":"get","consumes":["application\/json"],"tags":["teams"],"description":"Get team by its unique ID. All team members have read access for this resource.","extensions":{"weight":133,"cookies":false,"type":"","demo":"docs\/examples\/teams\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]},"put":{"summary":"Update Team","operationId":"update","consumes":["application\/json"],"tags":["teams"],"description":"Update team by its unique ID. Only team owners have write access for this resource.","extensions":{"weight":134,"cookies":false,"type":"","demo":"docs\/examples\/teams\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]},"delete":{"summary":"Delete Team","operationId":"delete","consumes":["application\/json"],"tags":["teams"],"description":"Delete team by its unique ID. Only team owners have write access for this resource.","extensions":{"weight":135,"cookies":false,"type":"","demo":"docs\/examples\/teams\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships":{"get":{"summary":"Get Team Memberships","operationId":"getMemberships","consumes":["application\/json"],"tags":["teams"],"description":"Get team members by the team unique ID. All team members have read access for this list of resources.","extensions":{"weight":137,"cookies":false,"type":"","demo":"docs\/examples\/teams\/get-memberships.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team-members.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team Membership","operationId":"createMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.\n\nUse 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.\n\nPlease 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.","extensions":{"weight":136,"cookies":false,"type":"","demo":"docs\/examples\/teams\/create-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"email","description":"New team member email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"name","description":"New team member name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"},{"name":"roles","description":"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).","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}":{"delete":{"summary":"Delete Team Membership","operationId":"deleteMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.","extensions":{"weight":139,"cookies":false,"type":"","demo":"docs\/examples\/teams\/delete-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"}]}},"\/users":{"get":{"summary":"List Users","operationId":"list","consumes":["application\/json"],"tags":["users"],"description":"Get a list of all the project users. You can use the query params to filter your results.","extensions":{"weight":141,"cookies":false,"type":"","demo":"docs\/examples\/users\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/list-users.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create User","operationId":"create","consumes":["application\/json"],"tags":["users"],"description":"Create a new user.","extensions":{"weight":140,"cookies":false,"type":"","demo":"docs\/examples\/users\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/create-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"name","description":"User name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"}]}},"\/users\/{userId}":{"get":{"summary":"Get User","operationId":"get","consumes":["application\/json"],"tags":["users"],"description":"Get user by its unique ID.","extensions":{"weight":142,"cookies":false,"type":"","demo":"docs\/examples\/users\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/logs":{"get":{"summary":"Get User Logs","operationId":"getLogs","consumes":["application\/json"],"tags":["users"],"description":"Get user activity logs list by its unique ID.","extensions":{"weight":145,"cookies":false,"type":"","demo":"docs\/examples\/users\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/prefs":{"get":{"summary":"Get User Preferences","operationId":"getPrefs","consumes":["application\/json"],"tags":["users"],"description":"Get user preferences by its unique ID.","extensions":{"weight":143,"cookies":false,"type":"","demo":"docs\/examples\/users\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"patch":{"summary":"Update User Preferences","operationId":"updatePrefs","consumes":["application\/json"],"tags":["users"],"description":"Update user preferences by its unique ID. You can pass only the specific settings you wish to update.","extensions":{"weight":147,"cookies":false,"type":"","demo":"docs\/examples\/users\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"prefs","description":"Prefs key-value JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"}]}},"\/users\/{userId}\/sessions":{"get":{"summary":"Get User Sessions","operationId":"getSessions","consumes":["application\/json"],"tags":["users"],"description":"Get user sessions list by its unique ID.","extensions":{"weight":144,"cookies":false,"type":"","demo":"docs\/examples\/users\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"delete":{"summary":"Delete User Sessions","operationId":"deleteSessions","consumes":["application\/json"],"tags":["users"],"description":"Delete all user sessions by its unique ID.","extensions":{"weight":149,"cookies":false,"type":"","demo":"docs\/examples\/users\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/sessions\/{sessionId}":{"delete":{"summary":"Delete User Session","operationId":"deleteSession","consumes":["application\/json"],"tags":["users"],"description":"Delete user sessions by its unique ID.","extensions":{"weight":148,"cookies":false,"type":"","demo":"docs\/examples\/users\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"sessionId","description":"User unique session ID.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/users\/{userId}\/status":{"patch":{"summary":"Update User Status","operationId":"updateStatus","consumes":["application\/json"],"tags":["users"],"description":"Update user status by its unique ID.","extensions":{"weight":146,"cookies":false,"type":"","demo":"docs\/examples\/users\/update-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"status","description":"User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0","required":true,"type":"string","x-example":1,"in":"formData"}]}}},"definitions":{"Error":{"required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"externalDocs":{"description":"Full API docs, specs and tutorials","url":"https:\/\/localhost\/docs"}} \ No newline at end of file +{"swagger":"2.0","info":{"version":"0.6.2","title":"Appwrite","description":"Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)","termsOfService":"https:\/\/appwrite.io\/policy\/terms","contact":{"name":"Appwrite Team","url":"https:\/\/appwrite.io\/support","email":"team@localhost.test"},"license":{"name":"BSD-3-Clause","url":"https:\/\/raw.githubusercontent.com\/appwrite\/appwrite\/master\/LICENSE"}},"host":"appwrite.io","basePath":"\/v1","schemes":["https"],"consumes":["application\/json","multipart\/form-data"],"produces":["application\/json"],"securityDefinitions":{"Project":{"type":"apiKey","name":"X-Appwrite-Project","description":"Your project ID","in":"header","x-appwrite":{"demo":"5df5acd0d48c2"}},"Key":{"type":"apiKey","name":"X-Appwrite-Key","description":"Your secret API key","in":"header","x-appwrite":{"demo":"919c2d18fb5d4...a2ae413da83346ad2"}},"Locale":{"type":"apiKey","name":"X-Appwrite-Locale","description":"","in":"header","x-appwrite":{"demo":"en"}}},"paths":{"\/avatars\/browsers\/{code}":{"get":{"summary":"Get Browser Icon","operationId":"getBrowser","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":54,"cookies":false,"type":"location","demo":"avatars\/get-browser.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-browser.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Browser Code.","required":true,"type":"string","x-example":"aa","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/credit-cards\/{code}":{"get":{"summary":"Get Credit Card Icon","operationId":"getCreditCard","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":53,"cookies":false,"type":"location","demo":"avatars\/get-credit-card.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-credit-card.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa.","required":true,"type":"string","x-example":"amex","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/favicon":{"get":{"summary":"Get Favicon","operationId":"getFavicon","consumes":["application\/json"],"tags":["avatars"],"description":"Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote website URL.","x-appwrite":{"weight":57,"cookies":false,"type":"location","demo":"avatars\/get-favicon.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-favicon.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Website URL which you want to fetch the favicon from.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"}]}},"\/avatars\/flags\/{code}":{"get":{"summary":"Get Country Flag","operationId":"getFlag","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":55,"cookies":false,"type":"location","demo":"avatars\/get-flag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-flag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Country Code. ISO Alpha-2 country code format.","required":true,"type":"string","x-example":"af","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/image":{"get":{"summary":"Get Image from URL","operationId":"getImage","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":56,"cookies":false,"type":"location","demo":"avatars\/get-image.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-image.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Image URL which you want to crop.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"}]}},"\/avatars\/initials":{"get":{"summary":"Get User Initials","operationId":"getInitials","consumes":["application\/json"],"tags":["avatars"],"description":"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.\n\nYou 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.","x-appwrite":{"weight":59,"cookies":false,"type":"location","demo":"avatars\/get-initials.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-initials.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Full Name. When empty, current user name or email will be used.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"query"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"color","description":"Changes text color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"},{"name":"background","description":"Changes background color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"}]}},"\/avatars\/qr":{"get":{"summary":"Get QR Code","operationId":"getQR","consumes":["application\/json"],"tags":["avatars"],"description":"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.","x-appwrite":{"weight":58,"cookies":false,"type":"location","demo":"avatars\/get-q-r.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-qr.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"text","description":"Plain text to be converted to QR code image.","required":true,"type":"string","x-example":"[TEXT]","in":"query"},{"name":"size","description":"QR code size. Pass an integer between 0 to 1000. Defaults to 400.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"margin","description":"Margin from edge. Pass an integer between 0 to 10. Defaults to 1.","required":false,"type":"integer","format":"int32","x-example":0,"default":1,"in":"query"},{"name":"download","description":"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.","required":false,"type":"boolean","x-example":false,"default":false,"in":"query"}]}},"\/database\/collections":{"get":{"summary":"List Collections","operationId":"listCollections","consumes":["application\/json"],"tags":["database"],"description":"Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project collections. [Learn more about different API modes](\/docs\/admin).","x-appwrite":{"weight":61,"cookies":false,"type":"","demo":"database\/list-collections.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-collections.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Collection","operationId":"createCollection","consumes":["application\/json"],"tags":["database"],"description":"Create a new Collection.","x-appwrite":{"weight":60,"cookies":false,"type":"","demo":"database\/create-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Collection name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"rules","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/database\/collections\/{collectionId}":{"get":{"summary":"Get Collection","operationId":"getCollection","consumes":["application\/json"],"tags":["database"],"description":"Get collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.","x-appwrite":{"weight":62,"cookies":false,"type":"","demo":"database\/get-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]},"put":{"summary":"Update Collection","operationId":"updateCollection","consumes":["application\/json"],"tags":["database"],"description":"Update collection by its unique ID.","x-appwrite":{"weight":63,"cookies":false,"type":"","demo":"database\/update-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"name","description":"Collection name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"rules","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"formData"}]},"delete":{"summary":"Delete Collection","operationId":"deleteCollection","consumes":["application\/json"],"tags":["database"],"description":"Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.","x-appwrite":{"weight":64,"cookies":false,"type":"","demo":"database\/delete-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]}},"\/database\/collections\/{collectionId}\/documents":{"get":{"summary":"List Documents","operationId":"listDocuments","consumes":["application\/json"],"tags":["database"],"description":"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).","x-appwrite":{"weight":66,"cookies":false,"type":"","demo":"database\/list-documents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-documents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"filters","description":"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'.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"},{"name":"offset","description":"Offset value. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"limit","description":"Maximum number of documents to return in response. Use this value to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":50,"in":"query"},{"name":"orderField","description":"Document field that results will be sorted by.","required":false,"type":"string","x-example":"[ORDER_FIELD]","default":"$id","in":"query"},{"name":"orderType","description":"Order direction. Possible values are DESC for descending order, or ASC for ascending order.","required":false,"type":"string","x-example":"DESC","default":"ASC","in":"query"},{"name":"orderCast","description":"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.","required":false,"type":"string","x-example":"int","default":"string","in":"query"},{"name":"search","description":"Search query. Enter any free text search. The database will try to find a match against all document attributes and children.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"}]},"post":{"summary":"Create Document","operationId":"createDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","x-appwrite":{"weight":65,"cookies":false,"type":"","demo":"database\/create-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"parentDocument","description":"Parent document unique ID. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","x-example":"[PARENT_DOCUMENT]","default":"","in":"formData"},{"name":"parentProperty","description":"Parent document property name. Use when you want your new document to be a child of a parent document.","required":false,"type":"string","default":"","in":"formData"},{"name":"parentPropertyType","description":"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.","required":false,"type":"string","x-example":"assign","default":"assign","in":"formData"}]}},"\/database\/collections\/{collectionId}\/documents\/{documentId}":{"get":{"summary":"Get Document","operationId":"getDocument","consumes":["application\/json"],"tags":["database"],"description":"Get document by its unique ID. This endpoint response returns a JSON object with the document data.","x-appwrite":{"weight":67,"cookies":false,"type":"","demo":"database\/get-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]},"patch":{"summary":"Update Document","operationId":"updateDocument","consumes":["application\/json"],"tags":["database"],"description":"","x-appwrite":{"weight":68,"cookies":false,"type":"","demo":"database\/update-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"},{"name":"data","description":"Document data as JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete Document","operationId":"deleteDocument","consumes":["application\/json"],"tags":["database"],"description":"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.","x-appwrite":{"weight":69,"cookies":false,"type":"","demo":"database\/delete-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]}},"\/health":{"get":{"summary":"Get HTTP","operationId":"get","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite HTTP server is up and responsive.","x-appwrite":{"weight":77,"cookies":false,"type":"","demo":"health\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/anti-virus":{"get":{"summary":"Get Anti virus","operationId":"getAntiVirus","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite Anti Virus server is up and connection is successful.","x-appwrite":{"weight":89,"cookies":false,"type":"","demo":"health\/get-anti-virus.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-anti-virus.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/cache":{"get":{"summary":"Get Cache","operationId":"getCache","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite in-memory cache server is up and connection is successful.","x-appwrite":{"weight":80,"cookies":false,"type":"","demo":"health\/get-cache.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-cache.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/db":{"get":{"summary":"Get DB","operationId":"getDB","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite database server is up and connection is successful.","x-appwrite":{"weight":79,"cookies":false,"type":"","demo":"health\/get-d-b.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-db.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/certificates":{"get":{"summary":"Get Certificate Queue","operationId":"getQueueCertificates","consumes":["application\/json"],"tags":["health"],"description":"Get the number of certificates that are waiting to be issued against [Letsencrypt](https:\/\/letsencrypt.org\/) in the Appwrite internal queue server.","x-appwrite":{"weight":86,"cookies":false,"type":"","demo":"health\/get-queue-certificates.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-certificates.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/functions":{"get":{"summary":"Get Functions Queue","operationId":"getQueueFunctions","consumes":["application\/json"],"tags":["health"],"description":"","x-appwrite":{"weight":87,"cookies":false,"type":"","demo":"health\/get-queue-functions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-functions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/logs":{"get":{"summary":"Get Logs Queue","operationId":"getQueueLogs","consumes":["application\/json"],"tags":["health"],"description":"Get the number of logs that are waiting to be processed in the Appwrite internal queue server.","x-appwrite":{"weight":84,"cookies":false,"type":"","demo":"health\/get-queue-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/tasks":{"get":{"summary":"Get Tasks Queue","operationId":"getQueueTasks","consumes":["application\/json"],"tags":["health"],"description":"Get the number of tasks that are waiting to be processed in the Appwrite internal queue server.","x-appwrite":{"weight":83,"cookies":false,"type":"","demo":"health\/get-queue-tasks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-tasks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/usage":{"get":{"summary":"Get Usage Queue","operationId":"getQueueUsage","consumes":["application\/json"],"tags":["health"],"description":"Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server.","x-appwrite":{"weight":85,"cookies":false,"type":"","demo":"health\/get-queue-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-usage.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/webhooks":{"get":{"summary":"Get Webhooks Queue","operationId":"getQueueWebhooks","consumes":["application\/json"],"tags":["health"],"description":"Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server.","x-appwrite":{"weight":82,"cookies":false,"type":"","demo":"health\/get-queue-webhooks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-webhooks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/storage\/local":{"get":{"summary":"Get Local Storage","operationId":"getStorageLocal","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite local storage device is up and connection is successful.","x-appwrite":{"weight":88,"cookies":false,"type":"","demo":"health\/get-storage-local.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-local.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/health\/time":{"get":{"summary":"Get Time","operationId":"getTime","consumes":["application\/json"],"tags":["health"],"description":"Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https:\/\/en.wikipedia.org\/wiki\/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP.","x-appwrite":{"weight":81,"cookies":false,"type":"","demo":"health\/get-time.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-time.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale":{"get":{"summary":"Get User Locale","operationId":"get","consumes":["application\/json"],"tags":["locale"],"description":"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.\n\n([IP Geolocation by DB-IP](https:\/\/db-ip.com))","x-appwrite":{"weight":70,"cookies":false,"type":"","demo":"locale\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-locale.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/continents":{"get":{"summary":"List Continents","operationId":"getContinents","consumes":["application\/json"],"tags":["locale"],"description":"List of all continents. You can use the locale header to get the data in a supported language.","x-appwrite":{"weight":74,"cookies":false,"type":"","demo":"locale\/get-continents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-continents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries":{"get":{"summary":"List Countries","operationId":"getCountries","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries. You can use the locale header to get the data in a supported language.","x-appwrite":{"weight":71,"cookies":false,"type":"","demo":"locale\/get-countries.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/eu":{"get":{"summary":"List EU Countries","operationId":"getCountriesEU","consumes":["application\/json"],"tags":["locale"],"description":"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.","x-appwrite":{"weight":72,"cookies":false,"type":"","demo":"locale\/get-countries-e-u.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-eu.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/phones":{"get":{"summary":"List Countries Phone Codes","operationId":"getCountriesPhones","consumes":["application\/json"],"tags":["locale"],"description":"List of all countries phone codes. You can use the locale header to get the data in a supported language.","x-appwrite":{"weight":73,"cookies":false,"type":"","demo":"locale\/get-countries-phones.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-phones.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/currencies":{"get":{"summary":"List Currencies","operationId":"getCurrencies","consumes":["application\/json"],"tags":["locale"],"description":"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.","x-appwrite":{"weight":75,"cookies":false,"type":"","demo":"locale\/get-currencies.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-currencies.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/locale\/languages":{"get":{"summary":"List Languages","operationId":"getLanguages","consumes":["application\/json"],"tags":["locale"],"description":"List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.","x-appwrite":{"weight":76,"cookies":false,"type":"","demo":"locale\/get-languages.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-languages.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}]}},"\/storage\/files":{"get":{"summary":"List Files","operationId":"listFiles","consumes":["application\/json"],"tags":["storage"],"description":"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).","x-appwrite":{"weight":124,"cookies":false,"type":"","demo":"storage\/list-files.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/list-files.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create File","operationId":"createFile","consumes":["multipart\/form-data"],"tags":["storage"],"description":"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.","x-appwrite":{"weight":123,"cookies":false,"type":"upload","demo":"storage\/create-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/create-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"file","description":"Binary File.","required":true,"type":"file","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/storage\/files\/{fileId}":{"get":{"summary":"Get File","operationId":"getFile","consumes":["application\/json"],"tags":["storage"],"description":"Get file by its unique ID. This endpoint response returns a JSON object with the file metadata.","x-appwrite":{"weight":125,"cookies":false,"type":"","demo":"storage\/get-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]},"put":{"summary":"Update File","operationId":"updateFile","consumes":["application\/json"],"tags":["storage"],"description":"Update file by its unique ID. Only users with write permissions have access to update this resource.","x-appwrite":{"weight":129,"cookies":false,"type":"","demo":"storage\/update-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/update-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]},"delete":{"summary":"Delete File","operationId":"deleteFile","consumes":["application\/json"],"tags":["storage"],"description":"Delete a file by its unique ID. Only users with write permissions have access to delete this resource.","x-appwrite":{"weight":130,"cookies":false,"type":"","demo":"storage\/delete-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/delete-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/download":{"get":{"summary":"Get File for Download","operationId":"getFileDownload","consumes":["application\/json"],"tags":["storage"],"description":"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.","x-appwrite":{"weight":127,"cookies":false,"type":"location","demo":"storage\/get-file-download.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-download.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/preview":{"get":{"summary":"Get File Preview","operationId":"getFilePreview","consumes":["application\/json"],"tags":["storage"],"description":"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.","x-appwrite":{"weight":126,"cookies":false,"type":"location","demo":"storage\/get-file-preview.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-preview.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"quality","description":"Preview image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"background","description":"Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.","required":false,"type":"string","default":"","in":"query"},{"name":"output","description":"Output format type (jpeg, jpg, png, gif and webp).","required":false,"type":"string","x-example":"jpg","in":"query"}]}},"\/storage\/files\/{fileId}\/view":{"get":{"summary":"Get File for View","operationId":"getFileView","consumes":["application\/json"],"tags":["storage"],"description":"Get file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.","x-appwrite":{"weight":128,"cookies":false,"type":"location","demo":"storage\/get-file-view.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-view.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"as","description":"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.","required":false,"type":"string","x-example":"pdf","default":"","in":"query"}]}},"\/teams":{"get":{"summary":"List Teams","operationId":"list","consumes":["application\/json"],"tags":["teams"],"description":"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).","x-appwrite":{"weight":132,"cookies":false,"type":"","demo":"teams\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/list-teams.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team","operationId":"create","consumes":["application\/json"],"tags":["teams"],"description":"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.","x-appwrite":{"weight":131,"cookies":false,"type":"","demo":"teams\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"},{"name":"roles","description":"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).","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":["owner"],"in":"formData"}]}},"\/teams\/{teamId}":{"get":{"summary":"Get Team","operationId":"get","consumes":["application\/json"],"tags":["teams"],"description":"Get team by its unique ID. All team members have read access for this resource.","x-appwrite":{"weight":133,"cookies":false,"type":"","demo":"teams\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]},"put":{"summary":"Update Team","operationId":"update","consumes":["application\/json"],"tags":["teams"],"description":"Update team by its unique ID. Only team owners have write access for this resource.","x-appwrite":{"weight":134,"cookies":false,"type":"","demo":"teams\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"name","description":"Team name.","required":true,"type":"string","x-example":"[NAME]","in":"formData"}]},"delete":{"summary":"Delete Team","operationId":"delete","consumes":["application\/json"],"tags":["teams"],"description":"Delete team by its unique ID. Only team owners have write access for this resource.","x-appwrite":{"weight":135,"cookies":false,"type":"","demo":"teams\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships":{"get":{"summary":"Get Team Memberships","operationId":"getMemberships","consumes":["application\/json"],"tags":["teams"],"description":"Get team members by the team unique ID. All team members have read access for this list of resources.","x-appwrite":{"weight":137,"cookies":false,"type":"","demo":"teams\/get-memberships.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team-members.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team Membership","operationId":"createMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.\n\nUse 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.\n\nPlease 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.","x-appwrite":{"weight":136,"cookies":false,"type":"","demo":"teams\/create-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"email","description":"New team member email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"name","description":"New team member name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"},{"name":"roles","description":"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).","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"url","description":"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.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"formData"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}":{"delete":{"summary":"Delete Team Membership","operationId":"deleteMembership","consumes":["application\/json"],"tags":["teams"],"description":"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.","x-appwrite":{"weight":139,"cookies":false,"type":"","demo":"teams\/delete-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"}]}},"\/users":{"get":{"summary":"List Users","operationId":"list","consumes":["application\/json"],"tags":["users"],"description":"Get a list of all the project users. You can use the query params to filter your results.","x-appwrite":{"weight":141,"cookies":false,"type":"","demo":"users\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/list-users.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create User","operationId":"create","consumes":["application\/json"],"tags":["users"],"description":"Create a new user.","x-appwrite":{"weight":140,"cookies":false,"type":"","demo":"users\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/create-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"email","description":"User email.","required":true,"type":"string","format":"email","x-example":"email@example.com","in":"formData"},{"name":"password","description":"User password. Must be between 6 to 32 chars.","required":true,"type":"string","format":"format","x-example":"password","in":"formData"},{"name":"name","description":"User name.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"formData"}]}},"\/users\/{userId}":{"get":{"summary":"Get User","operationId":"get","consumes":["application\/json"],"tags":["users"],"description":"Get user by its unique ID.","x-appwrite":{"weight":142,"cookies":false,"type":"","demo":"users\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/logs":{"get":{"summary":"Get User Logs","operationId":"getLogs","consumes":["application\/json"],"tags":["users"],"description":"Get user activity logs list by its unique ID.","x-appwrite":{"weight":145,"cookies":false,"type":"","demo":"users\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/prefs":{"get":{"summary":"Get User Preferences","operationId":"getPrefs","consumes":["application\/json"],"tags":["users"],"description":"Get user preferences by its unique ID.","x-appwrite":{"weight":143,"cookies":false,"type":"","demo":"users\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"patch":{"summary":"Update User Preferences","operationId":"updatePrefs","consumes":["application\/json"],"tags":["users"],"description":"Update user preferences by its unique ID. You can pass only the specific settings you wish to update.","x-appwrite":{"weight":147,"cookies":false,"type":"","demo":"users\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"prefs","description":"Prefs key-value JSON object.","required":true,"type":"object","x-example":"{}","in":"formData"}]}},"\/users\/{userId}\/sessions":{"get":{"summary":"Get User Sessions","operationId":"getSessions","consumes":["application\/json"],"tags":["users"],"description":"Get user sessions list by its unique ID.","x-appwrite":{"weight":144,"cookies":false,"type":"","demo":"users\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"delete":{"summary":"Delete User Sessions","operationId":"deleteSessions","consumes":["application\/json"],"tags":["users"],"description":"Delete all user sessions by its unique ID.","x-appwrite":{"weight":149,"cookies":false,"type":"","demo":"users\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/sessions\/{sessionId}":{"delete":{"summary":"Delete User Session","operationId":"deleteSession","consumes":["application\/json"],"tags":["users"],"description":"Delete user sessions by its unique ID.","x-appwrite":{"weight":148,"cookies":false,"type":"","demo":"users\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"sessionId","description":"User unique session ID.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/users\/{userId}\/status":{"patch":{"summary":"Update User Status","operationId":"updateStatus","consumes":["application\/json"],"tags":["users"],"description":"Update user status by its unique ID.","x-appwrite":{"weight":146,"cookies":false,"type":"","demo":"users\/update-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"]},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"status","description":"User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0","required":true,"type":"string","x-example":1,"in":"formData"}]}}},"definitions":{"Error":{"required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"externalDocs":{"description":"Full API docs, specs and tutorials","url":"https:\/\/localhost\/docs"}} \ No newline at end of file diff --git a/app/config/specs/0.7.0.client.json b/app/config/specs/0.7.0.client.json new file mode 100644 index 0000000000..34702ae6d4 --- /dev/null +++ b/app/config/specs/0.7.0.client.json @@ -0,0 +1 @@ +{"swagger":"2.0","info":{"version":"0.7.0","title":"Appwrite","description":"Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)","termsOfService":"https:\/\/appwrite.io\/policy\/terms","contact":{"name":"Appwrite Team","url":"https:\/\/appwrite.io\/support","email":"team@appwrite.io"},"license":{"name":"BSD-3-Clause","url":"https:\/\/raw.githubusercontent.com\/appwrite\/appwrite\/master\/LICENSE"}},"host":"appwrite.io","basePath":"\/v1","schemes":["https"],"consumes":["application\/json","multipart\/form-data"],"produces":["application\/json"],"securityDefinitions":{"Project":{"type":"apiKey","name":"X-Appwrite-Project","description":"Your project ID","in":"header","x-appwrite":{"demo":"5df5acd0d48c2"}},"Locale":{"type":"apiKey","name":"X-Appwrite-Locale","description":"","in":"header","x-appwrite":{"demo":"en"}}},"paths":{"\/account":{"get":{"summary":"Get Account","operationId":"accountGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Get currently logged in user data as JSON object.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"get","weight":42,"cookies":false,"type":"","demo":"account\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}]},"post":{"summary":"Create Account","operationId":"accountCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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#accountCreateVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](\/docs\/client\/account#accountCreateSession).","responses":{"201":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"create","weight":35,"cookies":false,"type":"","demo":"account\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"password":{"type":"string","description":"User password. Must be between 6 to 32 chars.","default":null,"x-example":"password"},"name":{"type":"string","description":"User name. Max length: 128 chars.","default":"","x-example":"[NAME]"}},"required":["email","password"]}}]},"delete":{"summary":"Delete Account","operationId":"accountDelete","consumes":["application\/json"],"produces":[],"tags":["account"],"description":"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.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"delete","weight":50,"cookies":false,"type":"","demo":"account\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}]}},"\/account\/email":{"patch":{"summary":"Update Account Email","operationId":"accountUpdateEmail","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"updateEmail","weight":48,"cookies":false,"type":"","demo":"account\/update-email.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-email.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"password":{"type":"string","description":"User password. Must be between 6 to 32 chars.","default":null,"x-example":"password"}},"required":["email","password"]}}]}},"\/account\/logs":{"get":{"summary":"Get Account Logs","operationId":"accountGetLogs","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.","responses":{"200":{"description":"Logs List","schema":{"$ref":"#\/definitions\/logList"}}},"x-appwrite":{"method":"getLogs","weight":45,"cookies":false,"type":"","demo":"account\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}]}},"\/account\/name":{"patch":{"summary":"Update Account Name","operationId":"accountUpdateName","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Update currently logged in user account name.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"updateName","weight":46,"cookies":false,"type":"","demo":"account\/update-name.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-name.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"User name. Max length: 128 chars.","default":null,"x-example":"[NAME]"}},"required":["name"]}}]}},"\/account\/password":{"patch":{"summary":"Update Account Password","operationId":"accountUpdatePassword","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Update currently logged in user password. For validation, user is required to pass the password twice.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"updatePassword","weight":47,"cookies":false,"type":"","demo":"account\/update-password.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-password.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"password":{"type":"string","description":"New user password. Must be between 6 to 32 chars.","default":null,"x-example":"password"},"oldPassword":{"type":"string","description":"Old user password. Must be between 6 to 32 chars.","default":null,"x-example":"password"}},"required":["password","oldPassword"]}}]}},"\/account\/prefs":{"get":{"summary":"Get Account Preferences","operationId":"accountGetPrefs","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Get currently logged in user preferences as a key-value object.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"getPrefs","weight":43,"cookies":false,"type":"","demo":"account\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}]},"patch":{"summary":"Update Account Preferences","operationId":"accountUpdatePrefs","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Update currently logged in user account preferences. You can pass only the specific settings you wish to update.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"updatePrefs","weight":49,"cookies":false,"type":"","demo":"account\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"prefs":{"type":"object","description":"Prefs key-value JSON object.","default":null,"x-example":"{}"}},"required":["prefs"]}}]}},"\/account\/recovery":{"post":{"summary":"Create Password Recovery","operationId":"accountCreateRecovery","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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#accountUpdateRecovery) endpoint to complete the process.","responses":{"201":{"description":"Token","schema":{"$ref":"#\/definitions\/token"}}},"x-appwrite":{"method":"createRecovery","weight":53,"cookies":false,"type":"","demo":"account\/create-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"url":{"type":"string","description":"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.","default":null,"x-example":"https:\/\/example.com"}},"required":["email","url"]}}]},"put":{"summary":"Complete Password Recovery","operationId":"accountUpdateRecovery","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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#accountCreateRecovery) endpoint.\n\nPlease 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.","responses":{"200":{"description":"Token","schema":{"$ref":"#\/definitions\/token"}}},"x-appwrite":{"method":"updateRecovery","weight":54,"cookies":false,"type":"","demo":"account\/update-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"userId":{"type":"string","description":"User account UID address.","default":null,"x-example":"[USER_ID]"},"secret":{"type":"string","description":"Valid reset token.","default":null,"x-example":"[SECRET]"},"password":{"type":"string","description":"New password. Must be between 6 to 32 chars.","default":null,"x-example":"password"},"passwordAgain":{"type":"string","description":"New password again. Must be between 6 to 32 chars.","default":null,"x-example":"password"}},"required":["userId","secret","password","passwordAgain"]}}]}},"\/account\/sessions":{"get":{"summary":"Get Account Sessions","operationId":"accountGetSessions","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of active sessions across different devices.","responses":{"200":{"description":"Sessions List","schema":{"$ref":"#\/definitions\/sessionList"}}},"x-appwrite":{"method":"getSessions","weight":44,"cookies":false,"type":"","demo":"account\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}]},"post":{"summary":"Create Account Session","operationId":"accountCreateSession","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.","responses":{"201":{"description":"Session","schema":{"$ref":"#\/definitions\/session"}}},"x-appwrite":{"method":"createSession","weight":36,"cookies":false,"type":"","demo":"account\/create-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"password":{"type":"string","description":"User password. Must be between 6 to 32 chars.","default":null,"x-example":"password"}},"required":["email","password"]}}]},"delete":{"summary":"Delete All Account Sessions","operationId":"accountDeleteSessions","consumes":["application\/json"],"produces":[],"tags":["account"],"description":"Delete all sessions from the user account and remove any sessions cookies from the end client.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteSessions","weight":52,"cookies":false,"type":"","demo":"account\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}]}},"\/account\/sessions\/oauth2\/{provider}":{"get":{"summary":"Create Account Session with OAuth2","operationId":"accountCreateOAuth2Session","consumes":["application\/json"],"produces":["text\/html"],"tags":["account"],"description":"Allow the user to login to their account using the OAuth2 provider of their 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.","responses":{"301":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"createOAuth2Session","weight":37,"cookies":false,"type":"webAuth","demo":"account\/create-o-auth2session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session-oauth2.md","rate-limit":50,"rate-time":3600,"rate-key":"ip:{ip}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"provider","description":"OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yandex, wordpress.","required":true,"type":"string","x-example":"amazon","in":"path"},{"name":"success","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"https:\/\/appwrite.io\/auth\/oauth2\/success","in":"query"},{"name":"failure","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"https:\/\/appwrite.io\/auth\/oauth2\/failure","in":"query"},{"name":"scopes","description":"A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"}]}},"\/account\/sessions\/{sessionId}":{"delete":{"summary":"Delete Account Session","operationId":"accountDeleteSession","consumes":["application\/json"],"produces":[],"tags":["account"],"description":"Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteSession","weight":51,"cookies":false,"type":"","demo":"account\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"sessionId","description":"Session unique ID. Use the string 'current' to delete the current device session.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/account\/verification":{"post":{"summary":"Create Email Verification","operationId":"accountCreateVerification","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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#accountUpdateVerification). \n\nPlease 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.\n","responses":{"201":{"description":"Token","schema":{"$ref":"#\/definitions\/token"}}},"x-appwrite":{"method":"createVerification","weight":55,"cookies":false,"type":"","demo":"account\/create-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"url":{"type":"string","description":"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.","default":null,"x-example":"https:\/\/example.com"}},"required":["url"]}}]},"put":{"summary":"Complete Email Verification","operationId":"accountUpdateVerification","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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.","responses":{"200":{"description":"Token","schema":{"$ref":"#\/definitions\/token"}}},"x-appwrite":{"method":"updateVerification","weight":56,"cookies":false,"type":"","demo":"account\/update-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"userId":{"type":"string","description":"User unique ID.","default":null,"x-example":"[USER_ID]"},"secret":{"type":"string","description":"Valid verification token.","default":null,"x-example":"[SECRET]"}},"required":["userId","secret"]}}]}},"\/avatars\/browsers\/{code}":{"get":{"summary":"Get Browser Icon","operationId":"avatarsGetBrowser","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getBrowser","weight":58,"cookies":false,"type":"location","demo":"avatars\/get-browser.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-browser.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"code","description":"Browser Code.","required":true,"type":"string","x-example":"aa","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/credit-cards\/{code}":{"get":{"summary":"Get Credit Card Icon","operationId":"avatarsGetCreditCard","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getCreditCard","weight":57,"cookies":false,"type":"location","demo":"avatars\/get-credit-card.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-credit-card.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"code","description":"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.","required":true,"type":"string","x-example":"amex","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/favicon":{"get":{"summary":"Get Favicon","operationId":"avatarsGetFavicon","consumes":["application\/json"],"produces":["image\/*"],"tags":["avatars"],"description":"Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL.\n","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getFavicon","weight":61,"cookies":false,"type":"location","demo":"avatars\/get-favicon.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-favicon.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"url","description":"Website URL which you want to fetch the favicon from.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"}]}},"\/avatars\/flags\/{code}":{"get":{"summary":"Get Country Flag","operationId":"avatarsGetFlag","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getFlag","weight":59,"cookies":false,"type":"location","demo":"avatars\/get-flag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-flag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"code","description":"Country Code. ISO Alpha-2 country code format.","required":true,"type":"string","x-example":"af","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/image":{"get":{"summary":"Get Image from URL","operationId":"avatarsGetImage","consumes":["application\/json"],"produces":["image\/*"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getImage","weight":60,"cookies":false,"type":"location","demo":"avatars\/get-image.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-image.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"url","description":"Image URL which you want to crop.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"}]}},"\/avatars\/initials":{"get":{"summary":"Get User Initials","operationId":"avatarsGetInitials","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.\n\nYou 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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getInitials","weight":63,"cookies":false,"type":"location","demo":"avatars\/get-initials.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-initials.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"name","description":"Full Name. When empty, current user name or email will be used. Max length: 128 chars.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"query"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"color","description":"Changes text color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"},{"name":"background","description":"Changes background color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"}]}},"\/avatars\/qr":{"get":{"summary":"Get QR Code","operationId":"avatarsGetQR","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getQR","weight":62,"cookies":false,"type":"location","demo":"avatars\/get-q-r.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-qr.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"text","description":"Plain text to be converted to QR code image.","required":true,"type":"string","x-example":"[TEXT]","in":"query"},{"name":"size","description":"QR code size. Pass an integer between 0 to 1000. Defaults to 400.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"margin","description":"Margin from edge. Pass an integer between 0 to 10. Defaults to 1.","required":false,"type":"integer","format":"int32","x-example":0,"default":1,"in":"query"},{"name":"download","description":"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.","required":false,"type":"boolean","x-example":false,"default":false,"in":"query"}]}},"\/database\/collections\/{collectionId}\/documents":{"get":{"summary":"List Documents","operationId":"databaseListDocuments","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"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's documents. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Documents List","schema":{"$ref":"#\/definitions\/documentList"}}},"x-appwrite":{"method":"listDocuments","weight":70,"cookies":false,"type":"","demo":"database\/list-documents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-documents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"filters","description":"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'.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"},{"name":"limit","description":"Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Offset value. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderField","description":"Document field that results will be sorted by.","required":false,"type":"string","x-example":"[ORDER_FIELD]","default":"","in":"query"},{"name":"orderType","description":"Order direction. Possible values are DESC for descending order, or ASC for ascending order.","required":false,"type":"string","x-example":"DESC","default":"ASC","in":"query"},{"name":"orderCast","description":"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.","required":false,"type":"string","x-example":"int","default":"string","in":"query"},{"name":"search","description":"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.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"}]},"post":{"summary":"Create Document","operationId":"databaseCreateDocument","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](\/docs\/server\/database#databaseCreateCollection) API or directly from your database console.","responses":{"201":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"createDocument","weight":69,"cookies":false,"type":"","demo":"database\/create-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"data":{"type":"object","description":"Document data as JSON object.","default":null,"x-example":"{}"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"parentDocument":{"type":"string","description":"Parent document unique ID. Use when you want your new document to be a child of a parent document.","default":"","x-example":"[PARENT_DOCUMENT]"},"parentProperty":{"type":"string","description":"Parent document property name. Use when you want your new document to be a child of a parent document.","default":"","x-example":null},"parentPropertyType":{"type":"string","description":"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.","default":"assign","x-example":"assign"}},"required":["data","read","write"]}}]}},"\/database\/collections\/{collectionId}\/documents\/{documentId}":{"get":{"summary":"Get Document","operationId":"databaseGetDocument","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Get a document by its unique ID. This endpoint response returns a JSON object with the document data.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"getDocument","weight":71,"cookies":false,"type":"","demo":"database\/get-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]},"patch":{"summary":"Update Document","operationId":"databaseUpdateDocument","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"updateDocument","weight":72,"cookies":false,"type":"","demo":"database\/update-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"data":{"type":"object","description":"Document data as JSON object.","default":null,"x-example":"{}"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}}},"required":["data","read","write"]}}]},"delete":{"summary":"Delete Document","operationId":"databaseDeleteDocument","consumes":["application\/json"],"produces":[],"tags":["database"],"description":"Delete a document by its unique ID. This endpoint deletes only the parent documents, its attributes and relations to other documents. Child documents **will not** be deleted.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteDocument","weight":73,"cookies":false,"type":"","demo":"database\/delete-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]}},"\/functions\/{functionId}\/executions":{"get":{"summary":"List Executions","operationId":"functionsListExecutions","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a list of all the current user function execution logs. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's teams. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Executions List","schema":{"$ref":"#\/definitions\/executionList"}}},"x-appwrite":{"method":"listExecutions","weight":167,"cookies":false,"type":"","demo":"functions\/list-executions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/list-executions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"execution.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Execution","operationId":"functionsCreateExecution","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.","responses":{"201":{"description":"Execution","schema":{"$ref":"#\/definitions\/execution"}}},"x-appwrite":{"method":"createExecution","weight":166,"cookies":false,"type":"","demo":"functions\/create-execution.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/create-execution.md","rate-limit":60,"rate-time":60,"rate-key":"url:{url},ip:{ip}","scope":"execution.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"}]}},"\/functions\/{functionId}\/executions\/{executionId}":{"get":{"summary":"Get Execution","operationId":"functionsGetExecution","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a function execution log by its unique ID.","responses":{"200":{"description":"Execution","schema":{"$ref":"#\/definitions\/execution"}}},"x-appwrite":{"method":"getExecution","weight":168,"cookies":false,"type":"","demo":"functions\/get-execution.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/get-execution.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"execution.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"executionId","description":"Execution unique ID.","required":true,"type":"string","x-example":"[EXECUTION_ID]","in":"path"}]}},"\/locale":{"get":{"summary":"Get User Locale","operationId":"localeGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"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.\n\n([IP Geolocation by DB-IP](https:\/\/db-ip.com))","responses":{"200":{"description":"Locale","schema":{"$ref":"#\/definitions\/locale"}}},"x-appwrite":{"method":"get","weight":74,"cookies":false,"type":"","demo":"locale\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-locale.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}]}},"\/locale\/continents":{"get":{"summary":"List Continents","operationId":"localeGetContinents","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all continents. You can use the locale header to get the data in a supported language.","responses":{"200":{"description":"Continents List","schema":{"$ref":"#\/definitions\/continentList"}}},"x-appwrite":{"method":"getContinents","weight":78,"cookies":false,"type":"","demo":"locale\/get-continents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-continents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}]}},"\/locale\/countries":{"get":{"summary":"List Countries","operationId":"localeGetCountries","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all countries. You can use the locale header to get the data in a supported language.","responses":{"200":{"description":"Countries List","schema":{"$ref":"#\/definitions\/countryList"}}},"x-appwrite":{"method":"getCountries","weight":75,"cookies":false,"type":"","demo":"locale\/get-countries.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}]}},"\/locale\/countries\/eu":{"get":{"summary":"List EU Countries","operationId":"localeGetCountriesEU","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"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.","responses":{"200":{"description":"Countries List","schema":{"$ref":"#\/definitions\/countryList"}}},"x-appwrite":{"method":"getCountriesEU","weight":76,"cookies":false,"type":"","demo":"locale\/get-countries-e-u.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-eu.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}]}},"\/locale\/countries\/phones":{"get":{"summary":"List Countries Phone Codes","operationId":"localeGetCountriesPhones","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all countries phone codes. You can use the locale header to get the data in a supported language.","responses":{"200":{"description":"Phones List","schema":{"$ref":"#\/definitions\/phoneList"}}},"x-appwrite":{"method":"getCountriesPhones","weight":77,"cookies":false,"type":"","demo":"locale\/get-countries-phones.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-phones.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}]}},"\/locale\/currencies":{"get":{"summary":"List Currencies","operationId":"localeGetCurrencies","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"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.","responses":{"200":{"description":"Currencies List","schema":{"$ref":"#\/definitions\/currencyList"}}},"x-appwrite":{"method":"getCurrencies","weight":79,"cookies":false,"type":"","demo":"locale\/get-currencies.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-currencies.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}]}},"\/locale\/languages":{"get":{"summary":"List Languages","operationId":"localeGetLanguages","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.","responses":{"200":{"description":"Languages List","schema":{"$ref":"#\/definitions\/languageList"}}},"x-appwrite":{"method":"getLanguages","weight":80,"cookies":false,"type":"","demo":"locale\/get-languages.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-languages.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}]}},"\/storage\/files":{"get":{"summary":"List Files","operationId":"storageListFiles","consumes":["application\/json"],"produces":["application\/json"],"tags":["storage"],"description":"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's files. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Files List","schema":{"$ref":"#\/definitions\/fileList"}}},"x-appwrite":{"method":"listFiles","weight":128,"cookies":false,"type":"","demo":"storage\/list-files.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/list-files.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create File","operationId":"storageCreateFile","consumes":["multipart\/form-data"],"produces":["application\/json"],"tags":["storage"],"description":"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.","responses":{"201":{"description":"File","schema":{"$ref":"#\/definitions\/file"}}},"x-appwrite":{"method":"createFile","weight":127,"cookies":false,"type":"upload","demo":"storage\/create-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/create-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"file","description":"Binary file.","required":true,"type":"file","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/storage\/files\/{fileId}":{"get":{"summary":"Get File","operationId":"storageGetFile","consumes":["application\/json"],"produces":["application\/json"],"tags":["storage"],"description":"Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.","responses":{"200":{"description":"File","schema":{"$ref":"#\/definitions\/file"}}},"x-appwrite":{"method":"getFile","weight":129,"cookies":false,"type":"","demo":"storage\/get-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]},"put":{"summary":"Update File","operationId":"storageUpdateFile","consumes":["application\/json"],"produces":["application\/json"],"tags":["storage"],"description":"Update a file by its unique ID. Only users with write permissions have access to update this resource.","responses":{"200":{"description":"File","schema":{"$ref":"#\/definitions\/file"}}},"x-appwrite":{"method":"updateFile","weight":133,"cookies":false,"type":"","demo":"storage\/update-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/update-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}}},"required":["read","write"]}}]},"delete":{"summary":"Delete File","operationId":"storageDeleteFile","consumes":["application\/json"],"produces":[],"tags":["storage"],"description":"Delete a file by its unique ID. Only users with write permissions have access to delete this resource.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteFile","weight":134,"cookies":false,"type":"","demo":"storage\/delete-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/delete-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/download":{"get":{"summary":"Get File for Download","operationId":"storageGetFileDownload","consumes":["application\/json"],"produces":["*\/*"],"tags":["storage"],"description":"Get a 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.","responses":{"200":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getFileDownload","weight":131,"cookies":false,"type":"location","demo":"storage\/get-file-download.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-download.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/preview":{"get":{"summary":"Get File Preview","operationId":"storageGetFilePreview","consumes":["application\/json"],"produces":["image\/*"],"tags":["storage"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getFilePreview","weight":130,"cookies":false,"type":"location","demo":"storage\/get-file-preview.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-preview.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"quality","description":"Preview image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"background","description":"Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.","required":false,"type":"string","default":"","in":"query"},{"name":"output","description":"Output format type (jpeg, jpg, png, gif and webp).","required":false,"type":"string","x-example":"jpg","default":"","in":"query"}]}},"\/storage\/files\/{fileId}\/view":{"get":{"summary":"Get File for View","operationId":"storageGetFileView","consumes":["application\/json"],"produces":["*\/*"],"tags":["storage"],"description":"Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.","responses":{"200":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getFileView","weight":132,"cookies":false,"type":"location","demo":"storage\/get-file-view.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-view.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/teams":{"get":{"summary":"List Teams","operationId":"teamsList","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"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's teams. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Teams List","schema":{"$ref":"#\/definitions\/teamList"}}},"x-appwrite":{"method":"list","weight":136,"cookies":false,"type":"","demo":"teams\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/list-teams.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team","operationId":"teamsCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"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.","responses":{"201":{"description":"Team","schema":{"$ref":"#\/definitions\/team"}}},"x-appwrite":{"method":"create","weight":135,"cookies":false,"type":"","demo":"teams\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Team name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"roles":{"type":"array","description":"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.","default":["owner"],"x-example":null,"items":{"type":"string"}}},"required":["name"]}}]}},"\/teams\/{teamId}":{"get":{"summary":"Get Team","operationId":"teamsGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Get a team by its unique ID. All team members have read access for this resource.","responses":{"200":{"description":"Team","schema":{"$ref":"#\/definitions\/team"}}},"x-appwrite":{"method":"get","weight":137,"cookies":false,"type":"","demo":"teams\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]},"put":{"summary":"Update Team","operationId":"teamsUpdate","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Update a team by its unique ID. Only team owners have write access for this resource.","responses":{"200":{"description":"Team","schema":{"$ref":"#\/definitions\/team"}}},"x-appwrite":{"method":"update","weight":138,"cookies":false,"type":"","demo":"teams\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Team name. Max length: 128 chars.","default":null,"x-example":"[NAME]"}},"required":["name"]}}]},"delete":{"summary":"Delete Team","operationId":"teamsDelete","consumes":["application\/json"],"produces":[],"tags":["teams"],"description":"Delete a team by its unique ID. Only team owners have write access for this resource.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"delete","weight":139,"cookies":false,"type":"","demo":"teams\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships":{"get":{"summary":"Get Team Memberships","operationId":"teamsGetMemberships","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Get a team members by the team unique ID. All team members have read access for this list of resources.","responses":{"200":{"description":"Memberships List","schema":{"$ref":"#\/definitions\/membershipList"}}},"x-appwrite":{"method":"getMemberships","weight":141,"cookies":false,"type":"","demo":"teams\/get-memberships.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team-members.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team Membership","operationId":"teamsCreateMembership","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"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.\n\nUse 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#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team.\n\nPlease 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.","responses":{"201":{"description":"Membership","schema":{"$ref":"#\/definitions\/membership"}}},"x-appwrite":{"method":"createMembership","weight":140,"cookies":false,"type":"","demo":"teams\/create-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"New team member email.","default":null,"x-example":"email@example.com"},"name":{"type":"string","description":"New team member name. Max length: 128 chars.","default":"","x-example":"[NAME]"},"roles":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"url":{"type":"string","description":"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.","default":null,"x-example":"https:\/\/example.com"}},"required":["email","roles","url"]}}]}},"\/teams\/{teamId}\/memberships\/{inviteId}":{"delete":{"summary":"Delete Team Membership","operationId":"teamsDeleteMembership","consumes":["application\/json"],"produces":[],"tags":["teams"],"description":"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 it is not accepted.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteMembership","weight":143,"cookies":false,"type":"","demo":"teams\/delete-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}\/status":{"patch":{"summary":"Update Team Membership Status","operationId":"teamsUpdateMembershipStatus","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email recieved by the user.","responses":{"200":{"description":"Membership","schema":{"$ref":"#\/definitions\/membership"}}},"x-appwrite":{"method":"updateMembershipStatus","weight":142,"cookies":false,"type":"","demo":"teams\/update-membership-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team-membership-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"userId":{"type":"string","description":"User unique ID.","default":null,"x-example":"[USER_ID]"},"secret":{"type":"string","description":"Secret key.","default":null,"x-example":"[SECRET]"}},"required":["userId","secret"]}}]}}},"tags":[{"name":"account","description":"The Account service allows you to authenticate and manage a user account."},{"name":"avatars","description":"The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars."},{"name":"database","description":"The Database service allows you to create structured collections of documents, query and filter lists of documents"},{"name":"locale","description":"The Locale service allows you to customize your app based on your users' location."},{"name":"health","description":"The Health service allows you to both validate and monitor your Appwrite server's health."},{"name":"projects","description":"The Project service allows you to manage all the projects in your Appwrite server."},{"name":"storage","description":"The Storage service allows you to manage your project files."},{"name":"teams","description":"The Teams service allows you to group users of your project and to enable them to share read and write access to your project resources"},{"name":"users","description":"The Users service allows you to manage your project users."},{"name":"functions","description":"The Functions Service allows you view, create and manage your Cloud Functions."}],"definitions":{"none":{"description":"None","type":"object"},"any":{"description":"Any","type":"object","additionalProperties":true},"error":{"description":"Error","type":"object","properties":{"message":{"type":"string","description":"Error message.","x-example":"Not found"},"code":{"type":"string","description":"Error code.","x-example":"404"},"version":{"type":"string","description":"Server version number.","x-example":"1.0"}},"required":["message","code","version"]},"collectionList":{"description":"Collections List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"collections":{"type":"array","description":"List of collections.","items":{"type":"object","$ref":"#\/definitions\/collection"},"x-example":""}},"required":["sum","collections"]},"documentList":{"description":"Documents List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"documents":{"type":"array","description":"List of documents.","items":{"type":"object","$ref":"#\/definitions\/any"},"x-example":""}},"required":["sum","documents"]},"userList":{"description":"Users List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"users":{"type":"array","description":"List of users.","items":{"type":"object","$ref":"#\/definitions\/user"},"x-example":""}},"required":["sum","users"]},"sessionList":{"description":"Sessions List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"sessions":{"type":"array","description":"List of sessions.","items":{"type":"object","$ref":"#\/definitions\/session"},"x-example":""}},"required":["sum","sessions"]},"logList":{"description":"Logs List","type":"object","properties":{"logs":{"type":"array","description":"List of logs.","items":{"type":"object","$ref":"#\/definitions\/log"},"x-example":""}},"required":["logs"]},"fileList":{"description":"Files List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"files":{"type":"array","description":"List of files.","items":{"type":"object","$ref":"#\/definitions\/file"},"x-example":""}},"required":["sum","files"]},"teamList":{"description":"Teams List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"teams":{"type":"array","description":"List of teams.","items":{"type":"object","$ref":"#\/definitions\/team"},"x-example":""}},"required":["sum","teams"]},"membershipList":{"description":"Memberships List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"memberships":{"type":"array","description":"List of memberships.","items":{"type":"object","$ref":"#\/definitions\/membership"},"x-example":""}},"required":["sum","memberships"]},"functionList":{"description":"Functions List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"functions":{"type":"array","description":"List of functions.","items":{"type":"object","$ref":"#\/definitions\/function"},"x-example":""}},"required":["sum","functions"]},"tagList":{"description":"Tags List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"tags":{"type":"array","description":"List of tags.","items":{"type":"object","$ref":"#\/definitions\/tag"},"x-example":""}},"required":["sum","tags"]},"executionList":{"description":"Executions List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"executions":{"type":"array","description":"List of executions.","items":{"type":"object","$ref":"#\/definitions\/execution"},"x-example":""}},"required":["sum","executions"]},"countryList":{"description":"Countries List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"countries":{"type":"array","description":"List of countries.","items":{"type":"object","$ref":"#\/definitions\/country"},"x-example":""}},"required":["sum","countries"]},"continentList":{"description":"Continents List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"continents":{"type":"array","description":"List of continents.","items":{"type":"object","$ref":"#\/definitions\/continent"},"x-example":""}},"required":["sum","continents"]},"languageList":{"description":"Languages List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"languages":{"type":"array","description":"List of languages.","items":{"type":"object","$ref":"#\/definitions\/language"},"x-example":""}},"required":["sum","languages"]},"currencyList":{"description":"Currencies List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"currencies":{"type":"array","description":"List of currencies.","items":{"type":"object","$ref":"#\/definitions\/currency"},"x-example":""}},"required":["sum","currencies"]},"phoneList":{"description":"Phones List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"phones":{"type":"array","description":"List of phones.","items":{"type":"object","$ref":"#\/definitions\/phone"},"x-example":""}},"required":["sum","phones"]},"permissions":{"description":"Permissions","type":"object","properties":{"read":{"type":"array","description":"Read permissions.","items":{"type":"string"},"x-example":"user:5e5ea5c16897e"},"write":{"type":"array","description":"Write permissions.","items":{"type":"string"},"x-example":"user:5e5ea5c16897e"}},"required":["read","write"]},"collection":{"description":"Collection","type":"object","properties":{"$id":{"type":"string","description":"Collection ID.","x-example":"5e5ea5c16897e"},"$permissions":{"type":"object","description":"Collection permissions.","x-example":{},"items":{"type":"object","$ref":"#\/definitions\/permissions"}},"name":{"type":"string","description":"Collection name.","x-example":"Movies"},"dateCreated":{"type":"integer","description":"Collection creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"dateUpdated":{"type":"integer","description":"Collection creation date in Unix timestamp.","x-example":1592981550,"format":"int32"},"rules":{"type":"array","description":"Collection rules.","items":{"type":"object","$ref":"#\/definitions\/rule"},"x-example":""}},"required":["$id","$permissions","name","dateCreated","dateUpdated","rules"]},"rule":{"description":"Rule","type":"object","properties":{"$id":{"type":"string","description":"Rule ID.","x-example":"5e5ea5c16897e"},"$collection":{"type":"string","description":"Rule Collection.","x-example":"5e5e66c16897e"},"type":{"type":"string","description":"Rule type. Possible values: ","x-example":"title"},"key":{"type":"string","description":"Rule key.","x-example":"title"},"label":{"type":"string","description":"Rule label.","x-example":"Title"},"default":{"type":"string","description":"Rule default value.","x-example":"Movie Name"},"array":{"type":"boolean","description":"Is array?","x-example":false},"required":{"type":"boolean","description":"Is required?","x-example":true},"list":{"type":"array","description":"List of allowed values","items":{"type":"string"},"x-example":"5e5ea5c168099"}},"required":["$id","$collection","type","key","label","default","array","required","list"]},"log":{"description":"Log","type":"object","properties":{"event":{"type":"string","description":"Event name.","x-example":"account.sessions.create"},"ip":{"type":"string","description":"IP session in use when the session was created.","x-example":"127.0.0.1"},"time":{"type":"integer","description":"Log creation time in Unix timestamp.","x-example":1592981250,"format":"int32"},"osCode":{"type":"string","description":"Operating system code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/os.json).","x-example":"Mac"},"osName":{"type":"string","description":"Operating system name.","x-example":"Mac"},"osVersion":{"type":"string","description":"Operating system version.","x-example":"Mac"},"clientType":{"type":"string","description":"Client type.","x-example":"browser"},"clientCode":{"type":"string","description":"Client code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/clients.json).","x-example":"CM"},"clientName":{"type":"string","description":"Client name.","x-example":"Chrome Mobile iOS"},"clientVersion":{"type":"string","description":"Client version.","x-example":"84.0"},"clientEngine":{"type":"string","description":"Client engine name.","x-example":"WebKit"},"clientEngineVersion":{"type":"string","description":"Client engine name.","x-example":"605.1.15"},"deviceName":{"type":"string","description":"Device name.","x-example":"smartphone"},"deviceBrand":{"type":"string","description":"Device brand name.","x-example":"Google"},"deviceModel":{"type":"string","description":"Device model name.","x-example":"Nexus 5"},"countryCode":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"},"countryName":{"type":"string","description":"Country name.","x-example":"United States"}},"required":["event","ip","time","osCode","osName","osVersion","clientType","clientCode","clientName","clientVersion","clientEngine","clientEngineVersion","deviceName","deviceBrand","deviceModel","countryCode","countryName"]},"user":{"description":"User","type":"object","properties":{"$id":{"type":"string","description":"User ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"User name.","x-example":"John Doe"},"registration":{"type":"integer","description":"User registration date in Unix timestamp.","x-example":1592981250,"format":"int32"},"status":{"type":"integer","description":"User status. 0 for Unactivated, 1 for active and 2 is blocked.","x-example":0,"format":"int32"},"email":{"type":"string","description":"User email address.","x-example":"john@appwrite.io"},"emailVerification":{"type":"boolean","description":"Email verification status.","x-example":true},"prefs":{"type":"string","description":"User preferences as a key-value object","x-example":{"theme":"pink","timezone":"UTC"}}},"required":["$id","name","registration","status","email","emailVerification","prefs"]},"session":{"description":"Session","type":"object","properties":{"$id":{"type":"string","description":"Session ID.","x-example":"5e5ea5c16897e"},"userId":{"type":"string","description":"User ID.","x-example":"5e5bb8c16897e"},"expire":{"type":"integer","description":"Session expiration date in Unix timestamp.","x-example":1592981250,"format":"int32"},"ip":{"type":"string","description":"IP in use when the session was created.","x-example":"127.0.0.1"},"osCode":{"type":"string","description":"Operating system code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/os.json).","x-example":"Mac"},"osName":{"type":"string","description":"Operating system name.","x-example":"Mac"},"osVersion":{"type":"string","description":"Operating system version.","x-example":"Mac"},"clientType":{"type":"string","description":"Client type.","x-example":"browser"},"clientCode":{"type":"string","description":"Client code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/clients.json).","x-example":"CM"},"clientName":{"type":"string","description":"Client name.","x-example":"Chrome Mobile iOS"},"clientVersion":{"type":"string","description":"Client version.","x-example":"84.0"},"clientEngine":{"type":"string","description":"Client engine name.","x-example":"WebKit"},"clientEngineVersion":{"type":"string","description":"Client engine name.","x-example":"605.1.15"},"deviceName":{"type":"string","description":"Device name.","x-example":"smartphone"},"deviceBrand":{"type":"string","description":"Device brand name.","x-example":"Google"},"deviceModel":{"type":"string","description":"Device model name.","x-example":"Nexus 5"},"countryCode":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"},"countryName":{"type":"string","description":"Country name.","x-example":"United States"},"current":{"type":"boolean","description":"Returns true if this the current user session.","x-example":true}},"required":["$id","userId","expire","ip","osCode","osName","osVersion","clientType","clientCode","clientName","clientVersion","clientEngine","clientEngineVersion","deviceName","deviceBrand","deviceModel","countryCode","countryName","current"]},"token":{"description":"Token","type":"object","properties":{"$id":{"type":"string","description":"Token ID.","x-example":"bb8ea5c16897e"},"userId":{"type":"string","description":"User ID.","x-example":"5e5ea5c168bb8"},"secret":{"type":"string","description":"Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.","x-example":""},"expire":{"type":"integer","description":"Token expiration date in Unix timestamp.","x-example":1592981250,"format":"int32"}},"required":["$id","userId","secret","expire"]},"jwt":{"description":"JWT","type":"object","properties":{"jwt":{"type":"string","description":"JWT encoded string.","x-example":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"}},"required":["jwt"]},"locale":{"description":"Locale","type":"object","properties":{"ip":{"type":"string","description":"User IP address.","x-example":"127.0.0.1"},"countryCode":{"type":"string","description":"Country code in [ISO 3166-1](http:\/\/en.wikipedia.org\/wiki\/ISO_3166-1) two-character format","x-example":"US"},"country":{"type":"string","description":"Country name. This field support localization.","x-example":"United States"},"continentCode":{"type":"string","description":"Continent code. A two character continent code \"AF\" for Africa, \"AN\" for Antarctica, \"AS\" for Asia, \"EU\" for Europe, \"NA\" for North America, \"OC\" for Oceania, and \"SA\" for South America.","x-example":"NA"},"continent":{"type":"string","description":"Continent name. This field support localization.","x-example":"North America"},"eu":{"type":"boolean","description":"True if country is part of the Europian Union.","x-example":false},"currency":{"type":"string","description":"Currency code in [ISO 4217-1](http:\/\/en.wikipedia.org\/wiki\/ISO_4217) three-character format","x-example":"USD"}},"required":["ip","countryCode","country","continentCode","continent","eu","currency"]},"file":{"description":"File","type":"object","properties":{"$id":{"type":"string","description":"File ID.","x-example":"5e5ea5c16897e"},"$permissions":{"type":"object","description":"File permissions.","x-example":{},"items":{"type":"object","$ref":"#\/definitions\/permissions"}},"name":{"type":"string","description":"File name.","x-example":"Pink.png"},"dateCreated":{"type":"integer","description":"File creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"signature":{"type":"string","description":"File MD5 signature.","x-example":"5d529fd02b544198ae075bd57c1762bb"},"mimeType":{"type":"string","description":"File mime type.","x-example":"image\/png"},"sizeOriginal":{"type":"integer","description":"File original size in bytes.","x-example":17890,"format":"int32"}},"required":["$id","$permissions","name","dateCreated","signature","mimeType","sizeOriginal"]},"team":{"description":"Team","type":"object","properties":{"$id":{"type":"string","description":"Team ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"Team name.","x-example":"VIP"},"dateCreated":{"type":"integer","description":"Team creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"sum":{"type":"integer","description":"Total sum of team members.","x-example":7,"format":"int32"}},"required":["$id","name","dateCreated","sum"]},"membership":{"description":"Membership","type":"object","properties":{"$id":{"type":"string","description":"Membership ID.","x-example":"5e5ea5c16897e"},"userId":{"type":"string","description":"User ID.","x-example":"5e5ea5c16897e"},"teamId":{"type":"string","description":"Team ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"User name.","x-example":"VIP"},"email":{"type":"string","description":"User email address.","x-example":"john@appwrite.io"},"invited":{"type":"integer","description":"Date, the user has been invited to join the team in Unix timestamp.","x-example":1592981250,"format":"int32"},"joined":{"type":"integer","description":"Date, the user has accepted the invitation to join the team in Unix timestamp.","x-example":1592981250,"format":"int32"},"confirm":{"type":"boolean","description":"User confirmation status, true if the user has joined the team or false otherwise.","x-example":false},"roles":{"type":"array","description":"User list of roles","items":{"type":"string"},"x-example":"admin"}},"required":["$id","userId","teamId","name","email","invited","joined","confirm","roles"]},"function":{"description":"Function","type":"object","properties":{"$id":{"type":"string","description":"Function ID.","x-example":"5e5ea5c16897e"},"$permissions":{"type":"object","description":"Function permissions.","x-example":{},"items":{"type":"object","$ref":"#\/definitions\/permissions"}},"name":{"type":"string","description":"Function name.","x-example":"My Function"},"dateCreated":{"type":"integer","description":"Function creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"dateUpdated":{"type":"integer","description":"Function update date in Unix timestamp.","x-example":1592981257,"format":"int32"},"status":{"type":"string","description":"Function status. Possible values: disabled, enabled","x-example":"enabled"},"env":{"type":"string","description":"Function execution environment.","x-example":"python-3.8"},"tag":{"type":"string","description":"Function active tag ID.","x-example":"5e5ea5c16897e"},"vars":{"type":"string","description":"Function environment variables.","x-example":{"key":"value"}},"events":{"type":"array","description":"Function trigger events.","items":{"type":"string"},"x-example":"account.create"},"schedule":{"type":"string","description":"Function execution schedult in CRON format.","x-example":"5 4 * * *"},"scheduleNext":{"type":"integer","description":"Function next scheduled execution date in Unix timestamp.","x-example":1592981292,"format":"int32"},"schedulePrevious":{"type":"integer","description":"Function next scheduled execution date in Unix timestamp.","x-example":1592981237,"format":"int32"},"timeout":{"type":"integer","description":"Function execution timeout in seconds.","x-example":1592981237,"format":"int32"}},"required":["$id","$permissions","name","dateCreated","dateUpdated","status","env","tag","vars","events","schedule","scheduleNext","schedulePrevious","timeout"]},"tag":{"description":"Tag","type":"object","properties":{"$id":{"type":"string","description":"Tag ID.","x-example":"5e5ea5c16897e"},"functionId":{"type":"string","description":"Function ID.","x-example":"5e5ea6g16897e"},"dateCreated":{"type":"integer","description":"The tag creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"command":{"type":"string","description":"The entrypoint command in use to execute the tag code.","x-example":"enabled"},"size":{"type":"string","description":"The code size in bytes.","x-example":"python-3.8"}},"required":["$id","functionId","dateCreated","command","size"]},"execution":{"description":"Execution","type":"object","properties":{"$id":{"type":"string","description":"Execution ID.","x-example":"5e5ea5c16897e"},"functionId":{"type":"string","description":"Function ID.","x-example":"5e5ea6g16897e"},"dateCreated":{"type":"integer","description":"The execution creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"trigger":{"type":"string","description":"The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.","x-example":"http"},"status":{"type":"string","description":"The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.","x-example":"processing"},"exitCode":{"type":"integer","description":"The script exit code.","x-example":0,"format":"int32"},"stdout":{"type":"string","description":"The script stdout output string.","x-example":""},"stderr":{"type":"string","description":"The script stderr output string.","x-example":""},"time":{"type":"number","description":"The script execution time in seconds.","x-example":0.4,"format":"float"}},"required":["$id","functionId","dateCreated","trigger","status","exitCode","stdout","stderr","time"]},"country":{"description":"Country","type":"object","properties":{"name":{"type":"string","description":"Country name.","x-example":"United States"},"code":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"}},"required":["name","code"]},"continent":{"description":"Continent","type":"object","properties":{"name":{"type":"string","description":"Continent name.","x-example":"Europe"},"code":{"type":"string","description":"Continent two letter code.","x-example":"EU"}},"required":["name","code"]},"language":{"description":"Language","type":"object","properties":{"name":{"type":"string","description":"Language name.","x-example":"Italian"},"code":{"type":"string","description":"Language two-character ISO 639-1 codes.","x-example":"it"},"nativeName":{"type":"string","description":"Language native name.","x-example":"Italiano"}},"required":["name","code","nativeName"]},"currency":{"description":"Currency","type":"object","properties":{"symbol":{"type":"string","description":"Currency symbol.","x-example":"$"},"name":{"type":"string","description":"Currency name.","x-example":"US dollar"},"symbolNative":{"type":"string","description":"Currency native symbol.","x-example":"$"},"decimalDigits":{"type":"integer","description":"Number of decimal digits.","x-example":2,"format":"int32"},"rounding":{"type":"number","description":"Currency digit rounding.","x-example":0,"format":"float"},"code":{"type":"string","description":"Currency code in [ISO 4217-1](http:\/\/en.wikipedia.org\/wiki\/ISO_4217) three-character format.","x-example":"USD"},"namePlural":{"type":"string","description":"Currency plural name","x-example":"US dollars"}},"required":["symbol","name","symbolNative","decimalDigits","rounding","code","namePlural"]},"phone":{"description":"Phone","type":"object","properties":{"code":{"type":"string","description":"Phone code.","x-example":"+1"},"countryCode":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"},"countryName":{"type":"string","description":"Country name.","x-example":"United States"}},"required":["code","countryCode","countryName"]}},"externalDocs":{"description":"Full API docs, specs and tutorials","url":"https:\/\/appwrite.io\/docs"}} \ No newline at end of file diff --git a/app/config/specs/0.7.0.console.json b/app/config/specs/0.7.0.console.json new file mode 100644 index 0000000000..16a044116d --- /dev/null +++ b/app/config/specs/0.7.0.console.json @@ -0,0 +1 @@ +{"swagger":"2.0","info":{"version":"0.7.0","title":"Appwrite","description":"Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)","termsOfService":"https:\/\/appwrite.io\/policy\/terms","contact":{"name":"Appwrite Team","url":"https:\/\/appwrite.io\/support","email":"team@appwrite.io"},"license":{"name":"BSD-3-Clause","url":"https:\/\/raw.githubusercontent.com\/appwrite\/appwrite\/master\/LICENSE"}},"host":"appwrite.io","basePath":"\/v1","schemes":["https"],"consumes":["application\/json","multipart\/form-data"],"produces":["application\/json"],"securityDefinitions":{"Project":{"type":"apiKey","name":"X-Appwrite-Project","description":"Your project ID","in":"header","x-appwrite":{"demo":"5df5acd0d48c2"}},"Key":{"type":"apiKey","name":"X-Appwrite-Key","description":"Your secret API key","in":"header","x-appwrite":{"demo":"919c2d18fb5d4...a2ae413da83346ad2"}},"Locale":{"type":"apiKey","name":"X-Appwrite-Locale","description":"","in":"header","x-appwrite":{"demo":"en"}},"Mode":{"type":"apiKey","name":"X-Appwrite-Mode","description":"","in":"header","x-appwrite":{"demo":""}}},"paths":{"\/account":{"get":{"summary":"Get Account","operationId":"accountGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Get currently logged in user data as JSON object.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"get","weight":42,"cookies":false,"type":"","demo":"account\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}]},"post":{"summary":"Create Account","operationId":"accountCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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#accountCreateVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](\/docs\/client\/account#accountCreateSession).","responses":{"201":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"create","weight":35,"cookies":false,"type":"","demo":"account\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"password":{"type":"string","description":"User password. Must be between 6 to 32 chars.","default":null,"x-example":"password"},"name":{"type":"string","description":"User name. Max length: 128 chars.","default":"","x-example":"[NAME]"}},"required":["email","password"]}}]},"delete":{"summary":"Delete Account","operationId":"accountDelete","consumes":["application\/json"],"produces":[],"tags":["account"],"description":"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.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"delete","weight":50,"cookies":false,"type":"","demo":"account\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/account\/email":{"patch":{"summary":"Update Account Email","operationId":"accountUpdateEmail","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"updateEmail","weight":48,"cookies":false,"type":"","demo":"account\/update-email.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-email.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"password":{"type":"string","description":"User password. Must be between 6 to 32 chars.","default":null,"x-example":"password"}},"required":["email","password"]}}]}},"\/account\/logs":{"get":{"summary":"Get Account Logs","operationId":"accountGetLogs","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.","responses":{"200":{"description":"Logs List","schema":{"$ref":"#\/definitions\/logList"}}},"x-appwrite":{"method":"getLogs","weight":45,"cookies":false,"type":"","demo":"account\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/account\/name":{"patch":{"summary":"Update Account Name","operationId":"accountUpdateName","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Update currently logged in user account name.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"updateName","weight":46,"cookies":false,"type":"","demo":"account\/update-name.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-name.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"User name. Max length: 128 chars.","default":null,"x-example":"[NAME]"}},"required":["name"]}}]}},"\/account\/password":{"patch":{"summary":"Update Account Password","operationId":"accountUpdatePassword","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Update currently logged in user password. For validation, user is required to pass the password twice.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"updatePassword","weight":47,"cookies":false,"type":"","demo":"account\/update-password.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-password.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"password":{"type":"string","description":"New user password. Must be between 6 to 32 chars.","default":null,"x-example":"password"},"oldPassword":{"type":"string","description":"Old user password. Must be between 6 to 32 chars.","default":null,"x-example":"password"}},"required":["password","oldPassword"]}}]}},"\/account\/prefs":{"get":{"summary":"Get Account Preferences","operationId":"accountGetPrefs","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Get currently logged in user preferences as a key-value object.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"getPrefs","weight":43,"cookies":false,"type":"","demo":"account\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}]},"patch":{"summary":"Update Account Preferences","operationId":"accountUpdatePrefs","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Update currently logged in user account preferences. You can pass only the specific settings you wish to update.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"updatePrefs","weight":49,"cookies":false,"type":"","demo":"account\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"prefs":{"type":"object","description":"Prefs key-value JSON object.","default":null,"x-example":"{}"}},"required":["prefs"]}}]}},"\/account\/recovery":{"post":{"summary":"Create Password Recovery","operationId":"accountCreateRecovery","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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#accountUpdateRecovery) endpoint to complete the process.","responses":{"201":{"description":"Token","schema":{"$ref":"#\/definitions\/token"}}},"x-appwrite":{"method":"createRecovery","weight":53,"cookies":false,"type":"","demo":"account\/create-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"url":{"type":"string","description":"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.","default":null,"x-example":"https:\/\/example.com"}},"required":["email","url"]}}]},"put":{"summary":"Complete Password Recovery","operationId":"accountUpdateRecovery","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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#accountCreateRecovery) endpoint.\n\nPlease 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.","responses":{"200":{"description":"Token","schema":{"$ref":"#\/definitions\/token"}}},"x-appwrite":{"method":"updateRecovery","weight":54,"cookies":false,"type":"","demo":"account\/update-recovery.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-recovery.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"userId":{"type":"string","description":"User account UID address.","default":null,"x-example":"[USER_ID]"},"secret":{"type":"string","description":"Valid reset token.","default":null,"x-example":"[SECRET]"},"password":{"type":"string","description":"New password. Must be between 6 to 32 chars.","default":null,"x-example":"password"},"passwordAgain":{"type":"string","description":"New password again. Must be between 6 to 32 chars.","default":null,"x-example":"password"}},"required":["userId","secret","password","passwordAgain"]}}]}},"\/account\/sessions":{"get":{"summary":"Get Account Sessions","operationId":"accountGetSessions","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Get currently logged in user list of active sessions across different devices.","responses":{"200":{"description":"Sessions List","schema":{"$ref":"#\/definitions\/sessionList"}}},"x-appwrite":{"method":"getSessions","weight":44,"cookies":false,"type":"","demo":"account\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/get-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}]},"post":{"summary":"Create Account Session","operationId":"accountCreateSession","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.","responses":{"201":{"description":"Session","schema":{"$ref":"#\/definitions\/session"}}},"x-appwrite":{"method":"createSession","weight":36,"cookies":false,"type":"","demo":"account\/create-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"password":{"type":"string","description":"User password. Must be between 6 to 32 chars.","default":null,"x-example":"password"}},"required":["email","password"]}}]},"delete":{"summary":"Delete All Account Sessions","operationId":"accountDeleteSessions","consumes":["application\/json"],"produces":[],"tags":["account"],"description":"Delete all sessions from the user account and remove any sessions cookies from the end client.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteSessions","weight":52,"cookies":false,"type":"","demo":"account\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-sessions.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/account\/sessions\/oauth2\/{provider}":{"get":{"summary":"Create Account Session with OAuth2","operationId":"accountCreateOAuth2Session","consumes":["application\/json"],"produces":["text\/html"],"tags":["account"],"description":"Allow the user to login to their account using the OAuth2 provider of their 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.","responses":{"301":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"createOAuth2Session","weight":37,"cookies":false,"type":"webAuth","demo":"account\/create-o-auth2session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-session-oauth2.md","rate-limit":50,"rate-time":3600,"rate-key":"ip:{ip}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"provider","description":"OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yandex, wordpress.","required":true,"type":"string","x-example":"amazon","in":"path"},{"name":"success","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"https:\/\/appwrite.io\/auth\/oauth2\/success","in":"query"},{"name":"failure","description":"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.","required":false,"type":"string","format":"url","x-example":"https:\/\/example.com","default":"https:\/\/appwrite.io\/auth\/oauth2\/failure","in":"query"},{"name":"scopes","description":"A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"}]}},"\/account\/sessions\/{sessionId}":{"delete":{"summary":"Delete Account Session","operationId":"accountDeleteSession","consumes":["application\/json"],"produces":[],"tags":["account"],"description":"Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteSession","weight":51,"cookies":false,"type":"","demo":"account\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/delete-session.md","rate-limit":100,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"sessionId","description":"Session unique ID. Use the string 'current' to delete the current device session.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/account\/verification":{"post":{"summary":"Create Email Verification","operationId":"accountCreateVerification","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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#accountUpdateVerification). \n\nPlease 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.\n","responses":{"201":{"description":"Token","schema":{"$ref":"#\/definitions\/token"}}},"x-appwrite":{"method":"createVerification","weight":55,"cookies":false,"type":"","demo":"account\/create-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/create-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},email:{param-email}","scope":"account","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"url":{"type":"string","description":"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.","default":null,"x-example":"https:\/\/example.com"}},"required":["url"]}}]},"put":{"summary":"Complete Email Verification","operationId":"accountUpdateVerification","consumes":["application\/json"],"produces":["application\/json"],"tags":["account"],"description":"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.","responses":{"200":{"description":"Token","schema":{"$ref":"#\/definitions\/token"}}},"x-appwrite":{"method":"updateVerification","weight":56,"cookies":false,"type":"","demo":"account\/update-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/account\/update-verification.md","rate-limit":10,"rate-time":3600,"rate-key":"url:{url},userId:{param-userId}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"userId":{"type":"string","description":"User unique ID.","default":null,"x-example":"[USER_ID]"},"secret":{"type":"string","description":"Valid verification token.","default":null,"x-example":"[SECRET]"}},"required":["userId","secret"]}}]}},"\/avatars\/browsers\/{code}":{"get":{"summary":"Get Browser Icon","operationId":"avatarsGetBrowser","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getBrowser","weight":58,"cookies":false,"type":"location","demo":"avatars\/get-browser.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-browser.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Browser Code.","required":true,"type":"string","x-example":"aa","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/credit-cards\/{code}":{"get":{"summary":"Get Credit Card Icon","operationId":"avatarsGetCreditCard","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getCreditCard","weight":57,"cookies":false,"type":"location","demo":"avatars\/get-credit-card.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-credit-card.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.","required":true,"type":"string","x-example":"amex","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/favicon":{"get":{"summary":"Get Favicon","operationId":"avatarsGetFavicon","consumes":["application\/json"],"produces":["image\/*"],"tags":["avatars"],"description":"Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL.\n","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getFavicon","weight":61,"cookies":false,"type":"location","demo":"avatars\/get-favicon.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-favicon.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Website URL which you want to fetch the favicon from.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"}]}},"\/avatars\/flags\/{code}":{"get":{"summary":"Get Country Flag","operationId":"avatarsGetFlag","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getFlag","weight":59,"cookies":false,"type":"location","demo":"avatars\/get-flag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-flag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Country Code. ISO Alpha-2 country code format.","required":true,"type":"string","x-example":"af","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/image":{"get":{"summary":"Get Image from URL","operationId":"avatarsGetImage","consumes":["application\/json"],"produces":["image\/*"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getImage","weight":60,"cookies":false,"type":"location","demo":"avatars\/get-image.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-image.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Image URL which you want to crop.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"}]}},"\/avatars\/initials":{"get":{"summary":"Get User Initials","operationId":"avatarsGetInitials","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.\n\nYou 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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getInitials","weight":63,"cookies":false,"type":"location","demo":"avatars\/get-initials.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-initials.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Full Name. When empty, current user name or email will be used. Max length: 128 chars.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"query"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"color","description":"Changes text color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"},{"name":"background","description":"Changes background color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"}]}},"\/avatars\/qr":{"get":{"summary":"Get QR Code","operationId":"avatarsGetQR","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getQR","weight":62,"cookies":false,"type":"location","demo":"avatars\/get-q-r.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-qr.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"text","description":"Plain text to be converted to QR code image.","required":true,"type":"string","x-example":"[TEXT]","in":"query"},{"name":"size","description":"QR code size. Pass an integer between 0 to 1000. Defaults to 400.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"margin","description":"Margin from edge. Pass an integer between 0 to 10. Defaults to 1.","required":false,"type":"integer","format":"int32","x-example":0,"default":1,"in":"query"},{"name":"download","description":"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.","required":false,"type":"boolean","x-example":false,"default":false,"in":"query"}]}},"\/database\/collections":{"get":{"summary":"List Collections","operationId":"databaseListCollections","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's collections. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Collections List","schema":{"$ref":"#\/definitions\/collectionList"}}},"x-appwrite":{"method":"listCollections","weight":65,"cookies":false,"type":"","demo":"database\/list-collections.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-collections.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Collection","operationId":"databaseCreateCollection","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Create a new Collection.","responses":{"201":{"description":"Collection","schema":{"$ref":"#\/definitions\/collection"}}},"x-appwrite":{"method":"createCollection","weight":64,"cookies":false,"type":"","demo":"database\/create-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Collection name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"rules":{"type":"array","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","default":null,"x-example":null,"items":{"type":"string"}}},"required":["name","read","write","rules"]}}]}},"\/database\/collections\/{collectionId}":{"get":{"summary":"Get Collection","operationId":"databaseGetCollection","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.","responses":{"200":{"description":"Collection","schema":{"$ref":"#\/definitions\/collection"}}},"x-appwrite":{"method":"getCollection","weight":66,"cookies":false,"type":"","demo":"database\/get-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]},"put":{"summary":"Update Collection","operationId":"databaseUpdateCollection","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Update a collection by its unique ID.","responses":{"200":{"description":"Collection","schema":{"$ref":"#\/definitions\/collection"}}},"x-appwrite":{"method":"updateCollection","weight":67,"cookies":false,"type":"","demo":"database\/update-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Collection name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"rules":{"type":"array","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","default":[],"x-example":null,"items":{"type":"string"}}},"required":["name","read","write"]}}]},"delete":{"summary":"Delete Collection","operationId":"databaseDeleteCollection","consumes":["application\/json"],"produces":[],"tags":["database"],"description":"Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteCollection","weight":68,"cookies":false,"type":"","demo":"database\/delete-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]}},"\/database\/collections\/{collectionId}\/documents":{"get":{"summary":"List Documents","operationId":"databaseListDocuments","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"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's documents. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Documents List","schema":{"$ref":"#\/definitions\/documentList"}}},"x-appwrite":{"method":"listDocuments","weight":70,"cookies":false,"type":"","demo":"database\/list-documents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-documents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"filters","description":"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'.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"},{"name":"limit","description":"Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Offset value. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderField","description":"Document field that results will be sorted by.","required":false,"type":"string","x-example":"[ORDER_FIELD]","default":"","in":"query"},{"name":"orderType","description":"Order direction. Possible values are DESC for descending order, or ASC for ascending order.","required":false,"type":"string","x-example":"DESC","default":"ASC","in":"query"},{"name":"orderCast","description":"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.","required":false,"type":"string","x-example":"int","default":"string","in":"query"},{"name":"search","description":"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.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"}]},"post":{"summary":"Create Document","operationId":"databaseCreateDocument","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](\/docs\/server\/database#databaseCreateCollection) API or directly from your database console.","responses":{"201":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"createDocument","weight":69,"cookies":false,"type":"","demo":"database\/create-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"data":{"type":"object","description":"Document data as JSON object.","default":null,"x-example":"{}"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"parentDocument":{"type":"string","description":"Parent document unique ID. Use when you want your new document to be a child of a parent document.","default":"","x-example":"[PARENT_DOCUMENT]"},"parentProperty":{"type":"string","description":"Parent document property name. Use when you want your new document to be a child of a parent document.","default":"","x-example":null},"parentPropertyType":{"type":"string","description":"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.","default":"assign","x-example":"assign"}},"required":["data","read","write"]}}]}},"\/database\/collections\/{collectionId}\/documents\/{documentId}":{"get":{"summary":"Get Document","operationId":"databaseGetDocument","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Get a document by its unique ID. This endpoint response returns a JSON object with the document data.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"getDocument","weight":71,"cookies":false,"type":"","demo":"database\/get-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]},"patch":{"summary":"Update Document","operationId":"databaseUpdateDocument","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"updateDocument","weight":72,"cookies":false,"type":"","demo":"database\/update-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"data":{"type":"object","description":"Document data as JSON object.","default":null,"x-example":"{}"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}}},"required":["data","read","write"]}}]},"delete":{"summary":"Delete Document","operationId":"databaseDeleteDocument","consumes":["application\/json"],"produces":[],"tags":["database"],"description":"Delete a document by its unique ID. This endpoint deletes only the parent documents, its attributes and relations to other documents. Child documents **will not** be deleted.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteDocument","weight":73,"cookies":false,"type":"","demo":"database\/delete-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]}},"\/functions":{"get":{"summary":"List Functions","operationId":"functionsList","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a list of all the project's functions. You can use the query params to filter your results.","responses":{"200":{"description":"Functions List","schema":{"$ref":"#\/definitions\/functionList"}}},"x-appwrite":{"method":"list","weight":156,"cookies":false,"type":"","demo":"functions\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/list-functions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Function","operationId":"functionsCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Create a new function. You can pass a list of [permissions](\/docs\/permissions) to allow different project users or team with access to execute the function using the client API.","responses":{"201":{"description":"Function","schema":{"$ref":"#\/definitions\/function"}}},"x-appwrite":{"method":"create","weight":155,"cookies":false,"type":"","demo":"functions\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/create-function.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"execute":{"type":"array","description":"An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](\/docs\/permissions) and get a full list of available permissions.","default":null,"x-example":null,"items":{"type":"string"}},"env":{"type":"string","description":"Execution enviornment.","default":null,"x-example":"node-14.5"},"vars":{"type":"object","description":"Key-value JSON object.","default":{},"x-example":"{}"},"events":{"type":"array","description":"Events list.","default":[],"x-example":null,"items":{"type":"string"}},"schedule":{"type":"string","description":"Schedule CRON syntax.","default":"","x-example":null},"timeout":{"type":"integer","description":"Function maximum execution time in seconds.","default":15,"x-example":1}},"required":["name","execute","env"]}}]}},"\/functions\/{functionId}":{"get":{"summary":"Get Function","operationId":"functionsGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a function by its unique ID.","responses":{"200":{"description":"Function","schema":{"$ref":"#\/definitions\/function"}}},"x-appwrite":{"method":"get","weight":157,"cookies":false,"type":"","demo":"functions\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/get-function.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"}]},"put":{"summary":"Update Function","operationId":"functionsUpdate","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Update function by its unique ID.","responses":{"200":{"description":"Function","schema":{"$ref":"#\/definitions\/function"}}},"x-appwrite":{"method":"update","weight":159,"cookies":false,"type":"","demo":"functions\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/update-function.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"execute":{"type":"array","description":"An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](\/docs\/permissions) and get a full list of available permissions.","default":null,"x-example":null,"items":{"type":"string"}},"vars":{"type":"object","description":"Key-value JSON object.","default":{},"x-example":"{}"},"events":{"type":"array","description":"Events list.","default":[],"x-example":null,"items":{"type":"string"}},"schedule":{"type":"string","description":"Schedule CRON syntax.","default":"","x-example":null},"timeout":{"type":"integer","description":"Function maximum execution time in seconds.","default":15,"x-example":1}},"required":["name","execute"]}}]},"delete":{"summary":"Delete Function","operationId":"functionsDelete","consumes":["application\/json"],"produces":[],"tags":["functions"],"description":"Delete a function by its unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"delete","weight":161,"cookies":false,"type":"","demo":"functions\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/delete-function.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"}]}},"\/functions\/{functionId}\/executions":{"get":{"summary":"List Executions","operationId":"functionsListExecutions","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a list of all the current user function execution logs. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's teams. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Executions List","schema":{"$ref":"#\/definitions\/executionList"}}},"x-appwrite":{"method":"listExecutions","weight":167,"cookies":false,"type":"","demo":"functions\/list-executions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/list-executions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"execution.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Execution","operationId":"functionsCreateExecution","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.","responses":{"201":{"description":"Execution","schema":{"$ref":"#\/definitions\/execution"}}},"x-appwrite":{"method":"createExecution","weight":166,"cookies":false,"type":"","demo":"functions\/create-execution.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/create-execution.md","rate-limit":60,"rate-time":60,"rate-key":"url:{url},ip:{ip}","scope":"execution.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"}]}},"\/functions\/{functionId}\/executions\/{executionId}":{"get":{"summary":"Get Execution","operationId":"functionsGetExecution","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a function execution log by its unique ID.","responses":{"200":{"description":"Execution","schema":{"$ref":"#\/definitions\/execution"}}},"x-appwrite":{"method":"getExecution","weight":168,"cookies":false,"type":"","demo":"functions\/get-execution.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/get-execution.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"execution.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"executionId","description":"Execution unique ID.","required":true,"type":"string","x-example":"[EXECUTION_ID]","in":"path"}]}},"\/functions\/{functionId}\/tag":{"patch":{"summary":"Update Function Tag","operationId":"functionsUpdateTag","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Update the function code tag ID using the unique function ID. Use this endpoint to switch the code tag that should be executed by the execution endpoint.","responses":{"200":{"description":"Function","schema":{"$ref":"#\/definitions\/function"}}},"x-appwrite":{"method":"updateTag","weight":160,"cookies":false,"type":"","demo":"functions\/update-tag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/update-function-tag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"tag":{"type":"string","description":"Tag unique ID.","default":null,"x-example":"[TAG]"}},"required":["tag"]}}]}},"\/functions\/{functionId}\/tags":{"get":{"summary":"List Tags","operationId":"functionsListTags","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a list of all the project's code tags. You can use the query params to filter your results.","responses":{"200":{"description":"Tags List","schema":{"$ref":"#\/definitions\/tagList"}}},"x-appwrite":{"method":"listTags","weight":163,"cookies":false,"type":"","demo":"functions\/list-tags.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/list-tags.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Tag","operationId":"functionsCreateTag","consumes":["multipart\/form-data"],"produces":["application\/json"],"tags":["functions"],"description":"Create a new function code tag. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's tag to use your new tag UID.\n\nThis endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](\/docs\/functions).\n\nUse the \"command\" param to set the entry point used to execute your code.","responses":{"201":{"description":"Tag","schema":{"$ref":"#\/definitions\/tag"}}},"x-appwrite":{"method":"createTag","weight":162,"cookies":false,"type":"","demo":"functions\/create-tag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/create-tag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":true},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"command","description":"Code execution command.","required":true,"type":"string","x-example":"[COMMAND]","in":"formData"},{"name":"code","description":"Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.","required":true,"type":"file","in":"formData"}]}},"\/functions\/{functionId}\/tags\/{tagId}":{"get":{"summary":"Get Tag","operationId":"functionsGetTag","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a code tag by its unique ID.","responses":{"200":{"description":"Tag","schema":{"$ref":"#\/definitions\/tag"}}},"x-appwrite":{"method":"getTag","weight":164,"cookies":false,"type":"","demo":"functions\/get-tag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/get-tag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"tagId","description":"Tag unique ID.","required":true,"type":"string","x-example":"[TAG_ID]","in":"path"}]},"delete":{"summary":"Delete Tag","operationId":"functionsDeleteTag","consumes":["application\/json"],"produces":[],"tags":["functions"],"description":"Delete a code tag by its unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteTag","weight":165,"cookies":false,"type":"","demo":"functions\/delete-tag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/delete-tag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"tagId","description":"Tag unique ID.","required":true,"type":"string","x-example":"[TAG_ID]","in":"path"}]}},"\/functions\/{functionId}\/usage":{"get":{"summary":"Get Function Usage","operationId":"functionsGetUsage","consumes":["application\/json"],"produces":[],"tags":["functions"],"description":"","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getUsage","weight":158,"cookies":false,"type":"","demo":"functions\/get-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.read","platforms":["console"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"range","description":"Date range.","required":false,"type":"string","x-example":"24h","default":"30d","in":"query"}]}},"\/health":{"get":{"summary":"Get HTTP","operationId":"healthGet","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite HTTP server is up and responsive.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"get","weight":81,"cookies":false,"type":"","demo":"health\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/anti-virus":{"get":{"summary":"Get Anti virus","operationId":"healthGetAntiVirus","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite Anti Virus server is up and connection is successful.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getAntiVirus","weight":93,"cookies":false,"type":"","demo":"health\/get-anti-virus.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-anti-virus.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/cache":{"get":{"summary":"Get Cache","operationId":"healthGetCache","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite in-memory cache server is up and connection is successful.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getCache","weight":84,"cookies":false,"type":"","demo":"health\/get-cache.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-cache.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/db":{"get":{"summary":"Get DB","operationId":"healthGetDB","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite database server is up and connection is successful.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getDB","weight":83,"cookies":false,"type":"","demo":"health\/get-d-b.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-db.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/certificates":{"get":{"summary":"Get Certificate Queue","operationId":"healthGetQueueCertificates","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of certificates that are waiting to be issued against [Letsencrypt](https:\/\/letsencrypt.org\/) in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueCertificates","weight":90,"cookies":false,"type":"","demo":"health\/get-queue-certificates.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-certificates.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/functions":{"get":{"summary":"Get Functions Queue","operationId":"healthGetQueueFunctions","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueFunctions","weight":91,"cookies":false,"type":"","demo":"health\/get-queue-functions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-functions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/logs":{"get":{"summary":"Get Logs Queue","operationId":"healthGetQueueLogs","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of logs that are waiting to be processed in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueLogs","weight":88,"cookies":false,"type":"","demo":"health\/get-queue-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/tasks":{"get":{"summary":"Get Tasks Queue","operationId":"healthGetQueueTasks","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of tasks that are waiting to be processed in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueTasks","weight":87,"cookies":false,"type":"","demo":"health\/get-queue-tasks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-tasks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/usage":{"get":{"summary":"Get Usage Queue","operationId":"healthGetQueueUsage","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueUsage","weight":89,"cookies":false,"type":"","demo":"health\/get-queue-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-usage.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/webhooks":{"get":{"summary":"Get Webhooks Queue","operationId":"healthGetQueueWebhooks","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueWebhooks","weight":86,"cookies":false,"type":"","demo":"health\/get-queue-webhooks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-webhooks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/storage\/local":{"get":{"summary":"Get Local Storage","operationId":"healthGetStorageLocal","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite local storage device is up and connection is successful.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getStorageLocal","weight":92,"cookies":false,"type":"","demo":"health\/get-storage-local.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-local.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/time":{"get":{"summary":"Get Time","operationId":"healthGetTime","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https:\/\/en.wikipedia.org\/wiki\/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getTime","weight":85,"cookies":false,"type":"","demo":"health\/get-time.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-time.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale":{"get":{"summary":"Get User Locale","operationId":"localeGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"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.\n\n([IP Geolocation by DB-IP](https:\/\/db-ip.com))","responses":{"200":{"description":"Locale","schema":{"$ref":"#\/definitions\/locale"}}},"x-appwrite":{"method":"get","weight":74,"cookies":false,"type":"","demo":"locale\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-locale.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/continents":{"get":{"summary":"List Continents","operationId":"localeGetContinents","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all continents. You can use the locale header to get the data in a supported language.","responses":{"200":{"description":"Continents List","schema":{"$ref":"#\/definitions\/continentList"}}},"x-appwrite":{"method":"getContinents","weight":78,"cookies":false,"type":"","demo":"locale\/get-continents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-continents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries":{"get":{"summary":"List Countries","operationId":"localeGetCountries","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all countries. You can use the locale header to get the data in a supported language.","responses":{"200":{"description":"Countries List","schema":{"$ref":"#\/definitions\/countryList"}}},"x-appwrite":{"method":"getCountries","weight":75,"cookies":false,"type":"","demo":"locale\/get-countries.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/eu":{"get":{"summary":"List EU Countries","operationId":"localeGetCountriesEU","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"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.","responses":{"200":{"description":"Countries List","schema":{"$ref":"#\/definitions\/countryList"}}},"x-appwrite":{"method":"getCountriesEU","weight":76,"cookies":false,"type":"","demo":"locale\/get-countries-e-u.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-eu.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/phones":{"get":{"summary":"List Countries Phone Codes","operationId":"localeGetCountriesPhones","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all countries phone codes. You can use the locale header to get the data in a supported language.","responses":{"200":{"description":"Phones List","schema":{"$ref":"#\/definitions\/phoneList"}}},"x-appwrite":{"method":"getCountriesPhones","weight":77,"cookies":false,"type":"","demo":"locale\/get-countries-phones.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-phones.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/currencies":{"get":{"summary":"List Currencies","operationId":"localeGetCurrencies","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"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.","responses":{"200":{"description":"Currencies List","schema":{"$ref":"#\/definitions\/currencyList"}}},"x-appwrite":{"method":"getCurrencies","weight":79,"cookies":false,"type":"","demo":"locale\/get-currencies.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-currencies.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/languages":{"get":{"summary":"List Languages","operationId":"localeGetLanguages","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.","responses":{"200":{"description":"Languages List","schema":{"$ref":"#\/definitions\/languageList"}}},"x-appwrite":{"method":"getLanguages","weight":80,"cookies":false,"type":"","demo":"locale\/get-languages.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-languages.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/projects":{"get":{"summary":"List Projects","operationId":"projectsList","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Projects List","schema":{"$ref":"#\/definitions\/projectList"}}},"x-appwrite":{"method":"list","weight":96,"cookies":false,"type":"","demo":"projects\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Project","operationId":"projectsCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"201":{"description":"Project","schema":{"$ref":"#\/definitions\/project"}}},"x-appwrite":{"method":"create","weight":95,"cookies":false,"type":"","demo":"projects\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Project name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"teamId":{"type":"string","description":"Team unique ID.","default":null,"x-example":"[TEAM_ID]"},"description":{"type":"string","description":"Project description. Max length: 256 chars.","default":"","x-example":"[DESCRIPTION]"},"logo":{"type":"string","description":"Project logo.","default":"","x-example":"[LOGO]"},"url":{"type":"string","description":"Project URL.","default":"","x-example":"https:\/\/example.com"},"legalName":{"type":"string","description":"Project legal Name. Max length: 256 chars.","default":"","x-example":"[LEGAL_NAME]"},"legalCountry":{"type":"string","description":"Project legal Country. Max length: 256 chars.","default":"","x-example":"[LEGAL_COUNTRY]"},"legalState":{"type":"string","description":"Project legal State. Max length: 256 chars.","default":"","x-example":"[LEGAL_STATE]"},"legalCity":{"type":"string","description":"Project legal City. Max length: 256 chars.","default":"","x-example":"[LEGAL_CITY]"},"legalAddress":{"type":"string","description":"Project legal Address. Max length: 256 chars.","default":"","x-example":"[LEGAL_ADDRESS]"},"legalTaxId":{"type":"string","description":"Project legal Tax ID. Max length: 256 chars.","default":"","x-example":"[LEGAL_TAX_ID]"}},"required":["name","teamId"]}}]}},"\/projects\/{projectId}":{"get":{"summary":"Get Project","operationId":"projectsGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Project","schema":{"$ref":"#\/definitions\/project"}}},"x-appwrite":{"method":"get","weight":97,"cookies":false,"type":"","demo":"projects\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"patch":{"summary":"Update Project","operationId":"projectsUpdate","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Project","schema":{"$ref":"#\/definitions\/project"}}},"x-appwrite":{"method":"update","weight":99,"cookies":false,"type":"","demo":"projects\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Project name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"description":{"type":"string","description":"Project description. Max length: 256 chars.","default":"","x-example":"[DESCRIPTION]"},"logo":{"type":"string","description":"Project logo.","default":"","x-example":"[LOGO]"},"url":{"type":"string","description":"Project URL.","default":"","x-example":"https:\/\/example.com"},"legalName":{"type":"string","description":"Project legal name. Max length: 256 chars.","default":"","x-example":"[LEGAL_NAME]"},"legalCountry":{"type":"string","description":"Project legal country. Max length: 256 chars.","default":"","x-example":"[LEGAL_COUNTRY]"},"legalState":{"type":"string","description":"Project legal state. Max length: 256 chars.","default":"","x-example":"[LEGAL_STATE]"},"legalCity":{"type":"string","description":"Project legal city. Max length: 256 chars.","default":"","x-example":"[LEGAL_CITY]"},"legalAddress":{"type":"string","description":"Project legal address. Max length: 256 chars.","default":"","x-example":"[LEGAL_ADDRESS]"},"legalTaxId":{"type":"string","description":"Project legal tax ID. Max length: 256 chars.","default":"","x-example":"[LEGAL_TAX_ID]"}},"required":["name"]}}]},"delete":{"summary":"Delete Project","operationId":"projectsDelete","consumes":["application\/json"],"produces":[],"tags":["projects"],"description":"","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"delete","weight":101,"cookies":false,"type":"","demo":"projects\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"password":{"type":"string","description":"Your user password for confirmation. Must be between 6 to 32 chars.","default":null,"x-example":"[PASSWORD]"}},"required":["password"]}}]}},"\/projects\/{projectId}\/domains":{"get":{"summary":"List Domains","operationId":"projectsListDomains","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Domains List","schema":{"$ref":"#\/definitions\/domainList"}}},"x-appwrite":{"method":"listDomains","weight":123,"cookies":false,"type":"","demo":"projects\/list-domains.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Domain","operationId":"projectsCreateDomain","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"201":{"description":"Domain","schema":{"$ref":"#\/definitions\/domain"}}},"x-appwrite":{"method":"createDomain","weight":122,"cookies":false,"type":"","demo":"projects\/create-domain.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"domain":{"type":"string","description":"Domain name.","default":null,"x-example":null}},"required":["domain"]}}]}},"\/projects\/{projectId}\/domains\/{domainId}":{"get":{"summary":"Get Domain","operationId":"projectsGetDomain","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Domain","schema":{"$ref":"#\/definitions\/domain"}}},"x-appwrite":{"method":"getDomain","weight":124,"cookies":false,"type":"","demo":"projects\/get-domain.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domainId","description":"Domain unique ID.","required":true,"type":"string","x-example":"[DOMAIN_ID]","in":"path"}]},"delete":{"summary":"Delete Domain","operationId":"projectsDeleteDomain","consumes":["application\/json"],"produces":[],"tags":["projects"],"description":"","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteDomain","weight":126,"cookies":false,"type":"","demo":"projects\/delete-domain.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domainId","description":"Domain unique ID.","required":true,"type":"string","x-example":"[DOMAIN_ID]","in":"path"}]}},"\/projects\/{projectId}\/domains\/{domainId}\/verification":{"patch":{"summary":"Update Domain Verification Status","operationId":"projectsUpdateDomainVerification","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Domain","schema":{"$ref":"#\/definitions\/domain"}}},"x-appwrite":{"method":"updateDomainVerification","weight":125,"cookies":false,"type":"","demo":"projects\/update-domain-verification.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"domainId","description":"Domain unique ID.","required":true,"type":"string","x-example":"[DOMAIN_ID]","in":"path"}]}},"\/projects\/{projectId}\/keys":{"get":{"summary":"List Keys","operationId":"projectsListKeys","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"API Keys List","schema":{"$ref":"#\/definitions\/keyList"}}},"x-appwrite":{"method":"listKeys","weight":108,"cookies":false,"type":"","demo":"projects\/list-keys.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Key","operationId":"projectsCreateKey","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"201":{"description":"Key","schema":{"$ref":"#\/definitions\/key"}}},"x-appwrite":{"method":"createKey","weight":107,"cookies":false,"type":"","demo":"projects\/create-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Key name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"scopes":{"type":"array","description":"Key scopes list.","default":null,"x-example":null,"items":{"type":"string"}}},"required":["name","scopes"]}}]}},"\/projects\/{projectId}\/keys\/{keyId}":{"get":{"summary":"Get Key","operationId":"projectsGetKey","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Key","schema":{"$ref":"#\/definitions\/key"}}},"x-appwrite":{"method":"getKey","weight":109,"cookies":false,"type":"","demo":"projects\/get-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"keyId","description":"Key unique ID.","required":true,"type":"string","x-example":"[KEY_ID]","in":"path"}]},"put":{"summary":"Update Key","operationId":"projectsUpdateKey","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Key","schema":{"$ref":"#\/definitions\/key"}}},"x-appwrite":{"method":"updateKey","weight":110,"cookies":false,"type":"","demo":"projects\/update-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"keyId","description":"Key unique ID.","required":true,"type":"string","x-example":"[KEY_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Key name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"scopes":{"type":"array","description":"Key scopes list","default":null,"x-example":null,"items":{"type":"string"}}},"required":["name","scopes"]}}]},"delete":{"summary":"Delete Key","operationId":"projectsDeleteKey","consumes":["application\/json"],"produces":[],"tags":["projects"],"description":"","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteKey","weight":111,"cookies":false,"type":"","demo":"projects\/delete-key.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"keyId","description":"Key unique ID.","required":true,"type":"string","x-example":"[KEY_ID]","in":"path"}]}},"\/projects\/{projectId}\/oauth2":{"patch":{"summary":"Update Project OAuth2","operationId":"projectsUpdateOAuth2","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Project","schema":{"$ref":"#\/definitions\/project"}}},"x-appwrite":{"method":"updateOAuth2","weight":100,"cookies":false,"type":"","demo":"projects\/update-o-auth2.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"provider":{"type":"string","description":"Provider Name","default":null,"x-example":"amazon"},"appId":{"type":"string","description":"Provider app ID. Max length: 256 chars.","default":"","x-example":"[APP_ID]"},"secret":{"type":"string","description":"Provider secret key. Max length: 512 chars.","default":"","x-example":"[SECRET]"}},"required":["provider"]}}]}},"\/projects\/{projectId}\/platforms":{"get":{"summary":"List Platforms","operationId":"projectsListPlatforms","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Platforms List","schema":{"$ref":"#\/definitions\/platformList"}}},"x-appwrite":{"method":"listPlatforms","weight":118,"cookies":false,"type":"","demo":"projects\/list-platforms.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Platform","operationId":"projectsCreatePlatform","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"201":{"description":"Platform","schema":{"$ref":"#\/definitions\/platform"}}},"x-appwrite":{"method":"createPlatform","weight":117,"cookies":false,"type":"","demo":"projects\/create-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"type":{"type":"string","description":"Platform type.","default":null,"x-example":"web"},"name":{"type":"string","description":"Platform name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"key":{"type":"string","description":"Package name for android or bundle ID for iOS. Max length: 256 chars.","default":"","x-example":"[KEY]"},"store":{"type":"string","description":"App store or Google Play store ID. Max length: 256 chars.","default":"","x-example":"[STORE]"},"hostname":{"type":"string","description":"Platform client hostname. Max length: 256 chars.","default":"","x-example":"[HOSTNAME]"}},"required":["type","name"]}}]}},"\/projects\/{projectId}\/platforms\/{platformId}":{"get":{"summary":"Get Platform","operationId":"projectsGetPlatform","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Platform","schema":{"$ref":"#\/definitions\/platform"}}},"x-appwrite":{"method":"getPlatform","weight":119,"cookies":false,"type":"","demo":"projects\/get-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"platformId","description":"Platform unique ID.","required":true,"type":"string","x-example":"[PLATFORM_ID]","in":"path"}]},"put":{"summary":"Update Platform","operationId":"projectsUpdatePlatform","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Platform","schema":{"$ref":"#\/definitions\/platform"}}},"x-appwrite":{"method":"updatePlatform","weight":120,"cookies":false,"type":"","demo":"projects\/update-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"platformId","description":"Platform unique ID.","required":true,"type":"string","x-example":"[PLATFORM_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Platform name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"key":{"type":"string","description":"Package name for android or bundle ID for iOS. Max length: 256 chars.","default":"","x-example":"[KEY]"},"store":{"type":"string","description":"App store or Google Play store ID. Max length: 256 chars.","default":"","x-example":"[STORE]"},"hostname":{"type":"string","description":"Platform client URL. Max length: 256 chars.","default":"","x-example":"[HOSTNAME]"}},"required":["name"]}}]},"delete":{"summary":"Delete Platform","operationId":"projectsDeletePlatform","consumes":["application\/json"],"produces":[],"tags":["projects"],"description":"","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deletePlatform","weight":121,"cookies":false,"type":"","demo":"projects\/delete-platform.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"platformId","description":"Platform unique ID.","required":true,"type":"string","x-example":"[PLATFORM_ID]","in":"path"}]}},"\/projects\/{projectId}\/tasks":{"get":{"summary":"List Tasks","operationId":"projectsListTasks","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Tasks List","schema":{"$ref":"#\/definitions\/taskList"}}},"x-appwrite":{"method":"listTasks","weight":113,"cookies":false,"type":"","demo":"projects\/list-tasks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Task","operationId":"projectsCreateTask","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"201":{"description":"Task","schema":{"$ref":"#\/definitions\/task"}}},"x-appwrite":{"method":"createTask","weight":112,"cookies":false,"type":"","demo":"projects\/create-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Task name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"status":{"type":"string","description":"Task status.","default":null,"x-example":"play"},"schedule":{"type":"string","description":"Task schedule CRON syntax.","default":null,"x-example":null},"security":{"type":"boolean","description":"Certificate verification, false for disabled or true for enabled.","default":null,"x-example":false},"httpMethod":{"type":"string","description":"Task HTTP method.","default":null,"x-example":"GET"},"httpUrl":{"type":"string","description":"Task HTTP URL","default":null,"x-example":"https:\/\/example.com"},"httpHeaders":{"type":"array","description":"Task HTTP headers list.","default":null,"x-example":null,"items":{"type":"string"}},"httpUser":{"type":"string","description":"Task HTTP user. Max length: 256 chars.","default":"","x-example":"[HTTP_USER]"},"httpPass":{"type":"string","description":"Task HTTP password. Max length: 256 chars.","default":"","x-example":"[HTTP_PASS]"}},"required":["name","status","schedule","security","httpMethod","httpUrl"]}}]}},"\/projects\/{projectId}\/tasks\/{taskId}":{"get":{"summary":"Get Task","operationId":"projectsGetTask","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Task","schema":{"$ref":"#\/definitions\/task"}}},"x-appwrite":{"method":"getTask","weight":114,"cookies":false,"type":"","demo":"projects\/get-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"taskId","description":"Task unique ID.","required":true,"type":"string","x-example":"[TASK_ID]","in":"path"}]},"put":{"summary":"Update Task","operationId":"projectsUpdateTask","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Task","schema":{"$ref":"#\/definitions\/task"}}},"x-appwrite":{"method":"updateTask","weight":115,"cookies":false,"type":"","demo":"projects\/update-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"taskId","description":"Task unique ID.","required":true,"type":"string","x-example":"[TASK_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Task name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"status":{"type":"string","description":"Task status.","default":null,"x-example":"play"},"schedule":{"type":"string","description":"Task schedule CRON syntax.","default":null,"x-example":null},"security":{"type":"boolean","description":"Certificate verification, false for disabled or true for enabled.","default":null,"x-example":false},"httpMethod":{"type":"string","description":"Task HTTP method.","default":null,"x-example":"GET"},"httpUrl":{"type":"string","description":"Task HTTP URL.","default":null,"x-example":"https:\/\/example.com"},"httpHeaders":{"type":"array","description":"Task HTTP headers list.","default":null,"x-example":null,"items":{"type":"string"}},"httpUser":{"type":"string","description":"Task HTTP user. Max length: 256 chars.","default":"","x-example":"[HTTP_USER]"},"httpPass":{"type":"string","description":"Task HTTP password. Max length: 256 chars.","default":"","x-example":"[HTTP_PASS]"}},"required":["name","status","schedule","security","httpMethod","httpUrl"]}}]},"delete":{"summary":"Delete Task","operationId":"projectsDeleteTask","consumes":["application\/json"],"produces":[],"tags":["projects"],"description":"","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteTask","weight":116,"cookies":false,"type":"","demo":"projects\/delete-task.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"taskId","description":"Task unique ID.","required":true,"type":"string","x-example":"[TASK_ID]","in":"path"}]}},"\/projects\/{projectId}\/usage":{"get":{"summary":"Get Project","operationId":"projectsGetUsage","consumes":["application\/json"],"produces":[],"tags":["projects"],"description":"","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getUsage","weight":98,"cookies":false,"type":"","demo":"projects\/get-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"range","description":"Date range.","required":false,"type":"string","x-example":"24h","default":"30d","in":"query"}]}},"\/projects\/{projectId}\/webhooks":{"get":{"summary":"List Webhooks","operationId":"projectsListWebhooks","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Webhooks List","schema":{"$ref":"#\/definitions\/webhookList"}}},"x-appwrite":{"method":"listWebhooks","weight":103,"cookies":false,"type":"","demo":"projects\/list-webhooks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"}]},"post":{"summary":"Create Webhook","operationId":"projectsCreateWebhook","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"201":{"description":"Webhook","schema":{"$ref":"#\/definitions\/webhook"}}},"x-appwrite":{"method":"createWebhook","weight":102,"cookies":false,"type":"","demo":"projects\/create-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Webhook name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"events":{"type":"array","description":"Events list.","default":null,"x-example":null,"items":{"type":"string"}},"url":{"type":"string","description":"Webhook URL.","default":null,"x-example":"https:\/\/example.com"},"security":{"type":"boolean","description":"Certificate verification, false for disabled or true for enabled.","default":null,"x-example":false},"httpUser":{"type":"string","description":"Webhook HTTP user. Max length: 256 chars.","default":"","x-example":"[HTTP_USER]"},"httpPass":{"type":"string","description":"Webhook HTTP password. Max length: 256 chars.","default":"","x-example":"[HTTP_PASS]"}},"required":["name","events","url","security"]}}]}},"\/projects\/{projectId}\/webhooks\/{webhookId}":{"get":{"summary":"Get Webhook","operationId":"projectsGetWebhook","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Webhook","schema":{"$ref":"#\/definitions\/webhook"}}},"x-appwrite":{"method":"getWebhook","weight":104,"cookies":false,"type":"","demo":"projects\/get-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.read","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"webhookId","description":"Webhook unique ID.","required":true,"type":"string","x-example":"[WEBHOOK_ID]","in":"path"}]},"put":{"summary":"Update Webhook","operationId":"projectsUpdateWebhook","consumes":["application\/json"],"produces":["application\/json"],"tags":["projects"],"description":"","responses":{"200":{"description":"Webhook","schema":{"$ref":"#\/definitions\/webhook"}}},"x-appwrite":{"method":"updateWebhook","weight":105,"cookies":false,"type":"","demo":"projects\/update-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"webhookId","description":"Webhook unique ID.","required":true,"type":"string","x-example":"[WEBHOOK_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Webhook name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"events":{"type":"array","description":"Events list.","default":null,"x-example":null,"items":{"type":"string"}},"url":{"type":"string","description":"Webhook URL.","default":null,"x-example":"https:\/\/example.com"},"security":{"type":"boolean","description":"Certificate verification, false for disabled or true for enabled.","default":null,"x-example":false},"httpUser":{"type":"string","description":"Webhook HTTP user. Max length: 256 chars.","default":"","x-example":"[HTTP_USER]"},"httpPass":{"type":"string","description":"Webhook HTTP password. Max length: 256 chars.","default":"","x-example":"[HTTP_PASS]"}},"required":["name","events","url","security"]}}]},"delete":{"summary":"Delete Webhook","operationId":"projectsDeleteWebhook","consumes":["application\/json"],"produces":[],"tags":["projects"],"description":"","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteWebhook","weight":106,"cookies":false,"type":"","demo":"projects\/delete-webhook.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"projects.write","platforms":[],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"projectId","description":"Project unique ID.","required":true,"type":"string","x-example":"[PROJECT_ID]","in":"path"},{"name":"webhookId","description":"Webhook unique ID.","required":true,"type":"string","x-example":"[WEBHOOK_ID]","in":"path"}]}},"\/storage\/files":{"get":{"summary":"List Files","operationId":"storageListFiles","consumes":["application\/json"],"produces":["application\/json"],"tags":["storage"],"description":"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's files. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Files List","schema":{"$ref":"#\/definitions\/fileList"}}},"x-appwrite":{"method":"listFiles","weight":128,"cookies":false,"type":"","demo":"storage\/list-files.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/list-files.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create File","operationId":"storageCreateFile","consumes":["multipart\/form-data"],"produces":["application\/json"],"tags":["storage"],"description":"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.","responses":{"201":{"description":"File","schema":{"$ref":"#\/definitions\/file"}}},"x-appwrite":{"method":"createFile","weight":127,"cookies":false,"type":"upload","demo":"storage\/create-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/create-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"file","description":"Binary file.","required":true,"type":"file","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/storage\/files\/{fileId}":{"get":{"summary":"Get File","operationId":"storageGetFile","consumes":["application\/json"],"produces":["application\/json"],"tags":["storage"],"description":"Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.","responses":{"200":{"description":"File","schema":{"$ref":"#\/definitions\/file"}}},"x-appwrite":{"method":"getFile","weight":129,"cookies":false,"type":"","demo":"storage\/get-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]},"put":{"summary":"Update File","operationId":"storageUpdateFile","consumes":["application\/json"],"produces":["application\/json"],"tags":["storage"],"description":"Update a file by its unique ID. Only users with write permissions have access to update this resource.","responses":{"200":{"description":"File","schema":{"$ref":"#\/definitions\/file"}}},"x-appwrite":{"method":"updateFile","weight":133,"cookies":false,"type":"","demo":"storage\/update-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/update-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}}},"required":["read","write"]}}]},"delete":{"summary":"Delete File","operationId":"storageDeleteFile","consumes":["application\/json"],"produces":[],"tags":["storage"],"description":"Delete a file by its unique ID. Only users with write permissions have access to delete this resource.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteFile","weight":134,"cookies":false,"type":"","demo":"storage\/delete-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/delete-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/download":{"get":{"summary":"Get File for Download","operationId":"storageGetFileDownload","consumes":["application\/json"],"produces":["*\/*"],"tags":["storage"],"description":"Get a 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.","responses":{"200":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getFileDownload","weight":131,"cookies":false,"type":"location","demo":"storage\/get-file-download.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-download.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/preview":{"get":{"summary":"Get File Preview","operationId":"storageGetFilePreview","consumes":["application\/json"],"produces":["image\/*"],"tags":["storage"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getFilePreview","weight":130,"cookies":false,"type":"location","demo":"storage\/get-file-preview.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-preview.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"quality","description":"Preview image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"background","description":"Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.","required":false,"type":"string","default":"","in":"query"},{"name":"output","description":"Output format type (jpeg, jpg, png, gif and webp).","required":false,"type":"string","x-example":"jpg","default":"","in":"query"}]}},"\/storage\/files\/{fileId}\/view":{"get":{"summary":"Get File for View","operationId":"storageGetFileView","consumes":["application\/json"],"produces":["*\/*"],"tags":["storage"],"description":"Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.","responses":{"200":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getFileView","weight":132,"cookies":false,"type":"location","demo":"storage\/get-file-view.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-view.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/teams":{"get":{"summary":"List Teams","operationId":"teamsList","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"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's teams. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Teams List","schema":{"$ref":"#\/definitions\/teamList"}}},"x-appwrite":{"method":"list","weight":136,"cookies":false,"type":"","demo":"teams\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/list-teams.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team","operationId":"teamsCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"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.","responses":{"201":{"description":"Team","schema":{"$ref":"#\/definitions\/team"}}},"x-appwrite":{"method":"create","weight":135,"cookies":false,"type":"","demo":"teams\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Team name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"roles":{"type":"array","description":"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.","default":["owner"],"x-example":null,"items":{"type":"string"}}},"required":["name"]}}]}},"\/teams\/{teamId}":{"get":{"summary":"Get Team","operationId":"teamsGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Get a team by its unique ID. All team members have read access for this resource.","responses":{"200":{"description":"Team","schema":{"$ref":"#\/definitions\/team"}}},"x-appwrite":{"method":"get","weight":137,"cookies":false,"type":"","demo":"teams\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]},"put":{"summary":"Update Team","operationId":"teamsUpdate","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Update a team by its unique ID. Only team owners have write access for this resource.","responses":{"200":{"description":"Team","schema":{"$ref":"#\/definitions\/team"}}},"x-appwrite":{"method":"update","weight":138,"cookies":false,"type":"","demo":"teams\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Team name. Max length: 128 chars.","default":null,"x-example":"[NAME]"}},"required":["name"]}}]},"delete":{"summary":"Delete Team","operationId":"teamsDelete","consumes":["application\/json"],"produces":[],"tags":["teams"],"description":"Delete a team by its unique ID. Only team owners have write access for this resource.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"delete","weight":139,"cookies":false,"type":"","demo":"teams\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships":{"get":{"summary":"Get Team Memberships","operationId":"teamsGetMemberships","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Get a team members by the team unique ID. All team members have read access for this list of resources.","responses":{"200":{"description":"Memberships List","schema":{"$ref":"#\/definitions\/membershipList"}}},"x-appwrite":{"method":"getMemberships","weight":141,"cookies":false,"type":"","demo":"teams\/get-memberships.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team-members.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team Membership","operationId":"teamsCreateMembership","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"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.\n\nUse 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#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team.\n\nPlease 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.","responses":{"201":{"description":"Membership","schema":{"$ref":"#\/definitions\/membership"}}},"x-appwrite":{"method":"createMembership","weight":140,"cookies":false,"type":"","demo":"teams\/create-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"New team member email.","default":null,"x-example":"email@example.com"},"name":{"type":"string","description":"New team member name. Max length: 128 chars.","default":"","x-example":"[NAME]"},"roles":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"url":{"type":"string","description":"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.","default":null,"x-example":"https:\/\/example.com"}},"required":["email","roles","url"]}}]}},"\/teams\/{teamId}\/memberships\/{inviteId}":{"delete":{"summary":"Delete Team Membership","operationId":"teamsDeleteMembership","consumes":["application\/json"],"produces":[],"tags":["teams"],"description":"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 it is not accepted.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteMembership","weight":143,"cookies":false,"type":"","demo":"teams\/delete-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships\/{inviteId}\/status":{"patch":{"summary":"Update Team Membership Status","operationId":"teamsUpdateMembershipStatus","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email recieved by the user.","responses":{"200":{"description":"Membership","schema":{"$ref":"#\/definitions\/membership"}}},"x-appwrite":{"method":"updateMembershipStatus","weight":142,"cookies":false,"type":"","demo":"teams\/update-membership-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team-membership-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"public","platforms":["client"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"userId":{"type":"string","description":"User unique ID.","default":null,"x-example":"[USER_ID]"},"secret":{"type":"string","description":"Secret key.","default":null,"x-example":"[SECRET]"}},"required":["userId","secret"]}}]}},"\/users":{"get":{"summary":"List Users","operationId":"usersList","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get a list of all the project's users. You can use the query params to filter your results.","responses":{"200":{"description":"Users List","schema":{"$ref":"#\/definitions\/userList"}}},"x-appwrite":{"method":"list","weight":145,"cookies":false,"type":"","demo":"users\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/list-users.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create User","operationId":"usersCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Create a new user.","responses":{"201":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"create","weight":144,"cookies":false,"type":"","demo":"users\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/create-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"password":{"type":"string","description":"User password. Must be between 6 to 32 chars.","default":null,"x-example":"password"},"name":{"type":"string","description":"User name. Max length: 128 chars.","default":"","x-example":"[NAME]"}},"required":["email","password"]}}]}},"\/users\/{userId}":{"get":{"summary":"Get User","operationId":"usersGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get a user by its unique ID.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"get","weight":146,"cookies":false,"type":"","demo":"users\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"delete":{"summary":"Delete User","operationId":"usersDeleteUser","consumes":["application\/json"],"produces":[],"tags":["users"],"description":"Delete a user by its unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteUser","weight":154,"cookies":false,"type":"","demo":"users\/delete-user.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/logs":{"get":{"summary":"Get User Logs","operationId":"usersGetLogs","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get a user activity logs list by its unique ID.","responses":{"200":{"description":"Logs List","schema":{"$ref":"#\/definitions\/logList"}}},"x-appwrite":{"method":"getLogs","weight":149,"cookies":false,"type":"","demo":"users\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/prefs":{"get":{"summary":"Get User Preferences","operationId":"usersGetPrefs","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get the user preferences by its unique ID.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"getPrefs","weight":147,"cookies":false,"type":"","demo":"users\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"patch":{"summary":"Update User Preferences","operationId":"usersUpdatePrefs","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Update the user preferences by its unique ID. You can pass only the specific settings you wish to update.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"updatePrefs","weight":151,"cookies":false,"type":"","demo":"users\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"prefs":{"type":"object","description":"Prefs key-value JSON object.","default":null,"x-example":"{}"}},"required":["prefs"]}}]}},"\/users\/{userId}\/sessions":{"get":{"summary":"Get User Sessions","operationId":"usersGetSessions","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get the user sessions list by its unique ID.","responses":{"200":{"description":"Sessions List","schema":{"$ref":"#\/definitions\/sessionList"}}},"x-appwrite":{"method":"getSessions","weight":148,"cookies":false,"type":"","demo":"users\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"delete":{"summary":"Delete User Sessions","operationId":"usersDeleteSessions","consumes":["application\/json"],"produces":[],"tags":["users"],"description":"Delete all user's sessions by using the user's unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteSessions","weight":153,"cookies":false,"type":"","demo":"users\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/sessions\/{sessionId}":{"delete":{"summary":"Delete User Session","operationId":"usersDeleteSession","consumes":["application\/json"],"produces":[],"tags":["users"],"description":"Delete a user sessions by its unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteSession","weight":152,"cookies":false,"type":"","demo":"users\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-session.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"sessionId","description":"User unique session ID.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/users\/{userId}\/status":{"patch":{"summary":"Update User Status","operationId":"usersUpdateStatus","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Update the user status by its unique ID.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"updateStatus","weight":150,"cookies":false,"type":"","demo":"users\/update-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"status":{"type":"string","description":"User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0","default":null,"x-example":1}},"required":["status"]}}]}}},"tags":[{"name":"account","description":"The Account service allows you to authenticate and manage a user account."},{"name":"avatars","description":"The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars."},{"name":"database","description":"The Database service allows you to create structured collections of documents, query and filter lists of documents"},{"name":"locale","description":"The Locale service allows you to customize your app based on your users' location."},{"name":"health","description":"The Health service allows you to both validate and monitor your Appwrite server's health."},{"name":"projects","description":"The Project service allows you to manage all the projects in your Appwrite server."},{"name":"storage","description":"The Storage service allows you to manage your project files."},{"name":"teams","description":"The Teams service allows you to group users of your project and to enable them to share read and write access to your project resources"},{"name":"users","description":"The Users service allows you to manage your project users."},{"name":"functions","description":"The Functions Service allows you view, create and manage your Cloud Functions."}],"definitions":{"none":{"description":"None","type":"object"},"any":{"description":"Any","type":"object","additionalProperties":true},"error":{"description":"Error","type":"object","properties":{"message":{"type":"string","description":"Error message.","x-example":"Not found"},"code":{"type":"string","description":"Error code.","x-example":"404"},"version":{"type":"string","description":"Server version number.","x-example":"1.0"}},"required":["message","code","version"]},"errorDev":{"description":"Error","type":"object","properties":{"message":{"type":"string","description":"Error message.","x-example":"Not found"},"code":{"type":"string","description":"Error code.","x-example":"404"},"version":{"type":"string","description":"Server version number.","x-example":"1.0"},"file":{"type":"string","description":"File path.","x-example":"\/usr\/code\/vendor\/utopia-php\/framework\/src\/App.php"},"line":{"type":"integer","description":"Line number.","x-example":209,"format":"int32"},"trace":{"type":"array","description":"Error trace.","items":{"type":"string"},"x-example":""}},"required":["message","code","version","file","line","trace"]},"collectionList":{"description":"Collections List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"collections":{"type":"array","description":"List of collections.","items":{"type":"object","$ref":"#\/definitions\/collection"},"x-example":""}},"required":["sum","collections"]},"documentList":{"description":"Documents List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"documents":{"type":"array","description":"List of documents.","items":{"type":"object","$ref":"#\/definitions\/any"},"x-example":""}},"required":["sum","documents"]},"userList":{"description":"Users List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"users":{"type":"array","description":"List of users.","items":{"type":"object","$ref":"#\/definitions\/user"},"x-example":""}},"required":["sum","users"]},"sessionList":{"description":"Sessions List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"sessions":{"type":"array","description":"List of sessions.","items":{"type":"object","$ref":"#\/definitions\/session"},"x-example":""}},"required":["sum","sessions"]},"logList":{"description":"Logs List","type":"object","properties":{"logs":{"type":"array","description":"List of logs.","items":{"type":"object","$ref":"#\/definitions\/log"},"x-example":""}},"required":["logs"]},"fileList":{"description":"Files List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"files":{"type":"array","description":"List of files.","items":{"type":"object","$ref":"#\/definitions\/file"},"x-example":""}},"required":["sum","files"]},"teamList":{"description":"Teams List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"teams":{"type":"array","description":"List of teams.","items":{"type":"object","$ref":"#\/definitions\/team"},"x-example":""}},"required":["sum","teams"]},"membershipList":{"description":"Memberships List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"memberships":{"type":"array","description":"List of memberships.","items":{"type":"object","$ref":"#\/definitions\/membership"},"x-example":""}},"required":["sum","memberships"]},"functionList":{"description":"Functions List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"functions":{"type":"array","description":"List of functions.","items":{"type":"object","$ref":"#\/definitions\/function"},"x-example":""}},"required":["sum","functions"]},"tagList":{"description":"Tags List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"tags":{"type":"array","description":"List of tags.","items":{"type":"object","$ref":"#\/definitions\/tag"},"x-example":""}},"required":["sum","tags"]},"executionList":{"description":"Executions List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"executions":{"type":"array","description":"List of executions.","items":{"type":"object","$ref":"#\/definitions\/execution"},"x-example":""}},"required":["sum","executions"]},"projectList":{"description":"Projects List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"projects":{"type":"array","description":"List of projects.","items":{"type":"object","$ref":"#\/definitions\/project"},"x-example":""}},"required":["sum","projects"]},"webhookList":{"description":"Webhooks List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"webhooks":{"type":"array","description":"List of webhooks.","items":{"type":"object","$ref":"#\/definitions\/webhook"},"x-example":""}},"required":["sum","webhooks"]},"keyList":{"description":"API Keys List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"keys":{"type":"array","description":"List of keys.","items":{"type":"object","$ref":"#\/definitions\/key"},"x-example":""}},"required":["sum","keys"]},"taskList":{"description":"Tasks List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"tasks":{"type":"array","description":"List of tasks.","items":{"type":"object","$ref":"#\/definitions\/task"},"x-example":""}},"required":["sum","tasks"]},"platformList":{"description":"Platforms List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"platforms":{"type":"array","description":"List of platforms.","items":{"type":"object","$ref":"#\/definitions\/platform"},"x-example":""}},"required":["sum","platforms"]},"domainList":{"description":"Domains List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"domains":{"type":"array","description":"List of domains.","items":{"type":"object","$ref":"#\/definitions\/domain"},"x-example":""}},"required":["sum","domains"]},"countryList":{"description":"Countries List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"countries":{"type":"array","description":"List of countries.","items":{"type":"object","$ref":"#\/definitions\/country"},"x-example":""}},"required":["sum","countries"]},"continentList":{"description":"Continents List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"continents":{"type":"array","description":"List of continents.","items":{"type":"object","$ref":"#\/definitions\/continent"},"x-example":""}},"required":["sum","continents"]},"languageList":{"description":"Languages List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"languages":{"type":"array","description":"List of languages.","items":{"type":"object","$ref":"#\/definitions\/language"},"x-example":""}},"required":["sum","languages"]},"currencyList":{"description":"Currencies List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"currencies":{"type":"array","description":"List of currencies.","items":{"type":"object","$ref":"#\/definitions\/currency"},"x-example":""}},"required":["sum","currencies"]},"phoneList":{"description":"Phones List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"phones":{"type":"array","description":"List of phones.","items":{"type":"object","$ref":"#\/definitions\/phone"},"x-example":""}},"required":["sum","phones"]},"permissions":{"description":"Permissions","type":"object","properties":{"read":{"type":"array","description":"Read permissions.","items":{"type":"string"},"x-example":"user:5e5ea5c16897e"},"write":{"type":"array","description":"Write permissions.","items":{"type":"string"},"x-example":"user:5e5ea5c16897e"}},"required":["read","write"]},"collection":{"description":"Collection","type":"object","properties":{"$id":{"type":"string","description":"Collection ID.","x-example":"5e5ea5c16897e"},"$permissions":{"type":"object","description":"Collection permissions.","x-example":{},"items":{"type":"object","$ref":"#\/definitions\/permissions"}},"name":{"type":"string","description":"Collection name.","x-example":"Movies"},"dateCreated":{"type":"integer","description":"Collection creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"dateUpdated":{"type":"integer","description":"Collection creation date in Unix timestamp.","x-example":1592981550,"format":"int32"},"rules":{"type":"array","description":"Collection rules.","items":{"type":"object","$ref":"#\/definitions\/rule"},"x-example":""}},"required":["$id","$permissions","name","dateCreated","dateUpdated","rules"]},"rule":{"description":"Rule","type":"object","properties":{"$id":{"type":"string","description":"Rule ID.","x-example":"5e5ea5c16897e"},"$collection":{"type":"string","description":"Rule Collection.","x-example":"5e5e66c16897e"},"type":{"type":"string","description":"Rule type. Possible values: ","x-example":"title"},"key":{"type":"string","description":"Rule key.","x-example":"title"},"label":{"type":"string","description":"Rule label.","x-example":"Title"},"default":{"type":"string","description":"Rule default value.","x-example":"Movie Name"},"array":{"type":"boolean","description":"Is array?","x-example":false},"required":{"type":"boolean","description":"Is required?","x-example":true},"list":{"type":"array","description":"List of allowed values","items":{"type":"string"},"x-example":"5e5ea5c168099"}},"required":["$id","$collection","type","key","label","default","array","required","list"]},"log":{"description":"Log","type":"object","properties":{"event":{"type":"string","description":"Event name.","x-example":"account.sessions.create"},"ip":{"type":"string","description":"IP session in use when the session was created.","x-example":"127.0.0.1"},"time":{"type":"integer","description":"Log creation time in Unix timestamp.","x-example":1592981250,"format":"int32"},"osCode":{"type":"string","description":"Operating system code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/os.json).","x-example":"Mac"},"osName":{"type":"string","description":"Operating system name.","x-example":"Mac"},"osVersion":{"type":"string","description":"Operating system version.","x-example":"Mac"},"clientType":{"type":"string","description":"Client type.","x-example":"browser"},"clientCode":{"type":"string","description":"Client code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/clients.json).","x-example":"CM"},"clientName":{"type":"string","description":"Client name.","x-example":"Chrome Mobile iOS"},"clientVersion":{"type":"string","description":"Client version.","x-example":"84.0"},"clientEngine":{"type":"string","description":"Client engine name.","x-example":"WebKit"},"clientEngineVersion":{"type":"string","description":"Client engine name.","x-example":"605.1.15"},"deviceName":{"type":"string","description":"Device name.","x-example":"smartphone"},"deviceBrand":{"type":"string","description":"Device brand name.","x-example":"Google"},"deviceModel":{"type":"string","description":"Device model name.","x-example":"Nexus 5"},"countryCode":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"},"countryName":{"type":"string","description":"Country name.","x-example":"United States"}},"required":["event","ip","time","osCode","osName","osVersion","clientType","clientCode","clientName","clientVersion","clientEngine","clientEngineVersion","deviceName","deviceBrand","deviceModel","countryCode","countryName"]},"user":{"description":"User","type":"object","properties":{"$id":{"type":"string","description":"User ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"User name.","x-example":"John Doe"},"registration":{"type":"integer","description":"User registration date in Unix timestamp.","x-example":1592981250,"format":"int32"},"status":{"type":"integer","description":"User status. 0 for Unactivated, 1 for active and 2 is blocked.","x-example":0,"format":"int32"},"email":{"type":"string","description":"User email address.","x-example":"john@appwrite.io"},"emailVerification":{"type":"boolean","description":"Email verification status.","x-example":true},"prefs":{"type":"string","description":"User preferences as a key-value object","x-example":{"theme":"pink","timezone":"UTC"}}},"required":["$id","name","registration","status","email","emailVerification","prefs"]},"session":{"description":"Session","type":"object","properties":{"$id":{"type":"string","description":"Session ID.","x-example":"5e5ea5c16897e"},"userId":{"type":"string","description":"User ID.","x-example":"5e5bb8c16897e"},"expire":{"type":"integer","description":"Session expiration date in Unix timestamp.","x-example":1592981250,"format":"int32"},"ip":{"type":"string","description":"IP in use when the session was created.","x-example":"127.0.0.1"},"osCode":{"type":"string","description":"Operating system code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/os.json).","x-example":"Mac"},"osName":{"type":"string","description":"Operating system name.","x-example":"Mac"},"osVersion":{"type":"string","description":"Operating system version.","x-example":"Mac"},"clientType":{"type":"string","description":"Client type.","x-example":"browser"},"clientCode":{"type":"string","description":"Client code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/clients.json).","x-example":"CM"},"clientName":{"type":"string","description":"Client name.","x-example":"Chrome Mobile iOS"},"clientVersion":{"type":"string","description":"Client version.","x-example":"84.0"},"clientEngine":{"type":"string","description":"Client engine name.","x-example":"WebKit"},"clientEngineVersion":{"type":"string","description":"Client engine name.","x-example":"605.1.15"},"deviceName":{"type":"string","description":"Device name.","x-example":"smartphone"},"deviceBrand":{"type":"string","description":"Device brand name.","x-example":"Google"},"deviceModel":{"type":"string","description":"Device model name.","x-example":"Nexus 5"},"countryCode":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"},"countryName":{"type":"string","description":"Country name.","x-example":"United States"},"current":{"type":"boolean","description":"Returns true if this the current user session.","x-example":true}},"required":["$id","userId","expire","ip","osCode","osName","osVersion","clientType","clientCode","clientName","clientVersion","clientEngine","clientEngineVersion","deviceName","deviceBrand","deviceModel","countryCode","countryName","current"]},"token":{"description":"Token","type":"object","properties":{"$id":{"type":"string","description":"Token ID.","x-example":"bb8ea5c16897e"},"userId":{"type":"string","description":"User ID.","x-example":"5e5ea5c168bb8"},"secret":{"type":"string","description":"Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.","x-example":""},"expire":{"type":"integer","description":"Token expiration date in Unix timestamp.","x-example":1592981250,"format":"int32"}},"required":["$id","userId","secret","expire"]},"jwt":{"description":"JWT","type":"object","properties":{"jwt":{"type":"string","description":"JWT encoded string.","x-example":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"}},"required":["jwt"]},"locale":{"description":"Locale","type":"object","properties":{"ip":{"type":"string","description":"User IP address.","x-example":"127.0.0.1"},"countryCode":{"type":"string","description":"Country code in [ISO 3166-1](http:\/\/en.wikipedia.org\/wiki\/ISO_3166-1) two-character format","x-example":"US"},"country":{"type":"string","description":"Country name. This field support localization.","x-example":"United States"},"continentCode":{"type":"string","description":"Continent code. A two character continent code \"AF\" for Africa, \"AN\" for Antarctica, \"AS\" for Asia, \"EU\" for Europe, \"NA\" for North America, \"OC\" for Oceania, and \"SA\" for South America.","x-example":"NA"},"continent":{"type":"string","description":"Continent name. This field support localization.","x-example":"North America"},"eu":{"type":"boolean","description":"True if country is part of the Europian Union.","x-example":false},"currency":{"type":"string","description":"Currency code in [ISO 4217-1](http:\/\/en.wikipedia.org\/wiki\/ISO_4217) three-character format","x-example":"USD"}},"required":["ip","countryCode","country","continentCode","continent","eu","currency"]},"file":{"description":"File","type":"object","properties":{"$id":{"type":"string","description":"File ID.","x-example":"5e5ea5c16897e"},"$permissions":{"type":"object","description":"File permissions.","x-example":{},"items":{"type":"object","$ref":"#\/definitions\/permissions"}},"name":{"type":"string","description":"File name.","x-example":"Pink.png"},"dateCreated":{"type":"integer","description":"File creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"signature":{"type":"string","description":"File MD5 signature.","x-example":"5d529fd02b544198ae075bd57c1762bb"},"mimeType":{"type":"string","description":"File mime type.","x-example":"image\/png"},"sizeOriginal":{"type":"integer","description":"File original size in bytes.","x-example":17890,"format":"int32"}},"required":["$id","$permissions","name","dateCreated","signature","mimeType","sizeOriginal"]},"team":{"description":"Team","type":"object","properties":{"$id":{"type":"string","description":"Team ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"Team name.","x-example":"VIP"},"dateCreated":{"type":"integer","description":"Team creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"sum":{"type":"integer","description":"Total sum of team members.","x-example":7,"format":"int32"}},"required":["$id","name","dateCreated","sum"]},"membership":{"description":"Membership","type":"object","properties":{"$id":{"type":"string","description":"Membership ID.","x-example":"5e5ea5c16897e"},"userId":{"type":"string","description":"User ID.","x-example":"5e5ea5c16897e"},"teamId":{"type":"string","description":"Team ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"User name.","x-example":"VIP"},"email":{"type":"string","description":"User email address.","x-example":"john@appwrite.io"},"invited":{"type":"integer","description":"Date, the user has been invited to join the team in Unix timestamp.","x-example":1592981250,"format":"int32"},"joined":{"type":"integer","description":"Date, the user has accepted the invitation to join the team in Unix timestamp.","x-example":1592981250,"format":"int32"},"confirm":{"type":"boolean","description":"User confirmation status, true if the user has joined the team or false otherwise.","x-example":false},"roles":{"type":"array","description":"User list of roles","items":{"type":"string"},"x-example":"admin"}},"required":["$id","userId","teamId","name","email","invited","joined","confirm","roles"]},"function":{"description":"Function","type":"object","properties":{"$id":{"type":"string","description":"Function ID.","x-example":"5e5ea5c16897e"},"$permissions":{"type":"object","description":"Function permissions.","x-example":{},"items":{"type":"object","$ref":"#\/definitions\/permissions"}},"name":{"type":"string","description":"Function name.","x-example":"My Function"},"dateCreated":{"type":"integer","description":"Function creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"dateUpdated":{"type":"integer","description":"Function update date in Unix timestamp.","x-example":1592981257,"format":"int32"},"status":{"type":"string","description":"Function status. Possible values: disabled, enabled","x-example":"enabled"},"env":{"type":"string","description":"Function execution environment.","x-example":"python-3.8"},"tag":{"type":"string","description":"Function active tag ID.","x-example":"5e5ea5c16897e"},"vars":{"type":"string","description":"Function environment variables.","x-example":{"key":"value"}},"events":{"type":"array","description":"Function trigger events.","items":{"type":"string"},"x-example":"account.create"},"schedule":{"type":"string","description":"Function execution schedult in CRON format.","x-example":"5 4 * * *"},"scheduleNext":{"type":"integer","description":"Function next scheduled execution date in Unix timestamp.","x-example":1592981292,"format":"int32"},"schedulePrevious":{"type":"integer","description":"Function next scheduled execution date in Unix timestamp.","x-example":1592981237,"format":"int32"},"timeout":{"type":"integer","description":"Function execution timeout in seconds.","x-example":1592981237,"format":"int32"}},"required":["$id","$permissions","name","dateCreated","dateUpdated","status","env","tag","vars","events","schedule","scheduleNext","schedulePrevious","timeout"]},"tag":{"description":"Tag","type":"object","properties":{"$id":{"type":"string","description":"Tag ID.","x-example":"5e5ea5c16897e"},"functionId":{"type":"string","description":"Function ID.","x-example":"5e5ea6g16897e"},"dateCreated":{"type":"integer","description":"The tag creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"command":{"type":"string","description":"The entrypoint command in use to execute the tag code.","x-example":"enabled"},"size":{"type":"string","description":"The code size in bytes.","x-example":"python-3.8"}},"required":["$id","functionId","dateCreated","command","size"]},"execution":{"description":"Execution","type":"object","properties":{"$id":{"type":"string","description":"Execution ID.","x-example":"5e5ea5c16897e"},"functionId":{"type":"string","description":"Function ID.","x-example":"5e5ea6g16897e"},"dateCreated":{"type":"integer","description":"The execution creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"trigger":{"type":"string","description":"The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.","x-example":"http"},"status":{"type":"string","description":"The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.","x-example":"processing"},"exitCode":{"type":"integer","description":"The script exit code.","x-example":0,"format":"int32"},"stdout":{"type":"string","description":"The script stdout output string.","x-example":""},"stderr":{"type":"string","description":"The script stderr output string.","x-example":""},"time":{"type":"number","description":"The script execution time in seconds.","x-example":0.4,"format":"float"}},"required":["$id","functionId","dateCreated","trigger","status","exitCode","stdout","stderr","time"]},"project":{"description":"Project","type":"object","properties":{"$id":{"type":"string","description":"Project ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"Project name.","x-example":"New Project"},"description":{"type":"string","description":"Project description.","x-example":"This is a new project."},"teamId":{"type":"string","description":"Project team ID.","x-example":"1592981250"},"logo":{"type":"string","description":"Project logo file ID.","x-example":"5f5c451b403cb"},"url":{"type":"string","description":"Project website URL.","x-example":"5f5c451b403cb"},"legalName":{"type":"string","description":"Company legal name.","x-example":"Company LTD."},"legalCountry":{"type":"string","description":"Country code in [ISO 3166-1](http:\/\/en.wikipedia.org\/wiki\/ISO_3166-1) two-character format.","x-example":"US"},"legalState":{"type":"string","description":"State name.","x-example":"New York"},"legalCity":{"type":"string","description":"City name.","x-example":"New York City."},"legalAddress":{"type":"string","description":"Company Address.","x-example":"620 Eighth Avenue, New York, NY 10018"},"legalTaxId":{"type":"string","description":"Company Tax ID.","x-example":"131102020"},"platforms":{"type":"array","description":"List of Platforms.","items":{"type":"object","$ref":"#\/definitions\/platform"},"x-example":{}},"webhooks":{"type":"array","description":"List of Webhooks.","items":{"type":"object","$ref":"#\/definitions\/webhook"},"x-example":{}},"keys":{"type":"array","description":"List of API Keys.","items":{"type":"object","$ref":"#\/definitions\/key"},"x-example":{}},"domains":{"type":"array","description":"List of Domains.","items":{"type":"object","$ref":"#\/definitions\/domain"},"x-example":{}},"tasks":{"type":"array","description":"List of Tasks.","items":{"type":"object","$ref":"#\/definitions\/task"},"x-example":{}},"usersOauth2AmazonAppid":{"type":"string","description":"Amazon OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2AmazonSecret":{"type":"string","description":"Amazon OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2AppleAppid":{"type":"string","description":"Apple OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2AppleSecret":{"type":"string","description":"Apple OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2BitbucketAppid":{"type":"string","description":"BitBucket OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2BitbucketSecret":{"type":"string","description":"BitBucket OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2BitlyAppid":{"type":"string","description":"Bitly OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2BitlySecret":{"type":"string","description":"Bitly OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2BoxAppid":{"type":"string","description":"Box OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2BoxSecret":{"type":"string","description":"Box OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2DiscordAppid":{"type":"string","description":"Discord OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2DiscordSecret":{"type":"string","description":"Discord OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2DropboxAppid":{"type":"string","description":"Dropbox OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2DropboxSecret":{"type":"string","description":"Dropbox OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2FacebookAppid":{"type":"string","description":"Facebook OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2FacebookSecret":{"type":"string","description":"Facebook OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2GithubAppid":{"type":"string","description":"GitHub OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2GithubSecret":{"type":"string","description":"GitHub OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2GitlabAppid":{"type":"string","description":"GitLab OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2GitlabSecret":{"type":"string","description":"GitLab OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2GoogleAppid":{"type":"string","description":"Google OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2GoogleSecret":{"type":"string","description":"Google OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2LinkedinAppid":{"type":"string","description":"LinkedIn OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2LinkedinSecret":{"type":"string","description":"LinkedIn OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2MicrosoftAppid":{"type":"string","description":"Microsoft OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2MicrosoftSecret":{"type":"string","description":"Microsoft OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2PaypalAppid":{"type":"string","description":"PayPal OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2PaypalSecret":{"type":"string","description":"PayPal OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2PaypalSandboxAppid":{"type":"string","description":"PayPal (Sandbox) OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2PaypalSandboxSecret":{"type":"string","description":"PayPal (Sandbox) OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2SalesforceAppid":{"type":"string","description":"Salesforce OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2SalesforceSecret":{"type":"string","description":"Salesforce OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2SlackAppid":{"type":"string","description":"Slack OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2SlackSecret":{"type":"string","description":"Slack OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2SpotifyAppid":{"type":"string","description":"Spotify OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2SpotifySecret":{"type":"string","description":"Spotify OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2TradeshiftAppid":{"type":"string","description":"Tradeshift OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2TradeshiftSecret":{"type":"string","description":"Tradeshift OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2TradeshiftBoxAppid":{"type":"string","description":"Tradeshift Sandbox OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2TradeshiftBoxSecret":{"type":"string","description":"Tradeshift Sandbox OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2TwitchAppid":{"type":"string","description":"Twitch OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2TwitchSecret":{"type":"string","description":"Twitch OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2VkAppid":{"type":"string","description":"VK OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2VkSecret":{"type":"string","description":"VK OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2YahooAppid":{"type":"string","description":"Yahoo OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2YahooSecret":{"type":"string","description":"Yahoo OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2YandexAppid":{"type":"string","description":"Yandex OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2YandexSecret":{"type":"string","description":"Yandex OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2WordpressAppid":{"type":"string","description":"WordPress OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2WordpressSecret":{"type":"string","description":"WordPress OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."},"usersOauth2MockAppid":{"type":"string","description":"Mock OAuth app ID.","x-example":"123247283472834787438"},"usersOauth2MockSecret":{"type":"string","description":"Mock OAuth secret ID.","x-example":"djsgudsdsewe43434343dd34..."}},"required":["$id","name","description","teamId","logo","url","legalName","legalCountry","legalState","legalCity","legalAddress","legalTaxId","platforms","webhooks","keys","domains","tasks","usersOauth2AmazonAppid","usersOauth2AmazonSecret","usersOauth2AppleAppid","usersOauth2AppleSecret","usersOauth2BitbucketAppid","usersOauth2BitbucketSecret","usersOauth2BitlyAppid","usersOauth2BitlySecret","usersOauth2BoxAppid","usersOauth2BoxSecret","usersOauth2DiscordAppid","usersOauth2DiscordSecret","usersOauth2DropboxAppid","usersOauth2DropboxSecret","usersOauth2FacebookAppid","usersOauth2FacebookSecret","usersOauth2GithubAppid","usersOauth2GithubSecret","usersOauth2GitlabAppid","usersOauth2GitlabSecret","usersOauth2GoogleAppid","usersOauth2GoogleSecret","usersOauth2LinkedinAppid","usersOauth2LinkedinSecret","usersOauth2MicrosoftAppid","usersOauth2MicrosoftSecret","usersOauth2PaypalAppid","usersOauth2PaypalSecret","usersOauth2PaypalSandboxAppid","usersOauth2PaypalSandboxSecret","usersOauth2SalesforceAppid","usersOauth2SalesforceSecret","usersOauth2SlackAppid","usersOauth2SlackSecret","usersOauth2SpotifyAppid","usersOauth2SpotifySecret","usersOauth2TradeshiftAppid","usersOauth2TradeshiftSecret","usersOauth2TradeshiftBoxAppid","usersOauth2TradeshiftBoxSecret","usersOauth2TwitchAppid","usersOauth2TwitchSecret","usersOauth2VkAppid","usersOauth2VkSecret","usersOauth2YahooAppid","usersOauth2YahooSecret","usersOauth2YandexAppid","usersOauth2YandexSecret","usersOauth2WordpressAppid","usersOauth2WordpressSecret","usersOauth2MockAppid","usersOauth2MockSecret"]},"webhook":{"description":"Webhook","type":"object","properties":{"$id":{"type":"string","description":"Webhook ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"Webhook name.","x-example":"My Webhook"},"url":{"type":"string","description":"Webhook URL endpoint.","x-example":"https:\/\/example.com\/webhook"},"events":{"type":"array","description":"Webhook trigger events.","items":{"type":"string"},"x-example":"database.collections.update"},"security":{"type":"boolean","description":"Indicated if SSL \/ TLS Certificate verification is enabled.","x-example":true},"httpUser":{"type":"string","description":"HTTP basic authentication username.","x-example":"username"},"httpPass":{"type":"string","description":"HTTP basic authentication password.","x-example":"password"}},"required":["$id","name","url","events","security","httpUser","httpPass"]},"key":{"description":"Key","type":"object","properties":{"$id":{"type":"string","description":"Key ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"Key name.","x-example":"My API Key"},"scopes":{"type":"array","description":"Allowed permission scopes.","items":{"type":"string"},"x-example":"users.read"},"secret":{"type":"string","description":"Secret key.","x-example":"919c2d18fb5d4...a2ae413da83346ad2"}},"required":["$id","name","scopes","secret"]},"task":{"description":"Task","type":"object","properties":{"$id":{"type":"string","description":"Task ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"Task name.","x-example":"My Task"},"security":{"type":"boolean","description":"Indicated if SSL \/ TLS Certificate verification is enabled.","x-example":true},"httpMethod":{"type":"string","description":"Task HTTP Method.","x-example":"POST"},"httpUrl":{"type":"string","description":"Task HTTP URL.","x-example":"https:\/\/example.com\/task"},"httpHeaders":{"type":"array","description":"Task HTTP headers.","items":{"type":"string"},"x-example":"key:value"},"httpUser":{"type":"string","description":"HTTP basic authentication username.","x-example":"username"},"httpPass":{"type":"string","description":"HTTP basic authentication password.","x-example":"password"},"duration":{"type":"number","description":"Task duration in seconds.","x-example":1.2,"format":"float"},"delay":{"type":"number","description":"Task delay time in seconds.","x-example":1.2,"format":"float"},"failures":{"type":"integer","description":"Number of recurring task failures.","x-example":0,"format":"int32"},"schedule":{"type":"string","description":"Task schedule in CRON syntax.","x-example":"* * * * *"},"status":{"type":"string","description":"Task status. Possible values: play, pause","x-example":"enabled"},"updated":{"type":"integer","description":"Task last updated time in Unix timestamp.","x-example":1592981250,"format":"int32"},"previous":{"type":"integer","description":"Task previous run time in Unix timestamp.","x-example":1592981250,"format":"int32"},"next":{"type":"integer","description":"Task next run time in Unix timestamp.","x-example":1592981650,"format":"int32"}},"required":["$id","name","security","httpMethod","httpUrl","httpHeaders","httpUser","httpPass","duration","delay","failures","schedule","status","updated","previous","next"]},"domain":{"description":"Domain","type":"object","properties":{"$id":{"type":"string","description":"Domain ID.","x-example":"5e5ea5c16897e"},"domain":{"type":"string","description":"Domain name.","x-example":"appwrite.company.com"},"registerable":{"type":"string","description":"Registerable domain name.","x-example":"company.com"},"tld":{"type":"string","description":"TLD name.","x-example":"com"},"verification":{"type":"boolean","description":"Verification process status.","x-example":true},"certificateId":{"type":"string","description":"Certificate ID.","x-example":"6ejea5c13377e"}},"required":["$id","domain","registerable","tld","verification","certificateId"]},"platform":{"description":"Platform","type":"object","properties":{"$id":{"type":"string","description":"Platform ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"Platform name.","x-example":"My Web App"},"type":{"type":"string","description":"Platform type. Possible values are: web, flutter-ios, flutter-android, ios, android, and unity.","x-example":"My Web App"},"key":{"type":"string","description":"Platform Key. iOS bundle ID or Android package name. Empty string for other platforms.","x-example":"com.company.appname"},"hostname":{"type":"string","description":"Web app hostname. Empty string for other platforms.","x-example":true},"httpUser":{"type":"string","description":"HTTP basic authentication username.","x-example":"username"},"httpPass":{"type":"string","description":"HTTP basic authentication password.","x-example":"password"}},"required":["$id","name","type","key","hostname","httpUser","httpPass"]},"country":{"description":"Country","type":"object","properties":{"name":{"type":"string","description":"Country name.","x-example":"United States"},"code":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"}},"required":["name","code"]},"continent":{"description":"Continent","type":"object","properties":{"name":{"type":"string","description":"Continent name.","x-example":"Europe"},"code":{"type":"string","description":"Continent two letter code.","x-example":"EU"}},"required":["name","code"]},"language":{"description":"Language","type":"object","properties":{"name":{"type":"string","description":"Language name.","x-example":"Italian"},"code":{"type":"string","description":"Language two-character ISO 639-1 codes.","x-example":"it"},"nativeName":{"type":"string","description":"Language native name.","x-example":"Italiano"}},"required":["name","code","nativeName"]},"currency":{"description":"Currency","type":"object","properties":{"symbol":{"type":"string","description":"Currency symbol.","x-example":"$"},"name":{"type":"string","description":"Currency name.","x-example":"US dollar"},"symbolNative":{"type":"string","description":"Currency native symbol.","x-example":"$"},"decimalDigits":{"type":"integer","description":"Number of decimal digits.","x-example":2,"format":"int32"},"rounding":{"type":"number","description":"Currency digit rounding.","x-example":0,"format":"float"},"code":{"type":"string","description":"Currency code in [ISO 4217-1](http:\/\/en.wikipedia.org\/wiki\/ISO_4217) three-character format.","x-example":"USD"},"namePlural":{"type":"string","description":"Currency plural name","x-example":"US dollars"}},"required":["symbol","name","symbolNative","decimalDigits","rounding","code","namePlural"]},"phone":{"description":"Phone","type":"object","properties":{"code":{"type":"string","description":"Phone code.","x-example":"+1"},"countryCode":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"},"countryName":{"type":"string","description":"Country name.","x-example":"United States"}},"required":["code","countryCode","countryName"]}},"externalDocs":{"description":"Full API docs, specs and tutorials","url":"https:\/\/appwrite.io\/docs"}} \ No newline at end of file diff --git a/app/config/specs/0.7.0.server.json b/app/config/specs/0.7.0.server.json new file mode 100644 index 0000000000..b6617f307e --- /dev/null +++ b/app/config/specs/0.7.0.server.json @@ -0,0 +1 @@ +{"swagger":"2.0","info":{"version":"0.7.0","title":"Appwrite","description":"Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https:\/\/appwrite.io\/docs](https:\/\/appwrite.io\/docs)","termsOfService":"https:\/\/appwrite.io\/policy\/terms","contact":{"name":"Appwrite Team","url":"https:\/\/appwrite.io\/support","email":"team@appwrite.io"},"license":{"name":"BSD-3-Clause","url":"https:\/\/raw.githubusercontent.com\/appwrite\/appwrite\/master\/LICENSE"}},"host":"appwrite.io","basePath":"\/v1","schemes":["https"],"consumes":["application\/json","multipart\/form-data"],"produces":["application\/json"],"securityDefinitions":{"Project":{"type":"apiKey","name":"X-Appwrite-Project","description":"Your project ID","in":"header","x-appwrite":{"demo":"5df5acd0d48c2"}},"Key":{"type":"apiKey","name":"X-Appwrite-Key","description":"Your secret API key","in":"header","x-appwrite":{"demo":"919c2d18fb5d4...a2ae413da83346ad2"}},"Locale":{"type":"apiKey","name":"X-Appwrite-Locale","description":"","in":"header","x-appwrite":{"demo":"en"}}},"paths":{"\/avatars\/browsers\/{code}":{"get":{"summary":"Get Browser Icon","operationId":"avatarsGetBrowser","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getBrowser","weight":58,"cookies":false,"type":"location","demo":"avatars\/get-browser.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-browser.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Browser Code.","required":true,"type":"string","x-example":"aa","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/credit-cards\/{code}":{"get":{"summary":"Get Credit Card Icon","operationId":"avatarsGetCreditCard","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getCreditCard","weight":57,"cookies":false,"type":"location","demo":"avatars\/get-credit-card.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-credit-card.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.","required":true,"type":"string","x-example":"amex","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/favicon":{"get":{"summary":"Get Favicon","operationId":"avatarsGetFavicon","consumes":["application\/json"],"produces":["image\/*"],"tags":["avatars"],"description":"Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL.\n","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getFavicon","weight":61,"cookies":false,"type":"location","demo":"avatars\/get-favicon.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-favicon.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Website URL which you want to fetch the favicon from.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"}]}},"\/avatars\/flags\/{code}":{"get":{"summary":"Get Country Flag","operationId":"avatarsGetFlag","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getFlag","weight":59,"cookies":false,"type":"location","demo":"avatars\/get-flag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-flag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"code","description":"Country Code. ISO Alpha-2 country code format.","required":true,"type":"string","x-example":"af","in":"path"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"quality","description":"Image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"}]}},"\/avatars\/image":{"get":{"summary":"Get Image from URL","operationId":"avatarsGetImage","consumes":["application\/json"],"produces":["image\/*"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getImage","weight":60,"cookies":false,"type":"location","demo":"avatars\/get-image.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-image.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"url","description":"Image URL which you want to crop.","required":true,"type":"string","format":"url","x-example":"https:\/\/example.com","in":"query"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 2000.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"}]}},"\/avatars\/initials":{"get":{"summary":"Get User Initials","operationId":"avatarsGetInitials","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.\n\nYou 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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getInitials","weight":63,"cookies":false,"type":"location","demo":"avatars\/get-initials.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-initials.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"name","description":"Full Name. When empty, current user name or email will be used. Max length: 128 chars.","required":false,"type":"string","x-example":"[NAME]","default":"","in":"query"},{"name":"width","description":"Image width. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"height","description":"Image height. Pass an integer between 0 to 2000. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":500,"in":"query"},{"name":"color","description":"Changes text color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"},{"name":"background","description":"Changes background color. By default a random color will be picked and stay will persistent to the given name.","required":false,"type":"string","default":"","in":"query"}]}},"\/avatars\/qr":{"get":{"summary":"Get QR Code","operationId":"avatarsGetQR","consumes":["application\/json"],"produces":["image\/png"],"tags":["avatars"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getQR","weight":62,"cookies":false,"type":"location","demo":"avatars\/get-q-r.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/avatars\/get-qr.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"avatars.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"text","description":"Plain text to be converted to QR code image.","required":true,"type":"string","x-example":"[TEXT]","in":"query"},{"name":"size","description":"QR code size. Pass an integer between 0 to 1000. Defaults to 400.","required":false,"type":"integer","format":"int32","x-example":0,"default":400,"in":"query"},{"name":"margin","description":"Margin from edge. Pass an integer between 0 to 10. Defaults to 1.","required":false,"type":"integer","format":"int32","x-example":0,"default":1,"in":"query"},{"name":"download","description":"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.","required":false,"type":"boolean","x-example":false,"default":false,"in":"query"}]}},"\/database\/collections":{"get":{"summary":"List Collections","operationId":"databaseListCollections","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's collections. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Collections List","schema":{"$ref":"#\/definitions\/collectionList"}}},"x-appwrite":{"method":"listCollections","weight":65,"cookies":false,"type":"","demo":"database\/list-collections.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-collections.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Collection","operationId":"databaseCreateCollection","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Create a new Collection.","responses":{"201":{"description":"Collection","schema":{"$ref":"#\/definitions\/collection"}}},"x-appwrite":{"method":"createCollection","weight":64,"cookies":false,"type":"","demo":"database\/create-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Collection name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"rules":{"type":"array","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","default":null,"x-example":null,"items":{"type":"string"}}},"required":["name","read","write","rules"]}}]}},"\/database\/collections\/{collectionId}":{"get":{"summary":"Get Collection","operationId":"databaseGetCollection","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.","responses":{"200":{"description":"Collection","schema":{"$ref":"#\/definitions\/collection"}}},"x-appwrite":{"method":"getCollection","weight":66,"cookies":false,"type":"","demo":"database\/get-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]},"put":{"summary":"Update Collection","operationId":"databaseUpdateCollection","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Update a collection by its unique ID.","responses":{"200":{"description":"Collection","schema":{"$ref":"#\/definitions\/collection"}}},"x-appwrite":{"method":"updateCollection","weight":67,"cookies":false,"type":"","demo":"database\/update-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Collection name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"rules":{"type":"array","description":"Array of [rule objects](\/docs\/rules). Each rule define a collection field name, data type and validation.","default":[],"x-example":null,"items":{"type":"string"}}},"required":["name","read","write"]}}]},"delete":{"summary":"Delete Collection","operationId":"databaseDeleteCollection","consumes":["application\/json"],"produces":[],"tags":["database"],"description":"Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteCollection","weight":68,"cookies":false,"type":"","demo":"database\/delete-collection.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-collection.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"collections.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID.","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"}]}},"\/database\/collections\/{collectionId}\/documents":{"get":{"summary":"List Documents","operationId":"databaseListDocuments","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"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's documents. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Documents List","schema":{"$ref":"#\/definitions\/documentList"}}},"x-appwrite":{"method":"listDocuments","weight":70,"cookies":false,"type":"","demo":"database\/list-documents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/list-documents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"filters","description":"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'.","required":false,"type":"array","collectionFormat":"multi","items":{"type":"string"},"default":[],"in":"query"},{"name":"limit","description":"Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Offset value. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderField","description":"Document field that results will be sorted by.","required":false,"type":"string","x-example":"[ORDER_FIELD]","default":"","in":"query"},{"name":"orderType","description":"Order direction. Possible values are DESC for descending order, or ASC for ascending order.","required":false,"type":"string","x-example":"DESC","default":"ASC","in":"query"},{"name":"orderCast","description":"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.","required":false,"type":"string","x-example":"int","default":"string","in":"query"},{"name":"search","description":"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.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"}]},"post":{"summary":"Create Document","operationId":"databaseCreateDocument","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](\/docs\/server\/database#databaseCreateCollection) API or directly from your database console.","responses":{"201":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"createDocument","weight":69,"cookies":false,"type":"","demo":"database\/create-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/create-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"data":{"type":"object","description":"Document data as JSON object.","default":null,"x-example":"{}"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"parentDocument":{"type":"string","description":"Parent document unique ID. Use when you want your new document to be a child of a parent document.","default":"","x-example":"[PARENT_DOCUMENT]"},"parentProperty":{"type":"string","description":"Parent document property name. Use when you want your new document to be a child of a parent document.","default":"","x-example":null},"parentPropertyType":{"type":"string","description":"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.","default":"assign","x-example":"assign"}},"required":["data","read","write"]}}]}},"\/database\/collections\/{collectionId}\/documents\/{documentId}":{"get":{"summary":"Get Document","operationId":"databaseGetDocument","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Get a document by its unique ID. This endpoint response returns a JSON object with the document data.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"getDocument","weight":71,"cookies":false,"type":"","demo":"database\/get-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/get-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]},"patch":{"summary":"Update Document","operationId":"databaseUpdateDocument","consumes":["application\/json"],"produces":["application\/json"],"tags":["database"],"description":"Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"updateDocument","weight":72,"cookies":false,"type":"","demo":"database\/update-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/update-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"data":{"type":"object","description":"Document data as JSON object.","default":null,"x-example":"{}"},"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}}},"required":["data","read","write"]}}]},"delete":{"summary":"Delete Document","operationId":"databaseDeleteDocument","consumes":["application\/json"],"produces":[],"tags":["database"],"description":"Delete a document by its unique ID. This endpoint deletes only the parent documents, its attributes and relations to other documents. Child documents **will not** be deleted.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteDocument","weight":73,"cookies":false,"type":"","demo":"database\/delete-document.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/database\/delete-document.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"documents.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"collectionId","description":"Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](\/docs\/server\/database#createCollection).","required":true,"type":"string","x-example":"[COLLECTION_ID]","in":"path"},{"name":"documentId","description":"Document unique ID.","required":true,"type":"string","x-example":"[DOCUMENT_ID]","in":"path"}]}},"\/functions":{"get":{"summary":"List Functions","operationId":"functionsList","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a list of all the project's functions. You can use the query params to filter your results.","responses":{"200":{"description":"Functions List","schema":{"$ref":"#\/definitions\/functionList"}}},"x-appwrite":{"method":"list","weight":156,"cookies":false,"type":"","demo":"functions\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/list-functions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Function","operationId":"functionsCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Create a new function. You can pass a list of [permissions](\/docs\/permissions) to allow different project users or team with access to execute the function using the client API.","responses":{"201":{"description":"Function","schema":{"$ref":"#\/definitions\/function"}}},"x-appwrite":{"method":"create","weight":155,"cookies":false,"type":"","demo":"functions\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/create-function.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"execute":{"type":"array","description":"An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](\/docs\/permissions) and get a full list of available permissions.","default":null,"x-example":null,"items":{"type":"string"}},"env":{"type":"string","description":"Execution enviornment.","default":null,"x-example":"node-14.5"},"vars":{"type":"object","description":"Key-value JSON object.","default":{},"x-example":"{}"},"events":{"type":"array","description":"Events list.","default":[],"x-example":null,"items":{"type":"string"}},"schedule":{"type":"string","description":"Schedule CRON syntax.","default":"","x-example":null},"timeout":{"type":"integer","description":"Function maximum execution time in seconds.","default":15,"x-example":1}},"required":["name","execute","env"]}}]}},"\/functions\/{functionId}":{"get":{"summary":"Get Function","operationId":"functionsGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a function by its unique ID.","responses":{"200":{"description":"Function","schema":{"$ref":"#\/definitions\/function"}}},"x-appwrite":{"method":"get","weight":157,"cookies":false,"type":"","demo":"functions\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/get-function.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"}]},"put":{"summary":"Update Function","operationId":"functionsUpdate","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Update function by its unique ID.","responses":{"200":{"description":"Function","schema":{"$ref":"#\/definitions\/function"}}},"x-appwrite":{"method":"update","weight":159,"cookies":false,"type":"","demo":"functions\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/update-function.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"execute":{"type":"array","description":"An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](\/docs\/permissions) and get a full list of available permissions.","default":null,"x-example":null,"items":{"type":"string"}},"vars":{"type":"object","description":"Key-value JSON object.","default":{},"x-example":"{}"},"events":{"type":"array","description":"Events list.","default":[],"x-example":null,"items":{"type":"string"}},"schedule":{"type":"string","description":"Schedule CRON syntax.","default":"","x-example":null},"timeout":{"type":"integer","description":"Function maximum execution time in seconds.","default":15,"x-example":1}},"required":["name","execute"]}}]},"delete":{"summary":"Delete Function","operationId":"functionsDelete","consumes":["application\/json"],"produces":[],"tags":["functions"],"description":"Delete a function by its unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"delete","weight":161,"cookies":false,"type":"","demo":"functions\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/delete-function.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"}]}},"\/functions\/{functionId}\/executions":{"get":{"summary":"List Executions","operationId":"functionsListExecutions","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a list of all the current user function execution logs. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's teams. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Executions List","schema":{"$ref":"#\/definitions\/executionList"}}},"x-appwrite":{"method":"listExecutions","weight":167,"cookies":false,"type":"","demo":"functions\/list-executions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/list-executions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"execution.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Execution","operationId":"functionsCreateExecution","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.","responses":{"201":{"description":"Execution","schema":{"$ref":"#\/definitions\/execution"}}},"x-appwrite":{"method":"createExecution","weight":166,"cookies":false,"type":"","demo":"functions\/create-execution.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/create-execution.md","rate-limit":60,"rate-time":60,"rate-key":"url:{url},ip:{ip}","scope":"execution.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"}]}},"\/functions\/{functionId}\/executions\/{executionId}":{"get":{"summary":"Get Execution","operationId":"functionsGetExecution","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a function execution log by its unique ID.","responses":{"200":{"description":"Execution","schema":{"$ref":"#\/definitions\/execution"}}},"x-appwrite":{"method":"getExecution","weight":168,"cookies":false,"type":"","demo":"functions\/get-execution.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/get-execution.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"execution.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"executionId","description":"Execution unique ID.","required":true,"type":"string","x-example":"[EXECUTION_ID]","in":"path"}]}},"\/functions\/{functionId}\/tag":{"patch":{"summary":"Update Function Tag","operationId":"functionsUpdateTag","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Update the function code tag ID using the unique function ID. Use this endpoint to switch the code tag that should be executed by the execution endpoint.","responses":{"200":{"description":"Function","schema":{"$ref":"#\/definitions\/function"}}},"x-appwrite":{"method":"updateTag","weight":160,"cookies":false,"type":"","demo":"functions\/update-tag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/update-function-tag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"tag":{"type":"string","description":"Tag unique ID.","default":null,"x-example":"[TAG]"}},"required":["tag"]}}]}},"\/functions\/{functionId}\/tags":{"get":{"summary":"List Tags","operationId":"functionsListTags","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a list of all the project's code tags. You can use the query params to filter your results.","responses":{"200":{"description":"Tags List","schema":{"$ref":"#\/definitions\/tagList"}}},"x-appwrite":{"method":"listTags","weight":163,"cookies":false,"type":"","demo":"functions\/list-tags.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/list-tags.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Tag","operationId":"functionsCreateTag","consumes":["multipart\/form-data"],"produces":["application\/json"],"tags":["functions"],"description":"Create a new function code tag. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's tag to use your new tag UID.\n\nThis endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](\/docs\/functions).\n\nUse the \"command\" param to set the entry point used to execute your code.","responses":{"201":{"description":"Tag","schema":{"$ref":"#\/definitions\/tag"}}},"x-appwrite":{"method":"createTag","weight":162,"cookies":false,"type":"","demo":"functions\/create-tag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/create-tag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":true},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"command","description":"Code execution command.","required":true,"type":"string","x-example":"[COMMAND]","in":"formData"},{"name":"code","description":"Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.","required":true,"type":"file","in":"formData"}]}},"\/functions\/{functionId}\/tags\/{tagId}":{"get":{"summary":"Get Tag","operationId":"functionsGetTag","consumes":["application\/json"],"produces":["application\/json"],"tags":["functions"],"description":"Get a code tag by its unique ID.","responses":{"200":{"description":"Tag","schema":{"$ref":"#\/definitions\/tag"}}},"x-appwrite":{"method":"getTag","weight":164,"cookies":false,"type":"","demo":"functions\/get-tag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/get-tag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"tagId","description":"Tag unique ID.","required":true,"type":"string","x-example":"[TAG_ID]","in":"path"}]},"delete":{"summary":"Delete Tag","operationId":"functionsDeleteTag","consumes":["application\/json"],"produces":[],"tags":["functions"],"description":"Delete a code tag by its unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteTag","weight":165,"cookies":false,"type":"","demo":"functions\/delete-tag.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/functions\/delete-tag.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"functions.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"functionId","description":"Function unique ID.","required":true,"type":"string","x-example":"[FUNCTION_ID]","in":"path"},{"name":"tagId","description":"Tag unique ID.","required":true,"type":"string","x-example":"[TAG_ID]","in":"path"}]}},"\/health":{"get":{"summary":"Get HTTP","operationId":"healthGet","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite HTTP server is up and responsive.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"get","weight":81,"cookies":false,"type":"","demo":"health\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/anti-virus":{"get":{"summary":"Get Anti virus","operationId":"healthGetAntiVirus","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite Anti Virus server is up and connection is successful.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getAntiVirus","weight":93,"cookies":false,"type":"","demo":"health\/get-anti-virus.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-anti-virus.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/cache":{"get":{"summary":"Get Cache","operationId":"healthGetCache","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite in-memory cache server is up and connection is successful.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getCache","weight":84,"cookies":false,"type":"","demo":"health\/get-cache.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-cache.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/db":{"get":{"summary":"Get DB","operationId":"healthGetDB","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite database server is up and connection is successful.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getDB","weight":83,"cookies":false,"type":"","demo":"health\/get-d-b.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-db.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/certificates":{"get":{"summary":"Get Certificate Queue","operationId":"healthGetQueueCertificates","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of certificates that are waiting to be issued against [Letsencrypt](https:\/\/letsencrypt.org\/) in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueCertificates","weight":90,"cookies":false,"type":"","demo":"health\/get-queue-certificates.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-certificates.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/functions":{"get":{"summary":"Get Functions Queue","operationId":"healthGetQueueFunctions","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueFunctions","weight":91,"cookies":false,"type":"","demo":"health\/get-queue-functions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-functions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/logs":{"get":{"summary":"Get Logs Queue","operationId":"healthGetQueueLogs","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of logs that are waiting to be processed in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueLogs","weight":88,"cookies":false,"type":"","demo":"health\/get-queue-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/tasks":{"get":{"summary":"Get Tasks Queue","operationId":"healthGetQueueTasks","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of tasks that are waiting to be processed in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueTasks","weight":87,"cookies":false,"type":"","demo":"health\/get-queue-tasks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-tasks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/usage":{"get":{"summary":"Get Usage Queue","operationId":"healthGetQueueUsage","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueUsage","weight":89,"cookies":false,"type":"","demo":"health\/get-queue-usage.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-usage.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/queue\/webhooks":{"get":{"summary":"Get Webhooks Queue","operationId":"healthGetQueueWebhooks","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getQueueWebhooks","weight":86,"cookies":false,"type":"","demo":"health\/get-queue-webhooks.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-queue-webhooks.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/storage\/local":{"get":{"summary":"Get Local Storage","operationId":"healthGetStorageLocal","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite local storage device is up and connection is successful.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getStorageLocal","weight":92,"cookies":false,"type":"","demo":"health\/get-storage-local.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-storage-local.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/health\/time":{"get":{"summary":"Get Time","operationId":"healthGetTime","consumes":["application\/json"],"produces":[],"tags":["health"],"description":"Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https:\/\/en.wikipedia.org\/wiki\/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP.","responses":{"500":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getTime","weight":85,"cookies":false,"type":"","demo":"health\/get-time.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/health\/get-time.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"health.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale":{"get":{"summary":"Get User Locale","operationId":"localeGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"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.\n\n([IP Geolocation by DB-IP](https:\/\/db-ip.com))","responses":{"200":{"description":"Locale","schema":{"$ref":"#\/definitions\/locale"}}},"x-appwrite":{"method":"get","weight":74,"cookies":false,"type":"","demo":"locale\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-locale.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/continents":{"get":{"summary":"List Continents","operationId":"localeGetContinents","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all continents. You can use the locale header to get the data in a supported language.","responses":{"200":{"description":"Continents List","schema":{"$ref":"#\/definitions\/continentList"}}},"x-appwrite":{"method":"getContinents","weight":78,"cookies":false,"type":"","demo":"locale\/get-continents.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-continents.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries":{"get":{"summary":"List Countries","operationId":"localeGetCountries","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all countries. You can use the locale header to get the data in a supported language.","responses":{"200":{"description":"Countries List","schema":{"$ref":"#\/definitions\/countryList"}}},"x-appwrite":{"method":"getCountries","weight":75,"cookies":false,"type":"","demo":"locale\/get-countries.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/eu":{"get":{"summary":"List EU Countries","operationId":"localeGetCountriesEU","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"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.","responses":{"200":{"description":"Countries List","schema":{"$ref":"#\/definitions\/countryList"}}},"x-appwrite":{"method":"getCountriesEU","weight":76,"cookies":false,"type":"","demo":"locale\/get-countries-e-u.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-eu.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/countries\/phones":{"get":{"summary":"List Countries Phone Codes","operationId":"localeGetCountriesPhones","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all countries phone codes. You can use the locale header to get the data in a supported language.","responses":{"200":{"description":"Phones List","schema":{"$ref":"#\/definitions\/phoneList"}}},"x-appwrite":{"method":"getCountriesPhones","weight":77,"cookies":false,"type":"","demo":"locale\/get-countries-phones.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-countries-phones.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/currencies":{"get":{"summary":"List Currencies","operationId":"localeGetCurrencies","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"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.","responses":{"200":{"description":"Currencies List","schema":{"$ref":"#\/definitions\/currencyList"}}},"x-appwrite":{"method":"getCurrencies","weight":79,"cookies":false,"type":"","demo":"locale\/get-currencies.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-currencies.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/locale\/languages":{"get":{"summary":"List Languages","operationId":"localeGetLanguages","consumes":["application\/json"],"produces":["application\/json"],"tags":["locale"],"description":"List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.","responses":{"200":{"description":"Languages List","schema":{"$ref":"#\/definitions\/languageList"}}},"x-appwrite":{"method":"getLanguages","weight":80,"cookies":false,"type":"","demo":"locale\/get-languages.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/locale\/get-languages.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"locale.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}]}},"\/storage\/files":{"get":{"summary":"List Files","operationId":"storageListFiles","consumes":["application\/json"],"produces":["application\/json"],"tags":["storage"],"description":"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's files. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Files List","schema":{"$ref":"#\/definitions\/fileList"}}},"x-appwrite":{"method":"listFiles","weight":128,"cookies":false,"type":"","demo":"storage\/list-files.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/list-files.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create File","operationId":"storageCreateFile","consumes":["multipart\/form-data"],"produces":["application\/json"],"tags":["storage"],"description":"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.","responses":{"201":{"description":"File","schema":{"$ref":"#\/definitions\/file"}}},"x-appwrite":{"method":"createFile","weight":127,"cookies":false,"type":"upload","demo":"storage\/create-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/create-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"file","description":"Binary file.","required":true,"type":"file","in":"formData"},{"name":"read","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"},{"name":"write","description":"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.","required":true,"type":"array","collectionFormat":"multi","items":{"type":"string"},"in":"formData"}]}},"\/storage\/files\/{fileId}":{"get":{"summary":"Get File","operationId":"storageGetFile","consumes":["application\/json"],"produces":["application\/json"],"tags":["storage"],"description":"Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.","responses":{"200":{"description":"File","schema":{"$ref":"#\/definitions\/file"}}},"x-appwrite":{"method":"getFile","weight":129,"cookies":false,"type":"","demo":"storage\/get-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]},"put":{"summary":"Update File","operationId":"storageUpdateFile","consumes":["application\/json"],"produces":["application\/json"],"tags":["storage"],"description":"Update a file by its unique ID. Only users with write permissions have access to update this resource.","responses":{"200":{"description":"File","schema":{"$ref":"#\/definitions\/file"}}},"x-appwrite":{"method":"updateFile","weight":133,"cookies":false,"type":"","demo":"storage\/update-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/update-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"read":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"write":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}}},"required":["read","write"]}}]},"delete":{"summary":"Delete File","operationId":"storageDeleteFile","consumes":["application\/json"],"produces":[],"tags":["storage"],"description":"Delete a file by its unique ID. Only users with write permissions have access to delete this resource.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteFile","weight":134,"cookies":false,"type":"","demo":"storage\/delete-file.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/delete-file.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/download":{"get":{"summary":"Get File for Download","operationId":"storageGetFileDownload","consumes":["application\/json"],"produces":["*\/*"],"tags":["storage"],"description":"Get a 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.","responses":{"200":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getFileDownload","weight":131,"cookies":false,"type":"location","demo":"storage\/get-file-download.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-download.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/storage\/files\/{fileId}\/preview":{"get":{"summary":"Get File Preview","operationId":"storageGetFilePreview","consumes":["application\/json"],"produces":["image\/*"],"tags":["storage"],"description":"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.","responses":{"200":{"description":"Image","schema":{"type":"file"}}},"x-appwrite":{"method":"getFilePreview","weight":130,"cookies":false,"type":"location","demo":"storage\/get-file-preview.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-preview.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"},{"name":"width","description":"Resize preview image width, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"height","description":"Resize preview image height, Pass an integer between 0 to 4000.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"quality","description":"Preview image quality. Pass an integer between 0 to 100. Defaults to 100.","required":false,"type":"integer","format":"int32","x-example":0,"default":100,"in":"query"},{"name":"background","description":"Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.","required":false,"type":"string","default":"","in":"query"},{"name":"output","description":"Output format type (jpeg, jpg, png, gif and webp).","required":false,"type":"string","x-example":"jpg","default":"","in":"query"}]}},"\/storage\/files\/{fileId}\/view":{"get":{"summary":"Get File for View","operationId":"storageGetFileView","consumes":["application\/json"],"produces":["*\/*"],"tags":["storage"],"description":"Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.","responses":{"200":{"description":"File","schema":{"type":"file"}}},"x-appwrite":{"method":"getFileView","weight":132,"cookies":false,"type":"location","demo":"storage\/get-file-view.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/storage\/get-file-view.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"files.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"fileId","description":"File unique ID.","required":true,"type":"string","x-example":"[FILE_ID]","in":"path"}]}},"\/teams":{"get":{"summary":"List Teams","operationId":"teamsList","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"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's teams. [Learn more about different API modes](\/docs\/admin).","responses":{"200":{"description":"Teams List","schema":{"$ref":"#\/definitions\/teamList"}}},"x-appwrite":{"method":"list","weight":136,"cookies":false,"type":"","demo":"teams\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/list-teams.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team","operationId":"teamsCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"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.","responses":{"201":{"description":"Team","schema":{"$ref":"#\/definitions\/team"}}},"x-appwrite":{"method":"create","weight":135,"cookies":false,"type":"","demo":"teams\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Team name. Max length: 128 chars.","default":null,"x-example":"[NAME]"},"roles":{"type":"array","description":"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.","default":["owner"],"x-example":null,"items":{"type":"string"}}},"required":["name"]}}]}},"\/teams\/{teamId}":{"get":{"summary":"Get Team","operationId":"teamsGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Get a team by its unique ID. All team members have read access for this resource.","responses":{"200":{"description":"Team","schema":{"$ref":"#\/definitions\/team"}}},"x-appwrite":{"method":"get","weight":137,"cookies":false,"type":"","demo":"teams\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]},"put":{"summary":"Update Team","operationId":"teamsUpdate","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Update a team by its unique ID. Only team owners have write access for this resource.","responses":{"200":{"description":"Team","schema":{"$ref":"#\/definitions\/team"}}},"x-appwrite":{"method":"update","weight":138,"cookies":false,"type":"","demo":"teams\/update.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/update-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"name":{"type":"string","description":"Team name. Max length: 128 chars.","default":null,"x-example":"[NAME]"}},"required":["name"]}}]},"delete":{"summary":"Delete Team","operationId":"teamsDelete","consumes":["application\/json"],"produces":[],"tags":["teams"],"description":"Delete a team by its unique ID. Only team owners have write access for this resource.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"delete","weight":139,"cookies":false,"type":"","demo":"teams\/delete.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"}]}},"\/teams\/{teamId}\/memberships":{"get":{"summary":"Get Team Memberships","operationId":"teamsGetMemberships","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"Get a team members by the team unique ID. All team members have read access for this list of resources.","responses":{"200":{"description":"Memberships List","schema":{"$ref":"#\/definitions\/membershipList"}}},"x-appwrite":{"method":"getMemberships","weight":141,"cookies":false,"type":"","demo":"teams\/get-memberships.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/get-team-members.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.read","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create Team Membership","operationId":"teamsCreateMembership","consumes":["application\/json"],"produces":["application\/json"],"tags":["teams"],"description":"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.\n\nUse 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#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team.\n\nPlease 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.","responses":{"201":{"description":"Membership","schema":{"$ref":"#\/definitions\/membership"}}},"x-appwrite":{"method":"createMembership","weight":140,"cookies":false,"type":"","demo":"teams\/create-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/create-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"New team member email.","default":null,"x-example":"email@example.com"},"name":{"type":"string","description":"New team member name. Max length: 128 chars.","default":"","x-example":"[NAME]"},"roles":{"type":"array","description":"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.","default":null,"x-example":null,"items":{"type":"string"}},"url":{"type":"string","description":"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.","default":null,"x-example":"https:\/\/example.com"}},"required":["email","roles","url"]}}]}},"\/teams\/{teamId}\/memberships\/{inviteId}":{"delete":{"summary":"Delete Team Membership","operationId":"teamsDeleteMembership","consumes":["application\/json"],"produces":[],"tags":["teams"],"description":"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 it is not accepted.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteMembership","weight":143,"cookies":false,"type":"","demo":"teams\/delete-membership.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/teams\/delete-team-membership.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"teams.write","platforms":["client","server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"teamId","description":"Team unique ID.","required":true,"type":"string","x-example":"[TEAM_ID]","in":"path"},{"name":"inviteId","description":"Invite unique ID.","required":true,"type":"string","x-example":"[INVITE_ID]","in":"path"}]}},"\/users":{"get":{"summary":"List Users","operationId":"usersList","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get a list of all the project's users. You can use the query params to filter your results.","responses":{"200":{"description":"Users List","schema":{"$ref":"#\/definitions\/userList"}}},"x-appwrite":{"method":"list","weight":145,"cookies":false,"type":"","demo":"users\/list.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/list-users.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"search","description":"Search term to filter your list results. Max length: 256 chars.","required":false,"type":"string","x-example":"[SEARCH]","default":"","in":"query"},{"name":"limit","description":"Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.","required":false,"type":"integer","format":"int32","x-example":0,"default":25,"in":"query"},{"name":"offset","description":"Results offset. The default value is 0. Use this param to manage pagination.","required":false,"type":"integer","format":"int32","x-example":0,"default":0,"in":"query"},{"name":"orderType","description":"Order result by ASC or DESC order.","required":false,"type":"string","x-example":"ASC","default":"ASC","in":"query"}]},"post":{"summary":"Create User","operationId":"usersCreate","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Create a new user.","responses":{"201":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"create","weight":144,"cookies":false,"type":"","demo":"users\/create.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/create-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"payload","in":"body","schema":{"type":"object","properties":{"email":{"type":"string","description":"User email.","default":null,"x-example":"email@example.com"},"password":{"type":"string","description":"User password. Must be between 6 to 32 chars.","default":null,"x-example":"password"},"name":{"type":"string","description":"User name. Max length: 128 chars.","default":"","x-example":"[NAME]"}},"required":["email","password"]}}]}},"\/users\/{userId}":{"get":{"summary":"Get User","operationId":"usersGet","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get a user by its unique ID.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"get","weight":146,"cookies":false,"type":"","demo":"users\/get.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"delete":{"summary":"Delete User","operationId":"usersDeleteUser","consumes":["application\/json"],"produces":[],"tags":["users"],"description":"Delete a user by its unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteUser","weight":154,"cookies":false,"type":"","demo":"users\/delete-user.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/logs":{"get":{"summary":"Get User Logs","operationId":"usersGetLogs","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get a user activity logs list by its unique ID.","responses":{"200":{"description":"Logs List","schema":{"$ref":"#\/definitions\/logList"}}},"x-appwrite":{"method":"getLogs","weight":149,"cookies":false,"type":"","demo":"users\/get-logs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-logs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/prefs":{"get":{"summary":"Get User Preferences","operationId":"usersGetPrefs","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get the user preferences by its unique ID.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"getPrefs","weight":147,"cookies":false,"type":"","demo":"users\/get-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"patch":{"summary":"Update User Preferences","operationId":"usersUpdatePrefs","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Update the user preferences by its unique ID. You can pass only the specific settings you wish to update.","responses":{"200":{"description":"Any","schema":{"$ref":"#\/definitions\/any"}}},"x-appwrite":{"method":"updatePrefs","weight":151,"cookies":false,"type":"","demo":"users\/update-prefs.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-prefs.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"prefs":{"type":"object","description":"Prefs key-value JSON object.","default":null,"x-example":"{}"}},"required":["prefs"]}}]}},"\/users\/{userId}\/sessions":{"get":{"summary":"Get User Sessions","operationId":"usersGetSessions","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Get the user sessions list by its unique ID.","responses":{"200":{"description":"Sessions List","schema":{"$ref":"#\/definitions\/sessionList"}}},"x-appwrite":{"method":"getSessions","weight":148,"cookies":false,"type":"","demo":"users\/get-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/get-user-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.read","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]},"delete":{"summary":"Delete User Sessions","operationId":"usersDeleteSessions","consumes":["application\/json"],"produces":[],"tags":["users"],"description":"Delete all user's sessions by using the user's unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteSessions","weight":153,"cookies":false,"type":"","demo":"users\/delete-sessions.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-sessions.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"}]}},"\/users\/{userId}\/sessions\/{sessionId}":{"delete":{"summary":"Delete User Session","operationId":"usersDeleteSession","consumes":["application\/json"],"produces":[],"tags":["users"],"description":"Delete a user sessions by its unique ID.","responses":{"204":{"description":"No content"}},"x-appwrite":{"method":"deleteSession","weight":152,"cookies":false,"type":"","demo":"users\/delete-session.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/delete-user-session.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"sessionId","description":"User unique session ID.","required":true,"type":"string","x-example":"[SESSION_ID]","in":"path"}]}},"\/users\/{userId}\/status":{"patch":{"summary":"Update User Status","operationId":"usersUpdateStatus","consumes":["application\/json"],"produces":["application\/json"],"tags":["users"],"description":"Update the user status by its unique ID.","responses":{"200":{"description":"User","schema":{"$ref":"#\/definitions\/user"}}},"x-appwrite":{"method":"updateStatus","weight":150,"cookies":false,"type":"","demo":"users\/update-status.md","edit":"https:\/\/github.com\/appwrite\/appwrite\/edit\/master\/docs\/references\/users\/update-user-status.md","rate-limit":0,"rate-time":3600,"rate-key":"url:{url},ip:{ip}","scope":"users.write","platforms":["server"],"packaging":false},"security":[{"Project":[],"Key":[]}],"parameters":[{"name":"userId","description":"User unique ID.","required":true,"type":"string","x-example":"[USER_ID]","in":"path"},{"name":"payload","in":"body","schema":{"type":"object","properties":{"status":{"type":"string","description":"User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0","default":null,"x-example":1}},"required":["status"]}}]}}},"tags":[{"name":"account","description":"The Account service allows you to authenticate and manage a user account."},{"name":"avatars","description":"The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars."},{"name":"database","description":"The Database service allows you to create structured collections of documents, query and filter lists of documents"},{"name":"locale","description":"The Locale service allows you to customize your app based on your users' location."},{"name":"health","description":"The Health service allows you to both validate and monitor your Appwrite server's health."},{"name":"projects","description":"The Project service allows you to manage all the projects in your Appwrite server."},{"name":"storage","description":"The Storage service allows you to manage your project files."},{"name":"teams","description":"The Teams service allows you to group users of your project and to enable them to share read and write access to your project resources"},{"name":"users","description":"The Users service allows you to manage your project users."},{"name":"functions","description":"The Functions Service allows you view, create and manage your Cloud Functions."}],"definitions":{"none":{"description":"None","type":"object"},"any":{"description":"Any","type":"object","additionalProperties":true},"error":{"description":"Error","type":"object","properties":{"message":{"type":"string","description":"Error message.","x-example":"Not found"},"code":{"type":"string","description":"Error code.","x-example":"404"},"version":{"type":"string","description":"Server version number.","x-example":"1.0"}},"required":["message","code","version"]},"collectionList":{"description":"Collections List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"collections":{"type":"array","description":"List of collections.","items":{"type":"object","$ref":"#\/definitions\/collection"},"x-example":""}},"required":["sum","collections"]},"documentList":{"description":"Documents List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"documents":{"type":"array","description":"List of documents.","items":{"type":"object","$ref":"#\/definitions\/any"},"x-example":""}},"required":["sum","documents"]},"userList":{"description":"Users List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"users":{"type":"array","description":"List of users.","items":{"type":"object","$ref":"#\/definitions\/user"},"x-example":""}},"required":["sum","users"]},"sessionList":{"description":"Sessions List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"sessions":{"type":"array","description":"List of sessions.","items":{"type":"object","$ref":"#\/definitions\/session"},"x-example":""}},"required":["sum","sessions"]},"logList":{"description":"Logs List","type":"object","properties":{"logs":{"type":"array","description":"List of logs.","items":{"type":"object","$ref":"#\/definitions\/log"},"x-example":""}},"required":["logs"]},"fileList":{"description":"Files List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"files":{"type":"array","description":"List of files.","items":{"type":"object","$ref":"#\/definitions\/file"},"x-example":""}},"required":["sum","files"]},"teamList":{"description":"Teams List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"teams":{"type":"array","description":"List of teams.","items":{"type":"object","$ref":"#\/definitions\/team"},"x-example":""}},"required":["sum","teams"]},"membershipList":{"description":"Memberships List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"memberships":{"type":"array","description":"List of memberships.","items":{"type":"object","$ref":"#\/definitions\/membership"},"x-example":""}},"required":["sum","memberships"]},"functionList":{"description":"Functions List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"functions":{"type":"array","description":"List of functions.","items":{"type":"object","$ref":"#\/definitions\/function"},"x-example":""}},"required":["sum","functions"]},"tagList":{"description":"Tags List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"tags":{"type":"array","description":"List of tags.","items":{"type":"object","$ref":"#\/definitions\/tag"},"x-example":""}},"required":["sum","tags"]},"executionList":{"description":"Executions List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"executions":{"type":"array","description":"List of executions.","items":{"type":"object","$ref":"#\/definitions\/execution"},"x-example":""}},"required":["sum","executions"]},"countryList":{"description":"Countries List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"countries":{"type":"array","description":"List of countries.","items":{"type":"object","$ref":"#\/definitions\/country"},"x-example":""}},"required":["sum","countries"]},"continentList":{"description":"Continents List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"continents":{"type":"array","description":"List of continents.","items":{"type":"object","$ref":"#\/definitions\/continent"},"x-example":""}},"required":["sum","continents"]},"languageList":{"description":"Languages List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"languages":{"type":"array","description":"List of languages.","items":{"type":"object","$ref":"#\/definitions\/language"},"x-example":""}},"required":["sum","languages"]},"currencyList":{"description":"Currencies List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"currencies":{"type":"array","description":"List of currencies.","items":{"type":"object","$ref":"#\/definitions\/currency"},"x-example":""}},"required":["sum","currencies"]},"phoneList":{"description":"Phones List","type":"object","properties":{"sum":{"type":"integer","description":"Total sum of items in the list.","x-example":5,"format":"int32"},"phones":{"type":"array","description":"List of phones.","items":{"type":"object","$ref":"#\/definitions\/phone"},"x-example":""}},"required":["sum","phones"]},"permissions":{"description":"Permissions","type":"object","properties":{"read":{"type":"array","description":"Read permissions.","items":{"type":"string"},"x-example":"user:5e5ea5c16897e"},"write":{"type":"array","description":"Write permissions.","items":{"type":"string"},"x-example":"user:5e5ea5c16897e"}},"required":["read","write"]},"collection":{"description":"Collection","type":"object","properties":{"$id":{"type":"string","description":"Collection ID.","x-example":"5e5ea5c16897e"},"$permissions":{"type":"object","description":"Collection permissions.","x-example":{},"items":{"type":"object","$ref":"#\/definitions\/permissions"}},"name":{"type":"string","description":"Collection name.","x-example":"Movies"},"dateCreated":{"type":"integer","description":"Collection creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"dateUpdated":{"type":"integer","description":"Collection creation date in Unix timestamp.","x-example":1592981550,"format":"int32"},"rules":{"type":"array","description":"Collection rules.","items":{"type":"object","$ref":"#\/definitions\/rule"},"x-example":""}},"required":["$id","$permissions","name","dateCreated","dateUpdated","rules"]},"rule":{"description":"Rule","type":"object","properties":{"$id":{"type":"string","description":"Rule ID.","x-example":"5e5ea5c16897e"},"$collection":{"type":"string","description":"Rule Collection.","x-example":"5e5e66c16897e"},"type":{"type":"string","description":"Rule type. Possible values: ","x-example":"title"},"key":{"type":"string","description":"Rule key.","x-example":"title"},"label":{"type":"string","description":"Rule label.","x-example":"Title"},"default":{"type":"string","description":"Rule default value.","x-example":"Movie Name"},"array":{"type":"boolean","description":"Is array?","x-example":false},"required":{"type":"boolean","description":"Is required?","x-example":true},"list":{"type":"array","description":"List of allowed values","items":{"type":"string"},"x-example":"5e5ea5c168099"}},"required":["$id","$collection","type","key","label","default","array","required","list"]},"log":{"description":"Log","type":"object","properties":{"event":{"type":"string","description":"Event name.","x-example":"account.sessions.create"},"ip":{"type":"string","description":"IP session in use when the session was created.","x-example":"127.0.0.1"},"time":{"type":"integer","description":"Log creation time in Unix timestamp.","x-example":1592981250,"format":"int32"},"osCode":{"type":"string","description":"Operating system code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/os.json).","x-example":"Mac"},"osName":{"type":"string","description":"Operating system name.","x-example":"Mac"},"osVersion":{"type":"string","description":"Operating system version.","x-example":"Mac"},"clientType":{"type":"string","description":"Client type.","x-example":"browser"},"clientCode":{"type":"string","description":"Client code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/clients.json).","x-example":"CM"},"clientName":{"type":"string","description":"Client name.","x-example":"Chrome Mobile iOS"},"clientVersion":{"type":"string","description":"Client version.","x-example":"84.0"},"clientEngine":{"type":"string","description":"Client engine name.","x-example":"WebKit"},"clientEngineVersion":{"type":"string","description":"Client engine name.","x-example":"605.1.15"},"deviceName":{"type":"string","description":"Device name.","x-example":"smartphone"},"deviceBrand":{"type":"string","description":"Device brand name.","x-example":"Google"},"deviceModel":{"type":"string","description":"Device model name.","x-example":"Nexus 5"},"countryCode":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"},"countryName":{"type":"string","description":"Country name.","x-example":"United States"}},"required":["event","ip","time","osCode","osName","osVersion","clientType","clientCode","clientName","clientVersion","clientEngine","clientEngineVersion","deviceName","deviceBrand","deviceModel","countryCode","countryName"]},"user":{"description":"User","type":"object","properties":{"$id":{"type":"string","description":"User ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"User name.","x-example":"John Doe"},"registration":{"type":"integer","description":"User registration date in Unix timestamp.","x-example":1592981250,"format":"int32"},"status":{"type":"integer","description":"User status. 0 for Unactivated, 1 for active and 2 is blocked.","x-example":0,"format":"int32"},"email":{"type":"string","description":"User email address.","x-example":"john@appwrite.io"},"emailVerification":{"type":"boolean","description":"Email verification status.","x-example":true},"prefs":{"type":"string","description":"User preferences as a key-value object","x-example":{"theme":"pink","timezone":"UTC"}}},"required":["$id","name","registration","status","email","emailVerification","prefs"]},"session":{"description":"Session","type":"object","properties":{"$id":{"type":"string","description":"Session ID.","x-example":"5e5ea5c16897e"},"userId":{"type":"string","description":"User ID.","x-example":"5e5bb8c16897e"},"expire":{"type":"integer","description":"Session expiration date in Unix timestamp.","x-example":1592981250,"format":"int32"},"ip":{"type":"string","description":"IP in use when the session was created.","x-example":"127.0.0.1"},"osCode":{"type":"string","description":"Operating system code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/os.json).","x-example":"Mac"},"osName":{"type":"string","description":"Operating system name.","x-example":"Mac"},"osVersion":{"type":"string","description":"Operating system version.","x-example":"Mac"},"clientType":{"type":"string","description":"Client type.","x-example":"browser"},"clientCode":{"type":"string","description":"Client code name. View list of [available options](https:\/\/github.com\/appwrite\/appwrite\/blob\/master\/docs\/lists\/clients.json).","x-example":"CM"},"clientName":{"type":"string","description":"Client name.","x-example":"Chrome Mobile iOS"},"clientVersion":{"type":"string","description":"Client version.","x-example":"84.0"},"clientEngine":{"type":"string","description":"Client engine name.","x-example":"WebKit"},"clientEngineVersion":{"type":"string","description":"Client engine name.","x-example":"605.1.15"},"deviceName":{"type":"string","description":"Device name.","x-example":"smartphone"},"deviceBrand":{"type":"string","description":"Device brand name.","x-example":"Google"},"deviceModel":{"type":"string","description":"Device model name.","x-example":"Nexus 5"},"countryCode":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"},"countryName":{"type":"string","description":"Country name.","x-example":"United States"},"current":{"type":"boolean","description":"Returns true if this the current user session.","x-example":true}},"required":["$id","userId","expire","ip","osCode","osName","osVersion","clientType","clientCode","clientName","clientVersion","clientEngine","clientEngineVersion","deviceName","deviceBrand","deviceModel","countryCode","countryName","current"]},"token":{"description":"Token","type":"object","properties":{"$id":{"type":"string","description":"Token ID.","x-example":"bb8ea5c16897e"},"userId":{"type":"string","description":"User ID.","x-example":"5e5ea5c168bb8"},"secret":{"type":"string","description":"Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.","x-example":""},"expire":{"type":"integer","description":"Token expiration date in Unix timestamp.","x-example":1592981250,"format":"int32"}},"required":["$id","userId","secret","expire"]},"jwt":{"description":"JWT","type":"object","properties":{"jwt":{"type":"string","description":"JWT encoded string.","x-example":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"}},"required":["jwt"]},"locale":{"description":"Locale","type":"object","properties":{"ip":{"type":"string","description":"User IP address.","x-example":"127.0.0.1"},"countryCode":{"type":"string","description":"Country code in [ISO 3166-1](http:\/\/en.wikipedia.org\/wiki\/ISO_3166-1) two-character format","x-example":"US"},"country":{"type":"string","description":"Country name. This field support localization.","x-example":"United States"},"continentCode":{"type":"string","description":"Continent code. A two character continent code \"AF\" for Africa, \"AN\" for Antarctica, \"AS\" for Asia, \"EU\" for Europe, \"NA\" for North America, \"OC\" for Oceania, and \"SA\" for South America.","x-example":"NA"},"continent":{"type":"string","description":"Continent name. This field support localization.","x-example":"North America"},"eu":{"type":"boolean","description":"True if country is part of the Europian Union.","x-example":false},"currency":{"type":"string","description":"Currency code in [ISO 4217-1](http:\/\/en.wikipedia.org\/wiki\/ISO_4217) three-character format","x-example":"USD"}},"required":["ip","countryCode","country","continentCode","continent","eu","currency"]},"file":{"description":"File","type":"object","properties":{"$id":{"type":"string","description":"File ID.","x-example":"5e5ea5c16897e"},"$permissions":{"type":"object","description":"File permissions.","x-example":{},"items":{"type":"object","$ref":"#\/definitions\/permissions"}},"name":{"type":"string","description":"File name.","x-example":"Pink.png"},"dateCreated":{"type":"integer","description":"File creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"signature":{"type":"string","description":"File MD5 signature.","x-example":"5d529fd02b544198ae075bd57c1762bb"},"mimeType":{"type":"string","description":"File mime type.","x-example":"image\/png"},"sizeOriginal":{"type":"integer","description":"File original size in bytes.","x-example":17890,"format":"int32"}},"required":["$id","$permissions","name","dateCreated","signature","mimeType","sizeOriginal"]},"team":{"description":"Team","type":"object","properties":{"$id":{"type":"string","description":"Team ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"Team name.","x-example":"VIP"},"dateCreated":{"type":"integer","description":"Team creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"sum":{"type":"integer","description":"Total sum of team members.","x-example":7,"format":"int32"}},"required":["$id","name","dateCreated","sum"]},"membership":{"description":"Membership","type":"object","properties":{"$id":{"type":"string","description":"Membership ID.","x-example":"5e5ea5c16897e"},"userId":{"type":"string","description":"User ID.","x-example":"5e5ea5c16897e"},"teamId":{"type":"string","description":"Team ID.","x-example":"5e5ea5c16897e"},"name":{"type":"string","description":"User name.","x-example":"VIP"},"email":{"type":"string","description":"User email address.","x-example":"john@appwrite.io"},"invited":{"type":"integer","description":"Date, the user has been invited to join the team in Unix timestamp.","x-example":1592981250,"format":"int32"},"joined":{"type":"integer","description":"Date, the user has accepted the invitation to join the team in Unix timestamp.","x-example":1592981250,"format":"int32"},"confirm":{"type":"boolean","description":"User confirmation status, true if the user has joined the team or false otherwise.","x-example":false},"roles":{"type":"array","description":"User list of roles","items":{"type":"string"},"x-example":"admin"}},"required":["$id","userId","teamId","name","email","invited","joined","confirm","roles"]},"function":{"description":"Function","type":"object","properties":{"$id":{"type":"string","description":"Function ID.","x-example":"5e5ea5c16897e"},"$permissions":{"type":"object","description":"Function permissions.","x-example":{},"items":{"type":"object","$ref":"#\/definitions\/permissions"}},"name":{"type":"string","description":"Function name.","x-example":"My Function"},"dateCreated":{"type":"integer","description":"Function creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"dateUpdated":{"type":"integer","description":"Function update date in Unix timestamp.","x-example":1592981257,"format":"int32"},"status":{"type":"string","description":"Function status. Possible values: disabled, enabled","x-example":"enabled"},"env":{"type":"string","description":"Function execution environment.","x-example":"python-3.8"},"tag":{"type":"string","description":"Function active tag ID.","x-example":"5e5ea5c16897e"},"vars":{"type":"string","description":"Function environment variables.","x-example":{"key":"value"}},"events":{"type":"array","description":"Function trigger events.","items":{"type":"string"},"x-example":"account.create"},"schedule":{"type":"string","description":"Function execution schedult in CRON format.","x-example":"5 4 * * *"},"scheduleNext":{"type":"integer","description":"Function next scheduled execution date in Unix timestamp.","x-example":1592981292,"format":"int32"},"schedulePrevious":{"type":"integer","description":"Function next scheduled execution date in Unix timestamp.","x-example":1592981237,"format":"int32"},"timeout":{"type":"integer","description":"Function execution timeout in seconds.","x-example":1592981237,"format":"int32"}},"required":["$id","$permissions","name","dateCreated","dateUpdated","status","env","tag","vars","events","schedule","scheduleNext","schedulePrevious","timeout"]},"tag":{"description":"Tag","type":"object","properties":{"$id":{"type":"string","description":"Tag ID.","x-example":"5e5ea5c16897e"},"functionId":{"type":"string","description":"Function ID.","x-example":"5e5ea6g16897e"},"dateCreated":{"type":"integer","description":"The tag creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"command":{"type":"string","description":"The entrypoint command in use to execute the tag code.","x-example":"enabled"},"size":{"type":"string","description":"The code size in bytes.","x-example":"python-3.8"}},"required":["$id","functionId","dateCreated","command","size"]},"execution":{"description":"Execution","type":"object","properties":{"$id":{"type":"string","description":"Execution ID.","x-example":"5e5ea5c16897e"},"functionId":{"type":"string","description":"Function ID.","x-example":"5e5ea6g16897e"},"dateCreated":{"type":"integer","description":"The execution creation date in Unix timestamp.","x-example":1592981250,"format":"int32"},"trigger":{"type":"string","description":"The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.","x-example":"http"},"status":{"type":"string","description":"The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.","x-example":"processing"},"exitCode":{"type":"integer","description":"The script exit code.","x-example":0,"format":"int32"},"stdout":{"type":"string","description":"The script stdout output string.","x-example":""},"stderr":{"type":"string","description":"The script stderr output string.","x-example":""},"time":{"type":"number","description":"The script execution time in seconds.","x-example":0.4,"format":"float"}},"required":["$id","functionId","dateCreated","trigger","status","exitCode","stdout","stderr","time"]},"country":{"description":"Country","type":"object","properties":{"name":{"type":"string","description":"Country name.","x-example":"United States"},"code":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"}},"required":["name","code"]},"continent":{"description":"Continent","type":"object","properties":{"name":{"type":"string","description":"Continent name.","x-example":"Europe"},"code":{"type":"string","description":"Continent two letter code.","x-example":"EU"}},"required":["name","code"]},"language":{"description":"Language","type":"object","properties":{"name":{"type":"string","description":"Language name.","x-example":"Italian"},"code":{"type":"string","description":"Language two-character ISO 639-1 codes.","x-example":"it"},"nativeName":{"type":"string","description":"Language native name.","x-example":"Italiano"}},"required":["name","code","nativeName"]},"currency":{"description":"Currency","type":"object","properties":{"symbol":{"type":"string","description":"Currency symbol.","x-example":"$"},"name":{"type":"string","description":"Currency name.","x-example":"US dollar"},"symbolNative":{"type":"string","description":"Currency native symbol.","x-example":"$"},"decimalDigits":{"type":"integer","description":"Number of decimal digits.","x-example":2,"format":"int32"},"rounding":{"type":"number","description":"Currency digit rounding.","x-example":0,"format":"float"},"code":{"type":"string","description":"Currency code in [ISO 4217-1](http:\/\/en.wikipedia.org\/wiki\/ISO_4217) three-character format.","x-example":"USD"},"namePlural":{"type":"string","description":"Currency plural name","x-example":"US dollars"}},"required":["symbol","name","symbolNative","decimalDigits","rounding","code","namePlural"]},"phone":{"description":"Phone","type":"object","properties":{"code":{"type":"string","description":"Phone code.","x-example":"+1"},"countryCode":{"type":"string","description":"Country two-character ISO 3166-1 alpha code.","x-example":"US"},"countryName":{"type":"string","description":"Country name.","x-example":"United States"}},"required":["code","countryCode","countryName"]}},"externalDocs":{"description":"Full API docs, specs and tutorials","url":"https:\/\/appwrite.io\/docs"}} \ No newline at end of file diff --git a/app/config/storage/inputs.php b/app/config/storage/inputs.php new file mode 100644 index 0000000000..c580316c53 --- /dev/null +++ b/app/config/storage/inputs.php @@ -0,0 +1,8 @@ + 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'gif' => 'image/gif', + 'png' => 'image/png', +]; \ No newline at end of file diff --git a/app/config/storage/logos.php b/app/config/storage/logos.php new file mode 100644 index 0000000000..3170762dca --- /dev/null +++ b/app/config/storage/logos.php @@ -0,0 +1,43 @@ + __DIR__.'/logos/none.png', + + // Video Files + 'video/mp4' => __DIR__.'/logos/video.png', + 'video/x-flv' => __DIR__.'/logos/video.png', + 'application/x-mpegURL' => __DIR__.'/logos/video.png', + 'video/MP2T' => __DIR__.'/logos/video.png', + 'video/3gpp' => __DIR__.'/logos/video.png', + 'video/quicktime' => __DIR__.'/logos/video.png', + 'video/x-msvideo' => __DIR__.'/logos/video.png', + 'video/x-ms-wmv' => __DIR__.'/logos/video.png', + + // // Microsoft Word + 'application/msword' => __DIR__.'/logos/word.png', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => __DIR__.'/logos/word.png', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => __DIR__.'/logos/word.png', + 'application/vnd.ms-word.document.macroEnabled.12' => __DIR__.'/logos/word.png', + + // // Microsoft Excel + 'application/vnd.ms-excel' => __DIR__.'/logos/excel.png', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => __DIR__.'/logos/excel.png', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => __DIR__.'/logos/excel.png', + 'application/vnd.ms-excel.sheet.macroEnabled.12' => __DIR__.'/logos/excel.png', + 'application/vnd.ms-excel.template.macroEnabled.12' => __DIR__.'/logos/excel.png', + 'application/vnd.ms-excel.addin.macroEnabled.12' => __DIR__.'/logos/excel.png', + 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => __DIR__.'/logos/excel.png', + + // // Microsoft Power Point + 'application/vnd.ms-powerpoint' => __DIR__.'/logos/ppt.png', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => __DIR__.'/logos/ppt.png', + 'application/vnd.openxmlformats-officedocument.presentationml.template' => __DIR__.'/logos/ppt.png', + 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => __DIR__.'/logos/ppt.png', + 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => __DIR__.'/logos/ppt.png', + 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => __DIR__.'/logos/ppt.png', + 'application/vnd.ms-powerpoint.template.macroEnabled.12' => __DIR__.'/logos/ppt.png', + 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => __DIR__.'/logos/ppt.png', + + // Adobe PDF + 'application/pdf' => __DIR__.'/logos/pdf.png', +]; \ No newline at end of file diff --git a/app/config/files/excel.png b/app/config/storage/logos/excel.png similarity index 100% rename from app/config/files/excel.png rename to app/config/storage/logos/excel.png diff --git a/app/config/files/none.png b/app/config/storage/logos/none.png similarity index 100% rename from app/config/files/none.png rename to app/config/storage/logos/none.png diff --git a/app/config/files/pdf.png b/app/config/storage/logos/pdf.png similarity index 100% rename from app/config/files/pdf.png rename to app/config/storage/logos/pdf.png diff --git a/app/config/files/ppt.png b/app/config/storage/logos/ppt.png similarity index 100% rename from app/config/files/ppt.png rename to app/config/storage/logos/ppt.png diff --git a/app/config/files/video.png b/app/config/storage/logos/video.png similarity index 100% rename from app/config/files/video.png rename to app/config/storage/logos/video.png diff --git a/app/config/files/word.png b/app/config/storage/logos/word.png similarity index 100% rename from app/config/files/word.png rename to app/config/storage/logos/word.png diff --git a/app/config/storage/mimes.php b/app/config/storage/mimes.php new file mode 100644 index 0000000000..242a990b8d --- /dev/null +++ b/app/config/storage/mimes.php @@ -0,0 +1,50 @@ + 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'gif' => 'image/gif', + 'png' => 'image/png', + 'webp' => 'image/webp', +]; \ No newline at end of file diff --git a/app/config/variables.php b/app/config/variables.php new file mode 100644 index 0000000000..e842283c2c --- /dev/null +++ b/app/config/variables.php @@ -0,0 +1,412 @@ + 'General', + 'description' => '', + 'variables' => [ + [ + 'name' => '_APP_ENV', + 'description' => 'Set your server running environment. By default, the var is set to \'development\'. When deploying to production, change it to: \'production\'.', + 'introduction' => '', + 'default' => 'production', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_OPTIONS_ABUSE', + 'description' => 'Allows you to disable abuse checks and API rate limiting. By default, set to \'enabled\'. To cancel the abuse checking, set to \'disabled\'. It is not recommended to disable this check-in a production environment.', + 'introduction' => '', + 'default' => 'enabled', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_OPTIONS_FORCE_HTTPS', + 'description' => 'Allows you to force HTTPS connection to your API. This feature redirects any HTTP call to HTTPS and adds the \'Strict-Transport-Security\' header to all HTTP responses. By default, set to \'disabled\'. To enable, set to \'enabled\'. This feature will work only when your ports are set to default 80 and 443.', + 'introduction' => '', + 'default' => 'enabled', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_OPENSSL_KEY_V1', + 'description' => 'This is your server private secret key that is used to encrypt all sensitive data on your server. Appwrite server encrypts all secret data on your server like webhooks, HTTP passwords, user sessions, and storage files. The var is not set by default, if you wish to take advantage of Appwrite encryption capabilities you should change it and make sure to **keep it a secret and have a backup for it**.', + 'introduction' => '', + 'default' => 'your-secret-key', + 'required' => true, + 'question' => 'Choose a secret API key, make sure to make a backup of your key in a secure location', + ], + [ + 'name' => '_APP_DOMAIN', + 'description' => 'Your Appwrite domain address. When setting a public suffix domain, Appwrite will attempt to issue a valid SSL certificate automatically. When used with a dev domain, Appwrite will assign a self-signed SSL certificate. The default value is \'localhost\'.', + 'introduction' => '', + 'default' => 'localhost', + 'required' => true, + 'question' => 'Enter your Appwrite hostname', + ], + [ + 'name' => '_APP_DOMAIN_TARGET', + 'description' => 'A DNS A record hostname to serve as a CNAME target for your Appwrite custom domains. You can use the same value as used for the Appwrite \'_APP_DOMAIN\' variable. The default value is \'localhost\'.', + 'introduction' => '', + 'default' => 'localhost', + 'required' => true, + 'question' => 'Enter a DNS A record hostname to serve as a CNAME for your custom domains.\nYou can use the same value as used for the Appwrite hostname.', + ], + [ + 'name' => '_APP_CONSOLE_WHITELIST_EMAILS', + 'description' => 'This option allows you to limit creation of users to Appwrite console. This option is very useful for small teams or sole developers. To enable it, pass a list of allowed email addresses separated by a comma.', + 'introduction' => '', + 'default' => '', + 'required' => false, + 'question' => '', + ], + // [ + // 'name' => '_APP_CONSOLE_WHITELIST_DOMAINS', + // 'description' => 'This option allows you to limit creation of users to Appwrite console for users sharing the same email domains. This option is very useful for team working with company emails domain.\n\nTo enable this option, pass a list of allowed email domains separated by a comma.', + // 'introduction' => '', + // 'default' => '', + // 'required' => false, + // 'question' => '', + // ], + [ + 'name' => '_APP_CONSOLE_WHITELIST_IPS', + 'description' => 'This last option allows you to limit creation of users in Appwrite console for users sharing the same set of IP addresses. This option is very useful for team working with a VPN service or a company IP.\n\nTo enable/activate this option, pass a list of allowed IP addresses separated by a comma.', + 'introduction' => '', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_SYSTEM_EMAIL_NAME', + 'description' => 'This is the sender name value that will appear on email messages sent to developers from the Appwrite console. The default value is: \'Appwrite\'. You can use url encoded strings for spaces and special chars.', + 'introduction' => '0.7.0', + 'default' => 'Appwrite', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_SYSTEM_EMAIL_ADDRESS', + 'description' => 'This is the sender email address that will appear on email messages sent to developers from the Appwrite console. The default value is \'team@appwrite.io\'. You should choose an email address that is allowed to be used from your SMTP server to avoid the server email ending in the users\' SPAM folders.', + 'introduction' => '0.7.0', + 'default' => 'team@appwrite.io', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_SYSTEM_RESPONSE_FORMAT', + 'description' => 'Use this environment variable to set the default Appwrite HTTP response format to support an older version of Appwrite. This option is useful to overcome breaking changes between versions. You can also use the `X-Appwrite-Response-Format` HTTP request header to overwrite the response for a specific request. This variable accepts any valid Appwrite version. To use the current version format, leave the value of the variable empty.', + 'introduction' => '0.7.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', + 'description' => 'This is the email address used to issue SSL certificates for custom domains or the user agent in webhooks. The default value is \'security@localhost.test\'.', + 'introduction' => '0.7.0', + 'default' => 'security@localhost.test', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_USAGE_STATS', + 'description' => 'This variable allows you to disable the collection and displaying of usage stats. This value is set to \'enabled\' by default, to disable the usage stats set the value to \'disabled\'. When disabled, it\'s recommended to turn off the Worker Usage, Influxdb and Telegraf containers for better resource usage.', + 'introduction' => '0.7.0', + 'default' => 'enabled', + 'required' => false, + 'question' => '', + ], + ], + ], + [ + 'category' => 'Redis', + 'description' => 'Appwrite uses a Redis server for managing cache, queues and scheduled tasks. The Redis env vars are used to allow Appwrite server to connect to the Redis container.', + 'variables' => [ + [ + 'name' => '_APP_REDIS_HOST', + 'description' => 'Redis server hostname address. Default value is: \'redis\'.', + 'introduction' => '', + 'default' => 'redis', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_REDIS_PORT', + 'description' => 'Redis server TCP port. Default value is: \'6379\'.', + 'introduction' => '', + 'default' => '6379', + 'required' => false, + 'question' => '', + ], + ], + ], + [ + 'category' => 'MariaDB', + 'description' => 'Appwrite is using a MariaDB server for managing persistent database data. The MariaDB env vars are used to allow Appwrite server to connect to the MariaDB container.', + 'variables' => [ + [ + 'name' => '_APP_DB_HOST', + 'description' => 'MariaDB server host name address. Default value is: \'mariadb\'.', + 'introduction' => '', + 'default' => 'mariadb', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_DB_PORT', + 'description' => 'MariaDB server TCP port. Default value is: \'3306\'.', + 'introduction' => '', + 'default' => '3306', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_DB_SCHEMA', + 'description' => 'MariaDB server database schema. Default value is: \'appwrite\'.', + 'introduction' => '', + 'default' => 'appwrite', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_DB_USER', + 'description' => 'MariaDB server user name. Default value is: \'user\'.', + 'introduction' => '', + 'default' => 'user', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_DB_PASS', + 'description' => 'MariaDB server user password. Default value is: \'password\'.', + 'introduction' => '', + 'default' => 'password', + 'required' => false, + 'question' => '', + ], + ], + ], + [ + 'category' => 'InfluxDB', + 'description' => 'Appwrite uses an InfluxDB server for managing time-series data and server stats. The InfluxDB env vars are used to allow Appwrite server to connect to the InfluxDB container.', + 'variables' => [ + [ + 'name' => '_APP_INFLUXDB_HOST', + 'description' => 'InfluxDB server host name address. Default value is: \'influxdb\'.', + 'introduction' => '', + 'default' => 'influxdb', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_INFLUXDB_PORT', + 'description' => 'InfluxDB server TCP port. Default value is: \'8086\'.', + 'introduction' => '', + 'default' => '8086', + 'required' => false, + 'question' => '', + ], + ], + ], + [ + 'category' => 'StatsD', + 'description' => 'Appwrite uses a StatsD server for aggregating and sending stats data over a fast UDP connection. The StatsD env vars are used to allow Appwrite server to connect to the StatsD container.', + 'variables' => [ + [ + 'name' => '_APP_STATSD_HOST', + 'description' => 'StatsD server host name address. Default value is: \'telegraf\'.', + 'introduction' => '', + 'default' => 'telegraf', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STATSD_PORT', + 'description' => 'StatsD server TCP port. Default value is: \'8125\'.', + 'introduction' => '', + 'default' => '8125', + 'required' => false, + 'question' => '', + ], + ], + ], + [ + 'category' => 'SMTP', + 'description' => 'Appwrite is using an SMTP server for emailing your projects users and server admins. The SMTP env vars are used to allow Appwrite server to connect to the SMTP container.\n\nIf running in production, it might be easier to use a 3rd party SMTP server as it might be a little more difficult to set up a production SMTP server that will not send all your emails into your user\'s SPAM folder.', + 'variables' => [ + [ + 'name' => '_APP_SMTP_HOST', + 'description' => 'SMTP server host name address. Default value is: \'smtp\'. Pass an empty string to disable all mail sending from the server.', + 'introduction' => '', + 'default' => 'smtp', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_SMTP_PORT', + 'description' => 'SMTP server TCP port. Default value is: \'25\'.', + 'introduction' => '', + 'default' => '25', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_SMTP_SECURE', + 'description' => 'SMTP secure connection protocol. Empty by default, change to \'tls\' if running on a secure connection.', + 'introduction' => '', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_SMTP_USERNAME', + 'description' => 'SMTP server user name. Empty by default.', + 'introduction' => '', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_SMTP_PASSWORD', + 'description' => 'SMTP server user password. Empty by default.', + 'introduction' => '', + 'default' => '', + 'required' => false, + 'question' => '', + ], + ], + ], + [ + 'category' => 'Storage', + 'description' => '', + 'variables' => [ + [ + 'name' => '_APP_STORAGE_LIMIT', + 'description' => 'Maximun file size allowed for file upload. The default value is 10MB limitation. You should pass your size limit value in bytes.', + 'introduction' => '0.7.0', + 'default' => '10000000', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_ANTIVIRUS', + 'description' => 'This variable allows you to disable the internal anti-virus scans. This value is set to \'enabled\' by default, to cancel the scans set the value to \'disabled\'. When disabled, it\'s recommended to turn off the ClamAV container for better resource usage.', + 'introduction' => '', + 'default' => 'enabled', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_ANTIVIRUS_HOST', + 'description' => 'ClamAV server host name address. Default value is: \'clamav\'.', + 'introduction' => '0.7.0', + 'default' => 'clamav', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_ANTIVIRUS_PORT', + 'description' => 'ClamAV server TCP port. Default value is: \'3310\'.', + 'introduction' => '0.7.0', + 'default' => '3310', + 'required' => false, + 'question' => '', + ], + ], + ], + [ + 'category' => 'Functions', + 'description' => '', + 'variables' => [ + [ + 'name' => '_APP_FUNCTIONS_TIMEOUT', + 'description' => 'The maximum number of seconds allowed as a timeout value when creating a new function. The default value is 900 seconds.', + 'introduction' => '0.7.0', + 'default' => '900', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_FUNCTIONS_CONTAINERS', + 'description' => 'The maximum number of containers Appwrite is allowed to keep alive in the background for function environments. Running containers allow faster execution time as there is no need to recreate each container every time a function gets executed. The default value is 10.', + 'introduction' => '0.7.0', + 'default' => '10', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_FUNCTIONS_CPUS', + 'description' => 'The maximum number of CPU core a single cloud function is allowed to use. Please note that setting a value higher than available cores will result in a function error, which might result in an error. The default value is empty. When it\'s empty, CPU limit will be disabled.', + 'introduction' => '0.7.0', + 'default' => '', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_FUNCTIONS_MEMORY', + 'description' => 'The maximum amount of memory a single cloud function is allowed to use in megabytes. The default value is empty. When it\'s empty, memory limit will be disabled.', + 'introduction' => '0.7.0', + 'default' => '256', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_FUNCTIONS_MEMORY_SWAP', + 'description' => 'The maximum amount of swap memory a single cloud function is allowed to use in megabytes. The default value is empty. When it\'s empty, swap memory limit will be disabled.', + 'introduction' => '0.7.0', + 'default' => '256', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_FUNCTIONS_ENVS', + 'description' => 'This option allows you to limit the available environments for cloud functions. This option is very useful for low-cost servers to safe disk space.\n\nTo enable/activate this option, pass a list of allowed environments separated by a comma.\n\nCurrently, supported environments are: ' . \implode(', ', \array_keys(Config::getParam('providers'))), + 'introduction' => '0.7.0', + 'default' => 'node-14.5,deno-1.6,php-7.4,python-3.8,ruby-3.0,dotnet-5.0', + 'required' => false, + 'question' => '', + ], + ], + [ + 'category' => 'Maintenance', + 'description' => '', + 'variables' => [ + [ + 'name' => '_APP_MAINTENANCE_INTERVAL', + 'description' => 'Interval value containing the number of seconds that the Appwrite maintenance process should wait before executing system cleanups and optimizations. The default value is 86400 seconds (1 day).', + 'introduction' => '0.7.0', + 'default' => '86400', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_MAINTENANCE_RETENTION_EXECUTION', + 'description' => 'The maximum duration (in seconds) upto which to retain execution logs. The default value is 1209600 seconds (14 days).', + 'introduction' => '0.7.0', + 'default' => '1209600', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_MAINTENANCE_RETENTION_AUDIT', + 'description' => 'IThe maximum duration (in seconds) upto which to retain audit logs. The default value is 1209600 seconds (14 days).', + 'introduction' => '0.7.0', + 'default' => '1209600', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_MAINTENANCE_RETENTION_ABUSE', + 'description' => 'The maximum duration (in seconds) upto which to retain abuse logs. The default value is 86400 seconds (1 day).', + 'introduction' => '0.7.0', + 'default' => '86400', + 'required' => false, + 'question' => '', + ] + ], + ], + ], +]; \ No newline at end of file diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 8ba5784412..52cf12b4a9 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1,10 +1,8 @@ init(function() use (&$oauth2Keys) { - foreach (Config::getParam('providers') as $key => $provider) { - if (!$provider['enabled']) { - continue; - } - - $oauth2Keys[] = 'oauth2'.\ucfirst($key); - $oauth2Keys[] = 'oauth2'.\ucfirst($key).'AccessToken'; - } -}, 'account'); - -$utopia->post('/v1/account') +App::post('/v1/account') ->desc('Create Account') ->groups(['api', 'account']) - ->label('webhook', 'account.create') + ->label('event', 'account.create') ->label('scope', 'public') ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'account') ->label('sdk.method', 'create') ->label('sdk.description', '/docs/references/account/create.md') + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_USER) ->label('abuse-limit', 10) - ->param('email', '', function () { return new Email(); }, 'User email.') - ->param('password', '', function () { return new Password(); }, 'User password. Must be between 6 to 32 chars.') - ->param('name', '', function () { return new Text(100); }, 'User name.', true) - ->action( - function ($email, $password, $name) use ($request, $response, $audit, $projectDB, $project, $webhook, $oauth2Keys) { - if ('console' === $project->getId()) { - $whitlistEmails = $project->getAttribute('authWhitelistEmails'); - $whitlistIPs = $project->getAttribute('authWhitelistIPs'); - $whitlistDomains = $project->getAttribute('authWhitelistDomains'); + ->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 */ + /** @var Appwrite\Database\Document $project */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ - if (!empty($whitlistEmails) && !\in_array($email, $whitlistEmails)) { - throw new Exception('Console registration is restricted to specific emails. Contact your administrator for more information.', 401); - } + if ('console' === $project->getId()) { + $whitlistEmails = $project->getAttribute('authWhitelistEmails'); + $whitlistIPs = $project->getAttribute('authWhitelistIPs'); + $whitlistDomains = $project->getAttribute('authWhitelistDomains'); - if (!empty($whitlistIPs) && !\in_array($request->getIP(), $whitlistIPs)) { - throw new Exception('Console registration is restricted to specific IPs. Contact your administrator for more information.', 401); - } - - if (!empty($whitlistDomains) && !\in_array(\substr(\strrchr($email, '@'), 1), $whitlistDomains)) { - throw new Exception('Console registration is restricted to specific domains. Contact your administrator for more information.', 401); - } + if (!empty($whitlistEmails) && !\in_array($email, $whitlistEmails)) { + throw new Exception('Console registration is restricted to specific emails. Contact your administrator for more information.', 401); } - $profile = $projectDB->getCollectionFirst([ // Get user by email address - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); - - if (!empty($profile)) { - throw new Exception('Account already exists', 409); + if (!empty($whitlistIPs) && !\in_array($request->getIP(), $whitlistIPs)) { + throw new Exception('Console registration is restricted to specific IPs. Contact your administrator for more information.', 401); } - Authorization::disable(); - - try { - $user = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_USERS, - '$permissions' => [ - 'read' => ['*'], - 'write' => ['user:{self}'], - ], - 'email' => $email, - 'emailVerification' => false, - 'status' => Auth::USER_STATUS_UNACTIVATED, - 'password' => Auth::passwordHash($password), - 'password-update' => \time(), - 'registration' => \time(), - 'reset' => false, - 'name' => $name, - ], ['email' => $email]); - } catch (Duplicate $th) { - throw new Exception('Account already exists', 409); + if (!empty($whitlistDomains) && !\in_array(\substr(\strrchr($email, '@'), 1), $whitlistDomains)) { + throw new Exception('Console registration is restricted to specific domains. Contact your administrator for more information.', 401); } - - Authorization::enable(); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $webhook - ->setParam('payload', [ - 'name' => $name, - 'email' => $email, - ]) - ; - - $audit - ->setParam('userId', $user->getId()) - ->setParam('event', 'account.create') - ->setParam('resource', 'users/'.$user->getId()) - ; - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json(\array_merge($user->getArrayCopy(\array_merge( - [ - '$id', - 'email', - 'registration', - 'name', - ], - $oauth2Keys - )), ['roles' => Authorization::getRoles()])); } - ); -$utopia->post('/v1/account/sessions') + $profile = $projectDB->getCollectionFirst([ // Get user by email address + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); + + if (!empty($profile)) { + throw new Exception('Account already exists', 409); + } + + Authorization::disable(); + + try { + $user = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_USERS, + '$permissions' => [ + 'read' => ['*'], + 'write' => ['user:{self}'], + ], + 'email' => $email, + 'emailVerification' => false, + 'status' => Auth::USER_STATUS_UNACTIVATED, + 'password' => Auth::passwordHash($password), + 'passwordUpdate' => \time(), + 'registration' => \time(), + 'reset' => false, + 'name' => $name, + ], ['email' => $email]); + } catch (Duplicate $th) { + throw new Exception('Account already exists', 409); + } + + Authorization::enable(); + + Authorization::unsetRole('role:'.Auth::USER_ROLE_GUEST); + Authorization::setRole('user:'.$user->getId()); + Authorization::setRole('role:'.Auth::USER_ROLE_MEMBER); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audits + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.create') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($user, Response::MODEL_USER) + ; + }); + +App::post('/v1/account/sessions') ->desc('Create Account Session') ->groups(['api', 'account']) - ->label('webhook', 'account.sessions.create') + ->label('event', 'account.sessions.create') ->label('scope', 'public') ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'account') ->label('sdk.method', 'createSession') ->label('sdk.description', '/docs/references/account/create-session.md') + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_SESSION) ->label('abuse-limit', 10) ->label('abuse-key', 'url:{url},email:{param-email}') - ->param('email', '', function () { return new Email(); }, 'User email.') - ->param('password', '', function () { return new Password(); }, 'User password. Must be between 6 to 32 chars.') - ->action( - function ($email, $password) use ($response, $request, $projectDB, $audit, $webhook) { - $protocol = Config::getParam('protocol'); - $profile = $projectDB->getCollectionFirst([ // Get user by email address - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$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 */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Utopia\Locale\Locale $locale */ + /** @var MaxMind\Db\Reader $geodb */ + /** @var Appwrite\Event\Event $audits */ - if (false == $profile || !Auth::passwordVerify($password, $profile->getAttribute('password'))) { - $audit - //->setParam('userId', $profile->getId()) - ->setParam('event', 'account.sesssions.failed') - ->setParam('resource', 'users/'.($profile ? $profile->getId() : '')) - ; + $protocol = $request->getProtocol(); + $profile = $projectDB->getCollectionFirst([ // Get user by email address + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); - throw new Exception('Invalid credentials', 401); // Wrong password or username - } - - $expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; - $secret = Auth::tokenGenerator(); - $session = new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$profile->getId()], 'write' => ['user:'.$profile->getId()]], - 'type' => Auth::TOKEN_TYPE_LOGIN, - 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak - 'expire' => $expiry, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]); - - Authorization::setRole('user:'.$profile->getId()); - - $session = $projectDB->createDocument($session->getArrayCopy()); - - if (false === $session) { - throw new Exception('Failed saving session to DB', 500); - } - - $profile->setAttribute('tokens', $session, Document::SET_TYPE_APPEND); - - $profile = $projectDB->updateDocument($profile->getArrayCopy()); - - if (false === $profile) { - throw new Exception('Failed saving user to DB', 500); - } - - $webhook - ->setParam('payload', [ - 'name' => $profile->getAttribute('name', ''), - 'email' => $profile->getAttribute('email', ''), - ]) + if (false == $profile || !Auth::passwordVerify($password, $profile->getAttribute('password'))) { + $audits + //->setParam('userId', $profile->getId()) + ->setParam('event', 'account.sesssions.failed') + ->setParam('resource', 'users/'.($profile ? $profile->getId() : '')) ; - $audit - ->setParam('userId', $profile->getId()) - ->setParam('event', 'account.sessions.create') - ->setParam('resource', 'users/'.$profile->getId()) - ; + throw new Exception('Invalid credentials', 401); // Wrong password or username + } - if (!Config::getParam('domainVerification')) { - $response - ->addHeader('X-Fallback-Cookies', \json_encode([Auth::$cookieName => Auth::encodeSession($profile->getId(), $secret)])) - ; - } - - $response - ->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($profile->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $protocol), true, null) - ->addCookie(Auth::$cookieName, Auth::encodeSession($profile->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $protocol), true, COOKIE_SAMESITE) - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($session->getArrayCopy(['$id', 'type', 'expire'])) + 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(); + + $os = $dd->getOs(); + $osCode = (isset($os['short_name'])) ? $os['short_name'] : ''; + $osName = (isset($os['name'])) ? $os['name'] : ''; + $osVersion = (isset($os['version'])) ? $os['version'] : ''; + + $client = $dd->getClient(); + $clientType = (isset($client['type'])) ? $client['type'] : ''; + $clientCode = (isset($client['short_name'])) ? $client['short_name'] : ''; + $clientName = (isset($client['name'])) ? $client['name'] : ''; + $clientVersion = (isset($client['version'])) ? $client['version'] : ''; + $clientEngine = (isset($client['engine'])) ? $client['engine'] : ''; + $clientEngineVersion = (isset($client['engine_version'])) ? $client['engine_version'] : ''; + + $expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; + $secret = Auth::tokenGenerator(); + $session = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['user:'.$profile->getId()], 'write' => ['user:'.$profile->getId()]], + 'userId' => $profile->getId(), + 'type' => Auth::TOKEN_TYPE_LOGIN, + 'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak + 'expire' => $expiry, + 'userAgent' => $request->getUserAgent('UNKNOWN'), + 'ip' => $request->getIP(), + 'osCode' => $osCode, + 'osName' => $osName, + 'osVersion' => $osVersion, + 'clientType' => $clientType, + 'clientCode' => $clientCode, + 'clientName' => $clientName, + 'clientVersion' => $clientVersion, + 'clientEngine' => $clientEngine, + 'clientEngineVersion' => $clientEngineVersion, + 'deviceName' => $dd->getDeviceName(), + 'deviceBrand' => $dd->getBrandName(), + 'deviceModel' => $dd->getModel(), + ]); + + $record = $geodb->get($request->getIP()); + + if($record) { + $session + ->setAttribute('countryCode', \strtolower($record['country']['iso_code'])) + ; + } else { + $session + ->setAttribute('countryCode', '--') ; } - ); -$utopia->get('/v1/account/sessions/oauth2/:provider') + Authorization::setRole('user:'.$profile->getId()); + + $session = $projectDB->createDocument($session->getArrayCopy()); + + if (false === $session) { + throw new Exception('Failed saving session to DB', 500); + } + + $profile->setAttribute('tokens', $session, Document::SET_TYPE_APPEND); + + $profile = $projectDB->updateDocument($profile->getArrayCopy()); + + if (false === $profile) { + throw new Exception('Failed saving user to DB', 500); + } + + $audits + ->setParam('userId', $profile->getId()) + ->setParam('event', 'account.sessions.create') + ->setParam('resource', 'users/'.$profile->getId()) + ; + + if (!Config::getParam('domainVerification')) { + $response + ->addHeader('X-Fallback-Cookies', \json_encode([Auth::$cookieName => Auth::encodeSession($profile->getId(), $secret)])) + ; + } + + $response + ->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($profile->getId(), $secret), $expiry, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, null) + ->addCookie(Auth::$cookieName, Auth::encodeSession($profile->getId(), $secret), $expiry, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite')) + ->setStatusCode(Response::STATUS_CODE_CREATED) + ; + + $session + ->setAttribute('current', true) + ->setAttribute('countryName', (isset($countries[$session->getAttribute('countryCode')])) ? $countries[$session->getAttribute('countryCode')] : $locale->getText('locale.country.unknown')) + ; + + $response->dynamic($session, Response::MODEL_SESSION); + }); + +App::get('/v1/account/sessions/oauth2/:provider') ->desc('Create Account Session with OAuth2') ->groups(['api', 'account']) ->label('error', __DIR__.'/../../views/general/error.phtml') @@ -249,562 +294,206 @@ $utopia->get('/v1/account/sessions/oauth2/:provider') ->label('sdk.methodType', 'webAuth') ->label('abuse-limit', 50) ->label('abuse-key', 'ip:{ip}') - ->param('provider', '', function () { return new WhiteList(\array_keys(Config::getParam('providers'))); }, 'OAuth2 Provider. Currently, supported providers are: ' . \implode(', ', \array_keys(\array_filter(Config::getParam('providers'), function($node) {return (!$node['mock']);}))).'.') - ->param('success', $oauthDefaultSuccess, function () use ($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) - ->param('failure', $oauthDefaultFailure, function () use ($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) - ->param('scopes', [], function () { return new ArrayList(new Text(128)); }, 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.', true) - ->action( - function ($provider, $success, $failure, $scopes) use ($response, $request, $project) { - $protocol = Config::getParam('protocol'); - $callback = $protocol.'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId(); - $appId = $project->getAttribute('usersOauth2'.\ucfirst($provider).'Appid', ''); - $appSecret = $project->getAttribute('usersOauth2'.\ucfirst($provider).'Secret', '{}'); + ->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 Provider. Currently, supported providers are: ' . \implode(', ', \array_keys(\array_filter(Config::getParam('providers'), function($node) {return (!$node['mock']);}))).'.') + ->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 */ + /** @var Appwrite\Database\Document $project */ - $appSecret = \json_decode($appSecret, true); + $protocol = $request->getProtocol(); + $callback = $protocol.'://'.$request->getHostname().'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId(); + $appId = $project->getAttribute('usersOauth2'.\ucfirst($provider).'Appid', ''); + $appSecret = $project->getAttribute('usersOauth2'.\ucfirst($provider).'Secret', '{}'); - if (!empty($appSecret) && isset($appSecret['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$appSecret['version']); - $appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag'])); - } - - if (empty($appId) || empty($appSecret)) { - throw new Exception('This provider is disabled. Please configure the provider app ID and app secret key from your '.APP_NAME.' console to continue.', 412); - } - - $classname = 'Appwrite\\Auth\\OAuth2\\'.\ucfirst($provider); - - if (!\class_exists($classname)) { - throw new Exception('Provider is not supported', 501); - } - - $oauth2 = new $classname($appId, $appSecret, $callback, ['success' => $success, 'failure' => $failure], $scopes); - - $response - ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') - ->addHeader('Pragma', 'no-cache') - ->redirect($oauth2->getLoginURL()); + 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'])); } - ); -$utopia->get('/v1/account/sessions/oauth2/callback/:provider/:projectId') + if (empty($appId) || empty($appSecret)) { + throw new Exception('This provider is disabled. Please configure the provider app ID and app secret key from your '.APP_NAME.' console to continue.', 412); + } + + $classname = 'Appwrite\\Auth\\OAuth2\\'.\ucfirst($provider); + + if (!\class_exists($classname)) { + throw new Exception('Provider is not supported', 501); + } + + $oauth2 = new $classname($appId, $appSecret, $callback, ['success' => $success, 'failure' => $failure], $scopes); + + $response + ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') + ->addHeader('Pragma', 'no-cache') + ->redirect($oauth2->getLoginURL()); + }); + +App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->desc('OAuth2 Callback') ->groups(['api', 'account']) ->label('error', __DIR__.'/../../views/general/error.phtml') ->label('scope', 'public') ->label('docs', false) - ->param('projectId', '', function () { return new Text(1024); }, 'Project unique ID.') - ->param('provider', '', function () { return new WhiteList(\array_keys(Config::getParam('providers'))); }, 'OAuth2 provider.') - ->param('code', '', function () { return new Text(1024); }, 'OAuth2 code.') - ->param('state', '', function () { return new Text(2048); }, 'Login state params.', true) - ->action( - function ($projectId, $provider, $code, $state) use ($response) { - $domain = Config::getParam('domain'); - $protocol = Config::getParam('protocol'); - - $response - ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') - ->addHeader('Pragma', 'no-cache') - ->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?' - .\http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state])); - } - ); + ->param('projectId', '', new Text(1024), 'Project unique ID.') + ->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 */ -$utopia->post('/v1/account/sessions/oauth2/callback/:provider/:projectId') + $domain = $request->getHostname(); + $protocol = $request->getProtocol(); + + $response + ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') + ->addHeader('Pragma', 'no-cache') + ->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?' + .\http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state])); + }); + +App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->desc('OAuth2 Callback') ->groups(['api', 'account']) ->label('error', __DIR__.'/../../views/general/error.phtml') ->label('scope', 'public') ->label('origin', '*') ->label('docs', false) - ->param('projectId', '', function () { return new Text(1024); }, 'Project unique ID.') - ->param('provider', '', function () { return new WhiteList(\array_keys(Config::getParam('providers'))); }, 'OAuth2 provider.') - ->param('code', '', function () { return new Text(1024); }, 'OAuth2 code.') - ->param('state', '', function () { return new Text(2048); }, 'Login state params.', true) - ->action( - function ($projectId, $provider, $code, $state) use ($response) { - $domain = Config::getParam('domain'); - $protocol = Config::getParam('protocol'); - - $response - ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') - ->addHeader('Pragma', 'no-cache') - ->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?' - .\http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state])); - } - ); + ->param('projectId', '', new Text(1024), 'Project unique ID.') + ->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 */ -$utopia->get('/v1/account/sessions/oauth2/:provider/redirect') + $domain = $request->getHostname(); + $protocol = $request->getProtocol(); + + $response + ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') + ->addHeader('Pragma', 'no-cache') + ->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?' + .\http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state])); + }); + +App::get('/v1/account/sessions/oauth2/:provider/redirect') ->desc('OAuth2 Redirect') ->groups(['api', 'account']) ->label('error', __DIR__.'/../../views/general/error.phtml') - ->label('webhook', 'account.sessions.create') + ->label('event', 'account.sessions.create') ->label('scope', 'public') ->label('abuse-limit', 50) ->label('abuse-key', 'ip:{ip}') ->label('docs', false) - ->param('provider', '', function () { return new WhiteList(\array_keys(Config::getParam('providers'))); }, 'OAuth2 provider.') - ->param('code', '', function () { return new Text(1024); }, 'OAuth2 code.') - ->param('state', '', function () { return new Text(2048); }, 'OAuth2 state params.', true) - ->action( - function ($provider, $code, $state) use ($response, $request, $user, $projectDB, $project, $audit, $oauthDefaultSuccess) { - $protocol = Config::getParam('protocol'); - $callback = $protocol.'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId(); - $defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => '']; - $validateURL = new URL(); + ->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 */ + /** @var Appwrite\Database\Document $project */ + /** @var Appwrite\Database\Document $user */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var MaxMind\Db\Reader $geodb */ + /** @var Appwrite\Event\Event $audits */ + + $protocol = $request->getProtocol(); + $callback = $protocol.'://'.$request->getHostname().'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId(); + $defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => '']; + $validateURL = new URL(); - $appId = $project->getAttribute('usersOauth2'.\ucfirst($provider).'Appid', ''); - $appSecret = $project->getAttribute('usersOauth2'.\ucfirst($provider).'Secret', '{}'); + $appId = $project->getAttribute('usersOauth2'.\ucfirst($provider).'Appid', ''); + $appSecret = $project->getAttribute('usersOauth2'.\ucfirst($provider).'Secret', '{}'); - $appSecret = \json_decode($appSecret, true); - - if (!empty($appSecret) && isset($appSecret['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$appSecret['version']); - $appSecret = OpenSSL::decrypt($appSecret['data'], $appSecret['method'], $key, 0, \hex2bin($appSecret['iv']), \hex2bin($appSecret['tag'])); - } - - $classname = 'Appwrite\\Auth\\OAuth2\\'.\ucfirst($provider); - - if (!\class_exists($classname)) { - throw new Exception('Provider is not supported', 501); - } - - $oauth2 = new $classname($appId, $appSecret, $callback); - - if (!empty($state)) { - try { - $state = \array_merge($defaultState, $oauth2->parseState($state)); - } catch (\Exception $exception) { - throw new Exception('Failed to parse login state params as passed from OAuth2 provider'); - } - } else { - $state = $defaultState; - } - - if (!$validateURL->isValid($state['success'])) { - throw new Exception('Invalid redirect URL for success login', 400); - } - - if (!empty($state['failure']) && !$validateURL->isValid($state['failure'])) { - throw new Exception('Invalid redirect URL for failure login', 400); - } - - $state['failure'] = null; - $accessToken = $oauth2->getAccessToken($code); - - if (empty($accessToken)) { - if (!empty($state['failure'])) { - $response->redirect($state['failure'], 301, 0); - } - - throw new Exception('Failed to obtain access token'); - } - - $oauth2ID = $oauth2->getUserID($accessToken); - - if (empty($oauth2ID)) { - if (!empty($state['failure'])) { - $response->redirect($state['failure'], 301, 0); - } - - throw new Exception('Missing ID from OAuth2 provider', 400); - } - - $current = Auth::tokenVerify($user->getAttribute('tokens', []), Auth::TOKEN_TYPE_LOGIN, Auth::$secret); - - if ($current) { - $projectDB->deleteDocument($current); //throw new Exception('User already logged in', 401); - } - - $user = (empty($user->getId())) ? $projectDB->getCollectionFirst([ // Get user by provider id - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'oauth2'.\ucfirst($provider).'='.$oauth2ID, - ], - ]) : $user; - - if (empty($user)) { // No user logged in or with OAuth2 provider ID, create new one or connect with account with same email - $name = $oauth2->getUserName($accessToken); - $email = $oauth2->getUserEmail($accessToken); - - $user = $projectDB->getCollectionFirst([ // Get user by provider email address - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); - - if (!$user || empty($user->getId())) { // Last option -> create user alone, generate random password - Authorization::disable(); - - try { - $user = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_USERS, - '$permissions' => ['read' => ['*'], 'write' => ['user:{self}']], - 'email' => $email, - 'emailVerification' => true, - 'status' => Auth::USER_STATUS_ACTIVATED, // Email should already be authenticated by OAuth2 provider - 'password' => Auth::passwordHash(Auth::passwordGenerator()), - 'password-update' => \time(), - 'registration' => \time(), - 'reset' => false, - 'name' => $name, - ], ['email' => $email]); - } catch (Duplicate $th) { - throw new Exception('Account already exists', 409); - } - - Authorization::enable(); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - } - } - - // Create session token, verify user account and update OAuth2 ID and Access Token - - $secret = Auth::tokenGenerator(); - $expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; - $session = new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$user['$id']], 'write' => ['user:'.$user['$id']]], - 'type' => Auth::TOKEN_TYPE_LOGIN, - 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak - 'expire' => $expiry, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]); - - $user - ->setAttribute('oauth2'.\ucfirst($provider), $oauth2ID) - ->setAttribute('oauth2'.\ucfirst($provider).'AccessToken', $accessToken) - ->setAttribute('status', Auth::USER_STATUS_ACTIVATED) - ->setAttribute('tokens', $session, Document::SET_TYPE_APPEND) - ; - - Authorization::setRole('user:'.$user->getId()); - - $user = $projectDB->updateDocument($user->getArrayCopy()); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $audit - ->setParam('userId', $user->getId()) - ->setParam('event', 'account.sessions.create') - ->setParam('resource', 'users/'.$user->getId()) - ->setParam('data', ['provider' => $provider]) - ; - - if (!Config::getParam('domainVerification')) { - $response - ->addHeader('X-Fallback-Cookies', \json_encode([Auth::$cookieName => Auth::encodeSession($user->getId(), $secret)])) - ; - } - - // Add keys for non-web platforms - TODO - add verification phase to aviod session sniffing - if (parse_url($state['success'], PHP_URL_PATH) === $oauthDefaultSuccess) { - $state['success'] = URLParser::parse($state['success']); - $query = URLParser::parseQuery($state['success']['query']); - $query['project'] = $project->getId(); - $query['domain'] = COOKIE_DOMAIN; - $query['key'] = Auth::$cookieName; - $query['secret'] = Auth::encodeSession($user->getId(), $secret); - $state['success']['query'] = URLParser::unparseQuery($query); - $state['success'] = URLParser::unparse($state['success']); - } - - $response - ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') - ->addHeader('Pragma', 'no-cache') - ->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $protocol), true, null) - ->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $protocol), true, COOKIE_SAMESITE) - ->redirect($state['success']) - ; + 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'])); } - ); -$utopia->get('/v1/account') - ->desc('Get Account') - ->groups(['api', 'account']) - ->label('scope', 'account') - ->label('sdk.platform', [APP_PLATFORM_CLIENT]) - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'get') - ->label('sdk.description', '/docs/references/account/get.md') - ->label('sdk.response', ['200' => 'user']) - ->action( - function () use ($response, &$user, $oauth2Keys) { - $response->json(\array_merge($user->getArrayCopy(\array_merge( - [ - '$id', - 'email', - 'emailVerification', - 'registration', - 'name', - ], - $oauth2Keys - )), ['roles' => Authorization::getRoles()])); + $classname = 'Appwrite\\Auth\\OAuth2\\'.\ucfirst($provider); + + if (!\class_exists($classname)) { + throw new Exception('Provider is not supported', 501); } - ); -$utopia->get('/v1/account/prefs') - ->desc('Get Account Preferences') - ->groups(['api', 'account']) - ->label('scope', 'account') - ->label('sdk.platform', [APP_PLATFORM_CLIENT]) - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'getPrefs') - ->label('sdk.description', '/docs/references/account/get-prefs.md') - ->action( - function () use ($response, $user) { - $prefs = $user->getAttribute('prefs', '{}'); + $oauth2 = new $classname($appId, $appSecret, $callback); + if (!empty($state)) { try { - $prefs = \json_decode($prefs, true); - $prefs = ($prefs) ? $prefs : []; - } catch (\Exception $error) { - throw new Exception('Failed to parse prefs', 500); + $state = \array_merge($defaultState, $oauth2->parseState($state)); + } catch (\Exception $exception) { + throw new Exception('Failed to parse login state params as passed from OAuth2 provider'); } - - $response->json($prefs); + } else { + $state = $defaultState; } - ); -$utopia->get('/v1/account/sessions') - ->desc('Get Account Sessions') - ->groups(['api', 'account']) - ->label('scope', 'account') - ->label('sdk.platform', [APP_PLATFORM_CLIENT]) - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'getSessions') - ->label('sdk.description', '/docs/references/account/get-sessions.md') - ->action( - function () use ($response, $user) { - $tokens = $user->getAttribute('tokens', []); - $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); - $sessions = []; - $current = Auth::tokenVerify($tokens, Auth::TOKEN_TYPE_LOGIN, Auth::$secret); - $index = 0; - $countries = Locale::getText('countries'); - - foreach ($tokens as $token) { /* @var $token Document */ - if (Auth::TOKEN_TYPE_LOGIN != $token->getAttribute('type')) { - continue; - } - - $userAgent = (!empty($token->getAttribute('userAgent'))) ? $token->getAttribute('userAgent') : 'UNKNOWN'; - - $dd = new DeviceDetector($userAgent); - - // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) - // $dd->skipBotDetection(); - - $dd->parse(); - - $sessions[$index] = [ - '$id' => $token->getId(), - 'OS' => $dd->getOs(), - 'client' => $dd->getClient(), - 'device' => $dd->getDevice(), - 'brand' => $dd->getBrand(), - 'model' => $dd->getModel(), - 'ip' => $token->getAttribute('ip', ''), - 'geo' => [], - 'current' => ($current == $token->getId()) ? true : false, - ]; - - try { - $record = $reader->country($token->getAttribute('ip', '')); - $sessions[$index]['geo']['isoCode'] = \strtolower($record->country->isoCode); - $sessions[$index]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); - } catch (\Exception $e) { - $sessions[$index]['geo']['isoCode'] = '--'; - $sessions[$index]['geo']['country'] = Locale::getText('locale.country.unknown'); - } - - ++$index; - } - - $response->json($sessions); + if (!$validateURL->isValid($state['success'])) { + throw new Exception('Invalid redirect URL for success login', 400); } - ); -$utopia->get('/v1/account/logs') - ->desc('Get Account Logs') - ->groups(['api', 'account']) - ->label('scope', 'account') - ->label('sdk.platform', [APP_PLATFORM_CLIENT]) - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'getLogs') - ->label('sdk.description', '/docs/references/account/get-logs.md') - ->action( - function () use ($response, $register, $project, $user) { - $adapter = new AuditAdapter($register->get('db')); - $adapter->setNamespace('app_'.$project->getId()); - - $audit = new Audit($adapter); - $countries = Locale::getText('countries'); - - $logs = $audit->getLogsByUserAndActions($user->getId(), [ - 'account.create', - 'account.delete', - 'account.update.name', - 'account.update.email', - 'account.update.password', - 'account.update.prefs', - 'account.sessions.create', - 'account.sessions.delete', - 'account.recovery.create', - 'account.recovery.update', - 'account.verification.create', - 'account.verification.update', - 'teams.membership.create', - 'teams.membership.update', - 'teams.membership.delete', - ]); - - $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); - $output = []; - - foreach ($logs as $i => &$log) { - $log['userAgent'] = (!empty($log['userAgent'])) ? $log['userAgent'] : 'UNKNOWN'; - - $dd = new DeviceDetector($log['userAgent']); - - $dd->skipBotDetection(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) - - $dd->parse(); - - $output[$i] = [ - 'event' => $log['event'], - 'ip' => $log['ip'], - 'time' => \strtotime($log['time']), - 'OS' => $dd->getOs(), - 'client' => $dd->getClient(), - 'device' => $dd->getDevice(), - 'brand' => $dd->getBrand(), - 'model' => $dd->getModel(), - 'geo' => [], - ]; - - try { - $record = $reader->country($log['ip']); - $output[$i]['geo']['isoCode'] = \strtolower($record->country->isoCode); - $output[$i]['geo']['country'] = $record->country->name; - $output[$i]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); - } catch (\Exception $e) { - $output[$i]['geo']['isoCode'] = '--'; - $output[$i]['geo']['country'] = Locale::getText('locale.country.unknown'); - } - } - - $response->json($output); + if (!empty($state['failure']) && !$validateURL->isValid($state['failure'])) { + throw new Exception('Invalid redirect URL for failure login', 400); } - ); + + $state['failure'] = null; + $accessToken = $oauth2->getAccessToken($code); -$utopia->patch('/v1/account/name') - ->desc('Update Account Name') - ->groups(['api', 'account']) - ->label('webhook', 'account.update.name') - ->label('scope', 'account') - ->label('sdk.platform', [APP_PLATFORM_CLIENT]) - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'updateName') - ->label('sdk.description', '/docs/references/account/update-name.md') - ->param('name', '', function () { return new Text(100); }, 'User name.') - ->action( - function ($name) use ($response, $user, $projectDB, $audit, $oauth2Keys) { - $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ - 'name' => $name, - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); + if (empty($accessToken)) { + if (!empty($state['failure'])) { + $response->redirect($state['failure'], 301, 0); } - $audit - ->setParam('userId', $user->getId()) - ->setParam('event', 'account.update.name') - ->setParam('resource', 'users/'.$user->getId()) - ; - - $response->json(\array_merge($user->getArrayCopy(\array_merge( - [ - '$id', - 'email', - 'registration', - 'name', - ], - $oauth2Keys - )), ['roles' => Authorization::getRoles()])); + throw new Exception('Failed to obtain access token'); } - ); -$utopia->patch('/v1/account/password') - ->desc('Update Account Password') - ->groups(['api', 'account']) - ->label('webhook', 'account.update.password') - ->label('scope', 'account') - ->label('sdk.platform', [APP_PLATFORM_CLIENT]) - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'updatePassword') - ->label('sdk.description', '/docs/references/account/update-password.md') - ->param('password', '', function () { return new Password(); }, 'New user password. Must be between 6 to 32 chars.') - ->param('oldPassword', '', function () { return new Password(); }, 'Old user password. Must be between 6 to 32 chars.') - ->action( - function ($password, $oldPassword) use ($response, $user, $projectDB, $audit, $oauth2Keys) { - if (!Auth::passwordVerify($oldPassword, $user->getAttribute('password'))) { // Double check user password - throw new Exception('Invalid credentials', 401); + $oauth2ID = $oauth2->getUserID($accessToken); + + if (empty($oauth2ID)) { + if (!empty($state['failure'])) { + $response->redirect($state['failure'], 301, 0); } - $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ - 'password' => Auth::passwordHash($password), - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $audit - ->setParam('userId', $user->getId()) - ->setParam('event', 'account.update.password') - ->setParam('resource', 'users/'.$user->getId()) - ; - - $response->json(\array_merge($user->getArrayCopy(\array_merge( - [ - '$id', - 'email', - 'registration', - 'name', - ], - $oauth2Keys - )), ['roles' => Authorization::getRoles()])); + throw new Exception('Missing ID from OAuth2 provider', 400); } - ); -$utopia->patch('/v1/account/email') - ->desc('Update Account Email') - ->groups(['api', 'account']) - ->label('webhook', 'account.update.email') - ->label('scope', 'account') - ->label('sdk.platform', [APP_PLATFORM_CLIENT]) - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'updateEmail') - ->label('sdk.description', '/docs/references/account/update-email.md') - ->param('email', '', function () { return new Email(); }, 'User email.') - ->param('password', '', function () { return new Password(); }, 'User password. Must be between 6 to 32 chars.') - ->action( - function ($email, $password) use ($response, $user, $projectDB, $audit, $oauth2Keys) { - if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password - throw new Exception('Invalid credentials', 401); - } + $current = Auth::tokenVerify($user->getAttribute('tokens', []), Auth::TOKEN_TYPE_LOGIN, Auth::$secret); - $profile = $projectDB->getCollectionFirst([ // Get user by email address + if ($current) { + $projectDB->deleteDocument($current); //throw new Exception('User already logged in', 401); + } + + $user = (empty($user->getId())) ? $projectDB->getCollectionFirst([ // Get user by provider id + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'oauth2'.\ucfirst($provider).'='.$oauth2ID, + ], + ]) : $user; + + if (empty($user)) { // No user logged in or with OAuth2 provider ID, create new one or connect with account with same email + $name = $oauth2->getUserName($accessToken); + $email = $oauth2->getUserEmail($accessToken); + + $user = $projectDB->getCollectionFirst([ // Get user by provider email address 'limit' => 1, 'filters' => [ '$collection='.Database::SYSTEM_COLLECTION_USERS, @@ -812,120 +501,740 @@ $utopia->patch('/v1/account/email') ], ]); - if (!empty($profile)) { - throw new Exception('User already registered', 400); + if (!$user || empty($user->getId())) { // Last option -> create user alone, generate random password + Authorization::disable(); + + try { + $user = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_USERS, + '$permissions' => ['read' => ['*'], 'write' => ['user:{self}']], + 'email' => $email, + 'emailVerification' => true, + 'status' => Auth::USER_STATUS_ACTIVATED, // Email should already be authenticated by OAuth2 provider + 'password' => Auth::passwordHash(Auth::passwordGenerator()), + 'passwordUpdate' => \time(), + 'registration' => \time(), + 'reset' => false, + 'name' => $name, + ], ['email' => $email]); + } catch (Duplicate $th) { + throw new Exception('Account already exists', 409); + } + + Authorization::enable(); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } } - - // TODO after this user needs to confirm mail again - - $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ - 'email' => $email, - 'emailVerification' => false, - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $audit - ->setParam('userId', $user->getId()) - ->setParam('event', 'account.update.email') - ->setParam('resource', 'users/'.$user->getId()) - ; - - $response->json(\array_merge($user->getArrayCopy(\array_merge( - [ - '$id', - 'email', - 'registration', - 'name', - ], - $oauth2Keys - )), ['roles' => Authorization::getRoles()])); } - ); -$utopia->patch('/v1/account/prefs') + 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')); + + $dd->parse(); + + $os = $dd->getOs(); + $osCode = (isset($os['short_name'])) ? $os['short_name'] : ''; + $osName = (isset($os['name'])) ? $os['name'] : ''; + $osVersion = (isset($os['version'])) ? $os['version'] : ''; + + $client = $dd->getClient(); + $clientType = (isset($client['type'])) ? $client['type'] : ''; + $clientCode = (isset($client['short_name'])) ? $client['short_name'] : ''; + $clientName = (isset($client['name'])) ? $client['name'] : ''; + $clientVersion = (isset($client['version'])) ? $client['version'] : ''; + $clientEngine = (isset($client['engine'])) ? $client['engine'] : ''; + $clientEngineVersion = (isset($client['engine_version'])) ? $client['engine_version'] : ''; + + $secret = Auth::tokenGenerator(); + $expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; + $session = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['user:'.$user['$id']], 'write' => ['user:'.$user['$id']]], + 'userId' => $user->getId(), + 'type' => Auth::TOKEN_TYPE_LOGIN, + 'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak + 'expire' => $expiry, + 'userAgent' => $request->getUserAgent('UNKNOWN'), + 'ip' => $request->getIP(), + 'osCode' => $osCode, + 'osName' => $osName, + 'osVersion' => $osVersion, + 'clientType' => $clientType, + 'clientCode' => $clientCode, + 'clientName' => $clientName, + 'clientVersion' => $clientVersion, + 'clientEngine' => $clientEngine, + 'clientEngineVersion' => $clientEngineVersion, + 'deviceName' => $dd->getDeviceName(), + 'deviceBrand' => $dd->getBrandName(), + 'deviceModel' => $dd->getModel(), + ]); + + $record = $geodb->get($request->getIP()); + + if($record) { + $session + ->setAttribute('countryCode', \strtolower($record['country']['iso_code'])) + ; + } else { + $session + ->setAttribute('countryCode', '--') + ; + } + + $user + ->setAttribute('oauth2'.\ucfirst($provider), $oauth2ID) + ->setAttribute('oauth2'.\ucfirst($provider).'AccessToken', $accessToken) + ->setAttribute('status', Auth::USER_STATUS_ACTIVATED) + ->setAttribute('tokens', $session, Document::SET_TYPE_APPEND) + ; + + Authorization::setRole('user:'.$user->getId()); + + $user = $projectDB->updateDocument($user->getArrayCopy()); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audits + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.sessions.create') + ->setParam('resource', 'users/'.$user->getId()) + ->setParam('data', ['provider' => $provider]) + ; + + if (!Config::getParam('domainVerification')) { + $response + ->addHeader('X-Fallback-Cookies', \json_encode([Auth::$cookieName => Auth::encodeSession($user->getId(), $secret)])) + ; + } + + // Add keys for non-web platforms - TODO - add verification phase to aviod session sniffing + if (parse_url($state['success'], PHP_URL_PATH) === parse_url($oauthDefaultSuccess, PHP_URL_PATH)) { + $state['success'] = URLParser::parse($state['success']); + $query = URLParser::parseQuery($state['success']['query']); + $query['project'] = $project->getId(); + $query['domain'] = Config::getParam('cookieDomain'); + $query['key'] = Auth::$cookieName; + $query['secret'] = Auth::encodeSession($user->getId(), $secret); + $state['success']['query'] = URLParser::unparseQuery($query); + $state['success'] = URLParser::unparse($state['success']); + } + + $response + ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') + ->addHeader('Pragma', 'no-cache') + ->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getId(), $secret), $expiry, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, null) + ->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite')) + ->redirect($state['success']) + ; + }); + +App::post('/v1/account/jwt') + ->desc('Create Account JWT') + ->groups(['api', 'account']) + ->label('scope', 'account') + ->label('docs', false) // Hidden for now - private beta + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'createJWT') + ->label('sdk.description', '/docs/references/account/create-jwt.md') + ->label('abuse-limit', 10) + ->label('abuse-key', 'url:{url},userId:{param-userId}') + ->inject('response') + ->inject('user') + ->action(function ($response, $user) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Document $user */ + + $tokens = $user->getAttribute('tokens', []); + $session = new Document(); + + foreach ($tokens as $token) { /** @var Appwrite\Database\Document $token */ + if ($token->getAttribute('secret') == Auth::hash(Auth::$secret)) { // If current session delete the cookies too + $session = $token; + } + } + + if($session->isEmpty()) { + throw new Exception('No valid session found', 401); + } + + $jwt = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway. + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic(new Document(['jwt' => $jwt->encode([ + // 'uid' => 1, + // 'aud' => 'http://site.com', + // 'scopes' => ['user'], + // 'iss' => 'http://api.mysite.com', + 'userId' => $user->getId(), + 'sessionId' => $session->getId(), + ])]), Response::MODEL_JWT); + }); + +App::get('/v1/account') + ->desc('Get Account') + ->groups(['api', 'account']) + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'get') + ->label('sdk.description', '/docs/references/account/get.md') + ->label('sdk.response.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); + }); + +App::get('/v1/account/prefs') + ->desc('Get Account Preferences') + ->groups(['api', 'account']) + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'getPrefs') + ->label('sdk.description', '/docs/references/account/get-prefs.md') + ->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 */ + + $prefs = $user->getAttribute('prefs', new \stdClass()); + + $response->dynamic(new Document($prefs), Response::MODEL_ANY); + }); + +App::get('/v1/account/sessions') + ->desc('Get Account Sessions') + ->groups(['api', 'account']) + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'getSessions') + ->label('sdk.description', '/docs/references/account/get-sessions.md') + ->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 */ + /** @var Utopia\Locale\Locale $locale */ + + $tokens = $user->getAttribute('tokens', []); + $sessions = []; + $countries = $locale->getText('countries'); + $current = Auth::tokenVerify($tokens, Auth::TOKEN_TYPE_LOGIN, Auth::$secret); + + foreach ($tokens as $token) { /* @var $token Document */ + if (Auth::TOKEN_TYPE_LOGIN != $token->getAttribute('type')) { + continue; + } + + $token->setAttribute('countryName', (isset($countries[$token->getAttribute('contryCode')])) + ? $countries[$token->getAttribute('contryCode')] + : $locale->getText('locale.country.unknown')); + $token->setAttribute('current', ($current == $token->getId()) ? true : false); + + $sessions[] = $token; + } + + $response->dynamic(new Document([ + 'sum' => count($sessions), + 'sessions' => $sessions + ]), Response::MODEL_SESSION_LIST); + }); + +App::get('/v1/account/logs') + ->desc('Get Account Logs') + ->groups(['api', 'account']) + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'getLogs') + ->label('sdk.description', '/docs/references/account/get-logs.md') + ->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 */ + /** @var Appwrite\Database\Document $user */ + /** @var Utopia\Locale\Locale $locale */ + /** @var MaxMind\Db\Reader $geodb */ + + $adapter = new AuditAdapter($register->get('db')); + $adapter->setNamespace('app_'.$project->getId()); + + $audit = new Audit($adapter); + $countries = $locale->getText('countries'); + + $logs = $audit->getLogsByUserAndActions($user->getId(), [ + 'account.create', + 'account.delete', + 'account.update.name', + 'account.update.email', + 'account.update.password', + 'account.update.prefs', + 'account.sessions.create', + 'account.sessions.delete', + 'account.recovery.create', + 'account.recovery.update', + 'account.verification.create', + 'account.verification.update', + 'teams.membership.create', + 'teams.membership.update', + 'teams.membership.delete', + ]); + + $output = []; + + foreach ($logs as $i => &$log) { + $log['userAgent'] = (!empty($log['userAgent'])) ? $log['userAgent'] : 'UNKNOWN'; + + $dd = new DeviceDetector($log['userAgent']); + + $dd->skipBotDetection(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) + + $dd->parse(); + + $os = $dd->getOs(); + $osCode = (isset($os['short_name'])) ? $os['short_name'] : ''; + $osName = (isset($os['name'])) ? $os['name'] : ''; + $osVersion = (isset($os['version'])) ? $os['version'] : ''; + + $client = $dd->getClient(); + $clientType = (isset($client['type'])) ? $client['type'] : ''; + $clientCode = (isset($client['short_name'])) ? $client['short_name'] : ''; + $clientName = (isset($client['name'])) ? $client['name'] : ''; + $clientVersion = (isset($client['version'])) ? $client['version'] : ''; + $clientEngine = (isset($client['engine'])) ? $client['engine'] : ''; + $clientEngineVersion = (isset($client['engine_version'])) ? $client['engine_version'] : ''; + + $output[$i] = new Document([ + 'event' => $log['event'], + 'ip' => $log['ip'], + 'time' => \strtotime($log['time']), + + 'osCode' => $osCode, + 'osName' => $osName, + 'osVersion' => $osVersion, + 'clientType' => $clientType, + 'clientCode' => $clientCode, + 'clientName' => $clientName, + 'clientVersion' => $clientVersion, + 'clientEngine' => $clientEngine, + 'clientEngineVersion' => $clientEngineVersion, + 'deviceName' => $dd->getDeviceName(), + 'deviceBrand' => $dd->getBrandName(), + 'deviceModel' => $dd->getModel(), + ]); + + $record = $geodb->get($log['ip']); + + if ($record) { + $output[$i]['countryCode'] = (isset($countries[$record['country']['iso_code']])) ? \strtolower($record['country']['iso_code']) : '--'; + $output[$i]['countryName'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); + } else { + $output[$i]['countryCode'] = '--'; + $output[$i]['countryName'] = $locale->getText('locale.country.unknown'); + } + + } + + $response->dynamic(new Document(['logs' => $output]), Response::MODEL_LOG_LIST); + }); + +App::patch('/v1/account/name') + ->desc('Update Account Name') + ->groups(['api', 'account']) + ->label('event', 'account.update.name') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'updateName') + ->label('sdk.description', '/docs/references/account/update-name.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ + + $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ + 'name' => $name, + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audits + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.update.name') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response->dynamic($user, Response::MODEL_USER); + }); + +App::patch('/v1/account/password') + ->desc('Update Account Password') + ->groups(['api', 'account']) + ->label('event', 'account.update.password') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'updatePassword') + ->label('sdk.description', '/docs/references/account/update-password.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ + + if (!Auth::passwordVerify($oldPassword, $user->getAttribute('password'))) { // Double check user password + throw new Exception('Invalid credentials', 401); + } + + $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ + 'password' => Auth::passwordHash($password), + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audits + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.update.password') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response->dynamic($user, Response::MODEL_USER); + }); + +App::patch('/v1/account/email') + ->desc('Update Account Email') + ->groups(['api', 'account']) + ->label('event', 'account.update.email') + ->label('scope', 'account') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'updateEmail') + ->label('sdk.description', '/docs/references/account/update-email.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ + + if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password + throw new Exception('Invalid credentials', 401); + } + + $profile = $projectDB->getCollectionFirst([ // Get user by email address + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); + + if (!empty($profile)) { + throw new Exception('User already registered', 400); + } + + // TODO after this user needs to confirm mail again + + $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ + 'email' => $email, + 'emailVerification' => false, + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $audits + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.update.email') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response->dynamic($user, Response::MODEL_USER); + }); + +App::patch('/v1/account/prefs') ->desc('Update Account Preferences') ->groups(['api', 'account']) - ->label('webhook', 'account.update.prefs') + ->label('event', 'account.update.prefs') ->label('scope', 'account') ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'account') ->label('sdk.method', 'updatePrefs') - ->param('prefs', '', function () { return new Assoc();}, 'Prefs key-value JSON object.') ->label('sdk.description', '/docs/references/account/update-prefs.md') - ->action( - function ($prefs) use ($response, $user, $projectDB, $audit) { - $old = \json_decode($user->getAttribute('prefs', '{}'), true); - $old = ($old) ? $old : []; + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ + + $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ + 'prefs' => $prefs, + ])); - $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ - 'prefs' => \json_encode(\array_merge($old, $prefs)), - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $audit - ->setParam('event', 'account.update.prefs') - ->setParam('resource', 'users/'.$user->getId()) - ; - - $prefs = $user->getAttribute('prefs', '{}'); - - try { - $prefs = \json_decode($prefs, true); - $prefs = ($prefs) ? $prefs : []; - } catch (\Exception $error) { - throw new Exception('Failed to parse prefs', 500); - } - - $response->json($prefs); + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); } - ); -$utopia->delete('/v1/account') + $audits + ->setParam('event', 'account.update.prefs') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response->dynamic($user, Response::MODEL_USER); + }); + +App::delete('/v1/account') ->desc('Delete Account') ->groups(['api', 'account']) - ->label('webhook', 'account.delete') + ->label('event', 'account.delete') ->label('scope', 'account') ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'account') ->label('sdk.method', 'delete') ->label('sdk.description', '/docs/references/account/delete.md') - ->action( - function () use ($response, $user, $projectDB, $audit, $webhook) { - $protocol = Config::getParam('protocol'); - $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ - 'status' => Auth::USER_STATUS_BLOCKED, - ])); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Database\Document $user */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $events */ - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); + $protocol = $request->getProtocol(); + $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ + 'status' => Auth::USER_STATUS_BLOCKED, + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + //TODO delete all tokens or only current session? + //TODO delete all user data according to GDPR. Make sure everything is backed up and backups are deleted later + /* + * Data to delete + * * Tokens + * * Memberships + */ + + $audits + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.delete') + ->setParam('resource', 'users/'.$user->getId()) + ->setParam('data', $user->getArrayCopy()) + ; + + $events + ->setParam('payload', $response->output($user, Response::MODEL_USER)) + ; + + if (!Config::getParam('domainVerification')) { + $response + ->addHeader('X-Fallback-Cookies', \json_encode([])) + ; + } + + $response + ->addCookie(Auth::$cookieName.'_legacy', '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, null) + ->addCookie(Auth::$cookieName, '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite')) + ->noContent() + ; + }); + +App::delete('/v1/account/sessions/:sessionId') + ->desc('Delete Account Session') + ->groups(['api', 'account']) + ->label('scope', 'account') + ->label('event', 'account.sessions.delete') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'deleteSession') + ->label('sdk.description', '/docs/references/account/delete-session.md') + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Database\Document $user */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $events */ + + $protocol = $request->getProtocol(); + $sessionId = ($sessionId === 'current') + ? Auth::tokenVerify($user->getAttribute('tokens'), Auth::TOKEN_TYPE_LOGIN, Auth::$secret) + : $sessionId; + + $tokens = $user->getAttribute('tokens', []); + + foreach ($tokens as $token) { /* @var $token Document */ + if (($sessionId == $token->getId()) && Auth::TOKEN_TYPE_LOGIN == $token->getAttribute('type')) { + if (!$projectDB->deleteDocument($token->getId())) { + throw new Exception('Failed to remove token from DB', 500); + } + + $audits + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.sessions.delete') + ->setParam('resource', '/user/'.$user->getId()) + ; + + if (!Config::getParam('domainVerification')) { + $response + ->addHeader('X-Fallback-Cookies', \json_encode([])) + ; + } + + $token->setAttribute('current', false); + + if ($token->getAttribute('secret') == Auth::hash(Auth::$secret)) { // If current session delete the cookies too + $token->setAttribute('current', true); + + $response + ->addCookie(Auth::$cookieName.'_legacy', '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, null) + ->addCookie(Auth::$cookieName, '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite')) + ; + } + + $events + ->setParam('payload', $response->output($token, Response::MODEL_SESSION)) + ; + + return $response->noContent(); + } + } + + throw new Exception('Session not found', 404); + }); + +App::delete('/v1/account/sessions') + ->desc('Delete All Account Sessions') + ->groups(['api', 'account']) + ->label('scope', 'account') + ->label('event', 'account.sessions.delete') + ->label('sdk.platform', [APP_PLATFORM_CLIENT]) + ->label('sdk.namespace', 'account') + ->label('sdk.method', 'deleteSessions') + ->label('sdk.description', '/docs/references/account/delete-sessions.md') + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Database\Document $user */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $events */ + + $protocol = $request->getProtocol(); + $tokens = $user->getAttribute('tokens', []); + + foreach ($tokens as $token) { /* @var $token Document */ + if (!$projectDB->deleteDocument($token->getId())) { + throw new Exception('Failed to remove token from DB', 500); } - //TODO delete all tokens or only current session? - //TODO delete all user data according to GDPR. Make sure everything is backed up and backups are deleted later - /* - * Data to delete - * * Tokens - * * Memberships - */ - - $audit + $audits ->setParam('userId', $user->getId()) - ->setParam('event', 'account.delete') - ->setParam('resource', 'users/'.$user->getId()) - ->setParam('data', $user->getArrayCopy()) - ; - - $webhook - ->setParam('payload', [ - 'name' => $user->getAttribute('name', ''), - 'email' => $user->getAttribute('email', ''), - ]) + ->setParam('event', 'account.sessions.delete') + ->setParam('resource', '/user/'.$user->getId()) ; if (!Config::getParam('domainVerification')) { @@ -934,439 +1243,437 @@ $utopia->delete('/v1/account') ; } - $response - ->addCookie(Auth::$cookieName.'_legacy', '', \time() - 3600, '/', COOKIE_DOMAIN, ('https' == $protocol), true, null) - ->addCookie(Auth::$cookieName, '', \time() - 3600, '/', COOKIE_DOMAIN, ('https' == $protocol), true, COOKIE_SAMESITE) - ->noContent() - ; - } - ); + $token->setAttribute('current', false); -$utopia->delete('/v1/account/sessions/:sessionId') - ->desc('Delete Account Session') - ->groups(['api', 'account']) - ->label('scope', 'account') - ->label('webhook', 'account.sessions.delete') - ->label('sdk.platform', [APP_PLATFORM_CLIENT]) - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'deleteSession') - ->label('sdk.description', '/docs/references/account/delete-session.md') - ->label('abuse-limit', 100) - ->param('sessionId', null, function () { return new UID(); }, 'Session unique ID. Use the string \'current\' to delete the current device session.') - ->action( - function ($sessionId) use ($response, $user, $projectDB, $webhook, $audit) { - $protocol = Config::getParam('protocol'); - $sessionId = ($sessionId === 'current') - ? Auth::tokenVerify($user->getAttribute('tokens'), Auth::TOKEN_TYPE_LOGIN, Auth::$secret) - : $sessionId; + if ($token->getAttribute('secret') == Auth::hash(Auth::$secret)) { // If current session delete the cookies too + $token->setAttribute('current', true); + $response + ->addCookie(Auth::$cookieName.'_legacy', '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, null) + ->addCookie(Auth::$cookieName, '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite')) + ; + } + } - $tokens = $user->getAttribute('tokens', []); + $events + ->setParam('payload', $response->output(new Document([ + 'sum' => count($tokens), + 'sessions' => $tokens + ]), Response::MODEL_SESSION_LIST)) + ; - foreach ($tokens as $token) { /* @var $token Document */ - if (($sessionId == $token->getId()) && Auth::TOKEN_TYPE_LOGIN == $token->getAttribute('type')) { - if (!$projectDB->deleteDocument($token->getId())) { - throw new Exception('Failed to remove token from DB', 500); - } + $response->noContent(); + }); - $audit - ->setParam('userId', $user->getId()) - ->setParam('event', 'account.sessions.delete') - ->setParam('resource', '/user/'.$user->getId()) - ; - - $webhook - ->setParam('payload', [ - 'name' => $user->getAttribute('name', ''), - 'email' => $user->getAttribute('email', ''), - ]) - ; - - if (!Config::getParam('domainVerification')) { - $response - ->addHeader('X-Fallback-Cookies', \json_encode([])) - ; - } - - if ($token->getAttribute('secret') == Auth::hash(Auth::$secret)) { // If current session delete the cookies too - $response - ->addCookie(Auth::$cookieName.'_legacy', '', \time() - 3600, '/', COOKIE_DOMAIN, ('https' == $protocol), true, null) - ->addCookie(Auth::$cookieName, '', \time() - 3600, '/', COOKIE_DOMAIN, ('https' == $protocol), true, COOKIE_SAMESITE) - ; - } - - return $response->noContent(); - } - } - - throw new Exception('Session not found', 404); - } - ); - -$utopia->delete('/v1/account/sessions') - ->desc('Delete All Account Sessions') - ->groups(['api', 'account']) - ->label('scope', 'account') - ->label('webhook', 'account.sessions.delete') - ->label('sdk.platform', [APP_PLATFORM_CLIENT]) - ->label('sdk.namespace', 'account') - ->label('sdk.method', 'deleteSessions') - ->label('sdk.description', '/docs/references/account/delete-sessions.md') - ->label('abuse-limit', 100) - ->action( - function () use ($response, $user, $projectDB, $audit, $webhook) { - $protocol = Config::getParam('protocol'); - $tokens = $user->getAttribute('tokens', []); - - foreach ($tokens as $token) { /* @var $token Document */ - if (!$projectDB->deleteDocument($token->getId())) { - throw new Exception('Failed to remove token from DB', 500); - } - - $audit - ->setParam('userId', $user->getId()) - ->setParam('event', 'account.sessions.delete') - ->setParam('resource', '/user/'.$user->getId()) - ; - - $webhook - ->setParam('payload', [ - 'name' => $user->getAttribute('name', ''), - 'email' => $user->getAttribute('email', ''), - ]) - ; - - if (!Config::getParam('domainVerification')) { - $response - ->addHeader('X-Fallback-Cookies', \json_encode([])) - ; - } - - if ($token->getAttribute('secret') == Auth::hash(Auth::$secret)) { // If current session delete the cookies too - $response - ->addCookie(Auth::$cookieName.'_legacy', '', \time() - 3600, '/', COOKIE_DOMAIN, ('https' == $protocol), true, null) - ->addCookie(Auth::$cookieName, '', \time() - 3600, '/', COOKIE_DOMAIN, ('https' == $protocol), true, COOKIE_SAMESITE) - ; - } - } - - $response->noContent(); - } - ); - -$utopia->post('/v1/account/recovery') +App::post('/v1/account/recovery') ->desc('Create Password Recovery') ->groups(['api', 'account']) ->label('scope', 'public') + ->label('event', 'account.recovery.create') ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'account') ->label('sdk.method', 'createRecovery') ->label('sdk.description', '/docs/references/account/create-recovery.md') + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TOKEN) ->label('abuse-limit', 10) ->label('abuse-key', 'url:{url},email:{param-email}') - ->param('email', '', function () { return new Email(); }, 'User email.') - ->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the recovery email. 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.') - ->action( - function ($email, $url) use ($request, $response, $projectDB, $mail, $audit, $project) { - $profile = $projectDB->getCollectionFirst([ // Get user by email address - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$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 */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Database\Document $project */ + /** @var Utopia\Locale\Locale $locale */ + /** @var Appwrite\Event\Event $mails */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $events */ - if (empty($profile)) { - throw new Exception('User not found', 404); // TODO maybe hide this - } + $isPreviliggedUser = Auth::isPreviliggedUser(Authorization::$roles); + $isAppUser = Auth::isAppUser(Authorization::$roles); - $secret = Auth::tokenGenerator(); - $recovery = new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$profile->getId()], 'write' => ['user:'.$profile->getId()]], - 'type' => Auth::TOKEN_TYPE_RECOVERY, - 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak - 'expire' => \time() + Auth::TOKEN_EXPIRATION_RECOVERY, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]); - - Authorization::setRole('user:'.$profile->getId()); + $profile = $projectDB->getCollectionFirst([ // Get user by email address + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); - $recovery = $projectDB->createDocument($recovery->getArrayCopy()); - - if (false === $recovery) { - throw new Exception('Failed saving recovery to DB', 500); - } - - $profile->setAttribute('tokens', $recovery, Document::SET_TYPE_APPEND); - - $profile = $projectDB->updateDocument($profile->getArrayCopy()); - - if (false === $profile) { - throw new Exception('Failed to save user to DB', 500); - } - - $url = Template::parseURL($url); - $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $profile->getId(), 'secret' => $secret]); - $url = Template::unParseURL($url); - - $body = new Template(__DIR__.'/../../config/locales/templates/_base.tpl'); - $content = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.recovery.body')); - $cta = new Template(__DIR__.'/../../config/locales/templates/_cta.tpl'); - - $body - ->setParam('{{content}}', $content->render()) - ->setParam('{{cta}}', $cta->render()) - ->setParam('{{title}}', Locale::getText('account.emails.recovery.title')) - ->setParam('{{direction}}', Locale::getText('settings.direction')) - ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) - ->setParam('{{name}}', $profile->getAttribute('name')) - ->setParam('{{redirect}}', $url) - ->setParam('{{bg-body}}', '#f6f6f6') - ->setParam('{{bg-content}}', '#ffffff') - ->setParam('{{bg-cta}}', '#3498db') - ->setParam('{{bg-cta-hover}}', '#34495e') - ->setParam('{{text-content}}', '#000000') - ->setParam('{{text-cta}}', '#ffffff') - ; - - $mail - ->setParam('event', 'account.recovery.create') - ->setParam('recipient', $profile->getAttribute('email', '')) - ->setParam('name', $profile->getAttribute('name', '')) - ->setParam('subject', Locale::getText('account.emails.recovery.title')) - ->setParam('body', $body->render()) - ->trigger(); - ; - - $audit - ->setParam('userId', $profile->getId()) - ->setParam('event', 'account.recovery.create') - ->setParam('resource', 'users/'.$profile->getId()) - ; - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($recovery->getArrayCopy(['$id', 'type', 'expire'])) - ; + if (empty($profile)) { + throw new Exception('User not found', 404); // TODO maybe hide this } - ); -$utopia->put('/v1/account/recovery') + 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, + '$permissions' => ['read' => ['user:'.$profile->getId()], 'write' => ['user:'.$profile->getId()]], + 'userId' => $profile->getId(), + 'type' => Auth::TOKEN_TYPE_RECOVERY, + 'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak + 'expire' => \time() + Auth::TOKEN_EXPIRATION_RECOVERY, + 'userAgent' => $request->getUserAgent('UNKNOWN'), + 'ip' => $request->getIP(), + ]); + + Authorization::setRole('user:'.$profile->getId()); + + $recovery = $projectDB->createDocument($recovery->getArrayCopy()); + + if (false === $recovery) { + throw new Exception('Failed saving recovery to DB', 500); + } + + $profile->setAttribute('tokens', $recovery, Document::SET_TYPE_APPEND); + + $profile = $projectDB->updateDocument($profile->getArrayCopy()); + + if (false === $profile) { + throw new Exception('Failed to save user to DB', 500); + } + + $url = Template::parseURL($url); + $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $profile->getId(), 'secret' => $secret]); + $url = Template::unParseURL($url); + + $body = new Template(__DIR__.'/../../config/locale/templates/email-base.tpl'); + $content = new Template(__DIR__.'/../../config/locale/translations/templates/'.$locale->getText('account.emails.recovery.body')); + $cta = new Template(__DIR__.'/../../config/locale/templates/email-cta.tpl'); + + $body + ->setParam('{{content}}', $content->render()) + ->setParam('{{cta}}', $cta->render()) + ->setParam('{{title}}', $locale->getText('account.emails.recovery.title')) + ->setParam('{{direction}}', $locale->getText('settings.direction')) + ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) + ->setParam('{{name}}', $profile->getAttribute('name')) + ->setParam('{{redirect}}', $url) + ->setParam('{{bg-body}}', '#f6f6f6') + ->setParam('{{bg-content}}', '#ffffff') + ->setParam('{{bg-cta}}', '#3498db') + ->setParam('{{bg-cta-hover}}', '#34495e') + ->setParam('{{text-content}}', '#000000') + ->setParam('{{text-cta}}', '#ffffff') + ; + + $mails + ->setParam('event', 'account.recovery.create') + ->setParam('from', ($project->getId() === 'console') ? '' : \sprintf($locale->getText('account.emails.team'), $project->getAttribute('name'))) + ->setParam('recipient', $profile->getAttribute('email', '')) + ->setParam('name', $profile->getAttribute('name', '')) + ->setParam('subject', $locale->getText('account.emails.recovery.title')) + ->setParam('body', $body->render()) + ->trigger(); + ; + + $events + ->setParam('payload', + $response->output($recovery->setAttribute('secret', $secret), + Response::MODEL_TOKEN + )) + ; + + $recovery // Hide secret for clients, sp + ->setAttribute('secret', + ($isPreviliggedUser || $isAppUser) ? $secret : ''); + + $audits + ->setParam('userId', $profile->getId()) + ->setParam('event', 'account.recovery.create') + ->setParam('resource', 'users/'.$profile->getId()) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($recovery, Response::MODEL_TOKEN) + ; + }); + +App::put('/v1/account/recovery') ->desc('Complete Password Recovery') ->groups(['api', 'account']) ->label('scope', 'public') + ->label('event', 'account.recovery.update') ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'account') ->label('sdk.method', 'updateRecovery') ->label('sdk.description', '/docs/references/account/update-recovery.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TOKEN) ->label('abuse-limit', 10) ->label('abuse-key', 'url:{url},userId:{param-userId}') - ->param('userId', '', function () { return new UID(); }, 'User account UID address.') - ->param('secret', '', function () { return new Text(256); }, 'Valid reset token.') - ->param('password', '', function () { return new Password(); }, 'New password. Must be between 6 to 32 chars.') - ->param('passwordAgain', '', function () {return new Password(); }, 'New password again. Must be between 6 to 32 chars.') - ->action( - function ($userId, $secret, $password, $passwordAgain) use ($response, $projectDB, $audit) { - if ($password !== $passwordAgain) { - throw new Exception('Passwords must match', 400); - } - - $profile = $projectDB->getCollectionFirst([ // Get user by email address - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - '$id='.$userId, - ], - ]); - - if (empty($profile)) { - throw new Exception('User not found', 404); // TODO maybe hide this - } - - $recovery = Auth::tokenVerify($profile->getAttribute('tokens', []), Auth::TOKEN_TYPE_RECOVERY, $secret); - - if (!$recovery) { - throw new Exception('Invalid recovery token', 401); - } - - Authorization::setRole('user:'.$profile->getId()); - - $profile = $projectDB->updateDocument(\array_merge($profile->getArrayCopy(), [ - 'password' => Auth::passwordHash($password), - 'password-update' => \time(), - 'emailVerification' => true, - ])); - - if (false === $profile) { - throw new Exception('Failed saving user to DB', 500); - } - - /** - * We act like we're updating and validating - * the recovery token but actually we don't need it anymore. - */ - if (!$projectDB->deleteDocument($recovery)) { - throw new Exception('Failed to remove recovery from DB', 500); - } - - $audit - ->setParam('userId', $profile->getId()) - ->setParam('event', 'account.recovery.update') - ->setParam('resource', 'users/'.$profile->getId()) - ; - - $recovery = $profile->search('$id', $recovery, $profile->getAttribute('tokens', [])); - - $response->json($recovery->getArrayCopy(['$id', 'type', 'expire'])); + ->param('userId', '', new UID(), 'User account UID address.') + ->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 */ + /** @var Appwrite\Event\Event $audits */ + + if ($password !== $passwordAgain) { + throw new Exception('Passwords must match', 400); } - ); -$utopia->post('/v1/account/verification') + $profile = $projectDB->getCollectionFirst([ // Get user by email address + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + '$id='.$userId, + ], + ]); + + if (empty($profile)) { + throw new Exception('User not found', 404); // TODO maybe hide this + } + + $recovery = Auth::tokenVerify($profile->getAttribute('tokens', []), Auth::TOKEN_TYPE_RECOVERY, $secret); + + if (!$recovery) { + throw new Exception('Invalid recovery token', 401); + } + + Authorization::setRole('user:'.$profile->getId()); + + $profile = $projectDB->updateDocument(\array_merge($profile->getArrayCopy(), [ + 'password' => Auth::passwordHash($password), + 'passwordUpdate' => \time(), + 'emailVerification' => true, + ])); + + if (false === $profile) { + throw new Exception('Failed saving user to DB', 500); + } + + /** + * We act like we're updating and validating + * the recovery token but actually we don't need it anymore. + */ + if (!$projectDB->deleteDocument($recovery)) { + throw new Exception('Failed to remove recovery from DB', 500); + } + + $audits + ->setParam('userId', $profile->getId()) + ->setParam('event', 'account.recovery.update') + ->setParam('resource', 'users/'.$profile->getId()) + ; + + $recovery = $profile->search('$id', $recovery, $profile->getAttribute('tokens', [])); + + $response->dynamic($recovery, Response::MODEL_TOKEN); + }); + +App::post('/v1/account/verification') ->desc('Create Email Verification') ->groups(['api', 'account']) ->label('scope', 'account') + ->label('event', 'account.verification.create') ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'account') ->label('sdk.method', 'createVerification') ->label('sdk.description', '/docs/references/account/create-verification.md') + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TOKEN) ->label('abuse-limit', 10) ->label('abuse-key', 'url:{url},email:{param-email}') - ->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email. 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.') // TODO add built-in confirm page - ->action( - function ($url) use ($request, $response, $mail, $user, $project, $projectDB, $audit) { - $verificationSecret = Auth::tokenGenerator(); + ->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 */ + /** @var Appwrite\Database\Document $project */ + /** @var Appwrite\Database\Document $user */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Utopia\Locale\Locale $locale */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $events */ + /** @var Appwrite\Event\Event $mails */ + + $isPreviliggedUser = Auth::isPreviliggedUser(Authorization::$roles); + $isAppUser = Auth::isAppUser(Authorization::$roles); + + $verificationSecret = Auth::tokenGenerator(); + + $verification = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['user:'.$user->getId()], 'write' => ['user:'.$user->getId()]], + 'userId' => $user->getId(), + 'type' => Auth::TOKEN_TYPE_VERIFICATION, + 'secret' => Auth::hash($verificationSecret), // One way hash encryption to protect DB leak + 'expire' => \time() + Auth::TOKEN_EXPIRATION_CONFIRM, + 'userAgent' => $request->getUserAgent('UNKNOWN'), + 'ip' => $request->getIP(), + ]); - $verification = new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$user->getId()], 'write' => ['user:'.$user->getId()]], - 'type' => Auth::TOKEN_TYPE_VERIFICATION, - 'secret' => Auth::hash($verificationSecret), // On way hash encryption to protect DB leak - 'expire' => \time() + Auth::TOKEN_EXPIRATION_CONFIRM, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]); - - Authorization::setRole('user:'.$user->getId()); + Authorization::setRole('user:'.$user->getId()); - $verification = $projectDB->createDocument($verification->getArrayCopy()); + $verification = $projectDB->createDocument($verification->getArrayCopy()); - if (false === $verification) { - throw new Exception('Failed saving verification to DB', 500); - } - - $user->setAttribute('tokens', $verification, Document::SET_TYPE_APPEND); - - $user = $projectDB->updateDocument($user->getArrayCopy()); - - if (false === $user) { - throw new Exception('Failed to save user to DB', 500); - } - - $url = Template::parseURL($url); - $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $user->getId(), 'secret' => $verificationSecret]); - $url = Template::unParseURL($url); - - $body = new Template(__DIR__.'/../../config/locales/templates/_base.tpl'); - $content = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.verification.body')); - $cta = new Template(__DIR__.'/../../config/locales/templates/_cta.tpl'); - - $body - ->setParam('{{content}}', $content->render()) - ->setParam('{{cta}}', $cta->render()) - ->setParam('{{title}}', Locale::getText('account.emails.verification.title')) - ->setParam('{{direction}}', Locale::getText('settings.direction')) - ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) - ->setParam('{{name}}', $user->getAttribute('name')) - ->setParam('{{redirect}}', $url) - ->setParam('{{bg-body}}', '#f6f6f6') - ->setParam('{{bg-content}}', '#ffffff') - ->setParam('{{bg-cta}}', '#3498db') - ->setParam('{{bg-cta-hover}}', '#34495e') - ->setParam('{{text-content}}', '#000000') - ->setParam('{{text-cta}}', '#ffffff') - ; - - $mail - ->setParam('event', 'account.verification.create') - ->setParam('recipient', $user->getAttribute('email')) - ->setParam('name', $user->getAttribute('name')) - ->setParam('subject', Locale::getText('account.emails.verification.title')) - ->setParam('body', $body->render()) - ->trigger() - ; - - $audit - ->setParam('userId', $user->getId()) - ->setParam('event', 'account.verification.create') - ->setParam('resource', 'users/'.$user->getId()) - ; - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($verification->getArrayCopy(['$id', 'type', 'expire'])) - ; + if (false === $verification) { + throw new Exception('Failed saving verification to DB', 500); } - ); -$utopia->put('/v1/account/verification') + $user->setAttribute('tokens', $verification, Document::SET_TYPE_APPEND); + + $user = $projectDB->updateDocument($user->getArrayCopy()); + + if (false === $user) { + throw new Exception('Failed to save user to DB', 500); + } + + $url = Template::parseURL($url); + $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $user->getId(), 'secret' => $verificationSecret]); + $url = Template::unParseURL($url); + + $body = new Template(__DIR__.'/../../config/locale/templates/email-base.tpl'); + $content = new Template(__DIR__.'/../../config/locale/translations/templates/'.$locale->getText('account.emails.verification.body')); + $cta = new Template(__DIR__.'/../../config/locale/templates/email-cta.tpl'); + + $body + ->setParam('{{content}}', $content->render()) + ->setParam('{{cta}}', $cta->render()) + ->setParam('{{title}}', $locale->getText('account.emails.verification.title')) + ->setParam('{{direction}}', $locale->getText('settings.direction')) + ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) + ->setParam('{{name}}', $user->getAttribute('name')) + ->setParam('{{redirect}}', $url) + ->setParam('{{bg-body}}', '#f6f6f6') + ->setParam('{{bg-content}}', '#ffffff') + ->setParam('{{bg-cta}}', '#3498db') + ->setParam('{{bg-cta-hover}}', '#34495e') + ->setParam('{{text-content}}', '#000000') + ->setParam('{{text-cta}}', '#ffffff') + ; + + $mails + ->setParam('event', 'account.verification.create') + ->setParam('from', ($project->getId() === 'console') ? '' : \sprintf($locale->getText('account.emails.team'), $project->getAttribute('name'))) + ->setParam('recipient', $user->getAttribute('email')) + ->setParam('name', $user->getAttribute('name')) + ->setParam('subject', $locale->getText('account.emails.verification.title')) + ->setParam('body', $body->render()) + ->trigger() + ; + + $events + ->setParam('payload', + $response->output($verification->setAttribute('secret', $verificationSecret), + Response::MODEL_TOKEN + )) + ; + + $verification // Hide secret for clients, sp + ->setAttribute('secret', + ($isPreviliggedUser || $isAppUser) ? $verificationSecret : ''); + + $audits + ->setParam('userId', $user->getId()) + ->setParam('event', 'account.verification.create') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($verification, Response::MODEL_TOKEN) + ; + }); + +App::put('/v1/account/verification') ->desc('Complete Email Verification') ->groups(['api', 'account']) ->label('scope', 'public') + ->label('event', 'account.verification.update') ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'account') ->label('sdk.method', 'updateVerification') ->label('sdk.description', '/docs/references/account/update-verification.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TOKEN) ->label('abuse-limit', 10) ->label('abuse-key', 'url:{url},userId:{param-userId}') - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->param('secret', '', function () { return new Text(256); }, 'Valid verification token.') - ->action( - function ($userId, $secret) use ($response, $user, $projectDB, $audit) { - $profile = $projectDB->getCollectionFirst([ // Get user by email address - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - '$id='.$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 */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ - if (empty($profile)) { - throw new Exception('User not found', 404); // TODO maybe hide this - } + $profile = $projectDB->getCollectionFirst([ // Get user by email address + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + '$id='.$userId, + ], + ]); - $verification = Auth::tokenVerify($profile->getAttribute('tokens', []), Auth::TOKEN_TYPE_VERIFICATION, $secret); - - if (!$verification) { - throw new Exception('Invalid verification token', 401); - } - - Authorization::setRole('user:'.$profile->getId()); - - $profile = $projectDB->updateDocument(\array_merge($profile->getArrayCopy(), [ - 'emailVerification' => true, - ])); - - if (false === $profile) { - throw new Exception('Failed saving user to DB', 500); - } - - /** - * We act like we're updating and validating - * the verification token but actually we don't need it anymore. - */ - if (!$projectDB->deleteDocument($verification)) { - throw new Exception('Failed to remove verification from DB', 500); - } - - $audit - ->setParam('userId', $profile->getId()) - ->setParam('event', 'account.verification.update') - ->setParam('resource', 'users/'.$user->getId()) - ; - - $verification = $profile->search('$id', $verification, $profile->getAttribute('tokens', [])); - - $response->json($verification->getArrayCopy(['$id', 'type', 'expire'])); + if (empty($profile)) { + throw new Exception('User not found', 404); // TODO maybe hide this } - ); \ No newline at end of file + + $verification = Auth::tokenVerify($profile->getAttribute('tokens', []), Auth::TOKEN_TYPE_VERIFICATION, $secret); + + if (!$verification) { + throw new Exception('Invalid verification token', 401); + } + + Authorization::setRole('user:'.$profile->getId()); + + $profile = $projectDB->updateDocument(\array_merge($profile->getArrayCopy(), [ + 'emailVerification' => true, + ])); + + if (false === $profile) { + throw new Exception('Failed saving user to DB', 500); + } + + /** + * We act like we're updating and validating + * the verification token but actually we don't need it anymore. + */ + if (!$projectDB->deleteDocument($verification)) { + throw new Exception('Failed to remove verification from DB', 500); + } + + $audits + ->setParam('userId', $profile->getId()) + ->setParam('event', 'account.verification.update') + ->setParam('resource', 'users/'.$user->getId()) + ; + + $verification = $profile->search('$id', $verification, $profile->getAttribute('tokens', [])); + + $response->dynamic($verification, Response::MODEL_TOKEN); + }); \ No newline at end of file diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index 9e888f7f7d..fe2b53f71f 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -1,7 +1,6 @@ include __DIR__.'/../../config/avatars/browsers.php', - 'credit-cards' => include __DIR__.'/../../config/avatars/credit-cards.php', - 'flags' => include __DIR__.'/../../config/avatars/flags.php', -]; +$avatarCallback = function ($type, $code, $width, $height, $quality, $response) { + /** @var Appwrite\Utopia\Response $response */ -$avatarCallback = function ($type, $code, $width, $height, $quality) use ($types, $response) { $code = \strtolower($code); $type = \strtolower($type); + $set = Config::getParam('avatar-'.$type, []); - if (!\array_key_exists($type, $types)) { + if (empty($set)) { throw new Exception('Avatar set not found', 404); } - if (!\array_key_exists($code, $types[$type])) { + if (!\array_key_exists($code, $set)) { throw new Exception('Avatar not found', 404); } @@ -44,7 +39,7 @@ $avatarCallback = function ($type, $code, $width, $height, $quality) use ($types $output = 'png'; $date = \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache $key = \md5('/v1/avatars/:type/:code-'.$code.$width.$height.$quality.$output); - $path = $types[$type][$code]; + $path = $set[$code]; $type = 'png'; if (!\is_readable($path)) { @@ -57,11 +52,11 @@ $avatarCallback = function ($type, $code, $width, $height, $quality) use ($types if ($data) { //$output = (empty($output)) ? $type : $output; - $response + return $response ->setContentType('image/png') ->addHeader('Expires', $date) ->addHeader('X-Appwrite-Cache', 'hit') - ->send($data, 0) + ->send($data) ; } @@ -71,403 +66,423 @@ $avatarCallback = function ($type, $code, $width, $height, $quality) use ($types $output = (empty($output)) ? $type : $output; + $data = $resize->output($output, $quality); + + $cache->save($key, $data); + $response ->setContentType('image/png') ->addHeader('Expires', $date) ->addHeader('X-Appwrite-Cache', 'miss') - ->send('', null) + ->send($data, null); ; - $data = $resize->output($output, $quality); - - $cache->save($key, $data); - - echo $data; - unset($resize); }; -$utopia->get('/v1/avatars/credit-cards/:code') +App::get('/v1/avatars/credit-cards/:code') ->desc('Get Credit Card Icon') ->groups(['api', 'avatars']) - ->param('code', '', function () use ($types) { return new WhiteList(\array_keys($types['credit-cards'])); }, 'Credit Card Code. Possible values: '.\implode(', ', \array_keys($types['credit-cards'])).'.') - ->param('width', 100, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) - ->param('height', 100, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) - ->param('quality', 100, function () { return new Range(0, 100); }, 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true) ->label('scope', 'avatars.read') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getCreditCard') ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-credit-card.md') - ->action(function ($code, $width, $height, $quality) use ($avatarCallback) { - return $avatarCallback('credit-cards', $code, $width, $height, $quality); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_IMAGE_PNG) + ->param('code', '', new WhiteList(\array_keys(Config::getParam('avatar-credit-cards'))), 'Credit Card Code. Possible values: '.\implode(', ', \array_keys(Config::getParam('avatar-credit-cards'))).'.') + ->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); }); -$utopia->get('/v1/avatars/browsers/:code') +App::get('/v1/avatars/browsers/:code') ->desc('Get Browser Icon') ->groups(['api', 'avatars']) - ->param('code', '', function () use ($types) { return new WhiteList(\array_keys($types['browsers'])); }, 'Browser Code.') - ->param('width', 100, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) - ->param('height', 100, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) - ->param('quality', 100, function () { return new Range(0, 100); }, 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true) ->label('scope', 'avatars.read') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getBrowser') ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-browser.md') - ->action(function ($code, $width, $height, $quality) use ($avatarCallback) { - return $avatarCallback('browsers', $code, $width, $height, $quality); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_IMAGE_PNG) + ->param('code', '', new WhiteList(\array_keys(Config::getParam('avatar-browsers'))), 'Browser 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); }); -$utopia->get('/v1/avatars/flags/:code') +App::get('/v1/avatars/flags/:code') ->desc('Get Country Flag') ->groups(['api', 'avatars']) - ->param('code', '', function () use ($types) { return new WhiteList(\array_keys($types['flags'])); }, 'Country Code. ISO Alpha-2 country code format.') - ->param('width', 100, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) - ->param('height', 100, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) - ->param('quality', 100, function () { return new Range(0, 100); }, 'Image quality. Pass an integer between 0 to 100. Defaults to 100.', true) ->label('scope', 'avatars.read') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getFlag') ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-flag.md') - ->action(function ($code, $width, $height, $quality) use ($avatarCallback) { - return $avatarCallback('flags', $code, $width, $height, $quality); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_IMAGE_PNG) + ->param('code', '', new WhiteList(\array_keys(Config::getParam('avatar-flags'))), 'Country Code. ISO Alpha-2 country code format.') + ->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); }); -$utopia->get('/v1/avatars/image') +App::get('/v1/avatars/image') ->desc('Get Image from URL') ->groups(['api', 'avatars']) - ->param('url', '', function () { return new URL(); }, 'Image URL which you want to crop.') - ->param('width', 400, function () { return new Range(0, 2000); }, 'Resize preview image width, Pass an integer between 0 to 2000.', true) - ->param('height', 400, function () { return new Range(0, 2000); }, 'Resize preview image height, Pass an integer between 0 to 2000.', true) ->label('scope', 'avatars.read') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getImage') ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-image.md') - ->action( - function ($url, $width, $height) use ($response) { - $quality = 80; - $output = 'png'; - $date = \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache - $key = \md5('/v2/avatars/images-'.$url.'-'.$width.'/'.$height.'/'.$quality); - $type = 'png'; - $cache = new Cache(new Filesystem(APP_STORAGE_CACHE.'/app-0')); // Limit file number or size - $data = $cache->load($key, 60 * 60 * 24 * 7 /* 1 week */); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_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 */ - if ($data) { - $response - ->setContentType('image/png') - ->addHeader('Expires', $date) - ->addHeader('X-Appwrite-Cache', 'hit') - ->send($data, 0) - ; - } + $quality = 80; + $output = 'png'; + $date = \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache + $key = \md5('/v2/avatars/images-'.$url.'-'.$width.'/'.$height.'/'.$quality); + $type = 'png'; + $cache = new Cache(new Filesystem(APP_STORAGE_CACHE.'/app-0')); // Limit file number or size + $data = $cache->load($key, 60 * 60 * 24 * 7 /* 1 week */); - if (!\extension_loaded('imagick')) { - throw new Exception('Imagick extension is missing', 500); - } - - $fetch = @\file_get_contents($url, false); - - if (!$fetch) { - throw new Exception('Image not found', 404); - } - - try { - $resize = new Resize($fetch); - } catch (\Exception $exception) { - throw new Exception('Unable to parse image', 500); - } - - $resize->crop((int) $width, (int) $height); - - $output = (empty($output)) ? $type : $output; - - $response + if ($data) { + return $response ->setContentType('image/png') ->addHeader('Expires', $date) - ->addHeader('X-Appwrite-Cache', 'miss') - ->send('', null) + ->addHeader('X-Appwrite-Cache', 'hit') + ->send($data) ; - - $data = $resize->output($output, $quality); - - $cache->save($key, $data); - - echo $data; - - unset($resize); } - ); -$utopia->get('/v1/avatars/favicon') + if (!\extension_loaded('imagick')) { + throw new Exception('Imagick extension is missing', 500); + } + + $fetch = @\file_get_contents($url, false); + + if (!$fetch) { + throw new Exception('Image not found', 404); + } + + try { + $resize = new Resize($fetch); + } catch (\Exception $exception) { + throw new Exception('Unable to parse image', 500); + } + + $resize->crop((int) $width, (int) $height); + + $output = (empty($output)) ? $type : $output; + + $data = $resize->output($output, $quality); + + $cache->save($key, $data); + + $response + ->setContentType('image/png') + ->addHeader('Expires', $date) + ->addHeader('X-Appwrite-Cache', 'miss') + ->send($data); + ; + + unset($resize); + }); + +App::get('/v1/avatars/favicon') ->desc('Get Favicon') ->groups(['api', 'avatars']) - ->param('url', '', function () { return new URL(); }, 'Website URL which you want to fetch the favicon from.') ->label('scope', 'avatars.read') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getFavicon') ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-favicon.md') - ->action( - function ($url) use ($response, $request) { - $width = 56; - $height = 56; - $quality = 80; - $output = 'png'; - $date = \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache - $key = \md5('/v2/avatars/favicon-'.$url); - $type = 'png'; - $cache = new Cache(new Filesystem(APP_STORAGE_CACHE.'/app-0')); // Limit file number or size - $data = $cache->load($key, 60 * 60 * 24 * 30 * 3 /* 3 months */); + ->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 */ - if ($data) { - $response - ->setContentType('image/png') - ->addHeader('Expires', $date) - ->addHeader('X-Appwrite-Cache', 'hit') - ->send($data, 0) - ; - } + $width = 56; + $height = 56; + $quality = 80; + $output = 'png'; + $date = \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache + $key = \md5('/v2/avatars/favicon-'.$url); + $type = 'png'; + $cache = new Cache(new Filesystem(APP_STORAGE_CACHE.'/app-0')); // Limit file number or size + $data = $cache->load($key, 60 * 60 * 24 * 30 * 3 /* 3 months */); - if (!\extension_loaded('imagick')) { - throw new Exception('Imagick extension is missing', 500); - } - - $curl = \curl_init(); - - \curl_setopt_array($curl, [ - CURLOPT_RETURNTRANSFER => 1, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_MAXREDIRS => 3, - CURLOPT_URL => $url, - CURLOPT_USERAGENT => \sprintf(APP_USERAGENT, - Config::getParam('version'), - $request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) - ), - ]); - - $html = \curl_exec($curl); - - \curl_close($curl); - - if (!$html) { - throw new Exception('Failed to fetch remote URL', 404); - } - - $doc = new DOMDocument(); - $doc->strictErrorChecking = false; - @$doc->loadHTML($html); - - $links = $doc->getElementsByTagName('link'); - $outputHref = ''; - $outputExt = ''; - $space = 0; - - foreach ($links as $link) { /* @var $link DOMElement */ - $href = $link->getAttribute('href'); - $rel = $link->getAttribute('rel'); - $sizes = $link->getAttribute('sizes'); - $absolute = URLParse::unparse(\array_merge(\parse_url($url), \parse_url($href))); - - switch (\strtolower($rel)) { - case 'icon': - case 'shortcut icon': - //case 'apple-touch-icon': - $ext = \pathinfo(\parse_url($absolute, PHP_URL_PATH), PATHINFO_EXTENSION); - - switch ($ext) { - case 'ico': - case 'png': - case 'jpg': - case 'jpeg': - $size = \explode('x', \strtolower($sizes)); - - $sizeWidth = (isset($size[0])) ? (int) $size[0] : 0; - $sizeHeight = (isset($size[1])) ? (int) $size[1] : 0; - - if (($sizeWidth * $sizeHeight) >= $space) { - $space = $sizeWidth * $sizeHeight; - $outputHref = $absolute; - $outputExt = $ext; - } - - break; - } - - break; - } - } - - if (empty($outputHref) || empty($outputExt)) { - $default = \parse_url($url); - - $outputHref = $default['scheme'].'://'.$default['host'].'/favicon.ico'; - $outputExt = 'ico'; - } - - if ('ico' == $outputExt) { // Skip crop, Imagick isn\'t supporting icon files - $data = @\file_get_contents($outputHref, false); - - if (empty($data) || (\mb_substr($data, 0, 5) === 'save($key, $data); - - $response - ->setContentType('image/x-icon') - ->addHeader('Expires', $date) - ->addHeader('X-Appwrite-Cache', 'miss') - ->send($data, 0) - ; - } - - $fetch = @\file_get_contents($outputHref, false); - - if (!$fetch) { - throw new Exception('Icon not found', 404); - } - - $resize = new Resize($fetch); - - $resize->crop((int) $width, (int) $height); - - $output = (empty($output)) ? $type : $output; - - $response + if ($data) { + return $response ->setContentType('image/png') ->addHeader('Expires', $date) - ->addHeader('X-Appwrite-Cache', 'miss') - ->send('', null) + ->addHeader('X-Appwrite-Cache', 'hit') + ->send($data) ; + } - $data = $resize->output($output, $quality); + if (!\extension_loaded('imagick')) { + throw new Exception('Imagick extension is missing', 500); + } + + $curl = \curl_init(); + + \curl_setopt_array($curl, [ + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_MAXREDIRS => 3, + CURLOPT_URL => $url, + CURLOPT_USERAGENT => \sprintf(APP_USERAGENT, + App::getEnv('_APP_VERSION', 'UNKNOWN'), + App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) + ), + ]); + + $html = \curl_exec($curl); + + \curl_close($curl); + + if (!$html) { + throw new Exception('Failed to fetch remote URL', 404); + } + + $doc = new DOMDocument(); + $doc->strictErrorChecking = false; + @$doc->loadHTML($html); + + $links = $doc->getElementsByTagName('link'); + $outputHref = ''; + $outputExt = ''; + $space = 0; + + foreach ($links as $link) { /* @var $link DOMElement */ + $href = $link->getAttribute('href'); + $rel = $link->getAttribute('rel'); + $sizes = $link->getAttribute('sizes'); + $absolute = URLParse::unparse(\array_merge(\parse_url($url), \parse_url($href))); + + switch (\strtolower($rel)) { + case 'icon': + case 'shortcut icon': + //case 'apple-touch-icon': + $ext = \pathinfo(\parse_url($absolute, PHP_URL_PATH), PATHINFO_EXTENSION); + + switch ($ext) { + case 'ico': + case 'png': + case 'jpg': + case 'jpeg': + $size = \explode('x', \strtolower($sizes)); + + $sizeWidth = (int) $size[0] ?? 0; + $sizeHeight = (int) $size[1] ?? 0; + + if (($sizeWidth * $sizeHeight) >= $space) { + $space = $sizeWidth * $sizeHeight; + $outputHref = $absolute; + $outputExt = $ext; + } + + break; + } + + break; + } + } + + if (empty($outputHref) || empty($outputExt)) { + $default = \parse_url($url); + + $outputHref = $default['scheme'].'://'.$default['host'].'/favicon.ico'; + $outputExt = 'ico'; + } + + if ('ico' == $outputExt) { // Skip crop, Imagick isn\'t supporting icon files + $data = @\file_get_contents($outputHref, false); + + if (empty($data) || (\mb_substr($data, 0, 5) === 'save($key, $data); - echo $data; - - unset($resize); + return $response + ->setContentType('image/x-icon') + ->addHeader('Expires', $date) + ->addHeader('X-Appwrite-Cache', 'miss') + ->send($data) + ; } - ); -$utopia->get('/v1/avatars/qr') + $fetch = @\file_get_contents($outputHref, false); + + if (!$fetch) { + throw new Exception('Icon not found', 404); + } + + $resize = new Resize($fetch); + + $resize->crop((int) $width, (int) $height); + + $output = (empty($output)) ? $type : $output; + + $data = $resize->output($output, $quality); + + $cache->save($key, $data); + + $response + ->setContentType('image/png') + ->addHeader('Expires', $date) + ->addHeader('X-Appwrite-Cache', 'miss') + ->send($data); + + unset($resize); + }); + +App::get('/v1/avatars/qr') ->desc('Get QR Code') ->groups(['api', 'avatars']) - ->param('text', '', function () { return new Text(512); }, 'Plain text to be converted to QR code image.') - ->param('size', 400, function () { return new Range(0, 1000); }, 'QR code size. Pass an integer between 0 to 1000. Defaults to 400.', true) - ->param('margin', 1, function () { return new Range(0, 10); }, 'Margin from edge. Pass an integer between 0 to 10. Defaults to 1.', true) - ->param('download', false, function () { return 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) ->label('scope', 'avatars.read') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getQR') ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-qr.md') - ->action( - function ($text, $size, $margin, $download) use ($response) { - $download = ($download === '1' || $download === 'true' || $download === 1 || $download === true); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_IMAGE_PNG) + ->param('text', '', new Text(512), 'Plain text to be converted to QR code image.') + ->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 */ - $renderer = new ImageRenderer( - new RendererStyle($size, $margin), - new ImagickImageBackEnd('png', 100) - ); + $download = ($download === '1' || $download === 'true' || $download === 1 || $download === true); + $options = new QROptions([ + 'addQuietzone' => true, + 'quietzoneSize' => $margin, + 'outputType' => QRCode::OUTPUT_IMAGICK, + ]); - $writer = new Writer($renderer); + $qrcode = new QRCode($options); - if ($download) { - $response->addHeader('Content-Disposition', 'attachment; filename="qr.png"'); - } - - $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache - ->setContentType('image/png') - ->send($writer->writeString($text)) - ; + if ($download) { + $response->addHeader('Content-Disposition', 'attachment; filename="qr.png"'); } - ); -$utopia->get('/v1/avatars/initials') + $resize = new Resize($qrcode->render($text)); + + $resize->crop((int) $size, (int) $size); + + $response + ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache + ->setContentType('image/png') + ->send($resize->output('png', 9)) + ; + }); + +App::get('/v1/avatars/initials') ->desc('Get User Initials') ->groups(['api', 'avatars']) - ->param('name', '', function () { return new Text(512); }, 'Full Name. When empty, current user name or email will be used.', true) - ->param('width', 500, function () { return new Range(0, 2000); }, 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) - ->param('height', 500, function () { return new Range(0, 2000); }, 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) - ->param('color', '', function () { return new HexColor(); }, 'Changes text color. By default a random color will be picked and stay will persistent to the given name.', true) - ->param('background', '', function () { return new HexColor(); }, 'Changes background color. By default a random color will be picked and stay will persistent to the given name.', true) ->label('scope', 'avatars.read') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getInitials') ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-initials.md') - ->action( - function ($name, $width, $height, $color, $background) use ($response, $user) { - $themes = [ - ['color' => '#27005e', 'background' => '#e1d2f6'], // VIOLET - ['color' => '#5e2700', 'background' => '#f3d9c6'], // ORANGE - ['color' => '#006128', 'background' => '#c9f3c6'], // GREEN - ['color' => '#580061', 'background' => '#f2d1f5'], // FUSCHIA - ['color' => '#00365d', 'background' => '#c6e1f3'], // BLUE - ['color' => '#00075c', 'background' => '#d2d5f6'], // INDIGO - ['color' => '#610038', 'background' => '#f5d1e6'], // PINK - ['color' => '#386100', 'background' => '#dcf1bd'], // LIME - ['color' => '#615800', 'background' => '#f1ecba'], // YELLOW - ['color' => '#610008', 'background' => '#f6d2d5'] // RED - ]; + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_IMAGE_PNG) + ->param('name', '', new Text(128), 'Full Name. When empty, current user name or email will be used. Max length: 128 chars.', true) + ->param('width', 500, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) + ->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 */ - $rand = \rand(0, \count($themes)-1); + $themes = [ + ['color' => '#27005e', 'background' => '#e1d2f6'], // VIOLET + ['color' => '#5e2700', 'background' => '#f3d9c6'], // ORANGE + ['color' => '#006128', 'background' => '#c9f3c6'], // GREEN + ['color' => '#580061', 'background' => '#f2d1f5'], // FUSCHIA + ['color' => '#00365d', 'background' => '#c6e1f3'], // BLUE + ['color' => '#00075c', 'background' => '#d2d5f6'], // INDIGO + ['color' => '#610038', 'background' => '#f5d1e6'], // PINK + ['color' => '#386100', 'background' => '#dcf1bd'], // LIME + ['color' => '#615800', 'background' => '#f1ecba'], // YELLOW + ['color' => '#610008', 'background' => '#f6d2d5'] // RED + ]; - $name = (!empty($name)) ? $name : $user->getAttribute('name', $user->getAttribute('email', '')); - $words = \explode(' ', \strtoupper($name)); - $initials = null; - $code = 0; + $rand = \rand(0, \count($themes)-1); - foreach ($words as $key => $w) { - $initials .= (isset($w[0])) ? $w[0] : ''; - $code += (isset($w[0])) ? \ord($w[0]) : 0; + $name = (!empty($name)) ? $name : $user->getAttribute('name', $user->getAttribute('email', '')); + $words = \explode(' ', \strtoupper($name)); + $initials = null; + $code = 0; - if ($key == 1) { - break; - } + foreach ($words as $key => $w) { + $initials .= $w[0] ?? ''; + $code += (isset($w[0])) ? \ord($w[0]) : 0; + + if ($key == 1) { + break; } - - $length = \count($words); - $rand = \substr($code,-1); - $background = (!empty($background)) ? '#'.$background : $themes[$rand]['background']; - $color = (!empty($color)) ? '#'.$color : $themes[$rand]['color']; - - $image = new \Imagick(); - $draw = new \ImagickDraw(); - $fontSize = \min($width, $height) / 2; - - $draw->setFont(__DIR__."/../../../public/fonts/poppins-v9-latin-500.ttf"); - $image->setFont(__DIR__."/../../../public/fonts/poppins-v9-latin-500.ttf"); - - $draw->setFillColor(new \ImagickPixel($color)); - $draw->setFontSize($fontSize); - - $draw->setTextAlignment(\Imagick::ALIGN_CENTER); - $draw->annotation($width / 1.97, ($height / 2) + ($fontSize / 3), $initials); - - $image->newImage($width, $height, $background); - $image->setImageFormat("png"); - $image->drawImage($draw); - - //$image->setImageCompressionQuality(9 - round(($quality / 100) * 9)); - - $response - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache - ->setContentType('image/png') - ->send($image->getImageBlob()) - ; } - ); \ No newline at end of file + + $length = \count($words); + $rand = \substr($code,-1); + $background = (!empty($background)) ? '#'.$background : $themes[$rand]['background']; + $color = (!empty($color)) ? '#'.$color : $themes[$rand]['color']; + + $image = new \Imagick(); + $draw = new \ImagickDraw(); + $fontSize = \min($width, $height) / 2; + + $draw->setFont(__DIR__."/../../../public/fonts/poppins-v9-latin-500.ttf"); + $image->setFont(__DIR__."/../../../public/fonts/poppins-v9-latin-500.ttf"); + + $draw->setFillColor(new \ImagickPixel($color)); + $draw->setFontSize($fontSize); + + $draw->setTextAlignment(\Imagick::ALIGN_CENTER); + $draw->annotation($width / 1.97, ($height / 2) + ($fontSize / 3), $initials); + + $image->newImage($width, $height, $background); + $image->setImageFormat("png"); + $image->drawImage($draw); + + //$image->setImageCompressionQuality(9 - round(($quality / 100) * 9)); + + $response + ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache + ->setContentType('image/png') + ->send($image->getImageBlob()) + ; + }); diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index dadf7e9576..77de5953ad 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -1,19 +1,12 @@ post('/v1/database/collections') +App::post('/v1/database/collections') ->desc('Create Collection') ->groups(['api', 'database']) - ->label('webhook', 'database.collections.create') + ->label('event', 'database.collections.create') ->label('scope', 'collections.write') ->label('sdk.namespace', 'database') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.method', 'createCollection') ->label('sdk.description', '/docs/references/database/create-collection.md') - ->param('name', '', function () { return new Text(256); }, 'Collection name.') - ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('rules', [], function () use ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.') - ->action( - function ($name, $read, $write, $rules) use ($response, $projectDB, $webhook, $audit) { - $parsedRules = []; + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_COLLECTION) + ->param('name', '', new Text(128), 'Collection name. Max length: 128 chars.') + ->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 */ + /** @var Appwrite\Event\Event $audits */ - foreach ($rules as &$rule) { - $parsedRules[] = \array_merge([ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - '$permissions' => [ - 'read' => $read, - 'write' => $write, - ], - ], $rule); - } + $parsedRules = []; - try { - $data = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - 'name' => $name, - 'dateCreated' => \time(), - 'dateUpdated' => \time(), - 'structure' => true, - '$permissions' => [ - 'read' => $read, - 'write' => $write, - ], - 'rules' => $parsedRules, - ]); - } catch (AuthorizationException $exception) { - throw new Exception('Unauthorized action', 401); - } catch (StructureException $exception) { - throw new Exception('Bad structure. '.$exception->getMessage(), 400); - } catch (\Exception $exception) { - throw new Exception('Failed saving document to DB', 500); - } - - if (false === $data) { - throw new Exception('Failed saving collection to DB', 500); - } - - $data = $data->getArrayCopy(); - - $webhook - ->setParam('payload', $data) - ; - - $audit - ->setParam('event', 'database.collections.create') - ->setParam('resource', 'database/collection/'.$data['$id']) - ->setParam('data', $data) - ; - - /* - * View - */ - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($data) - ; + foreach ($rules as &$rule) { + $parsedRules[] = \array_merge([ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + '$permissions' => [ + 'read' => $read, + 'write' => $write, + ], + ], $rule); } - ); -$utopia->get('/v1/database/collections') + try { + $data = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + 'name' => $name, + 'dateCreated' => \time(), + 'dateUpdated' => \time(), + 'structure' => true, + '$permissions' => [ + 'read' => $read, + 'write' => $write, + ], + 'rules' => $parsedRules, + ]); + } catch (AuthorizationException $exception) { + throw new Exception('Unauthorized permissions', 401); + } catch (StructureException $exception) { + throw new Exception('Bad structure. '.$exception->getMessage(), 400); + } catch (\Exception $exception) { + throw new Exception('Failed saving document to DB', 500); + } + + if (false === $data) { + throw new Exception('Failed saving collection to DB', 500); + } + + $audits + ->setParam('event', 'database.collections.create') + ->setParam('resource', 'database/collection/'.$data->getId()) + ->setParam('data', $data->getArrayCopy()) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($data, Response::MODEL_COLLECTION) + ; + }); + +App::get('/v1/database/collections') ->desc('List Collections') ->groups(['api', 'database']) ->label('scope', 'collections.read') @@ -109,48 +99,36 @@ $utopia->get('/v1/database/collections') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.method', 'listCollections') ->label('sdk.description', '/docs/references/database/list-collections.md') - ->param('search', '', function () { return new Text(256); }, 'Search term to filter your list results.', true) - ->param('limit', 25, function () { return new Range(0, 100); }, 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0, function () { return new Range(0, 40000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true) - ->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true) - ->action( - function ($search, $limit, $offset, $orderType) use ($response, $projectDB) { - /*$vl = new Structure($projectDB); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_COLLECTION_LIST) + ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) + ->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 */ - var_dump($vl->isValid(new Document([ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - '$permissions' => [ - 'read' => ['*'], - 'write' => ['*'], - ], - 'label' => 'Platforms', - 'key' => 'platforms', - 'type' => 'document', - 'default' => [], - 'required' => false, - 'array' => true, - 'options' => [Database::SYSTEM_COLLECTION_PLATFORMS], - ]))); + $results = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderType' => $orderType, + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_COLLECTIONS, + ], + ]); - var_dump($vl->getDescription());*/ + $response->dynamic(new Document([ + 'sum' => $projectDB->getSum(), + 'collections' => $results + ]), Response::MODEL_COLLECTION_LIST); + }); - $results = $projectDB->getCollection([ - 'limit' => $limit, - 'offset' => $offset, - 'orderField' => 'name', - 'orderType' => $orderType, - 'orderCast' => 'string', - 'search' => $search, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_COLLECTIONS, - ], - ]); - - $response->json(['sum' => $projectDB->getSum(), 'collections' => $results]); - } - ); - -$utopia->get('/v1/database/collections/:collectionId') +App::get('/v1/database/collections/:collectionId') ->desc('Get Collection') ->groups(['api', 'database']) ->label('scope', 'collections.read') @@ -158,316 +136,272 @@ $utopia->get('/v1/database/collections/:collectionId') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.method', 'getCollection') ->label('sdk.description', '/docs/references/database/get-collection.md') - ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') - ->action( - function ($collectionId) use ($response, $projectDB) { - $collection = $projectDB->getDocument($collectionId, false); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ + + $collection = $projectDB->getDocument($collectionId, false); - if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } - - $response->json($collection->getArrayCopy()); + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); } - ); -// $utopia->get('/v1/database/collections/:collectionId/logs') -// ->desc('Get Collection Logs') -// ->groups(['api', 'database']) -// ->label('scope', 'collections.read') -// ->label('sdk.platform', [APP_PLATFORM_SERVER]) -// ->label('sdk.namespace', 'database') -// ->label('sdk.method', 'getCollectionLogs') -// ->label('sdk.description', '/docs/references/database/get-collection-logs.md') -// ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') -// ->action( -// function ($collectionId) use ($response, $register, $projectDB, $project) { -// $collection = $projectDB->getDocument($collectionId, false); + $response->dynamic($collection, Response::MODEL_COLLECTION); + }); -// if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { -// throw new Exception('Collection not found', 404); -// } - -// $adapter = new AuditAdapter($register->get('db')); -// $adapter->setNamespace('app_'.$project->getId()); - -// $audit = new Audit($adapter); - -// $countries = Locale::getText('countries'); - -// $logs = $audit->getLogsByResource('database/collection/'.$collection->getId()); - -// $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); -// $output = []; - -// foreach ($logs as $i => &$log) { -// $log['userAgent'] = (!empty($log['userAgent'])) ? $log['userAgent'] : 'UNKNOWN'; - -// $dd = new DeviceDetector($log['userAgent']); - -// $dd->skipBotDetection(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) - -// $dd->parse(); - -// $output[$i] = [ -// 'event' => $log['event'], -// 'ip' => $log['ip'], -// 'time' => strtotime($log['time']), -// 'OS' => $dd->getOs(), -// 'client' => $dd->getClient(), -// 'device' => $dd->getDevice(), -// 'brand' => $dd->getBrand(), -// 'model' => $dd->getModel(), -// 'geo' => [], -// ]; - -// try { -// $record = $reader->country($log['ip']); -// $output[$i]['geo']['isoCode'] = strtolower($record->country->isoCode); -// $output[$i]['geo']['country'] = $record->country->name; -// $output[$i]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); -// } catch (\Exception $e) { -// $output[$i]['geo']['isoCode'] = '--'; -// $output[$i]['geo']['country'] = Locale::getText('locale.country.unknown'); -// } -// } - -// $response->json($output); -// } -// ); - -$utopia->put('/v1/database/collections/:collectionId') +App::put('/v1/database/collections/:collectionId') ->desc('Update Collection') ->groups(['api', 'database']) ->label('scope', 'collections.write') - ->label('webhook', 'database.collections.update') + ->label('event', 'database.collections.update') ->label('sdk.namespace', 'database') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.method', 'updateCollection') ->label('sdk.description', '/docs/references/database/update-collection.md') - ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Collection name.') - ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions(/docs/permissions) and get a full list of available permissions.') - ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('rules', [], function () use ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', true) - ->action( - function ($collectionId, $name, $read, $write, $rules) use ($response, $projectDB, $webhook, $audit) { - $collection = $projectDB->getDocument($collectionId, false); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_COLLECTION) + ->param('collectionId', '', new UID(), 'Collection unique ID.') + ->param('name', null, new Text(128), 'Collection name. Max length: 128 chars.') + ->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 */ + /** @var Appwrite\Event\Event $audits */ - if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } + $collection = $projectDB->getDocument($collectionId, false); - $parsedRules = []; - - foreach ($rules as &$rule) { - $parsedRules[] = \array_merge([ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - '$permissions' => [ - 'read' => $read, - 'write' => $write, - ], - ], $rule); - } - - try { - $collection = $projectDB->updateDocument(\array_merge($collection->getArrayCopy(), [ - 'name' => $name, - 'structure' => true, - 'dateUpdated' => \time(), - '$permissions' => [ - 'read' => $read, - 'write' => $write, - ], - 'rules' => $parsedRules, - ])); - } catch (AuthorizationException $exception) { - throw new Exception('Unauthorized action', 401); - } catch (StructureException $exception) { - throw new Exception('Bad structure. '.$exception->getMessage(), 400); - } catch (\Exception $exception) { - throw new Exception('Failed saving document to DB', 500); - } - - if (false === $collection) { - throw new Exception('Failed saving collection to DB', 500); - } - - $data = $collection->getArrayCopy(); - - $webhook - ->setParam('payload', $data) - ; - - $audit - ->setParam('event', 'database.collections.update') - ->setParam('resource', 'database/collections/'.$data['$id']) - ->setParam('data', $data) - ; - - $response->json($collection->getArrayCopy()); + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); } - ); -$utopia->delete('/v1/database/collections/:collectionId') + $parsedRules = []; + + foreach ($rules as &$rule) { + $parsedRules[] = \array_merge([ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + '$permissions' => [ + 'read' => $read, + 'write' => $write, + ], + ], $rule); + } + + try { + $collection = $projectDB->updateDocument(\array_merge($collection->getArrayCopy(), [ + 'name' => $name, + 'structure' => true, + 'dateUpdated' => \time(), + '$permissions' => [ + 'read' => $read, + 'write' => $write, + ], + 'rules' => $parsedRules, + ])); + } catch (AuthorizationException $exception) { + throw new Exception('Unauthorized permissions', 401); + } catch (StructureException $exception) { + throw new Exception('Bad structure. '.$exception->getMessage(), 400); + } catch (\Exception $exception) { + throw new Exception('Failed saving document to DB', 500); + } + + if (false === $collection) { + throw new Exception('Failed saving collection to DB', 500); + } + + $audits + ->setParam('event', 'database.collections.update') + ->setParam('resource', 'database/collections/'.$collection->getId()) + ->setParam('data', $collection->getArrayCopy()) + ; + + $response->dynamic($collection, Response::MODEL_COLLECTION); + }); + +App::delete('/v1/database/collections/:collectionId') ->desc('Delete Collection') ->groups(['api', 'database']) ->label('scope', 'collections.write') - ->label('webhook', 'database.collections.delete') + ->label('event', 'database.collections.delete') ->label('sdk.namespace', 'database') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.method', 'deleteCollection') ->label('sdk.description', '/docs/references/database/delete-collection.md') - ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') - ->action( - function ($collectionId) use ($response, $projectDB, $webhook, $audit) { - $collection = $projectDB->getDocument($collectionId, false); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Event\Event $events */ + /** @var Appwrite\Event\Event $audits */ - if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } + $collection = $projectDB->getDocument($collectionId, false); - if (!$projectDB->deleteDocument($collectionId)) { - throw new Exception('Failed to remove collection from DB', 500); - } - - $data = $collection->getArrayCopy(); - - $webhook - ->setParam('payload', $data) - ; - - $audit - ->setParam('event', 'database.collections.delete') - ->setParam('resource', 'database/collections/'.$data['$id']) - ->setParam('data', $data) - ; - - $response->noContent(); + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); } - ); -$utopia->post('/v1/database/collections/:collectionId/documents') + if (!$projectDB->deleteDocument($collectionId)) { + throw new Exception('Failed to remove collection from DB', 500); + } + + $deletes + ->setParam('type', DELETE_TYPE_DOCUMENT) + ->setParam('document', $collection) + ; + + $events + ->setParam('payload', $response->output($collection, Response::MODEL_COLLECTION)) + ; + + $audits + ->setParam('event', 'database.collections.delete') + ->setParam('resource', 'database/collections/'.$collection->getId()) + ->setParam('data', $collection->getArrayCopy()) + ; + + $response->noContent(); + }); + +App::post('/v1/database/collections/:collectionId/documents') ->desc('Create Document') ->groups(['api', 'database']) - ->label('webhook', 'database.documents.create') + ->label('event', 'database.documents.create') ->label('scope', 'documents.write') ->label('sdk.namespace', 'database') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.method', 'createDocument') ->label('sdk.description', '/docs/references/database/create-document.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).') - ->param('data', [], function () { return new JSON(); }, 'Document data as JSON object.') - ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('parentDocument', '', function () { return new UID(); }, 'Parent document unique ID. Use when you want your new document to be a child of a parent document.', true) - ->param('parentProperty', '', function () { return 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, function () { return new WhiteList([Document::SET_TYPE_ASSIGN, Document::SET_TYPE_APPEND, Document::SET_TYPE_PREPEND]); }, '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) - ->action( - function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType) use ($response, $projectDB, $webhook, $audit) { - $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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('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.') + ->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 */ + /** @var Appwrite\Event\Event $audits */ + + $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array - if (empty($data)) { - throw new Exception('Missing payload', 400); + if (empty($data)) { + throw new Exception('Missing payload', 400); + } + + if (isset($data['$id'])) { + throw new Exception('$id is not allowed for creating new documents, try update instead', 400); + } + + $collection = $projectDB->getDocument($collectionId, false); + + if (\is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); + } + + $data['$collection'] = $collectionId; // Adding this param to make API easier for developers + $data['$permissions'] = [ + 'read' => $read, + 'write' => $write, + ]; + + // Read parent document + validate not 404 + validate read / write permission like patch method + // Add payload to parent document property + if ((!empty($parentDocument)) && (!empty($parentProperty))) { + $parentDocument = $projectDB->getDocument($parentDocument, false); + + if (empty($parentDocument->getArrayCopy())) { // Check empty + throw new Exception('No parent document found', 404); } - if (isset($data['$id'])) { - throw new Exception('$id is not allowed for creating new documents, try update instead', 400); - } - - $collection = $projectDB->getDocument($collectionId, false); - - if (\is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } - - $data['$collection'] = $collectionId; // Adding this param to make API easier for developers - $data['$permissions'] = [ - 'read' => $read, - 'write' => $write, - ]; - - // Read parent document + validate not 404 + validate read / write permission like patch method - // Add payload to parent document property - if ((!empty($parentDocument)) && (!empty($parentProperty))) { - $parentDocument = $projectDB->getDocument($parentDocument, false); - - if (empty($parentDocument->getArrayCopy())) { // Check empty - throw new Exception('No parent document found', 404); - } - - /* - * 1. Check child has valid structure, - * 2. Check user have write permission for parent document - * 3. Assign parent data (including child) to $data - * 4. Validate the combined result has valid structure (inside $projectDB->createDocument method) - */ - - $new = new Document($data); - - $structure = new Structure($projectDB); - - if (!$structure->isValid($new)) { - throw new Exception('Invalid data structure: '.$structure->getDescription(), 400); - } - - $authorization = new Authorization($parentDocument, 'write'); - - if (!$authorization->isValid($new->getPermissions())) { - throw new Exception('Unauthorized action', 401); - } - - $parentDocument - ->setAttribute($parentProperty, $data, $parentPropertyType); - - $data = $parentDocument->getArrayCopy(); - } - - /** - * Set default collection values - */ - foreach ($collection->getAttribute('rules') as $key => $rule) { - $key = (isset($rule['key'])) ? $rule['key'] : ''; - $default = (isset($rule['default'])) ? $rule['default'] : null; - - if (!isset($data[$key])) { - $data[$key] = $default; - } - } - - try { - $data = $projectDB->createDocument($data); - } catch (AuthorizationException $exception) { - throw new Exception('Unauthorized action', 401); - } catch (StructureException $exception) { - throw new Exception('Bad structure. '.$exception->getMessage(), 400); - } catch (\Exception $exception) { - throw new Exception('Failed saving document to DB'.$exception->getMessage(), 500); - } - - $data = $data->getArrayCopy(); - - $webhook - ->setParam('payload', $data) - ; - - $audit - ->setParam('event', 'database.documents.create') - ->setParam('resource', 'database/document/'.$data['$id']) - ->setParam('data', $data) - ; - /* - * View + * 1. Check child has valid structure, + * 2. Check user have write permission for parent document + * 3. Assign parent data (including child) to $data + * 4. Validate the combined result has valid structure (inside $projectDB->createDocument method) */ - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($data) - ; - } - ); -$utopia->get('/v1/database/collections/:collectionId/documents') + $new = new Document($data); + + $structure = new Structure($projectDB); + + if (!$structure->isValid($new)) { + throw new Exception('Invalid data structure: '.$structure->getDescription(), 400); + } + + $authorization = new Authorization($parentDocument, 'write'); + + if (!$authorization->isValid($new->getPermissions())) { + throw new Exception('Unauthorized permissions', 401); + } + + $parentDocument + ->setAttribute($parentProperty, $data, $parentPropertyType); + + $data = $parentDocument->getArrayCopy(); + $collection = $projectDB->getDocument($parentDocument->getCollection(), false); + } + + /** + * Set default collection values + */ + foreach ($collection->getAttribute('rules') as $key => $rule) { + $key = $rule['key'] ?? ''; + $default = $rule['default'] ?? null; + + if (!isset($data[$key])) { + $data[$key] = $default; + } + } + + try { + $data = $projectDB->createDocument($data); + } catch (AuthorizationException $exception) { + throw new Exception('Unauthorized permissions', 401); + } catch (StructureException $exception) { + throw new Exception('Bad structure. '.$exception->getMessage(), 400); + } catch (\Exception $exception) { + throw new Exception('Failed saving document to DB'.$exception->getMessage(), 500); + } + + $audits + ->setParam('event', 'database.documents.create') + ->setParam('resource', 'database/document/'.$data['$id']) + ->setParam('data', $data->getArrayCopy()) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($data, Response::MODEL_ANY) + ; + }); + +App::get('/v1/database/collections/:collectionId/documents') ->desc('List Documents') ->groups(['api', 'database']) ->label('scope', 'documents.read') @@ -475,59 +409,62 @@ $utopia->get('/v1/database/collections/:collectionId/documents') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.method', 'listDocuments') ->label('sdk.description', '/docs/references/database/list-documents.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).') - ->param('filters', [], function () { return new ArrayList(new Text(128)); }, 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: \'name=John Doe\' or \'category.$id>=5bed2d152c362\'.', true) - ->param('offset', 0, function () { return new Range(0, 900000000); }, 'Offset value. Use this value to manage pagination.', true) - ->param('limit', 50, function () { return new Range(0, 1000); }, 'Maximum number of documents to return in response. Use this value to manage pagination.', true) - ->param('orderField', '$id', function () { return new Text(128); }, 'Document field that results will be sorted by.', true) - ->param('orderType', 'ASC', function () { return new WhiteList(array('DESC', 'ASC')); }, 'Order direction. Possible values are DESC for descending order, or ASC for ascending order.', true) - ->param('orderCast', 'string', function () { return new WhiteList(array('int', 'string', 'date', 'time', 'datetime')); }, 'Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string.', true) - ->param('search', '', function () { return new Text(256); }, 'Search query. Enter any free text search. The database will try to find a match against all document attributes and children.', true) - ->action( - function ($collectionId, $filters, $offset, $limit, $orderField, $orderType, $orderCast, $search) use ($response, $projectDB, $utopia) { - $collection = $projectDB->getDocument($collectionId, false); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_DOCUMENT_LIST) + ->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('filters', [], new ArrayList(new Text(128)), 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: \'name=John Doe\' or \'category.$id>=5bed2d152c362\'.', true) + ->param('limit', 25, new Range(0, 100), 'Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0, new Range(0, 900000000), 'Offset value. The default value is 0. Use this param to manage pagination.', true) + ->param('orderField', '', new Text(128), 'Document field that results will be sorted by.', true) + ->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 */ - if (\is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } + $collection = $projectDB->getDocument($collectionId, false); - $list = $projectDB->getCollection([ - 'limit' => $limit, - 'offset' => $offset, - 'orderField' => $orderField, - 'orderType' => $orderType, - 'orderCast' => $orderCast, - 'search' => $search, - 'filters' => \array_merge($filters, [ - '$collection='.$collectionId, - ]), - ]); - - if ($utopia->isDevelopment()) { - $collection - ->setAttribute('debug', $projectDB->getDebug()) - ->setAttribute('limit', $limit) - ->setAttribute('offset', $offset) - ->setAttribute('orderField', $orderField) - ->setAttribute('orderType', $orderType) - ->setAttribute('orderCast', $orderCast) - ->setAttribute('filters', $filters) - ; - } - - $collection - ->setAttribute('sum', $projectDB->getSum()) - ->setAttribute('documents', $list) - ; - - /* - * View - */ - $response->json($collection->getArrayCopy(/*['$id', '$collection', 'name', 'documents']*/[], ['rules'])); + if (\is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); } - ); -$utopia->get('/v1/database/collections/:collectionId/documents/:documentId') + $list = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderField' => $orderField, + 'orderType' => $orderType, + 'orderCast' => $orderCast, + 'search' => $search, + 'filters' => \array_merge($filters, [ + '$collection='.$collectionId, + ]), + ]); + + // if (App::isDevelopment()) { + // $collection + // ->setAttribute('debug', $projectDB->getDebug()) + // ->setAttribute('limit', $limit) + // ->setAttribute('offset', $offset) + // ->setAttribute('orderField', $orderField) + // ->setAttribute('orderType', $orderType) + // ->setAttribute('orderCast', $orderCast) + // ->setAttribute('filters', $filters) + // ; + // } + + $collection + ->setAttribute('sum', $projectDB->getSum()) + ->setAttribute('documents', $list) + ; + + $response->dynamic($collection, Response::MODEL_DOCUMENT_LIST); + }); + +App::get('/v1/database/collections/:collectionId/documents/:documentId') ->desc('Get Document') ->groups(['api', 'database']) ->label('scope', 'documents.read') @@ -535,170 +472,160 @@ $utopia->get('/v1/database/collections/:collectionId/documents/:documentId') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.method', 'getDocument') ->label('sdk.description', '/docs/references/database/get-document.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).') - ->param('documentId', null, function () { return new UID(); }, 'Document unique ID.') - ->action( - function ($collectionId, $documentId) use ($response, $request, $projectDB) { - $document = $projectDB->getDocument($documentId, false); - $collection = $projectDB->getDocument($collectionId, false); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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.') + ->inject('response') + ->inject('projectDB') + ->action(function ($collectionId, $documentId, $response, $projectDB) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ - if (empty($document->getArrayCopy()) || $document->getCollection() != $collection->getId()) { // Check empty - throw new Exception('No document found', 404); - } + $document = $projectDB->getDocument($documentId, false); + $collection = $projectDB->getDocument($collectionId, false); - $output = $document->getArrayCopy(); - - $paths = \explode('/', $request->getParam('q', '')); - $paths = \array_slice($paths, 7, \count($paths)); - - if (\count($paths) > 0) { - if (\count($paths) % 2 == 1) { - $output = $document->getAttribute(\implode('.', $paths)); - } else { - $id = (int) \array_pop($paths); - $output = $document->search('$id', $id, $document->getAttribute(\implode('.', $paths))); - } - - $output = ($output instanceof Document) ? $output->getArrayCopy() : $output; - - if (!\is_array($output)) { - throw new Exception('No document found', 404); - } - } - - /* - * View - */ - $response->json($output); + if (empty($document->getArrayCopy()) || $document->getCollection() != $collection->getId()) { // Check empty + throw new Exception('No document found', 404); } - ); -$utopia->patch('/v1/database/collections/:collectionId/documents/:documentId') + $response->dynamic($document, Response::MODEL_ANY); + }); + +App::patch('/v1/database/collections/:collectionId/documents/:documentId') ->desc('Update Document') ->groups(['api', 'database']) - ->label('webhook', 'database.documents.update') + ->label('event', 'database.documents.update') ->label('scope', 'documents.write') ->label('sdk.namespace', 'database') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.method', 'updateDocument') ->label('sdk.description', '/docs/references/database/update-document.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).') - ->param('documentId', null, function () { return new UID(); }, 'Document unique ID.') - ->param('data', [], function () { return new JSON(); }, 'Document data as JSON object.') - ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->action( - function ($collectionId, $documentId, $data, $read, $write) use ($response, $projectDB, $webhook, $audit) { - $collection = $projectDB->getDocument($collectionId, false); - $document = $projectDB->getDocument($documentId, false); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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.') + ->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 */ + /** @var Appwrite\Event\Event $audits */ - $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array + $collection = $projectDB->getDocument($collectionId, false); + $document = $projectDB->getDocument($documentId, false); - if (!\is_array($data)) { - throw new Exception('Data param should be a valid JSON', 400); - } + $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array - if (\is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } - - if (empty($document->getArrayCopy()) || $document->getCollection() != $collectionId) { // Check empty - throw new Exception('No document found', 404); - } - - //TODO check merge read write permissions - - if (!empty($read)) { // Overwrite permissions only when passed - $data['$permissions']['read'] = $read; - } - - if (!empty($write)) { // Overwrite permissions only when passed - $data['$permissions']['write'] = $write; - } - - $data = \array_merge($document->getArrayCopy(), $data); - - $data['$collection'] = $collection->getId(); // Make sure user don't switch collectionID - $data['$id'] = $document->getId(); // Make sure user don't switch document unique ID - - if (empty($data)) { - throw new Exception('Missing payload', 400); - } - try { - $data = $projectDB->updateDocument($data); - } catch (AuthorizationException $exception) { - throw new Exception('Unauthorized action', 401); - } catch (StructureException $exception) { - throw new Exception('Bad structure. '.$exception->getMessage(), 400); - } catch (\Exception $exception) { - throw new Exception('Failed saving document to DB', 500); - } - - $data = $data->getArrayCopy(); - - $webhook - ->setParam('payload', $data) - ; - - $audit - ->setParam('event', 'database.documents.update') - ->setParam('resource', 'database/document/'.$data['$id']) - ->setParam('data', $data) - ; - - /* - * View - */ - $response->json($data); + if (!\is_array($data)) { + throw new Exception('Data param should be a valid JSON object', 400); } - ); -$utopia->delete('/v1/database/collections/:collectionId/documents/:documentId') + if (\is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); + } + + if (empty($document->getArrayCopy()) || $document->getCollection() != $collectionId) { // Check empty + throw new Exception('No document found', 404); + } + + //TODO check merge read write permissions + + if (!empty($read)) { // Overwrite permissions only when passed + $data['$permissions']['read'] = $read; + } + + if (!empty($write)) { // Overwrite permissions only when passed + $data['$permissions']['write'] = $write; + } + + $data = \array_merge($document->getArrayCopy(), $data); + + $data['$collection'] = $collection->getId(); // Make sure user don't switch collectionID + $data['$id'] = $document->getId(); // Make sure user don't switch document unique ID + + if (empty($data)) { + throw new Exception('Missing payload', 400); + } + + try { + $data = $projectDB->updateDocument($data); + } catch (AuthorizationException $exception) { + throw new Exception('Unauthorized permissions', 401); + } catch (StructureException $exception) { + throw new Exception('Bad structure. '.$exception->getMessage(), 400); + } catch (\Exception $exception) { + throw new Exception('Failed saving document to DB', 500); + } + + $audits + ->setParam('event', 'database.documents.update') + ->setParam('resource', 'database/document/'.$data->getId()) + ->setParam('data', $data->getArrayCopy()) + ; + + $response->dynamic($data, Response::MODEL_ANY); + }); + +App::delete('/v1/database/collections/:collectionId/documents/:documentId') ->desc('Delete Document') ->groups(['api', 'database']) ->label('scope', 'documents.write') - ->label('webhook', 'database.documents.delete') + ->label('event', 'database.documents.delete') ->label('sdk.namespace', 'database') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.method', 'deleteDocument') ->label('sdk.description', '/docs/references/database/delete-document.md') - ->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).') - ->param('documentId', null, function () { return new UID(); }, 'Document unique ID.') - ->action( - function ($collectionId, $documentId) use ($response, $projectDB, $audit, $webhook) { - $collection = $projectDB->getDocument($collectionId, false); - $document = $projectDB->getDocument($documentId, false); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Event\Event $events */ + /** @var Appwrite\Event\Event $audits */ - if (empty($document->getArrayCopy()) || $document->getCollection() != $collectionId) { // Check empty - throw new Exception('No document found', 404); - } + $collection = $projectDB->getDocument($collectionId, false); + $document = $projectDB->getDocument($documentId, false); - if (\is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } - - try { - $projectDB->deleteDocument($documentId); - } catch (AuthorizationException $exception) { - throw new Exception('Unauthorized action', 401); - } catch (StructureException $exception) { - throw new Exception('Bad structure. '.$exception->getMessage(), 400); - } catch (\Exception $exception) { - throw new Exception('Failed to remove document from DB', 500); - } - - $data = $document->getArrayCopy(); - - $webhook - ->setParam('payload', $data) - ; - - $audit - ->setParam('event', 'database.documents.delete') - ->setParam('resource', 'database/document/'.$data['$id']) - ->setParam('data', $data) // Audit document in case of malicious or disastrous action - ; - - $response->noContent(); + if (empty($document->getArrayCopy()) || $document->getCollection() != $collectionId) { // Check empty + throw new Exception('No document found', 404); } - ); + + if (\is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); + } + + try { + $projectDB->deleteDocument($documentId); + } catch (AuthorizationException $exception) { + throw new Exception('Unauthorized permissions', 401); + } catch (StructureException $exception) { + throw new Exception('Bad structure. '.$exception->getMessage(), 400); + } catch (\Exception $exception) { + throw new Exception('Failed to remove document from DB', 500); + } + + $events + ->setParam('payload', $response->output($document, Response::MODEL_ANY)) + ; + + $audits + ->setParam('event', 'database.documents.delete') + ->setParam('resource', 'database/document/'.$document->getId()) + ->setParam('data', $document->getArrayCopy()) // Audit document in case of malicious or disastrous action + ; + + $response->noContent(); + }); \ No newline at end of file diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php new file mode 100644 index 0000000000..e51fdd044f --- /dev/null +++ b/app/controllers/api/functions.php @@ -0,0 +1,828 @@ +groups(['api', 'functions']) + ->desc('Create Function') + ->label('scope', 'functions.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'create') + ->label('sdk.description', '/docs/references/functions/create-function.md') + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_FUNCTION) + ->param('name', '', new Text(128), 'Function name. Max length: 128 chars.') + ->param('execute', [], new ArrayList(new Text(64)), 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') + ->param('env', '', new WhiteList(array_keys(Config::getParam('environments')), true), 'Execution enviornment.') + ->param('vars', [], new Assoc(), 'Key-value JSON object.', true) + ->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, $execute, $env, $vars, $events, $schedule, $timeout, $response, $projectDB) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + + $function = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_FUNCTIONS, + '$permissions' => [ + 'execute' => $execute, + ], + 'dateCreated' => time(), + 'dateUpdated' => time(), + 'status' => 'disabled', + 'name' => $name, + 'env' => $env, + 'tag' => '', + 'vars' => $vars, + 'events' => $events, + 'schedule' => $schedule, + 'schedulePrevious' => null, + 'scheduleNext' => null, + 'timeout' => $timeout, + ]); + + if (false === $function) { + throw new Exception('Failed saving function to DB', 500); + } + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($function, Response::MODEL_FUNCTION) + ; + }); + +App::get('/v1/functions') + ->groups(['api', 'functions']) + ->desc('List Functions') + ->label('scope', 'functions.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'list') + ->label('sdk.description', '/docs/references/functions/list-functions.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_FUNCTION_LIST) + ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) + ->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 */ + + $results = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderType' => $orderType, + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_FUNCTIONS, + ], + ]); + + $response->dynamic(new Document([ + 'sum' => $projectDB->getSum(), + 'functions' => $results + ]), Response::MODEL_FUNCTION_LIST); + }); + +App::get('/v1/functions/:functionId') + ->groups(['api', 'functions']) + ->desc('Get Function') + ->label('scope', 'functions.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'get') + ->label('sdk.description', '/docs/references/functions/get-function.md') + ->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.') + ->inject('response') + ->inject('projectDB') + ->action(function ($functionId, $response, $projectDB) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + $response->dynamic($function, Response::MODEL_FUNCTION); + }); + +App::get('/v1/functions/:functionId/usage') + ->desc('Get Function Usage') + ->groups(['api', 'functions']) + ->label('scope', 'functions.read') + ->label('sdk.platform', [APP_PLATFORM_CONSOLE]) + ->label('sdk.namespace', 'functions') + ->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 */ + /** @var Appwrite\Database\Database $consoleDB */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Utopia\Registry\Registry $register */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + if(App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { + $period = [ + '24h' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-24 hours')), + 'end' => DateTime::createFromFormat('U', \strtotime('+1 hour')), + 'group' => '30m', + ], + '7d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-7 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + '30d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-30 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + '90d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-90 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + ]; + + $client = $register->get('influxdb'); + + $executions = []; + $failures = []; + $compute = []; + + if ($client) { + $start = $period[$range]['start']->format(DateTime::RFC3339); + $end = $period[$range]['end']->format(DateTime::RFC3339); + $database = $client->selectDB('telegraf'); + + // Executions + $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().'\' AND "functionId"=\''.$function->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $executions[] = [ + 'value' => (!empty($point['value'])) ? $point['value'] : 0, + 'date' => \strtotime($point['time']), + ]; + } + + // Failures + $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().'\' AND "functionId"=\''.$function->getId().'\' AND "functionStatus"=\'failed\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $failures[] = [ + 'value' => (!empty($point['value'])) ? $point['value'] : 0, + 'date' => \strtotime($point['time']), + ]; + } + + // Compute + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_time" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $compute[] = [ + 'value' => round((!empty($point['value'])) ? $point['value'] / 1000 : 0, 2), // minutes + 'date' => \strtotime($point['time']), + ]; + } + } + + $response->json([ + 'range' => $range, + 'executions' => [ + 'data' => $executions, + 'total' => \array_sum(\array_map(function ($item) { + return $item['value']; + }, $executions)), + ], + 'failures' => [ + 'data' => $failures, + 'total' => \array_sum(\array_map(function ($item) { + return $item['value']; + }, $failures)), + ], + 'compute' => [ + 'data' => $compute, + 'total' => \array_sum(\array_map(function ($item) { + return $item['value']; + }, $compute)), + ], + ]); + } else { + $response->json([]); + } + }); + +App::put('/v1/functions/:functionId') + ->groups(['api', 'functions']) + ->desc('Update Function') + ->label('scope', 'functions.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'update') + ->label('sdk.description', '/docs/references/functions/update-function.md') + ->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('name', '', new Text(128), 'Function name. Max length: 128 chars.') + ->param('execute', [], new ArrayList(new Text(64)), 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') + ->param('vars', [], new Assoc(), 'Key-value JSON object.', true) + ->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') + ->inject('project') + ->action(function ($functionId, $name, $execute, $vars, $events, $schedule, $timeout, $response, $projectDB, $project) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Database\Document $project */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + $original = $function->getAttribute('schedule', ''); + $cron = (!empty($function->getAttribute('tag', null)) && !empty($schedule)) ? CronExpression::factory($schedule) : null; + $next = (!empty($function->getAttribute('tag', null)) && !empty($schedule)) ? $cron->getNextRunDate()->format('U') : null; + + $function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [ + '$permissions' => [ + 'execute' => $execute, + ], + 'dateUpdated' => time(), + 'name' => $name, + 'vars' => $vars, + 'events' => $events, + 'schedule' => $schedule, + 'scheduleNext' => $next, + 'timeout' => $timeout, + ])); + + if (false === $function) { + throw new Exception('Failed saving function to DB', 500); + } + + if ($next && $schedule !== $original) { + ResqueScheduler::enqueueAt($next, 'v1-functions', 'FunctionsV1', [ + 'projectId' => $project->getId(), + 'functionId' => $function->getId(), + 'executionId' => null, + 'trigger' => 'schedule', + ]); // Async task rescheduale + } + + $response->dynamic($function, Response::MODEL_FUNCTION); + }); + +App::patch('/v1/functions/:functionId/tag') + ->groups(['api', 'functions']) + ->desc('Update Function Tag') + ->label('scope', 'functions.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'updateTag') + ->label('sdk.description', '/docs/references/functions/update-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') + ->inject('project') + ->action(function ($functionId, $tag, $response, $projectDB, $project) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Database\Document $project */ + + $function = $projectDB->getDocument($functionId); + $tag = $projectDB->getDocument($tag); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + if (empty($tag->getId()) || Database::SYSTEM_COLLECTION_TAGS != $tag->getCollection()) { + throw new Exception('Tag not found', 404); + } + + $schedule = $function->getAttribute('schedule', ''); + $cron = (empty($function->getAttribute('tag')) && !empty($schedule)) ? CronExpression::factory($schedule) : null; + $next = (empty($function->getAttribute('tag')) && !empty($schedule)) ? $cron->getNextRunDate()->format('U') : null; + + $function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [ + 'tag' => $tag->getId(), + 'scheduleNext' => $next, + ])); + + if ($next) { // Init first schedule + ResqueScheduler::enqueueAt($next, 'v1-functions', 'FunctionsV1', [ + 'projectId' => $project->getId(), + 'functionId' => $function->getId(), + 'executionId' => null, + 'trigger' => 'schedule', + ]); // Async task rescheduale + } + + if (false === $function) { + throw new Exception('Failed saving function to DB', 500); + } + + $response->dynamic($function, Response::MODEL_FUNCTION); + }); + +App::delete('/v1/functions/:functionId') + ->groups(['api', 'functions']) + ->desc('Delete Function') + ->label('scope', 'functions.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'delete') + ->label('sdk.description', '/docs/references/functions/delete-function.md') + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Event\Event $deletes */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + if (!$projectDB->deleteDocument($function->getId())) { + throw new Exception('Failed to remove function from DB', 500); + } + + $deletes + ->setParam('type', DELETE_TYPE_DOCUMENT) + ->setParam('document', $function->getArrayCopy()) + ; + + $response->noContent(); + }); + +App::post('/v1/functions/:functionId/tags') + ->groups(['api', 'functions']) + ->desc('Create Tag') + ->label('scope', 'functions.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'createTag') + ->label('sdk.description', '/docs/references/functions/create-tag.md') + ->label('sdk.packaging', true) + ->label('sdk.request.type', 'multipart/form-data') + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TAG) + ->param('functionId', '', new UID(), 'Function unique ID.') + ->param('command', '', new Text('1028'), 'Code execution command.') + ->param('code', null, new File(), 'Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.', false) + ->inject('request') + ->inject('response') + ->inject('projectDB') + ->inject('usage') + ->action(function ($functionId, $command, $file, $request, $response, $projectDB, $usage) { + /** @var Utopia\Swoole\Request $request */ + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $usage */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + $file = $request->getFiles('code'); + $device = Storage::getDevice('functions'); + $fileExt = new FileExt([FileExt::TYPE_GZIP]); + $fileSize = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0)); + $upload = new Upload(); + + if (empty($file)) { + throw new Exception('No file sent', 400); + } + + // Make sure we handle a single file and multiple files the same way + $file['name'] = (\is_array($file['name']) && isset($file['name'][0])) ? $file['name'][0] : $file['name']; + $file['tmp_name'] = (\is_array($file['tmp_name']) && isset($file['tmp_name'][0])) ? $file['tmp_name'][0] : $file['tmp_name']; + $file['size'] = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size']; + + if (!$fileExt->isValid($file['name'])) { // Check if file type is allowed + throw new Exception('File type not allowed', 400); + } + + if (!$fileSize->isValid($file['size'])) { // Check if file size is exceeding allowed limit + throw new Exception('File size not allowed', 400); + } + + if (!$upload->isValid($file['tmp_name'])) { + throw new Exception('Invalid file', 403); + } + + // Save to storage + $size = $device->getFileSize($file['tmp_name']); + $path = $device->getPath(\uniqid().'.'.\pathinfo($file['name'], PATHINFO_EXTENSION)); + + if (!$device->upload($file['tmp_name'], $path)) { // TODO deprecate 'upload' and replace with 'move' + throw new Exception('Failed moving file', 500); + } + + $tag = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_TAGS, + '$permissions' => [ + 'read' => [], + 'write' => [], + ], + 'functionId' => $function->getId(), + 'dateCreated' => time(), + 'command' => $command, + 'path' => $path, + 'size' => $size, + ]); + + if (false === $tag) { + throw new Exception('Failed saving tag to DB', 500); + } + + $usage + ->setParam('storage', $tag->getAttribute('size', 0)) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($tag, Response::MODEL_TAG) + ; + }); + +App::get('/v1/functions/:functionId/tags') + ->groups(['api', 'functions']) + ->desc('List Tags') + ->label('scope', 'functions.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'listTags') + ->label('sdk.description', '/docs/references/functions/list-tags.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TAG_LIST) + ->param('functionId', '', new UID(), 'Function unique ID.') + ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) + ->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) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + $results = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderType' => $orderType, + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_TAGS, + 'functionId='.$function->getId(), + ], + ]); + + $response->dynamic(new Document([ + 'sum' => $projectDB->getSum(), + 'tags' => $results + ]), Response::MODEL_TAG_LIST); + }); + +App::get('/v1/functions/:functionId/tags/:tagId') + ->groups(['api', 'functions']) + ->desc('Get Tag') + ->label('scope', 'functions.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'getTag') + ->label('sdk.description', '/docs/references/functions/get-tag.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + $tag = $projectDB->getDocument($tagId); + + if ($tag->getAttribute('functionId') !== $function->getId()) { + throw new Exception('Tag not found', 404); + } + + if (empty($tag->getId()) || Database::SYSTEM_COLLECTION_TAGS != $tag->getCollection()) { + throw new Exception('Tag not found', 404); + } + + $response->dynamic($tag, Response::MODEL_TAG); + }); + +App::delete('/v1/functions/:functionId/tags/:tagId') + ->groups(['api', 'functions']) + ->desc('Delete Tag') + ->label('scope', 'functions.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'deleteTag') + ->label('sdk.description', '/docs/references/functions/delete-tag.md') + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $usage */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + $tag = $projectDB->getDocument($tagId); + + if ($tag->getAttribute('functionId') !== $function->getId()) { + throw new Exception('Tag not found', 404); + } + + if (empty($tag->getId()) || Database::SYSTEM_COLLECTION_TAGS != $tag->getCollection()) { + throw new Exception('Tag not found', 404); + } + + $device = Storage::getDevice('functions'); + + if ($device->delete($tag->getAttribute('path', ''))) { + if (!$projectDB->deleteDocument($tag->getId())) { + throw new Exception('Failed to remove tag from DB', 500); + } + } + + if($function->getAttribute('tag') === $tag->getId()) { // Reset function tag + $function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [ + 'tag' => '', + ])); + + if (false === $function) { + throw new Exception('Failed saving function to DB', 500); + } + } + + $usage + ->setParam('storage', $tag->getAttribute('size', 0) * -1) + ; + + $response->noContent(); + }); + +App::post('/v1/functions/:functionId/executions') + ->groups(['api', 'functions']) + ->desc('Create Execution') + ->label('scope', 'execution.write') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'createExecution') + ->label('sdk.description', '/docs/references/functions/create-execution.md') + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_EXECUTION) + ->label('abuse-limit', 60) + ->label('abuse-time', 60) + ->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 */ + /** @var Appwrite\Database\Database $projectDB */ + + Authorization::disable(); + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + $tag = $projectDB->getDocument($function->getAttribute('tag')); + + if ($tag->getAttribute('functionId') !== $function->getId()) { + throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404); + } + + if (empty($tag->getId()) || Database::SYSTEM_COLLECTION_TAGS != $tag->getCollection()) { + throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404); + } + + Authorization::reset(); + + $validator = new Authorization($function, 'execute'); + + if (!$validator->isValid($function->getPermissions())) { // Check if user has write access to execute function + throw new Exception($validator->getDescription(), 401); + } + + Authorization::disable(); + + $execution = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_EXECUTIONS, + '$permissions' => [ + 'read' => $function->getPermissions()['execute'] ?? [], + 'write' => [], + ], + 'dateCreated' => time(), + 'functionId' => $function->getId(), + 'trigger' => 'http', // http / schedule / event + 'status' => 'waiting', // waiting / processing / completed / failed + 'exitCode' => 0, + 'stdout' => '', + 'stderr' => '', + 'time' => 0, + ]); + + Authorization::reset(); + + if (false === $execution) { + throw new Exception('Failed saving execution to DB', 500); + } + + Resque::enqueue('v1-functions', 'FunctionsV1', [ + 'projectId' => $project->getId(), + 'functionId' => $function->getId(), + 'executionId' => $execution->getId(), + 'trigger' => 'http', + ]); + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($execution, Response::MODEL_EXECUTION) + ; + }); + +App::get('/v1/functions/:functionId/executions') + ->groups(['api', 'functions']) + ->desc('List Executions') + ->label('scope', 'execution.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'listExecutions') + ->label('sdk.description', '/docs/references/functions/list-executions.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_EXECUTION_LIST) + ->param('functionId', '', new UID(), 'Function unique ID.') + ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) + ->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) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + $results = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderType' => $orderType, + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_EXECUTIONS, + 'functionId='.$function->getId(), + ], + ]); + + $response->dynamic(new Document([ + 'sum' => $projectDB->getSum(), + 'executions' => $results + ]), Response::MODEL_EXECUTION_LIST); + }); + +App::get('/v1/functions/:functionId/executions/:executionId') + ->groups(['api', 'functions']) + ->desc('Get Execution') + ->label('scope', 'execution.read') + ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'functions') + ->label('sdk.method', 'getExecution') + ->label('sdk.description', '/docs/references/functions/get-execution.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $projectDB */ + + $function = $projectDB->getDocument($functionId); + + if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { + throw new Exception('Function not found', 404); + } + + $execution = $projectDB->getDocument($executionId); + + if ($execution->getAttribute('functionId') !== $function->getId()) { + throw new Exception('Execution not found', 404); + } + + if (empty($execution->getId()) || Database::SYSTEM_COLLECTION_EXECUTIONS != $execution->getCollection()) { + throw new Exception('Execution not found', 404); + } + + $response->dynamic($execution, Response::MODEL_EXECUTION); + }); diff --git a/app/controllers/api/graphql.php b/app/controllers/api/graphql.php index 0eecb23e15..cf72731c6a 100644 --- a/app/controllers/api/graphql.php +++ b/app/controllers/api/graphql.php @@ -1,6 +1,6 @@ post('/v1/graphql') +App::post('/v1/graphql') ->desc('GraphQL Endpoint') ->groups(['api', 'graphql']) ->label('scope', 'public') diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 76727563ae..696247f3da 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -1,13 +1,13 @@ get('/v1/health') +App::get('/v1/health') ->desc('Get HTTP') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -15,23 +15,25 @@ $utopia->get('/v1/health') ->label('sdk.namespace', 'health') ->label('sdk.method', 'get') ->label('sdk.description', '/docs/references/health/get.md') - ->action( - function () use ($response) { - $response->json(['status' => 'OK']); - } - ); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/health/version') + $response->json(['status' => 'OK']); + }); + +App::get('/v1/health/version') ->desc('Get Version') ->groups(['api', 'health']) ->label('scope', 'public') - ->action( - function () use ($response) { - $response->json(['version' => APP_VERSION_STABLE]); - } - ); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/health/db') + $response->json(['version' => APP_VERSION_STABLE]); + }); + +App::get('/v1/health/db') ->desc('Get DB') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -39,15 +41,18 @@ $utopia->get('/v1/health/db') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getDB') ->label('sdk.description', '/docs/references/health/get-db.md') - ->action( - function () use ($response, $register) { - $register->get('db'); /* @var $db PDO */ + ->inject('response') + ->inject('register') + ->action(function ($response, $register) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Utopia\Registry\Registry $register */ - $response->json(['status' => 'OK']); - } - ); + $register->get('db'); /* @var $db PDO */ -$utopia->get('/v1/health/cache') + $response->json(['status' => 'OK']); + }); + +App::get('/v1/health/cache') ->desc('Get Cache') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -55,15 +60,17 @@ $utopia->get('/v1/health/cache') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getCache') ->label('sdk.description', '/docs/references/health/get-cache.md') - ->action( - function () use ($response, $register) { - $register->get('cache'); /* @var $cache Predis\Client */ + ->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->json(['status' => 'OK']); + }); -$utopia->get('/v1/health/time') +App::get('/v1/health/time') ->desc('Get Time') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -71,47 +78,48 @@ $utopia->get('/v1/health/time') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getTime') ->label('sdk.description', '/docs/references/health/get-time.md') - ->action( - function () use ($response) { - /* - * Code from: @see https://www.beliefmedia.com.au/query-ntp-time-server - */ - $host = 'time.google.com'; // https://developers.google.com/time/ - $gap = 60; // Allow [X] seconds gap + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ - /* Create a socket and connect to NTP server */ - $sock = \socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + /* + * Code from: @see https://www.beliefmedia.com.au/query-ntp-time-server + */ + $host = 'time.google.com'; // https://developers.google.com/time/ + $gap = 60; // Allow [X] seconds gap - \socket_connect($sock, $host, 123); + /* Create a socket and connect to NTP server */ + $sock = \socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - /* Send request */ - $msg = "\010".\str_repeat("\0", 47); + \socket_connect($sock, $host, 123); - \socket_send($sock, $msg, \strlen($msg), 0); + /* Send request */ + $msg = "\010".\str_repeat("\0", 47); - /* Receive response and close socket */ - \socket_recv($sock, $recv, 48, MSG_WAITALL); - \socket_close($sock); + \socket_send($sock, $msg, \strlen($msg), 0); - /* Interpret response */ - $data = \unpack('N12', $recv); - $timestamp = \sprintf('%u', $data[9]); + /* Receive response and close socket */ + \socket_recv($sock, $recv, 48, MSG_WAITALL); + \socket_close($sock); - /* NTP is number of seconds since 0000 UT on 1 January 1900 - Unix time is seconds since 0000 UT on 1 January 1970 */ - $timestamp -= 2208988800; + /* Interpret response */ + $data = \unpack('N12', $recv); + $timestamp = \sprintf('%u', $data[9]); - $diff = ($timestamp - \time()); + /* NTP is number of seconds since 0000 UT on 1 January 1900 + Unix time is seconds since 0000 UT on 1 January 1970 */ + $timestamp -= 2208988800; - if ($diff > $gap || $diff < ($gap * -1)) { - throw new Exception('Server time gaps detected'); - } + $diff = ($timestamp - \time()); - $response->json(['remote' => $timestamp, 'local' => \time(), 'diff' => $diff]); + if ($diff > $gap || $diff < ($gap * -1)) { + throw new Exception('Server time gaps detected'); } - ); -$utopia->get('/v1/health/queue/webhooks') + $response->json(['remote' => $timestamp, 'local' => \time(), 'diff' => $diff]); + }); + +App::get('/v1/health/queue/webhooks') ->desc('Get Webhooks Queue') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -119,13 +127,14 @@ $utopia->get('/v1/health/queue/webhooks') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueWebhooks') ->label('sdk.description', '/docs/references/health/get-queue-webhooks.md') - ->action( - function () use ($response) { - $response->json(['size' => Resque::size('v1-webhooks')]); - } - ); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/health/queue/tasks') + $response->json(['size' => Resque::size(Event::WEBHOOK_QUEUE_NAME)]); + }, ['response']); + +App::get('/v1/health/queue/tasks') ->desc('Get Tasks Queue') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -133,13 +142,14 @@ $utopia->get('/v1/health/queue/tasks') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueTasks') ->label('sdk.description', '/docs/references/health/get-queue-tasks.md') - ->action( - function () use ($response) { - $response->json(['size' => Resque::size('v1-tasks')]); - } - ); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/health/queue/logs') + $response->json(['size' => Resque::size(Event::TASK_QUEUE_NAME)]); + }, ['response']); + +App::get('/v1/health/queue/logs') ->desc('Get Logs Queue') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -147,13 +157,14 @@ $utopia->get('/v1/health/queue/logs') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueLogs') ->label('sdk.description', '/docs/references/health/get-queue-logs.md') - ->action( - function () use ($response) { - $response->json(['size' => Resque::size('v1-audit')]); - } - ); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/health/queue/usage') + $response->json(['size' => Resque::size(Event::AUDITS_QUEUE_NAME)]); + }, ['response']); + +App::get('/v1/health/queue/usage') ->desc('Get Usage Queue') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -161,13 +172,14 @@ $utopia->get('/v1/health/queue/usage') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueUsage') ->label('sdk.description', '/docs/references/health/get-queue-usage.md') - ->action( - function () use ($response) { - $response->json(['size' => Resque::size('v1-usage')]); - } - ); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/health/queue/certificates') + $response->json(['size' => Resque::size(Event::USAGE_QUEUE_NAME)]); + }, ['response']); + +App::get('/v1/health/queue/certificates') ->desc('Get Certificate Queue') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -175,13 +187,14 @@ $utopia->get('/v1/health/queue/certificates') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueCertificates') ->label('sdk.description', '/docs/references/health/get-queue-certificates.md') - ->action( - function () use ($response) { - $response->json(['size' => Resque::size('v1-certificates')]); - } - ); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/health/queue/functions') + $response->json(['size' => Resque::size(Event::CERTIFICATES_QUEUE_NAME)]); + }, ['response']); + +App::get('/v1/health/queue/functions') ->desc('Get Functions Queue') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -189,13 +202,14 @@ $utopia->get('/v1/health/queue/functions') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getQueueFunctions') ->label('sdk.description', '/docs/references/health/get-queue-functions.md') - ->action( - function () use ($response) { - $response->json(['size' => Resque::size('v1-functions')]); - } - ); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/health/storage/local') + $response->json(['size' => Resque::size(Event::FUNCTIONS_QUEUE_NAME)]); + }, ['response']); + +App::get('/v1/health/storage/local') ->desc('Get Local Storage') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -203,30 +217,31 @@ $utopia->get('/v1/health/storage/local') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getStorageLocal') ->label('sdk.description', '/docs/references/health/get-storage-local.md') - ->action( - function () use ($response) { - foreach ([ - 'Uploads' => APP_STORAGE_UPLOADS, - 'Cache' => APP_STORAGE_CACHE, - 'Config' => APP_STORAGE_CONFIG, - 'Certs' => APP_STORAGE_CERTIFICATES - ] as $key => $volume) { - $device = new Local($volume); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ - if (!\is_readable($device->getRoot())) { - throw new Exception('Device '.$key.' dir is not readable'); - } + foreach ([ + 'Uploads' => APP_STORAGE_UPLOADS, + 'Cache' => APP_STORAGE_CACHE, + 'Config' => APP_STORAGE_CONFIG, + 'Certs' => APP_STORAGE_CERTIFICATES + ] as $key => $volume) { + $device = new Local($volume); - if (!\is_writable($device->getRoot())) { - throw new Exception('Device '.$key.' dir is not writable'); - } + if (!\is_readable($device->getRoot())) { + throw new Exception('Device '.$key.' dir is not readable'); } - $response->json(['status' => 'OK']); + if (!\is_writable($device->getRoot())) { + throw new Exception('Device '.$key.' dir is not writable'); + } } - ); -$utopia->get('/v1/health/anti-virus') + $response->json(['status' => 'OK']); + }); + +App::get('/v1/health/anti-virus') ->desc('Get Anti virus') ->groups(['api', 'health']) ->label('scope', 'health.read') @@ -234,22 +249,24 @@ $utopia->get('/v1/health/anti-virus') ->label('sdk.namespace', 'health') ->label('sdk.method', 'getAntiVirus') ->label('sdk.description', '/docs/references/health/get-storage-anti-virus.md') - ->action( - function () use ($request, $response) { - if ($request->getServer('_APP_STORAGE_ANTIVIRUS') === 'disabled') { // Check if scans are enabled - throw new Exception('Anitvirus is disabled'); - } + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ - $antiVirus = new Network('clamav', 3310); - - $response->json([ - 'status' => (@$antiVirus->ping()) ? 'online' : 'offline', - 'version' => @$antiVirus->version(), - ]); + if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'disabled') { // Check if scans are enabled + throw new Exception('Anitvirus is disabled'); } - ); -$utopia->get('/v1/health/stats') // Currently only used internally + $antiVirus = new Network(App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), + (int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)); + + $response->json([ + 'status' => (@$antiVirus->ping()) ? 'online' : 'offline', + 'version' => @$antiVirus->version(), + ]); + }); + +App::get('/v1/health/stats') // Currently only used internally ->desc('Get System Stats') ->groups(['api', 'health']) ->label('scope', 'god') @@ -257,34 +274,33 @@ $utopia->get('/v1/health/stats') // Currently only used internally // ->label('sdk.namespace', 'health') // ->label('sdk.method', 'getStats') ->label('docs', false) - ->action( - function () use ($response, $register) { - $device = Storage::getDevice('local'); - $cache = $register->get('cache'); + ->inject('response') + ->inject('register') + ->action(function ($response, $register) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Utopia\Registry\Registry $register */ - $cacheStats = $cache->info(); + $device = Storage::getDevice('files'); + $cache = $register->get('cache'); - $response - ->json([ - 'server' => [ - 'name' => 'nginx', - 'version' => \shell_exec('nginx -v 2>&1'), - ], - 'storage' => [ - 'used' => Storage::human($device->getDirectorySize($device->getRoot().'/')), - 'partitionTotal' => Storage::human($device->getPartitionTotalSpace()), - 'partitionFree' => Storage::human($device->getPartitionFreeSpace()), - ], - 'cache' => [ - 'uptime' => (isset($cacheStats['uptime_in_seconds'])) ? $cacheStats['uptime_in_seconds'] : 0, - 'clients' => (isset($cacheStats['connected_clients'])) ? $cacheStats['connected_clients'] : 0, - 'hits' => (isset($cacheStats['keyspace_hits'])) ? $cacheStats['keyspace_hits'] : 0, - 'misses' => (isset($cacheStats['keyspace_misses'])) ? $cacheStats['keyspace_misses'] : 0, - 'memory_used' => (isset($cacheStats['used_memory'])) ? $cacheStats['used_memory'] : 0, - 'memory_used_human' => (isset($cacheStats['used_memory_human'])) ? $cacheStats['used_memory_human'] : 0, - 'memory_used_peak' => (isset($cacheStats['used_memory_peak'])) ? $cacheStats['used_memory_peak'] : 0, - 'memory_used_peak_human' => (isset($cacheStats['used_memory_peak_human'])) ? $cacheStats['used_memory_peak_human'] : 0, - ], - ]); - } - ); + $cacheStats = $cache->info(); + + $response + ->json([ + 'storage' => [ + 'used' => Storage::human($device->getDirectorySize($device->getRoot().'/')), + 'partitionTotal' => Storage::human($device->getPartitionTotalSpace()), + 'partitionFree' => Storage::human($device->getPartitionFreeSpace()), + ], + 'cache' => [ + 'uptime' => $cacheStats['uptime_in_seconds'] ?? 0, + 'clients' => $cacheStats['connected_clients'] ?? 0, + 'hits' => $cacheStats['keyspace_hits'] ?? 0, + 'misses' => $cacheStats['keyspace_misses'] ?? 0, + 'memory_used' => $cacheStats['used_memory'] ?? 0, + 'memory_used_human' => $cacheStats['used_memory_human'] ?? 0, + 'memory_used_peak' => $cacheStats['used_memory_peak'] ?? 0, + 'memory_used_peak_human' => $cacheStats['used_memory_peak_human'] ?? 0, + ], + ]); + }); diff --git a/app/controllers/api/locale.php b/app/controllers/api/locale.php index 148ee3e8e9..80826bdc03 100644 --- a/app/controllers/api/locale.php +++ b/app/controllers/api/locale.php @@ -1,12 +1,11 @@ get('/v1/locale') +App::get('/v1/locale') ->desc('Get User Locale') ->groups(['api', 'locale']) ->label('scope', 'locale.read') @@ -14,58 +13,64 @@ $utopia->get('/v1/locale') ->label('sdk.namespace', 'locale') ->label('sdk.method', 'get') ->label('sdk.description', '/docs/references/locale/get-locale.md') - ->action( - function () use ($response, $request, $utopia) { - $eu = include __DIR__.'/../../config/eu.php'; - $currencies = include __DIR__.'/../../config/currencies.php'; - $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); - $output = []; - $ip = $request->getIP(); - $time = (60 * 60 * 24 * 45); // 45 days cache - $countries = Locale::getText('countries'); - $continents = Locale::getText('continents'); + ->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 */ + /** @var Utopia\Locale\Locale $locale */ + /** @var MaxMind\Db\Reader $geodb */ - if (App::MODE_TYPE_PRODUCTION !== $utopia->getMode()) { - $ip = '79.177.241.94'; - } + $eu = Config::getParam('locale-eu'); + $currencies = Config::getParam('locale-currencies'); + $output = []; + $ip = $request->getIP(); + $time = (60 * 60 * 24 * 45); // 45 days cache + $countries = $locale->getText('countries'); + $continents = $locale->getText('continents'); - $output['ip'] = $ip; + $output['ip'] = $ip; - $currency = null; + $currency = null; - try { - $record = $reader->country($ip); - $output['countryCode'] = $record->country->isoCode; - $output['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); - //$output['countryTimeZone'] = DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, $record->country->isoCode); - $output['continent'] = (isset($continents[$record->continent->code])) ? $continents[$record->continent->code] : Locale::getText('locale.country.unknown'); - $output['continentCode'] = $record->continent->code; - $output['eu'] = (\in_array($record->country->isoCode, $eu)) ? true : false; + $record = $geodb->get($ip); - foreach ($currencies as $code => $element) { - if (isset($element['locations']) && isset($element['code']) && \in_array($record->country->isoCode, $element['locations'])) { - $currency = $element['code']; - } + if ($record) { + $output['countryCode'] = $record['country']['iso_code']; + $output['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); + $output['continent'] = (isset($continents[$record['continent']['code']])) ? $continents[$record['continent']['code']] : $locale->getText('locale.country.unknown'); + $output['continentCode'] = $record['continent']['code']; + $output['eu'] = (\in_array($record['country']['iso_code'], $eu)) ? true : false; + + foreach ($currencies as $code => $element) { + if (isset($element['locations']) && isset($element['code']) && \in_array($record['country']['iso_code'], $element['locations'])) { + $currency = $element['code']; } - - $output['currency'] = $currency; - } catch (\Exception $e) { - $output['countryCode'] = '--'; - $output['country'] = Locale::getText('locale.country.unknown'); - $output['continent'] = Locale::getText('locale.country.unknown'); - $output['continentCode'] = '--'; - $output['eu'] = false; - $output['currency'] = $currency; } - $response - ->addHeader('Cache-Control', 'public, max-age='.$time) - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache - ->json($output); + $output['currency'] = $currency; + } else { + $output['countryCode'] = '--'; + $output['country'] = $locale->getText('locale.country.unknown'); + $output['continent'] = $locale->getText('locale.country.unknown'); + $output['continentCode'] = '--'; + $output['eu'] = false; + $output['currency'] = $currency; } - ); -$utopia->get('/v1/locale/countries') + $response + ->addHeader('Cache-Control', 'public, max-age='.$time) + ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache + ; + $response->dynamic(new Document($output), Response::MODEL_LOCALE); + }); + +App::get('/v1/locale/countries') ->desc('List Countries') ->groups(['api', 'locale']) ->label('scope', 'locale.read') @@ -73,17 +78,31 @@ $utopia->get('/v1/locale/countries') ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getCountries') ->label('sdk.description', '/docs/references/locale/get-countries.md') - ->action( - function () use ($response) { - $list = Locale::getText('countries'); /* @var $list array */ + ->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 */ - \asort($list); + $list = $locale->getText('countries'); /* @var $list array */ + $output = []; - $response->json($list); + \asort($list); // sort by abc per locale + + foreach ($list as $key => $value) { + $output[] = new Document([ + 'name' => $value, + 'code' => $key, + ]); } - ); -$utopia->get('/v1/locale/countries/eu') + $response->dynamic(new Document(['countries' => $output, 'sum' => \count($output)]), Response::MODEL_COUNTRY_LIST); + }); + +App::get('/v1/locale/countries/eu') ->desc('List EU Countries') ->groups(['api', 'locale']) ->label('scope', 'locale.read') @@ -91,25 +110,34 @@ $utopia->get('/v1/locale/countries/eu') ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getCountriesEU') ->label('sdk.description', '/docs/references/locale/get-countries-eu.md') - ->action( - function () use ($response) { - $countries = Locale::getText('countries'); /* @var $countries array */ - $eu = include __DIR__.'/../../config/eu.php'; - $list = []; + ->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 */ - foreach ($eu as $code) { - if (\array_key_exists($code, $countries)) { - $list[$code] = $countries[$code]; - } + $list = $locale->getText('countries'); /* @var $countries array */ + $eu = Config::getParam('locale-eu'); + $output = []; + + \asort($list); + + foreach ($eu as $code) { + if (\array_key_exists($code, $list)) { + $output[] = new Document([ + 'name' => $list[$code], + 'code' => $code, + ]); } - - \asort($list); - - $response->json($list); } - ); -$utopia->get('/v1/locale/countries/phones') + $response->dynamic(new Document(['countries' => $output, 'sum' => \count($output)]), Response::MODEL_COUNTRY_LIST); + }); + +App::get('/v1/locale/countries/phones') ->desc('List Countries Phone Codes') ->groups(['api', 'locale']) ->label('scope', 'locale.read') @@ -117,25 +145,35 @@ $utopia->get('/v1/locale/countries/phones') ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getCountriesPhones') ->label('sdk.description', '/docs/references/locale/get-countries-phones.md') - ->action( - function () use ($response) { - $list = include __DIR__.'/../../config/phones.php'; /* @var $list array */ + ->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 */ - $countries = Locale::getText('countries'); /* @var $countries array */ + $list = Config::getParam('locale-phones'); /* @var $list array */ + $countries = $locale->getText('countries'); /* @var $countries array */ + $output = []; + + \asort($list); - foreach ($list as $code => $name) { - if (\array_key_exists($code, $countries)) { - $list[$code] = '+'.$list[$code]; - } + foreach ($list as $code => $name) { + if (\array_key_exists($code, $countries)) { + $output[] = new Document([ + 'code' => '+'.$list[$code], + 'countryCode' => $code, + 'countryName' => $countries[$code], + ]); } - - \asort($list); - - $response->json($list); } - ); -$utopia->get('/v1/locale/continents') + $response->dynamic(new Document(['phones' => $output, 'sum' => \count($output)]), Response::MODEL_PHONE_LIST); + }); + +App::get('/v1/locale/continents') ->desc('List Continents') ->groups(['api', 'locale']) ->label('scope', 'locale.read') @@ -143,18 +181,30 @@ $utopia->get('/v1/locale/continents') ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getContinents') ->label('sdk.description', '/docs/references/locale/get-continents.md') - ->action( - function () use ($response) { - $list = Locale::getText('continents'); /* @var $list array */ + ->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 */ - \asort($list); + $list = $locale->getText('continents'); /* @var $list array */ - $response->json($list); + \asort($list); + + foreach ($list as $key => $value) { + $output[] = new Document([ + 'name' => $value, + 'code' => $key, + ]); } - ); + $response->dynamic(new Document(['continents' => $output, 'sum' => \count($output)]), Response::MODEL_CONTINENT_LIST); + }); -$utopia->get('/v1/locale/currencies') +App::get('/v1/locale/currencies') ->desc('List Currencies') ->groups(['api', 'locale']) ->label('scope', 'locale.read') @@ -162,16 +212,24 @@ $utopia->get('/v1/locale/currencies') ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getCurrencies') ->label('sdk.description', '/docs/references/locale/get-currencies.md') - ->action( - function () use ($response) { - $currencies = include __DIR__.'/../../config/currencies.php'; + ->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 */ - $response->json($currencies); - } - ); + $list = Config::getParam('locale-currencies'); + + $list = array_map(function($node) { + return new Document($node); + }, $list); + + $response->dynamic(new Document(['currencies' => $list, 'sum' => \count($list)]), Response::MODEL_CURRENCY_LIST); + }); -$utopia->get('/v1/locale/languages') +App::get('/v1/locale/languages') ->desc('List Languages') ->groups(['api', 'locale']) ->label('scope', 'locale.read') @@ -179,10 +237,18 @@ $utopia->get('/v1/locale/languages') ->label('sdk.namespace', 'locale') ->label('sdk.method', 'getLanguages') ->label('sdk.description', '/docs/references/locale/get-languages.md') - ->action( - function () use ($response) { - $languages = include __DIR__.'/../../config/languages.php'; + ->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 */ - $response->json($languages); - } - ); \ No newline at end of file + $list = Config::getParam('locale-languages'); + + $list = array_map(function($node) { + return new Document($node); + }, $list); + + $response->dynamic(new Document(['languages' => $list, 'sum' => \count($list)]), Response::MODEL_LANGUAGE_LIST); + }); \ No newline at end of file diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index cf81df66ba..ed0d3a4435 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -1,14 +1,13 @@ post('/v1/projects') +App::post('/v1/projects') ->desc('Create Project') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'create') - ->param('name', null, function () { return new Text(100); }, 'Project name.') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('description', '', function () { return new Text(255); }, 'Project description.', true) - ->param('logo', '', function () { return new Text(1024); }, 'Project logo.', true) - ->param('url', '', function () { return new URL(); }, 'Project URL.', true) - ->param('legalName', '', function () { return new Text(256); }, 'Project legal Name.', true) - ->param('legalCountry', '', function () { return new Text(256); }, 'Project legal Country.', true) - ->param('legalState', '', function () { return new Text(256); }, 'Project legal State.', true) - ->param('legalCity', '', function () { return new Text(256); }, 'Project legal City.', true) - ->param('legalAddress', '', function () { return new Text(256); }, 'Project legal Address.', true) - ->param('legalTaxId', '', function () { return new Text(256); }, 'Project legal Tax ID.', true) - ->action( - function ($name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId) use ($response, $user, $consoleDB, $projectDB) { - $team = $projectDB->getDocument($teamId); + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_PROJECT) + ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') + ->param('teamId', '', new UID(), 'Team unique ID.') + ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) + ->param('logo', '', new Text(1024), 'Project logo.', true) + ->param('url', '', new URL(), 'Project URL.', true) + ->param('legalName', '', new Text(256), 'Project legal Name. Max length: 256 chars.', true) + ->param('legalCountry', '', new Text(256), 'Project legal Country. Max length: 256 chars.', true) + ->param('legalState', '', new Text(256), 'Project legal State. Max length: 256 chars.', true) + ->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 */ + /** @var Appwrite\Database\Database $projectDB */ - if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } + $team = $projectDB->getDocument($teamId); - $project = $consoleDB->createDocument( - [ - '$collection' => Database::SYSTEM_COLLECTION_PROJECTS, - '$permissions' => [ - 'read' => ['team:'.$teamId], - 'write' => ['team:'.$teamId.'/owner', 'team:'.$teamId.'/developer'], - ], - 'name' => $name, - 'description' => $description, - 'logo' => $logo, - 'url' => $url, - 'legalName' => $legalName, - 'legalCountry' => $legalCountry, - 'legalState' => $legalState, - 'legalCity' => $legalCity, - 'legalAddress' => $legalAddress, - 'legalTaxId' => $legalTaxId, - 'teamId' => $team->getId(), - 'platforms' => [], - 'webhooks' => [], - 'keys' => [], - 'tasks' => [], - ] - ); - - if (false === $project) { - throw new Exception('Failed saving project to DB', 500); - } - - $consoleDB->createNamespace($project->getId()); - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($project->getArrayCopy()) - ; + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + throw new Exception('Team not found', 404); } - ); -$utopia->get('/v1/projects') - ->desc('List Projects') - ->groups(['api', 'projects']) - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'list') - ->action( - function () use ($request, $response, $consoleDB) { - $results = $consoleDB->getCollection([ - 'limit' => 20, - 'offset' => 0, - 'orderField' => 'name', - 'orderType' => 'ASC', - 'orderCast' => 'string', - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_PROJECTS, + $project = $consoleDB->createDocument( + [ + '$collection' => Database::SYSTEM_COLLECTION_PROJECTS, + '$permissions' => [ + 'read' => ['team:'.$teamId], + 'write' => ['team:'.$teamId.'/owner', 'team:'.$teamId.'/developer'], ], - ]); - - foreach ($results as $project) { - foreach (Config::getParam('providers') as $provider => $node) { - $secret = \json_decode($project->getAttribute('usersOauth2'.\ucfirst($provider).'Secret', '{}'), true); - - if (!empty($secret) && isset($secret['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$secret['version']); - $project->setAttribute('usersOauth2'.\ucfirst($provider).'Secret', OpenSSL::decrypt($secret['data'], $secret['method'], $key, 0, \hex2bin($secret['iv']), \hex2bin($secret['tag']))); - } - } - } - - $response->json($results); - } - ); - -$utopia->get('/v1/projects/:projectId') - ->desc('Get Project') - ->groups(['api', 'projects']) - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'get') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - foreach (Config::getParam('providers') as $provider => $node) { - $secret = \json_decode($project->getAttribute('usersOauth2'.\ucfirst($provider).'Secret', '{}'), true); - - if (!empty($secret) && isset($secret['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$secret['version']); - $project->setAttribute('usersOauth2'.\ucfirst($provider).'Secret', OpenSSL::decrypt($secret['data'], $secret['method'], $key, 0, \hex2bin($secret['iv']), \hex2bin($secret['tag']))); - } - } - - $response->json($project->getArrayCopy()); - } - ); - -$utopia->get('/v1/projects/:projectId/usage') - ->desc('Get Project') - ->groups(['api', 'projects']) - ->label('scope', 'projects.read') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'getUsage') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->param('range', 'last30', function () { return new WhiteList(['daily', 'monthly', 'last30', 'last90']); }, 'Date range.', true) - ->action( - function ($projectId, $range) use ($response, $consoleDB, $projectDB, $register) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $period = [ - 'daily' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('today')), - 'end' => DateTime::createFromFormat('U', \strtotime('tomorrow')), - 'group' => '1m', - ], - 'monthly' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('midnight first day of this month')), - 'end' => DateTime::createFromFormat('U', \strtotime('midnight last day of this month')), - 'group' => '1d', - ], - 'last30' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-30 days')), - 'end' => DateTime::createFromFormat('U', \strtotime('tomorrow')), - 'group' => '1d', - ], - 'last90' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-90 days')), - 'end' => DateTime::createFromFormat('U', \strtotime('today')), - 'group' => '1d', - ], - // 'yearly' => [ - // 'start' => DateTime::createFromFormat('U', strtotime('midnight first day of january')), - // 'end' => DateTime::createFromFormat('U', strtotime('midnight last day of december')), - // 'group' => '4w', - // ], - ]; - - $client = $register->get('influxdb'); - - $requests = []; - $network = []; - - if ($client) { - $start = $period[$range]['start']->format(DateTime::RFC3339); - $end = $period[$range]['end']->format(DateTime::RFC3339); - $database = $client->selectDB('telegraf'); - - // Requests - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); - $points = $result->getPoints(); - - foreach ($points as $point) { - $requests[] = [ - 'value' => (!empty($point['value'])) ? $point['value'] : 0, - 'date' => \strtotime($point['time']), - ]; - } - - // Network - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); - $points = $result->getPoints(); - - foreach ($points as $point) { - $network[] = [ - 'value' => (!empty($point['value'])) ? $point['value'] : 0, - 'date' => \strtotime($point['time']), - ]; - } - } - - // Users - - $projectDB->getCollection([ - 'limit' => 0, - 'offset' => 0, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - ], - ]); - - $usersTotal = $projectDB->getSum(); - - // Documents - - $collections = $projectDB->getCollection([ - 'limit' => 100, - 'offset' => 0, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_COLLECTIONS, - ], - ]); - - $collectionsTotal = $projectDB->getSum(); - - $documents = []; - - foreach ($collections as $collection) { - $result = $projectDB->getCollection([ - 'limit' => 0, - 'offset' => 0, - 'filters' => [ - '$collection='.$collection['$id'], - ], - ]); - - $documents[] = ['name' => $collection['name'], 'total' => $projectDB->getSum()]; - } - - // Tasks - $tasksTotal = \count($project->getAttribute('tasks', [])); - - $response->json([ - 'requests' => [ - 'data' => $requests, - 'total' => \array_sum(\array_map(function ($item) { - return $item['value']; - }, $requests)), - ], - 'network' => [ - 'data' => $network, - 'total' => \array_sum(\array_map(function ($item) { - return $item['value']; - }, $network)), - ], - 'collections' => [ - 'data' => $collections, - 'total' => $collectionsTotal, - ], - 'documents' => [ - 'data' => $documents, - 'total' => \array_sum(\array_map(function ($item) { - return $item['total']; - }, $documents)), - ], - 'users' => [ - 'data' => [], - 'total' => $usersTotal, - ], - 'tasks' => [ - 'data' => [], - 'total' => $tasksTotal, - ], - 'storage' => [ - 'total' => $projectDB->getCount( - [ - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_FILES, - ], - ] - ), - ], - ]); - } - ); - -$utopia->patch('/v1/projects/:projectId') - ->desc('Update Project') - ->groups(['api', 'projects']) - ->label('scope', 'projects.write') - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'update') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->param('name', null, function () { return new Text(100); }, 'Project name.') - ->param('description', '', function () { return new Text(255); }, 'Project description.', true) - ->param('logo', '', function () { return new Text(1024); }, 'Project logo.', true) - ->param('url', '', function () { return new URL(); }, 'Project URL.', true) - ->param('legalName', '', function () { return new Text(256); }, 'Project legal name.', true) - ->param('legalCountry', '', function () { return new Text(256); }, 'Project legal country..', true) - ->param('legalState', '', function () { return new Text(256); }, 'Project legal state.', true) - ->param('legalCity', '', function () { return new Text(256); }, 'Project legal city.', true) - ->param('legalAddress', '', function () { return new Text(256); }, 'Project legal address.', true) - ->param('legalTaxId', '', function () { return new Text(256); }, 'Project legal tax ID.', true) - ->action( - function ($projectId, $name, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); - - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $project = $consoleDB->updateDocument(\array_merge($project->getArrayCopy(), [ 'name' => $name, 'description' => $description, 'logo' => $logo, @@ -346,1107 +71,1533 @@ $utopia->patch('/v1/projects/:projectId') 'legalCity' => $legalCity, 'legalAddress' => $legalAddress, 'legalTaxId' => $legalTaxId, - ])); + 'teamId' => $team->getId(), + 'platforms' => [], + 'webhooks' => [], + 'keys' => [], + 'tasks' => [], + 'domains' => [], + ] + ); - if (false === $project) { - throw new Exception('Failed saving project to DB', 500); - } - - $response->json($project->getArrayCopy()); + if (false === $project) { + throw new Exception('Failed saving project to DB', 500); } - ); -$utopia->patch('/v1/projects/:projectId/oauth2') + $consoleDB->createNamespace($project->getId()); + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($project, Response::MODEL_PROJECT) + ; + }); + +App::get('/v1/projects') + ->desc('List Projects') + ->groups(['api', 'projects']) + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'list') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_PROJECT_LIST) + ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) + ->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 */ + + $results = $consoleDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderType' => $orderType, + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_PROJECTS, + ], + ]); + + $response->dynamic(new Document([ + 'sum' => $consoleDB->getSum(), + 'projects' => $results + ]), Response::MODEL_PROJECT_LIST); + }); + +App::get('/v1/projects/:projectId') + ->desc('Get Project') + ->groups(['api', 'projects']) + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'get') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ + + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $response->dynamic($project, Response::MODEL_PROJECT); + }); + +App::get('/v1/projects/:projectId/usage') + ->desc('Get Project') + ->groups(['api', 'projects']) + ->label('scope', 'projects.read') + ->label('sdk.namespace', 'projects') + ->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 */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Utopia\Registry\Registry $register */ + + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + if(App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { + + $period = [ + '24h' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-24 hours')), + 'end' => DateTime::createFromFormat('U', \strtotime('+1 hour')), + 'group' => '30m', + ], + '7d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-7 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + '30d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-30 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + '90d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-90 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + ]; + + $client = $register->get('influxdb'); + + $requests = []; + $network = []; + $functions = []; + + if ($client) { + $start = $period[$range]['start']->format(DateTime::RFC3339); + $end = $period[$range]['end']->format(DateTime::RFC3339); + $database = $client->selectDB('telegraf'); + + // Requests + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $requests[] = [ + 'value' => (!empty($point['value'])) ? $point['value'] : 0, + 'date' => \strtotime($point['time']), + ]; + } + + // Network + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $network[] = [ + 'value' => (!empty($point['value'])) ? $point['value'] : 0, + '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']), + ]; + } + } + } else { + $requests = []; + $network = []; + $functions = []; + } + + + // Users + + $projectDB->getCollection([ + 'limit' => 0, + 'offset' => 0, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + ], + ]); + + $usersTotal = $projectDB->getSum(); + + // Documents + + $collections = $projectDB->getCollection([ + 'limit' => 100, + 'offset' => 0, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_COLLECTIONS, + ], + ]); + + $collectionsTotal = $projectDB->getSum(); + + $documents = []; + + foreach ($collections as $collection) { + $result = $projectDB->getCollection([ + 'limit' => 0, + 'offset' => 0, + 'filters' => [ + '$collection='.$collection['$id'], + ], + ]); + + $documents[] = ['name' => $collection['name'], 'total' => $projectDB->getSum()]; + } + + // Tasks + $tasksTotal = \count($project->getAttribute('tasks', [])); + + $response->json([ + 'range' => $range, + 'requests' => [ + 'data' => $requests, + 'total' => \array_sum(\array_map(function ($item) { + return $item['value']; + }, $requests)), + ], + 'network' => [ + 'data' => \array_map(function ($value) {return ['value' => \round($value['value'] / 1000000, 2), 'date' => $value['date']];}, $network), // convert bytes to mb + 'total' => \array_sum(\array_map(function ($item) { + return $item['value']; + }, $network)), + ], + 'functions' => [ + 'data' => $functions, + 'total' => \array_sum(\array_map(function ($item) { + return $item['value']; + }, $functions)), + ], + 'collections' => [ + 'data' => $collections, + 'total' => $collectionsTotal, + ], + 'documents' => [ + 'data' => $documents, + 'total' => \array_sum(\array_map(function ($item) { + return $item['total']; + }, $documents)), + ], + 'users' => [ + 'data' => [], + 'total' => $usersTotal, + ], + 'tasks' => [ + 'data' => [], + 'total' => $tasksTotal, + ], + 'storage' => [ + 'total' => $projectDB->getCount( + [ + 'attribute' => 'sizeOriginal', + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_FILES, + ], + ] + ) + + $projectDB->getCount( + [ + 'attribute' => 'size', + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_TAGS, + ], + ] + ), + ], + ]); + }); + +App::patch('/v1/projects/:projectId') + ->desc('Update Project') + ->groups(['api', 'projects']) + ->label('scope', 'projects.write') + ->label('sdk.namespace', 'projects') + ->label('sdk.method', 'update') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_PROJECT) + ->param('projectId', '', new UID(), 'Project unique ID.') + ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') + ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) + ->param('logo', '', new Text(1024), 'Project logo.', true) + ->param('url', '', new URL(), 'Project URL.', true) + ->param('legalName', '', new Text(256), 'Project legal name. Max length: 256 chars.', true) + ->param('legalCountry', '', new Text(256), 'Project legal country. Max length: 256 chars.', true) + ->param('legalState', '', new Text(256), 'Project legal state. Max length: 256 chars.', true) + ->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 */ + + $project = $consoleDB->getDocument($projectId); + + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } + + $project = $consoleDB->updateDocument(\array_merge($project->getArrayCopy(), [ + 'name' => $name, + 'description' => $description, + 'logo' => $logo, + 'url' => $url, + 'legalName' => $legalName, + 'legalCountry' => $legalCountry, + 'legalState' => $legalState, + 'legalCity' => $legalCity, + 'legalAddress' => $legalAddress, + 'legalTaxId' => $legalTaxId, + ])); + + if (false === $project) { + throw new Exception('Failed saving project to DB', 500); + } + + $response->dynamic($project, Response::MODEL_PROJECT); + }); + +App::patch('/v1/projects/:projectId/oauth2') ->desc('Update Project OAuth2') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'updateOAuth2') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->param('provider', '', function () { return new WhiteList(\array_keys(Config::getParam('providers'))); }, 'Provider Name', false) - ->param('appId', '', function () { return new Text(256); }, 'Provider app ID.', true) - ->param('secret', '', function () { return new text(512); }, 'Provider secret key.', true) - ->action( - function ($projectId, $provider, $appId, $secret) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_PROJECT) + ->param('projectId', '', new UID(), 'Project unique ID.') + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $key = $request->getServer('_APP_OPENSSL_KEY_V1'); - $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); - $tag = null; - $secret = \json_encode([ - 'data' => OpenSSL::encrypt($secret, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), - 'method' => OpenSSL::CIPHER_AES_128_GCM, - 'iv' => \bin2hex($iv), - 'tag' => \bin2hex($tag), - 'version' => '1', - ]); - - $project = $consoleDB->updateDocument(\array_merge($project->getArrayCopy(), [ - 'usersOauth2'.\ucfirst($provider).'Appid' => $appId, - 'usersOauth2'.\ucfirst($provider).'Secret' => $secret, - ])); - - if (false === $project) { - throw new Exception('Failed saving project to DB', 500); - } - - $response->json($project->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->delete('/v1/projects/:projectId') + $project = $consoleDB->updateDocument(\array_merge($project->getArrayCopy(), [ + 'usersOauth2'.\ucfirst($provider).'Appid' => $appId, + 'usersOauth2'.\ucfirst($provider).'Secret' => $secret, + ])); + + if (false === $project) { + throw new Exception('Failed saving project to DB', 500); + } + + $response->dynamic($project, Response::MODEL_PROJECT); + }); + +App::delete('/v1/projects/:projectId') ->desc('Delete Project') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'delete') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->param('password', '', function () { return new UID(); }, 'Your user password for confirmation. Must be between 6 to 32 chars.') - ->action( - function ($projectId, $password) use ($response, $consoleDB, $user, $deletes) { - if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password - throw new Exception('Invalid credentials', 401); - } + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Database\Database $consoleDB */ + /** @var Appwrite\Event\Event $deletes */ - $project = $consoleDB->getDocument($projectId); + if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password + throw new Exception('Invalid credentials', 401); + } - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $deletes->setParam('document', $project->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); + } - foreach (['keys', 'webhooks', 'tasks', 'platforms', 'domains'] as $key) { // Delete all children (keys, webhooks, tasks [stop tasks?], platforms) - $list = $project->getAttribute('webhooks', []); + $deletes + ->setParam('type', DELETE_TYPE_DOCUMENT) + ->setParam('document', $project->getArrayCopy()) + ; - foreach ($list as $document) { /* @var $document Document */ - if (!$consoleDB->deleteDocument($projectId)) { - throw new Exception('Failed to remove project document ('.$key.')] from DB', 500); + foreach (['keys', 'webhooks', 'tasks', 'platforms', 'domains'] as $key) { // Delete all children (keys, webhooks, tasks [stop tasks?], platforms) + $list = $project->getAttribute($key, []); + foreach ($list as $document) { + /** @var Document $document */ + if ($consoleDB->deleteDocument($document->getId())) { + if ($document->getCollection() == Database::SYSTEM_COLLECTION_DOMAINS) { + $deletes + ->setParam('type', DELETE_TYPE_CERTIFICATES) + ->setParam('document', $document) + ; } + } else { + throw new Exception('Failed to remove project document ('.$key.')] from DB', 500); } } - - if (!$consoleDB->deleteDocument($project->getAttribute('teamId', null))) { - throw new Exception('Failed to remove project team from DB', 500); - } - - if (!$consoleDB->deleteDocument($projectId)) { - throw new Exception('Failed to remove project from DB', 500); - } - - $response->noContent(); } - ); + + if (!$consoleDB->deleteDocument($project->getAttribute('teamId', null))) { + throw new Exception('Failed to remove project team from DB', 500); + } + + if (!$consoleDB->deleteDocument($projectId)) { + throw new Exception('Failed to remove project from DB', 500); + } + + $response->noContent(); + }); // Webhooks -$utopia->post('/v1/projects/:projectId/webhooks') +App::post('/v1/projects/:projectId/webhooks') ->desc('Create Webhook') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createWebhook') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Webhook name.') - ->param('events', null, function () { return new ArrayList(new Text(256)); }, 'Webhook events list.') - ->param('url', null, function () { return new Text(2000); }, 'Webhook URL.') - ->param('security', false, function () { return new Boolean(true); }, 'Certificate verification, false for disabled or true for enabled.') - ->param('httpUser', '', function () { return new Text(256); }, 'Webhook HTTP user.', true) - ->param('httpPass', '', function () { return new Text(256); }, 'Webhook HTTP password.', true) - ->action( - function ($projectId, $name, $events, $url, $security, $httpUser, $httpPass) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_WEBHOOK) + ->param('projectId', null, new UID(), 'Project unique ID.') + ->param('name', null, new Text(128), 'Webhook name. Max length: 128 chars.') + ->param('events', null, new ArrayList(new WhiteList(array_keys(Config::getParam('events'), true), true)), 'Events list.') + ->param('url', null, new URL(), 'Webhook URL.') + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $security = ($security === '1' || $security === 'true' || $security === 1 || $security === true); - $key = $request->getServer('_APP_OPENSSL_KEY_V1'); - $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); - $tag = null; - $httpPass = \json_encode([ - 'data' => OpenSSL::encrypt($httpPass, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), - 'method' => OpenSSL::CIPHER_AES_128_GCM, - 'iv' => \bin2hex($iv), - 'tag' => \bin2hex($tag), - 'version' => '1', - ]); - - $webhook = $consoleDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_WEBHOOKS, - '$permissions' => [ - 'read' => ['team:'.$project->getAttribute('teamId', null)], - 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], - ], - 'name' => $name, - 'events' => $events, - 'url' => $url, - 'security' => (int) $security, - 'httpUser' => $httpUser, - 'httpPass' => $httpPass, - ]); - - if (false === $webhook) { - throw new Exception('Failed saving webhook to DB', 500); - } - - $project->setAttribute('webhooks', $webhook, Document::SET_TYPE_APPEND); - - $project = $consoleDB->updateDocument($project->getArrayCopy()); - - if (false === $project) { - throw new Exception('Failed saving project to DB', 500); - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($webhook->getArrayCopy()) - ; + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->get('/v1/projects/:projectId/webhooks') + $security = ($security === '1' || $security === 'true' || $security === 1 || $security === true); + + $webhook = $consoleDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_WEBHOOKS, + '$permissions' => [ + 'read' => ['team:'.$project->getAttribute('teamId', null)], + 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], + ], + 'name' => $name, + 'events' => $events, + 'url' => $url, + 'security' => $security, + 'httpUser' => $httpUser, + 'httpPass' => $httpPass, + ]); + + if (false === $webhook) { + throw new Exception('Failed saving webhook to DB', 500); + } + + $project->setAttribute('webhooks', $webhook, Document::SET_TYPE_APPEND); + + $project = $consoleDB->updateDocument($project->getArrayCopy()); + + if (false === $project) { + throw new Exception('Failed saving project to DB', 500); + } + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($webhook, Response::MODEL_WEBHOOK) + ; + }); + +App::get('/v1/projects/:projectId/webhooks') ->desc('List Webhooks') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'listWebhooks') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $webhooks = $project->getAttribute('webhooks', []); - - foreach ($webhooks as $webhook) { /* @var $webhook Document */ - $httpPass = \json_decode($webhook->getAttribute('httpPass', '{}'), true); - - if (empty($httpPass) || !isset($httpPass['version'])) { - continue; - } - - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); - - $webhook->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, \hex2bin($httpPass['iv']), \hex2bin($httpPass['tag']))); - } - - $response->json($webhooks); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->get('/v1/projects/:projectId/webhooks/:webhookId') + $webhooks = $project->getAttribute('webhooks', []); + + $response->dynamic(new Document([ + 'sum' => count($webhooks), + 'webhooks' => $webhooks + ]), Response::MODEL_WEBHOOK_LIST); + }); + +App::get('/v1/projects/:projectId/webhooks/:webhookId') ->desc('Get Webhook') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'getWebhook') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('webhookId', null, function () { return new UID(); }, 'Webhook unique ID.') - ->action( - function ($projectId, $webhookId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', [])); - - if (empty($webhook) || !$webhook instanceof Document) { - throw new Exception('Webhook not found', 404); - } - - $httpPass = \json_decode($webhook->getAttribute('httpPass', '{}'), true); - - if (!empty($httpPass) && isset($httpPass['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); - $webhook->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, \hex2bin($httpPass['iv']), \hex2bin($httpPass['tag']))); - } - - $response->json($webhook->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); + $webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', [])); -$utopia->put('/v1/projects/:projectId/webhooks/:webhookId') + if (empty($webhook) || !$webhook instanceof Document) { + throw new Exception('Webhook not found', 404); + } + + $response->dynamic($webhook, Response::MODEL_WEBHOOK); + }); + +App::put('/v1/projects/:projectId/webhooks/:webhookId') ->desc('Update Webhook') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'updateWebhook') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('webhookId', null, function () { return new UID(); }, 'Webhook unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Webhook name.') - ->param('events', null, function () { return new ArrayList(new Text(256)); }, 'Webhook events list.') - ->param('url', null, function () { return new Text(2000); }, 'Webhook URL.') - ->param('security', false, function () { return new Boolean(true); }, 'Certificate verification, false for disabled or true for enabled.') ->param('httpUser', '', function () { return new Text(256); }, 'Webhook HTTP user.', true) - ->param('httpPass', '', function () { return new Text(256); }, 'Webhook HTTP password.', true) - ->action( - function ($projectId, $webhookId, $name, $events, $url, $security, $httpUser, $httpPass) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_WEBHOOK) + ->param('projectId', null, new UID(), 'Project unique ID.') + ->param('webhookId', null, new UID(), 'Webhook unique ID.') + ->param('name', null, new Text(128), 'Webhook name. Max length: 128 chars.') + ->param('events', null, new ArrayList(new WhiteList(array_keys(Config::getParam('events'), true), true)), 'Events list.') + ->param('url', null, new URL(), 'Webhook URL.') + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $security = ($security === '1' || $security === 'true' || $security === 1 || $security === true); - $key = $request->getServer('_APP_OPENSSL_KEY_V1'); - $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); - $tag = null; - $httpPass = \json_encode([ - 'data' => OpenSSL::encrypt($httpPass, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), - 'method' => OpenSSL::CIPHER_AES_128_GCM, - 'iv' => \bin2hex($iv), - 'tag' => \bin2hex($tag), - 'version' => '1', - ]); - - $webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', [])); - - if (empty($webhook) || !$webhook instanceof Document) { - throw new Exception('Webhook not found', 404); - } - - $webhook - ->setAttribute('name', $name) - ->setAttribute('events', $events) - ->setAttribute('url', $url) - ->setAttribute('security', (int) $security) - ->setAttribute('httpUser', $httpUser) - ->setAttribute('httpPass', $httpPass) - ; - - if (false === $consoleDB->updateDocument($webhook->getArrayCopy())) { - throw new Exception('Failed saving webhook to DB', 500); - } - - $response->json($webhook->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->delete('/v1/projects/:projectId/webhooks/:webhookId') + $security = ($security === '1' || $security === 'true' || $security === 1 || $security === true); + + $webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', [])); + + if (empty($webhook) || !$webhook instanceof Document) { + throw new Exception('Webhook not found', 404); + } + + $webhook + ->setAttribute('name', $name) + ->setAttribute('events', $events) + ->setAttribute('url', $url) + ->setAttribute('security', $security) + ->setAttribute('httpUser', $httpUser) + ->setAttribute('httpPass', $httpPass) + ; + + if (false === $consoleDB->updateDocument($webhook->getArrayCopy())) { + throw new Exception('Failed saving webhook to DB', 500); + } + + $response->dynamic($webhook, Response::MODEL_WEBHOOK); + }); + +App::delete('/v1/projects/:projectId/webhooks/:webhookId') ->desc('Delete Webhook') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'deleteWebhook') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('webhookId', null, function () { return new UID(); }, 'Webhook unique ID.') - ->action( - function ($projectId, $webhookId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', [])); - - if (empty($webhook) || !$webhook instanceof Document) { - throw new Exception('Webhook not found', 404); - } - - if (!$consoleDB->deleteDocument($webhook->getId())) { - throw new Exception('Failed to remove webhook from DB', 500); - } - - $response->noContent(); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); + + $webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', [])); + + if (empty($webhook) || !$webhook instanceof Document) { + throw new Exception('Webhook not found', 404); + } + + if (!$consoleDB->deleteDocument($webhook->getId())) { + throw new Exception('Failed to remove webhook from DB', 500); + } + + $response->noContent(); + }); // Keys -$utopia->post('/v1/projects/:projectId/keys') +App::post('/v1/projects/:projectId/keys') ->desc('Create Key') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createKey') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Key name.') - ->param('scopes', null, function () use ($scopes) { return new ArrayList(new WhiteList($scopes)); }, 'Key scopes list.') - ->action( - function ($projectId, $name, $scopes) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_KEY) + ->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(array_keys(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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $key = $consoleDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_KEYS, - '$permissions' => [ - 'read' => ['team:'.$project->getAttribute('teamId', null)], - 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], - ], - 'name' => $name, - 'scopes' => $scopes, - 'secret' => \bin2hex(\random_bytes(128)), - ]); - - if (false === $key) { - throw new Exception('Failed saving key to DB', 500); - } - - $project->setAttribute('keys', $key, Document::SET_TYPE_APPEND); - - $project = $consoleDB->updateDocument($project->getArrayCopy()); - - if (false === $project) { - throw new Exception('Failed saving project to DB', 500); - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($key->getArrayCopy()) - ; + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->get('/v1/projects/:projectId/keys') + $key = $consoleDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_KEYS, + '$permissions' => [ + 'read' => ['team:'.$project->getAttribute('teamId', null)], + 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], + ], + 'name' => $name, + 'scopes' => $scopes, + 'secret' => \bin2hex(\random_bytes(128)), + ]); + + if (false === $key) { + throw new Exception('Failed saving key to DB', 500); + } + + $project->setAttribute('keys', $key, Document::SET_TYPE_APPEND); + + $project = $consoleDB->updateDocument($project->getArrayCopy()); + + if (false === $project) { + throw new Exception('Failed saving project to DB', 500); + } + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($key, Response::MODEL_KEY) + ; + }); + +App::get('/v1/projects/:projectId/keys') ->desc('List Keys') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'listKeys') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ + + $project = $consoleDB->getDocument($projectId); - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $response->json($project->getAttribute('keys', [])); //FIXME make sure array objects return correctly + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->get('/v1/projects/:projectId/keys/:keyId') + $keys = $project->getAttribute('keys', []); + + $response->dynamic(new Document([ + 'sum' => count($keys), + 'keys' => $keys + ]), Response::MODEL_KEY_LIST); + }); + +App::get('/v1/projects/:projectId/keys/:keyId') ->desc('Get Key') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'getKey') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('keyId', null, function () { return new UID(); }, 'Key unique ID.') - ->action( - function ($projectId, $keyId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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); - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } - - $key = $project->search('$id', $keyId, $project->getAttribute('keys', [])); - - if (empty($key) || !$key instanceof Document) { - throw new Exception('Key not found', 404); - } - - $response->json($key->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->put('/v1/projects/:projectId/keys/:keyId') + $key = $project->search('$id', $keyId, $project->getAttribute('keys', [])); + + if (empty($key) || !$key instanceof Document) { + throw new Exception('Key not found', 404); + } + + $response->dynamic($key, Response::MODEL_KEY); + }); + +App::put('/v1/projects/:projectId/keys/:keyId') ->desc('Update Key') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'updateKey') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('keyId', null, function () { return new UID(); }, 'Key unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Key name.') - ->param('scopes', null, function () use ($scopes) { return new ArrayList(new WhiteList($scopes)); }, 'Key scopes list') - ->action( - function ($projectId, $keyId, $name, $scopes) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_KEY) + ->param('projectId', null, new UID(), 'Project unique ID.') + ->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(array_keys(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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $key = $project->search('$id', $keyId, $project->getAttribute('keys', [])); - - if (empty($key) || !$key instanceof Document) { - throw new Exception('Key not found', 404); - } - - $key - ->setAttribute('name', $name) - ->setAttribute('scopes', $scopes) - ; - - if (false === $consoleDB->updateDocument($key->getArrayCopy())) { - throw new Exception('Failed saving key to DB', 500); - } - - $response->json($key->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->delete('/v1/projects/:projectId/keys/:keyId') + $key = $project->search('$id', $keyId, $project->getAttribute('keys', [])); + + if (empty($key) || !$key instanceof Document) { + throw new Exception('Key not found', 404); + } + + $key + ->setAttribute('name', $name) + ->setAttribute('scopes', $scopes) + ; + + if (false === $consoleDB->updateDocument($key->getArrayCopy())) { + throw new Exception('Failed saving key to DB', 500); + } + + $response->dynamic($key, Response::MODEL_KEY); + }); + +App::delete('/v1/projects/:projectId/keys/:keyId') ->desc('Delete Key') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'deleteKey') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('keyId', null, function () { return new UID(); }, 'Key unique ID.') - ->action( - function ($projectId, $keyId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $key = $project->search('$id', $keyId, $project->getAttribute('keys', [])); - - if (empty($key) || !$key instanceof Document) { - throw new Exception('Key not found', 404); - } - - if (!$consoleDB->deleteDocument($key->getId())) { - throw new Exception('Failed to remove key from DB', 500); - } - - $response->noContent(); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); + + $key = $project->search('$id', $keyId, $project->getAttribute('keys', [])); + + if (empty($key) || !$key instanceof Document) { + throw new Exception('Key not found', 404); + } + + if (!$consoleDB->deleteDocument($key->getId())) { + throw new Exception('Failed to remove key from DB', 500); + } + + $response->noContent(); + }); // Tasks -$utopia->post('/v1/projects/:projectId/tasks') +App::post('/v1/projects/:projectId/tasks') ->desc('Create Task') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createTask') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Task name.') - ->param('status', null, function () { return new WhiteList(['play', 'pause']); }, 'Task status.') - ->param('schedule', null, function () { return new Cron(); }, 'Task schedule CRON syntax.') - ->param('security', false, function () { return new Boolean(true); }, 'Certificate verification, false for disabled or true for enabled.') ->param('httpMethod', '', function () { return new WhiteList(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT']); }, 'Task HTTP method.') - ->param('httpUrl', '', function () { return new URL(); }, 'Task HTTP URL') - ->param('httpHeaders', null, function () { return new ArrayList(new Text(256)); }, 'Task HTTP headers list.', true) - ->param('httpUser', '', function () { return new Text(256); }, 'Task HTTP user.', true) - ->param('httpPass', '', function () { return new Text(256); }, 'Task HTTP password.', true) - ->action( - function ($projectId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TASK) + ->param('projectId', null, new UID(), 'Project unique ID.') + ->param('name', null, new Text(128), 'Task name. Max length: 128 chars.') + ->param('status', null, new WhiteList(['play', 'pause'], true), 'Task status.') + ->param('schedule', null, new Cron(), 'Task schedule CRON syntax.') + ->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.') + ->param('httpMethod', '', new WhiteList(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT'], true), 'Task HTTP method.') + ->param('httpUrl', '', new URL(), 'Task HTTP URL') + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $cron = CronExpression::factory($schedule); - $next = ($status == 'play') ? $cron->getNextRunDate()->format('U') : null; - - $security = ($security === '1' || $security === 'true' || $security === 1 || $security === true); - $key = $request->getServer('_APP_OPENSSL_KEY_V1'); - $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); - $tag = null; - $httpPass = \json_encode([ - 'data' => OpenSSL::encrypt($httpPass, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), - 'method' => OpenSSL::CIPHER_AES_128_GCM, - 'iv' => \bin2hex($iv), - 'tag' => \bin2hex($tag), - 'version' => '1', - ]); - - $task = $consoleDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_TASKS, - '$permissions' => [ - 'read' => ['team:'.$project->getAttribute('teamId', null)], - 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], - ], - 'name' => $name, - 'status' => $status, - 'schedule' => $schedule, - 'updated' => \time(), - 'previous' => null, - 'next' => $next, - 'security' => (int) $security, - 'httpMethod' => $httpMethod, - 'httpUrl' => $httpUrl, - 'httpHeaders' => $httpHeaders, - 'httpUser' => $httpUser, - 'httpPass' => $httpPass, - 'log' => '{}', - 'failures' => 0, - ]); - - if (false === $task) { - throw new Exception('Failed saving tasks to DB', 500); - } - - $project->setAttribute('tasks', $task, Document::SET_TYPE_APPEND); - - $project = $consoleDB->updateDocument($project->getArrayCopy()); - - if (false === $project) { - throw new Exception('Failed saving project to DB', 500); - } - - if ($next) { - ResqueScheduler::enqueueAt($next, 'v1-tasks', 'TasksV1', $task->getArrayCopy()); - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($task->getArrayCopy()) - ; + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->get('/v1/projects/:projectId/tasks') + $cron = CronExpression::factory($schedule); + $next = ($status == 'play') ? $cron->getNextRunDate()->format('U') : null; + + $security = ($security === '1' || $security === 'true' || $security === 1 || $security === true); + + $task = $consoleDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_TASKS, + '$permissions' => [ + 'read' => ['team:'.$project->getAttribute('teamId', null)], + 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], + ], + 'name' => $name, + 'status' => $status, + 'schedule' => $schedule, + 'updated' => \time(), + 'previous' => null, + 'next' => $next, + 'security' => $security, + 'httpMethod' => $httpMethod, + 'httpUrl' => $httpUrl, + 'httpHeaders' => $httpHeaders, + 'httpUser' => $httpUser, + 'httpPass' => $httpPass, + 'log' => '{}', + 'failures' => 0, + ]); + + if (false === $task) { + throw new Exception('Failed saving tasks to DB', 500); + } + + $project->setAttribute('tasks', $task, Document::SET_TYPE_APPEND); + + $project = $consoleDB->updateDocument($project->getArrayCopy()); + + if (false === $project) { + throw new Exception('Failed saving project to DB', 500); + } + + if ($next) { + ResqueScheduler::enqueueAt($next, 'v1-tasks', 'TasksV1', $task->getArrayCopy()); + } + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($task, Response::MODEL_TASK) + ; + }); + +App::get('/v1/projects/:projectId/tasks') ->desc('List Tasks') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'listTasks') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $tasks = $project->getAttribute('tasks', []); - - foreach ($tasks as $task) { /* @var $task Document */ - $httpPass = \json_decode($task->getAttribute('httpPass', '{}'), true); - - if (empty($httpPass) || !isset($httpPass['version'])) { - continue; - } - - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); - - $task->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, \hex2bin($httpPass['iv']), \hex2bin($httpPass['tag']))); - } - - $response->json($tasks); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->get('/v1/projects/:projectId/tasks/:taskId') + $tasks = $project->getAttribute('tasks', []); + + $response->dynamic(new Document([ + 'sum' => count($tasks), + 'tasks' => $tasks + ]), Response::MODEL_TASK_LIST); + + }); + +App::get('/v1/projects/:projectId/tasks/:taskId') ->desc('Get Task') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'getTask') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('taskId', null, function () { return new UID(); }, 'Task unique ID.') - ->action( - function ($projectId, $taskId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $task = $project->search('$id', $taskId, $project->getAttribute('tasks', [])); - - if (empty($task) || !$task instanceof Document) { - throw new Exception('Task not found', 404); - } - - $httpPass = \json_decode($task->getAttribute('httpPass', '{}'), true); - - if (!empty($httpPass) && isset($httpPass['version'])) { - $key = $request->getServer('_APP_OPENSSL_KEY_V'.$httpPass['version']); - $task->setAttribute('httpPass', OpenSSL::decrypt($httpPass['data'], $httpPass['method'], $key, 0, \hex2bin($httpPass['iv']), \hex2bin($httpPass['tag']))); - } - - $response->json($task->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->put('/v1/projects/:projectId/tasks/:taskId') + $task = $project->search('$id', $taskId, $project->getAttribute('tasks', [])); + + if (empty($task) || !$task instanceof Document) { + throw new Exception('Task not found', 404); + } + + $response->dynamic($task, Response::MODEL_TASK); + }); + +App::put('/v1/projects/:projectId/tasks/:taskId') ->desc('Update Task') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'updateTask') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('taskId', null, function () { return new UID(); }, 'Task unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Task name.') - ->param('status', null, function () { return new WhiteList(['play', 'pause']); }, 'Task status.') - ->param('schedule', null, function () { return new Cron(); }, 'Task schedule CRON syntax.') - ->param('security', false, function () { return new Boolean(true); }, 'Certificate verification, false for disabled or true for enabled.') - ->param('httpMethod', '', function () { return new WhiteList(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT']); }, 'Task HTTP method.') - ->param('httpUrl', '', function () { return new URL(); }, 'Task HTTP URL.') - ->param('httpHeaders', null, function () { return new ArrayList(new Text(256)); }, 'Task HTTP headers list.', true) - ->param('httpUser', '', function () { return new Text(256); }, 'Task HTTP user.', true) - ->param('httpPass', '', function () { return new Text(256); }, 'Task HTTP password.', true) - ->action( - function ($projectId, $taskId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TASK) + ->param('projectId', null, new UID(), 'Project unique ID.') + ->param('taskId', null, new UID(), 'Task unique ID.') + ->param('name', null, new Text(128), 'Task name. Max length: 128 chars.') + ->param('status', null, new WhiteList(['play', 'pause'], true), 'Task status.') + ->param('schedule', null, new Cron(), 'Task schedule CRON syntax.') + ->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.') + ->param('httpMethod', '', new WhiteList(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT'], true), 'Task HTTP method.') + ->param('httpUrl', '', new URL(), 'Task HTTP URL.') + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $task = $project->search('$id', $taskId, $project->getAttribute('tasks', [])); - - if (empty($task) || !$task instanceof Document) { - throw new Exception('Task not found', 404); - } - - $cron = CronExpression::factory($schedule); - $next = ($status == 'play') ? $cron->getNextRunDate()->format('U') : null; - - $security = ($security === '1' || $security === 'true' || $security === 1 || $security === true); - $key = $request->getServer('_APP_OPENSSL_KEY_V1'); - $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); - $tag = null; - $httpPass = \json_encode([ - 'data' => OpenSSL::encrypt($httpPass, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), - 'method' => OpenSSL::CIPHER_AES_128_GCM, - 'iv' => \bin2hex($iv), - 'tag' => \bin2hex($tag), - 'version' => '1', - ]); - - $task - ->setAttribute('name', $name) - ->setAttribute('status', $status) - ->setAttribute('schedule', $schedule) - ->setAttribute('updated', \time()) - ->setAttribute('next', $next) - ->setAttribute('security', (int) $security) - ->setAttribute('httpMethod', $httpMethod) - ->setAttribute('httpUrl', $httpUrl) - ->setAttribute('httpHeaders', $httpHeaders) - ->setAttribute('httpUser', $httpUser) - ->setAttribute('httpPass', $httpPass) - ; - - if (false === $consoleDB->updateDocument($task->getArrayCopy())) { - throw new Exception('Failed saving tasks to DB', 500); - } - - if ($next) { - ResqueScheduler::enqueueAt($next, 'v1-tasks', 'TasksV1', $task->getArrayCopy()); - } - - $response->json($task->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->delete('/v1/projects/:projectId/tasks/:taskId') + $task = $project->search('$id', $taskId, $project->getAttribute('tasks', [])); + + if (empty($task) || !$task instanceof Document) { + throw new Exception('Task not found', 404); + } + + $cron = CronExpression::factory($schedule); + $next = ($status == 'play') ? $cron->getNextRunDate()->format('U') : null; + + $security = ($security === '1' || $security === 'true' || $security === 1 || $security === true); + + $task + ->setAttribute('name', $name) + ->setAttribute('status', $status) + ->setAttribute('schedule', $schedule) + ->setAttribute('updated', \time()) + ->setAttribute('next', $next) + ->setAttribute('security', $security) + ->setAttribute('httpMethod', $httpMethod) + ->setAttribute('httpUrl', $httpUrl) + ->setAttribute('httpHeaders', $httpHeaders) + ->setAttribute('httpUser', $httpUser) + ->setAttribute('httpPass', $httpPass) + ; + + if (false === $consoleDB->updateDocument($task->getArrayCopy())) { + throw new Exception('Failed saving tasks to DB', 500); + } + + if ($next) { + ResqueScheduler::enqueueAt($next, 'v1-tasks', 'TasksV1', $task->getArrayCopy()); + } + + $response->dynamic($task, Response::MODEL_TASK); + }); + +App::delete('/v1/projects/:projectId/tasks/:taskId') ->desc('Delete Task') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'deleteTask') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('taskId', null, function () { return new UID(); }, 'Task unique ID.') - ->action( - function ($projectId, $taskId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $task = $project->search('$id', $taskId, $project->getAttribute('tasks', [])); - - if (empty($task) || !$task instanceof Document) { - throw new Exception('Task not found', 404); - } - - if (!$consoleDB->deleteDocument($task->getId())) { - throw new Exception('Failed to remove tasks from DB', 500); - } - - $response->noContent(); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); + + $task = $project->search('$id', $taskId, $project->getAttribute('tasks', [])); + + if (empty($task) || !$task instanceof Document) { + throw new Exception('Task not found', 404); + } + + if (!$consoleDB->deleteDocument($task->getId())) { + throw new Exception('Failed to remove tasks from DB', 500); + } + + $response->noContent(); + }); // Platforms -$utopia->post('/v1/projects/:projectId/platforms') +App::post('/v1/projects/:projectId/platforms') ->desc('Create Platform') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createPlatform') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('type', null, function () { return new WhiteList(['web', 'flutter-ios', 'flutter-android', 'ios', 'android', 'unity']); }, 'Platform type.') - ->param('name', null, function () { return new Text(256); }, 'Platform name.') - ->param('key', '', function () { return new Text(256); }, 'Package name for android or bundle ID for iOS.', true) - ->param('store', '', function () { return new Text(256); }, 'App store or Google Play store ID.', true) - ->param('hostname', '', function () { return new Text(256); }, 'Platform client hostname.', true) - ->action( - function ($projectId, $type, $name, $key, $store, $hostname) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_PLATFORM) + ->param('projectId', null, new UID(), 'Project unique ID.') + ->param('type', null, new WhiteList(['web', 'flutter-ios', 'flutter-android', 'ios', 'android', 'unity'], true), 'Platform type.') + ->param('name', null, new Text(128), 'Platform name. Max length: 128 chars.') + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $platform = $consoleDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, - '$permissions' => [ - 'read' => ['team:'.$project->getAttribute('teamId', null)], - 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], - ], - 'type' => $type, - 'name' => $name, - 'key' => $key, - 'store' => $store, - 'hostname' => $hostname, - 'dateCreated' => \time(), - 'dateUpdated' => \time(), - ]); - - if (false === $platform) { - throw new Exception('Failed saving platform to DB', 500); - } - - $project->setAttribute('platforms', $platform, Document::SET_TYPE_APPEND); - - $project = $consoleDB->updateDocument($project->getArrayCopy()); - - if (false === $project) { - throw new Exception('Failed saving project to DB', 500); - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($platform->getArrayCopy()) - ; + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); + + $platform = $consoleDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, + '$permissions' => [ + 'read' => ['team:'.$project->getAttribute('teamId', null)], + 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], + ], + 'type' => $type, + 'name' => $name, + 'key' => $key, + 'store' => $store, + 'hostname' => $hostname, + 'dateCreated' => \time(), + 'dateUpdated' => \time(), + ]); + + if (false === $platform) { + throw new Exception('Failed saving platform to DB', 500); + } + + $project->setAttribute('platforms', $platform, Document::SET_TYPE_APPEND); + + $project = $consoleDB->updateDocument($project->getArrayCopy()); + + if (false === $project) { + throw new Exception('Failed saving project to DB', 500); + } + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($platform, Response::MODEL_PLATFORM) + ; + }); -$utopia->get('/v1/projects/:projectId/platforms') +App::get('/v1/projects/:projectId/platforms') ->desc('List Platforms') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'listPlatforms') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $platforms = $project->getAttribute('platforms', []); - - $response->json($platforms); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->get('/v1/projects/:projectId/platforms/:platformId') + $platforms = $project->getAttribute('platforms', []); + + $response->dynamic(new Document([ + 'sum' => count($platforms), + 'platforms' => $platforms + ]), Response::MODEL_PLATFORM_LIST); + }); + +App::get('/v1/projects/:projectId/platforms/:platformId') ->desc('Get Platform') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'getPlatform') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('platformId', null, function () { return new UID(); }, 'Platform unique ID.') - ->action( - function ($projectId, $platformId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $platform = $project->search('$id', $platformId, $project->getAttribute('platforms', [])); - - if (empty($platform) || !$platform instanceof Document) { - throw new Exception('Platform not found', 404); - } - - $response->json($platform->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->put('/v1/projects/:projectId/platforms/:platformId') + $platform = $project->search('$id', $platformId, $project->getAttribute('platforms', [])); + + if (empty($platform) || !$platform instanceof Document) { + throw new Exception('Platform not found', 404); + } + + $response->dynamic($platform, Response::MODEL_PLATFORM); + }); + +App::put('/v1/projects/:projectId/platforms/:platformId') ->desc('Update Platform') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'updatePlatform') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('platformId', null, function () { return new UID(); }, 'Platform unique ID.') - ->param('name', null, function () { return new Text(256); }, 'Platform name.') - ->param('key', '', function () { return new Text(256); }, 'Package name for android or bundle ID for iOS.', true) - ->param('store', '', function () { return new Text(256); }, 'App store or Google Play store ID.', true) - ->param('hostname', '', function () { return new Text(256); }, 'Platform client URL.', true) - ->action( - function ($projectId, $platformId, $name, $key, $store, $hostname) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_PLATFORM) + ->param('projectId', null, new UID(), 'Project unique ID.') + ->param('platformId', null, new UID(), 'Platform unique ID.') + ->param('name', null, new Text(128), 'Platform name. Max length: 128 chars.') + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $platform = $project->search('$id', $platformId, $project->getAttribute('platforms', [])); - - if (empty($platform) || !$platform instanceof Document) { - throw new Exception('Platform not found', 404); - } - - $platform - ->setAttribute('name', $name) - ->setAttribute('dateUpdated', \time()) - ->setAttribute('key', $key) - ->setAttribute('store', $store) - ->setAttribute('hostname', $hostname) - ; - - if (false === $consoleDB->updateDocument($platform->getArrayCopy())) { - throw new Exception('Failed saving platform to DB', 500); - } - - $response->json($platform->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->delete('/v1/projects/:projectId/platforms/:platformId') + $platform = $project->search('$id', $platformId, $project->getAttribute('platforms', [])); + + if (empty($platform) || !$platform instanceof Document) { + throw new Exception('Platform not found', 404); + } + + $platform + ->setAttribute('name', $name) + ->setAttribute('dateUpdated', \time()) + ->setAttribute('key', $key) + ->setAttribute('store', $store) + ->setAttribute('hostname', $hostname) + ; + + if (false === $consoleDB->updateDocument($platform->getArrayCopy())) { + throw new Exception('Failed saving platform to DB', 500); + } + + $response->dynamic($platform, Response::MODEL_PLATFORM); + }); + +App::delete('/v1/projects/:projectId/platforms/:platformId') ->desc('Delete Platform') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'deletePlatform') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('platformId', null, function () { return new UID(); }, 'Platform unique ID.') - ->action( - function ($projectId, $platformId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $platform = $project->search('$id', $platformId, $project->getAttribute('platforms', [])); - - if (empty($platform) || !$platform instanceof Document) { - throw new Exception('Platform not found', 404); - } - - if (!$consoleDB->deleteDocument($platform->getId())) { - throw new Exception('Failed to remove platform from DB', 500); - } - - $response->noContent(); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); + + $platform = $project->search('$id', $platformId, $project->getAttribute('platforms', [])); + + if (empty($platform) || !$platform instanceof Document) { + throw new Exception('Platform not found', 404); + } + + if (!$consoleDB->deleteDocument($platform->getId())) { + throw new Exception('Failed to remove platform from DB', 500); + } + + $response->noContent(); + }); // Domains -$utopia->post('/v1/projects/:projectId/domains') +App::post('/v1/projects/:projectId/domains') ->desc('Create Domain') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createDomain') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('domain', null, function () { return new DomainValidator(); }, 'Domain name.') - ->action( - function ($projectId, $domain) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $document = $project->search('domain', $domain, $project->getAttribute('domains', [])); - - if (!empty($document)) { - throw new Exception('Domain already exists', 409); - } - - $target = new Domain($request->getServer('_APP_DOMAIN_TARGET', '')); - - if (!$target->isKnown() || $target->isTest()) { - throw new Exception('Unreachable CNAME target ('.$target->get().'), plesse use a domain with a public suffix.', 500); - } - - $domain = new Domain($domain); - - $domain = $consoleDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_DOMAINS, - '$permissions' => [ - 'read' => ['team:'.$project->getAttribute('teamId', null)], - 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], - ], - 'updated' => \time(), - 'domain' => $domain->get(), - 'tld' => $domain->getSuffix(), - 'registerable' => $domain->getRegisterable(), - 'verification' => false, - 'certificateId' => null, - ]); - - if (false === $domain) { - throw new Exception('Failed saving domain to DB', 500); - } - - $project->setAttribute('domains', $domain, Document::SET_TYPE_APPEND); - - $project = $consoleDB->updateDocument($project->getArrayCopy()); - - if (false === $project) { - throw new Exception('Failed saving project to DB', 500); - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($domain->getArrayCopy()) - ; + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->get('/v1/projects/:projectId/domains') + $document = $project->search('domain', $domain, $project->getAttribute('domains', [])); + + if (!empty($document)) { + throw new Exception('Domain already exists', 409); + } + + $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); + + if (!$target->isKnown() || $target->isTest()) { + throw new Exception('Unreachable CNAME target ('.$target->get().'), please use a domain with a public suffix.', 500); + } + + $domain = new Domain($domain); + + $domain = $consoleDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_DOMAINS, + '$permissions' => [ + 'read' => ['team:'.$project->getAttribute('teamId', null)], + 'write' => ['team:'.$project->getAttribute('teamId', null).'/owner', 'team:'.$project->getAttribute('teamId', null).'/developer'], + ], + 'updated' => \time(), + 'domain' => $domain->get(), + 'tld' => $domain->getSuffix(), + 'registerable' => $domain->getRegisterable(), + 'verification' => false, + 'certificateId' => null, + ]); + + if (false === $domain) { + throw new Exception('Failed saving domain to DB', 500); + } + + $project->setAttribute('domains', $domain, Document::SET_TYPE_APPEND); + + $project = $consoleDB->updateDocument($project->getArrayCopy()); + + if (false === $project) { + throw new Exception('Failed saving project to DB', 500); + } + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($domain, Response::MODEL_DOMAIN) + ; + }); + +App::get('/v1/projects/:projectId/domains') ->desc('List Domains') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'listDomains') - ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') - ->action( - function ($projectId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $domains = $project->getAttribute('domains', []); - - $response->json($domains); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->get('/v1/projects/:projectId/domains/:domainId') + $domains = $project->getAttribute('domains', []); + + $response->dynamic(new Document([ + 'sum' => count($domains), + 'domains' => $domains + ]), Response::MODEL_DOMAIN_LIST); + }); + +App::get('/v1/projects/:projectId/domains/:domainId') ->desc('Get Domain') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'getDomain') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('domainId', null, function () { return new UID(); }, 'Domain unique ID.') - ->action( - function ($projectId, $domainId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $domain = $project->search('$id', $domainId, $project->getAttribute('domains', [])); - - if (empty($domain) || !$domain instanceof Document) { - throw new Exception('Domain not found', 404); - } - - $response->json($domain->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->patch('/v1/projects/:projectId/domains/:domainId/verification') + $domain = $project->search('$id', $domainId, $project->getAttribute('domains', [])); + + if (empty($domain) || !$domain instanceof Document) { + throw new Exception('Domain not found', 404); + } + + $response->dynamic($domain, Response::MODEL_DOMAIN); + }); + +App::patch('/v1/projects/:projectId/domains/:domainId/verification') ->desc('Update Domain Verification Status') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'updateDomainVerification') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('domainId', null, function () { return new UID(); }, 'Domain unique ID.') - ->action( - function ($projectId, $domainId) use ($request, $response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $domain = $project->search('$id', $domainId, $project->getAttribute('domains', [])); - - if (empty($domain) || !$domain instanceof Document) { - throw new Exception('Domain not found', 404); - } - - $target = new Domain($request->getServer('_APP_DOMAIN_TARGET', '')); - - if (!$target->isKnown() || $target->isTest()) { - throw new Exception('Unreachable CNAME target ('.$target->get().'), plesse use a domain with a public suffix.', 500); - } - - if ($domain->getAttribute('verification') === true) { - return $response->json($domain->getArrayCopy()); - } - - // Verify Domain with DNS records - $validator = new CNAME($target->get()); - - if (!$validator->isValid($domain->getAttribute('domain', ''))) { - throw new Exception('Failed to verify domain', 401); - } - - $domain - ->setAttribute('verification', true) - ; - - if (false === $consoleDB->updateDocument($domain->getArrayCopy())) { - throw new Exception('Failed saving domains to DB', 500); - } - - // Issue a TLS certificate when domain is verified - Resque::enqueue('v1-certificates', 'CertificatesV1', [ - 'document' => $domain->getArrayCopy(), - 'domain' => $domain->getAttribute('domain'), - ]); - - $response->json($domain->getArrayCopy()); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); -$utopia->delete('/v1/projects/:projectId/domains/:domainId') + $domain = $project->search('$id', $domainId, $project->getAttribute('domains', [])); + + if (empty($domain) || !$domain instanceof Document) { + throw new Exception('Domain not found', 404); + } + + $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); + + if (!$target->isKnown() || $target->isTest()) { + throw new Exception('Unreachable CNAME target ('.$target->get().'), please use a domain with a public suffix.', 500); + } + + if ($domain->getAttribute('verification') === true) { + return $response->dynamic($domain, Response::MODEL_DOMAIN); + } + + // Verify Domain with DNS records + $validator = new CNAME($target->get()); + + if (!$validator->isValid($domain->getAttribute('domain', ''))) { + throw new Exception('Failed to verify domain', 401); + } + + $domain + ->setAttribute('verification', true) + ; + + if (false === $consoleDB->updateDocument($domain->getArrayCopy())) { + throw new Exception('Failed saving domains to DB', 500); + } + + // Issue a TLS certificate when domain is verified + Resque::enqueue('v1-certificates', 'CertificatesV1', [ + 'document' => $domain->getArrayCopy(), + 'domain' => $domain->getAttribute('domain'), + ]); + + $response->dynamic($domain, Response::MODEL_DOMAIN); + }); + +App::delete('/v1/projects/:projectId/domains/:domainId') ->desc('Delete Domain') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'deleteDomain') - ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('domainId', null, function () { return new UID(); }, 'Domain unique ID.') - ->action( - function ($projectId, $domainId) use ($response, $consoleDB) { - $project = $consoleDB->getDocument($projectId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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') + ->inject('deletes') + ->action(function ($projectId, $domainId, $response, $consoleDB, $deletes) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Database $consoleDB */ - if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { - throw new Exception('Project not found', 404); - } + $project = $consoleDB->getDocument($projectId); - $domain = $project->search('$id', $domainId, $project->getAttribute('domains', [])); - - if (empty($domain) || !$domain instanceof Document) { - throw new Exception('Domain not found', 404); - } - - if (!$consoleDB->deleteDocument($domain->getId())) { - throw new Exception('Failed to remove domains from DB', 500); - } - - $response->noContent(); + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { + throw new Exception('Project not found', 404); } - ); \ No newline at end of file + + $domain = $project->search('$id', $domainId, $project->getAttribute('domains', [])); + + if (empty($domain) || !$domain instanceof Document) { + throw new Exception('Domain not found', 404); + } + + if ($consoleDB->deleteDocument($domain->getId())) { + $deletes + ->setParam('type', DELETE_TYPE_CERTIFICATES) + ->setParam('document', $domain) + ; + } else { + throw new Exception('Failed to remove domains from DB', 500); + } + + $response->noContent(); + }); \ No newline at end of file diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 853bdade6a..98980fd6bd 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -1,9 +1,7 @@ getId())); - -$fileLogos = [ // Based on this list @see http://stackoverflow.com/a/4212908/2299554 - 'default' => __DIR__.'/../../config/files/none.png', - - // Video Files - 'video/mp4' => __DIR__.'/../../config/files/video.png', - 'video/x-flv' => __DIR__.'/../../config/files/video.png', - 'application/x-mpegURL' => __DIR__.'/../../config/files/video.png', - 'video/MP2T' => __DIR__.'/../../config/files/video.png', - 'video/3gpp' => __DIR__.'/../../config/files/video.png', - 'video/quicktime' => __DIR__.'/../../config/files/video.png', - 'video/x-msvideo' => __DIR__.'/../../config/files/video.png', - 'video/x-ms-wmv' => __DIR__.'/../../config/files/video.png', - - // // Microsoft Word - 'application/msword' => __DIR__.'/../../config/files/word.png', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => __DIR__.'/../../config/files/word.png', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => __DIR__.'/../../config/files/word.png', - 'application/vnd.ms-word.document.macroEnabled.12' => __DIR__.'/../../config/files/word.png', - - // // Microsoft Excel - 'application/vnd.ms-excel' => __DIR__.'/../../config/files/excel.png', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => __DIR__.'/../../config/files/excel.png', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => __DIR__.'/../../config/files/excel.png', - 'application/vnd.ms-excel.sheet.macroEnabled.12' => __DIR__.'/../../config/files/excel.png', - 'application/vnd.ms-excel.template.macroEnabled.12' => __DIR__.'/../../config/files/excel.png', - 'application/vnd.ms-excel.addin.macroEnabled.12' => __DIR__.'/../../config/files/excel.png', - 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => __DIR__.'/../../config/files/excel.png', - - // // Microsoft Power Point - 'application/vnd.ms-powerpoint' => __DIR__.'/../../config/files/ppt.png', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => __DIR__.'/../../config/files/ppt.png', - 'application/vnd.openxmlformats-officedocument.presentationml.template' => __DIR__.'/../../config/files/ppt.png', - 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => __DIR__.'/../../config/files/ppt.png', - 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => __DIR__.'/../../config/files/ppt.png', - 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => __DIR__.'/../../config/files/ppt.png', - 'application/vnd.ms-powerpoint.template.macroEnabled.12' => __DIR__.'/../../config/files/ppt.png', - 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => __DIR__.'/../../config/files/ppt.png', - - // Adobe PDF - 'application/pdf' => __DIR__.'/../../config/files/pdf.png', -]; - -$inputs = [ - 'jpg' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'gif' => 'image/gif', - 'png' => 'image/png', -]; - -$outputs = [ - 'jpg' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'gif' => 'image/gif', - 'png' => 'image/png', - 'webp' => 'image/webp', -]; - -$mimes = [ - 'image/jpeg', - 'image/jpeg', - 'image/gif', - 'image/png', - 'image/webp', - - // Video Files - 'video/mp4', - 'video/x-flv', - 'application/x-mpegURL', - 'video/MP2T', - 'video/3gpp', - 'video/quicktime', - 'video/x-msvideo', - 'video/x-ms-wmv', - - // Microsoft Word - 'application/msword', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', - 'application/vnd.ms-word.document.macroEnabled.12', - - // Microsoft Excel - 'application/vnd.ms-excel', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', - 'application/vnd.ms-excel.sheet.macroEnabled.12', - 'application/vnd.ms-excel.template.macroEnabled.12', - 'application/vnd.ms-excel.addin.macroEnabled.12', - 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', - - // Microsoft Power Point - 'application/vnd.ms-powerpoint', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'application/vnd.openxmlformats-officedocument.presentationml.template', - 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', - 'application/vnd.ms-powerpoint.addin.macroEnabled.12', - 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', - 'application/vnd.ms-powerpoint.template.macroEnabled.12', - 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', - - // Microsoft Access - 'application/vnd.ms-access', - - // Adobe PDF - 'application/pdf', -]; - -$utopia->post('/v1/storage/files') +App::post('/v1/storage/files') ->desc('Create File') ->groups(['api', 'storage']) ->label('scope', 'files.write') - ->label('webhook', 'storage.files.create') + ->label('event', 'storage.files.create') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'createFile') ->label('sdk.description', '/docs/references/storage/create-file.md') - ->label('sdk.consumes', 'multipart/form-data') + ->label('sdk.request.type', 'multipart/form-data') ->label('sdk.methodType', 'upload') - ->param('file', [], function () { return new File(); }, 'Binary File.', false) - ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - // ->param('folderId', '', function () { return new UID(); }, 'Folder to associate files with.', true) - ->action( - function ($file, $read, $write, $folderId = '') use ($request, $response, $user, $projectDB, $webhook, $audit, $usage) { - $file = $request->getFiles('file'); - $read = (empty($read)) ? ['user:'.$user->getId()] : $read; - $write = (empty($write)) ? ['user:'.$user->getId()] : $write; + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_FILE) + ->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.') + ->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\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $usage */ - /* - * Validators - */ - //$fileType = new FileType(array(FileType::FILE_TYPE_PNG, FileType::FILE_TYPE_GIF, FileType::FILE_TYPE_JPEG)); - $fileSize = new FileSize($request->getServer('_APP_STORAGE_LIMIT', 0)); - $upload = new Upload(); + $file = $request->getFiles('file'); - if (empty($file)) { - throw new Exception('No file sent', 400); - } + /* + * Validators + */ + //$fileType = new FileType(array(FileType::FILE_TYPE_PNG, FileType::FILE_TYPE_GIF, FileType::FILE_TYPE_JPEG)); + $fileSize = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0)); + $upload = new Upload(); - // Make sure we handle a single file and multiple files the same way - $file['name'] = (\is_array($file['name']) && isset($file['name'][0])) ? $file['name'][0] : $file['name']; - $file['tmp_name'] = (\is_array($file['tmp_name']) && isset($file['tmp_name'][0])) ? $file['tmp_name'][0] : $file['tmp_name']; - $file['size'] = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size']; + if (empty($file)) { + throw new Exception('No file sent', 400); + } - // Check if file type is allowed (feature for project settings?) - //if (!$fileType->isValid($file['tmp_name'])) { - //throw new Exception('File type not allowed', 400); - //} + // Make sure we handle a single file and multiple files the same way + $file['name'] = (\is_array($file['name']) && isset($file['name'][0])) ? $file['name'][0] : $file['name']; + $file['tmp_name'] = (\is_array($file['tmp_name']) && isset($file['tmp_name'][0])) ? $file['tmp_name'][0] : $file['tmp_name']; + $file['size'] = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size']; - // Check if file size is exceeding allowed limit - if (!$fileSize->isValid($file['size'])) { - throw new Exception('File size not allowed', 400); - } + // Check if file type is allowed (feature for project settings?) + //if (!$fileType->isValid($file['tmp_name'])) { + //throw new Exception('File type not allowed', 400); + //} - /* - * Models - */ - $device = Storage::getDevice('local'); + if (!$fileSize->isValid($file['size'])) { // Check if file size is exceeding allowed limit + throw new Exception('File size not allowed', 400); + } - if (!$upload->isValid($file['tmp_name'])) { + $device = Storage::getDevice('files'); + + if (!$upload->isValid($file['tmp_name'])) { + throw new Exception('Invalid file', 403); + } + + // Save to storage + $size = $device->getFileSize($file['tmp_name']); + $path = $device->getPath(\uniqid().'.'.\pathinfo($file['name'], PATHINFO_EXTENSION)); + + if (!$device->upload($file['tmp_name'], $path)) { // TODO deprecate 'upload' and replace with 'move' + throw new Exception('Failed moving file', 500); + } + + $mimeType = $device->getFileMimeType($path); // Get mime-type before compression and encryption + + if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled + $antiVirus = new Network(App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), + (int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)); + + if (!$antiVirus->fileScan($path)) { + $device->delete($path); throw new Exception('Invalid file', 403); } - - // Save to storage - $size = $device->getFileSize($file['tmp_name']); - $path = $device->getPath(\uniqid().'.'.\pathinfo($file['name'], PATHINFO_EXTENSION)); - - if (!$device->upload($file['tmp_name'], $path)) { // TODO deprecate 'upload' and replace with 'move' - throw new Exception('Failed moving file', 500); - } - - $mimeType = $device->getFileMimeType($path); // Get mime-type before compression and encryption - - if ($request->getServer('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled - $antiVirus = new Network('clamav', 3310); - - // Check if file size is exceeding allowed limit - if (!$antiVirus->fileScan($path)) { - $device->delete($path); - throw new Exception('Invalid file', 403); - } - } - - // Compression - $compressor = new GZIP(); - $data = $device->read($path); - $data = $compressor->compress($data); - $key = $request->getServer('_APP_OPENSSL_KEY_V1'); - $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); - $data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag); - - if (!$device->write($path, $data)) { - throw new Exception('Failed to save file', 500); - } - - $sizeActual = $device->getFileSize($path); - - $file = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_FILES, - '$permissions' => [ - 'read' => $read, - 'write' => $write, - ], - 'dateCreated' => \time(), - 'folderId' => $folderId, - 'name' => $file['name'], - 'path' => $path, - 'signature' => $device->getFileHash($path), - 'mimeType' => $mimeType, - 'sizeOriginal' => $size, - 'sizeActual' => $sizeActual, - 'algorithm' => $compressor->getName(), - 'token' => \bin2hex(\random_bytes(64)), - 'comment' => '', - 'fileOpenSSLVersion' => '1', - 'fileOpenSSLCipher' => OpenSSL::CIPHER_AES_128_GCM, - 'fileOpenSSLTag' => \bin2hex($tag), - 'fileOpenSSLIV' => \bin2hex($iv), - ]); - - if (false === $file) { - throw new Exception('Failed saving file to DB', 500); - } - - $webhook - ->setParam('payload', $file->getArrayCopy()) - ; - - $audit - ->setParam('event', 'storage.files.create') - ->setParam('resource', 'storage/files/'.$file->getId()) - ; - - $usage - ->setParam('storage', $sizeActual) - ; - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($file->getArrayCopy()) - ; } - ); -$utopia->get('/v1/storage/files') + // Compression + $compressor = new GZIP(); + $data = $device->read($path); + $data = $compressor->compress($data); + $key = App::getEnv('_APP_OPENSSL_KEY_V1'); + $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); + $data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag); + + if (!$device->write($path, $data)) { + throw new Exception('Failed to save file', 500); + } + + $sizeActual = $device->getFileSize($path); + + $file = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_FILES, + '$permissions' => [ + 'read' => $read, + 'write' => $write, + ], + 'dateCreated' => \time(), + 'folderId' => '', + 'name' => $file['name'], + 'path' => $path, + 'signature' => $device->getFileHash($path), + 'mimeType' => $mimeType, + 'sizeOriginal' => $size, + 'sizeActual' => $sizeActual, + 'algorithm' => $compressor->getName(), + 'token' => \bin2hex(\random_bytes(64)), + 'comment' => '', + 'fileOpenSSLVersion' => '1', + 'fileOpenSSLCipher' => OpenSSL::CIPHER_AES_128_GCM, + 'fileOpenSSLTag' => \bin2hex($tag), + 'fileOpenSSLIV' => \bin2hex($iv), + ]); + + if (false === $file) { + throw new Exception('Failed saving file to DB', 500); + } + + $audits + ->setParam('event', 'storage.files.create') + ->setParam('resource', 'storage/files/'.$file->getId()) + ; + + $usage + ->setParam('storage', $sizeActual) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($file, Response::MODEL_FILE) + ; + }); + +App::get('/v1/storage/files') ->desc('List Files') ->groups(['api', 'storage']) ->label('scope', 'files.read') @@ -276,33 +169,36 @@ $utopia->get('/v1/storage/files') ->label('sdk.namespace', 'storage') ->label('sdk.method', 'listFiles') ->label('sdk.description', '/docs/references/storage/list-files.md') - ->param('search', '', function () { return new Text(256); }, 'Search term to filter your list results.', true) - ->param('limit', 25, function () { return new Range(0, 100); }, 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0, function () { return new Range(0, 2000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true) - ->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true) - ->action( - function ($search, $limit, $offset, $orderType) use ($response, $projectDB) { - $results = $projectDB->getCollection([ - 'limit' => $limit, - 'offset' => $offset, - 'orderField' => 'dateCreated', - 'orderType' => $orderType, - 'orderCast' => 'int', - 'search' => $search, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_FILES, - ], - ]); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_FILE_LIST) + ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) + ->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 */ - $results = \array_map(function ($value) { /* @var $value \Database\Document */ - return $value->getArrayCopy(['$id', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal']); - }, $results); + $results = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderType' => $orderType, + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_FILES, + ], + ]); - $response->json(['sum' => $projectDB->getSum(), 'files' => $results]); - } - ); + $response->dynamic(new Document([ + 'sum' => $projectDB->getSum(), + 'files' => $results + ]), Response::MODEL_FILE_LIST); + }); -$utopia->get('/v1/storage/files/:fileId') +App::get('/v1/storage/files/:fileId') ->desc('Get File') ->groups(['api', 'storage']) ->label('scope', 'files.read') @@ -310,20 +206,26 @@ $utopia->get('/v1/storage/files/:fileId') ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFile') ->label('sdk.description', '/docs/references/storage/get-file.md') - ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') - ->action( - function ($fileId) use ($response, $projectDB) { - $file = $projectDB->getDocument($fileId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ - if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { - throw new Exception('File not found', 404); - } + $file = $projectDB->getDocument($fileId); - $response->json($file->getArrayCopy(['$id', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal'])); + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + throw new Exception('File not found', 404); } - ); -$utopia->get('/v1/storage/files/:fileId/preview') + $response->dynamic($file, Response::MODEL_FILE); + }); + +App::get('/v1/storage/files/:fileId/preview') ->desc('Get File Preview') ->groups(['api', 'storage']) ->label('scope', 'files.read') @@ -331,120 +233,130 @@ $utopia->get('/v1/storage/files/:fileId/preview') ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFilePreview') ->label('sdk.description', '/docs/references/storage/get-file-preview.md') - ->label('sdk.response.type', 'image/*') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_IMAGE) ->label('sdk.methodType', 'location') - ->param('fileId', '', function () { return new UID(); }, 'File unique ID') - ->param('width', 0, function () { return new Range(0, 4000); }, 'Resize preview image width, Pass an integer between 0 to 4000.', true) - ->param('height', 0, function () { return new Range(0, 4000); }, 'Resize preview image height, Pass an integer between 0 to 4000.', true) - ->param('quality', 100, function () { return new Range(0, 100); }, 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true) - ->param('background', '', function () { return new HexColor(); }, 'Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.', true) - ->param('output', null, function () use ($outputs) { return new WhiteList(\array_merge(\array_keys($outputs), [null])); }, 'Output format type (jpeg, jpg, png, gif and webp).', true) - ->action( - function ($fileId, $width, $height, $quality, $background, $output) use ($request, $response, $projectDB, $project, $inputs, $outputs, $fileLogos) { - $storage = 'local'; + ->param('fileId', '', new UID(), 'File unique ID') + ->param('width', 0, new Range(0, 4000), 'Resize preview image width, Pass an integer between 0 to 4000.', true) + ->param('height', 0, new Range(0, 4000), 'Resize preview image height, Pass an integer between 0 to 4000.', true) + ->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 */ + /** @var Appwrite\Database\Document $project */ + /** @var Appwrite\Database\Database $projectDB */ - if (!\extension_loaded('imagick')) { - throw new Exception('Imagick extension is missing', 500); - } + $storage = 'files'; - if (!Storage::exists($storage)) { - throw new Exception('No such storage device', 400); - } + if (!\extension_loaded('imagick')) { + throw new Exception('Imagick extension is missing', 500); + } - if ((\strpos($request->getServer('HTTP_ACCEPT'), 'image/webp') === false) && ('webp' == $output)) { // Fallback webp to jpeg when no browser support - $output = 'jpg'; - } + if (!Storage::exists($storage)) { + throw new Exception('No such storage device', 400); + } - $date = \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache - $key = \md5($fileId.$width.$height.$quality.$background.$storage.$output); + if ((\strpos($request->getAccept(), 'image/webp') === false) && ('webp' == $output)) { // Fallback webp to jpeg when no browser support + $output = 'jpg'; + } - $file = $projectDB->getDocument($fileId); + $inputs = Config::getParam('storage-inputs'); + $outputs = Config::getParam('storage-outputs'); + $fileLogos = Config::getParam('storage-logos'); - if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { - throw new Exception('File not found', 404); - } + $date = \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache + $key = \md5($fileId.$width.$height.$quality.$background.$storage.$output); - $path = $file->getAttribute('path'); + $file = $projectDB->getDocument($fileId); + + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + throw new Exception('File not found', 404); + } + + $path = $file->getAttribute('path'); + $type = \strtolower(\pathinfo($path, PATHINFO_EXTENSION)); + $algorithm = $file->getAttribute('algorithm'); + $cipher = $file->getAttribute('fileOpenSSLCipher'); + $mime = $file->getAttribute('mimeType'); + + if (!\in_array($mime, $inputs)) { + $path = (\array_key_exists($mime, $fileLogos)) ? $fileLogos[$mime] : $fileLogos['default']; + $algorithm = null; + $cipher = null; + $background = (empty($background)) ? 'eceff1' : $background; $type = \strtolower(\pathinfo($path, PATHINFO_EXTENSION)); - $algorithm = $file->getAttribute('algorithm'); - $cipher = $file->getAttribute('fileOpenSSLCipher'); - $mime = $file->getAttribute('mimeType'); + $key = \md5($path.$width.$height.$quality.$background.$storage.$output); + } - if (!\in_array($mime, $inputs)) { - $path = (\array_key_exists($mime, $fileLogos)) ? $fileLogos[$mime] : $fileLogos['default']; - $algorithm = null; - $cipher = null; - $background = (empty($background)) ? 'eceff1' : $background; - $type = \strtolower(\pathinfo($path, PATHINFO_EXTENSION)); - $key = \md5($path.$width.$height.$quality.$background.$storage.$output); - } + $compressor = new GZIP(); + $device = Storage::getDevice('files'); - $compressor = new GZIP(); - $device = Storage::getDevice('local'); + if (!\file_exists($path)) { + throw new Exception('File not found', 404); + } - if (!\file_exists($path)) { - throw new Exception('File not found', 404); - } - - $cache = new Cache(new Filesystem(APP_STORAGE_CACHE.'/app-'.$project->getId())); // Limit file number or size - $data = $cache->load($key, 60 * 60 * 24 * 30 * 3 /* 3 months */); - - if ($data) { - $output = (empty($output)) ? $type : $output; - - $response - ->setContentType((\in_array($output, $outputs)) ? $outputs[$output] : $outputs['jpg']) - ->addHeader('Expires', $date) - ->addHeader('X-Appwrite-Cache', 'hit') - ->send($data) - ; - - return; - } - - $source = $device->read($path); - - if (!empty($cipher)) { // Decrypt - $source = OpenSSL::decrypt( - $source, - $file->getAttribute('fileOpenSSLCipher'), - $request->getServer('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')), - 0, - \hex2bin($file->getAttribute('fileOpenSSLIV')), - \hex2bin($file->getAttribute('fileOpenSSLTag')) - ); - } - - if (!empty($algorithm)) { - $source = $compressor->decompress($source); - } - - $resize = new Resize($source); - - $resize->crop((int) $width, (int) $height); - - if (!empty($background)) { - $resize->setBackground('#'.$background); - } + $cache = new Cache(new Filesystem(APP_STORAGE_CACHE.'/app-'.$project->getId())); // Limit file number or size + $data = $cache->load($key, 60 * 60 * 24 * 30 * 3 /* 3 months */); + if ($data) { $output = (empty($output)) ? $type : $output; - $data = $resize->output($output, $quality); - - $cache->save($key, $data); - - $response - ->setContentType($outputs[$output]) + return $response + ->setContentType((\array_key_exists($output, $outputs)) ? $outputs[$output] : $outputs['jpg']) ->addHeader('Expires', $date) - ->addHeader('X-Appwrite-Cache', 'miss') + ->addHeader('X-Appwrite-Cache', 'hit') ->send($data) ; - - unset($resize); } - ); -$utopia->get('/v1/storage/files/:fileId/download') + $source = $device->read($path); + + if (!empty($cipher)) { // Decrypt + $source = OpenSSL::decrypt( + $source, + $file->getAttribute('fileOpenSSLCipher'), + App::getEnv('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')), + 0, + \hex2bin($file->getAttribute('fileOpenSSLIV')), + \hex2bin($file->getAttribute('fileOpenSSLTag')) + ); + } + + if (!empty($algorithm)) { + $source = $compressor->decompress($source); + } + + $resize = new Resize($source); + + $resize->crop((int) $width, (int) $height); + + if (!empty($background)) { + $resize->setBackground('#'.$background); + } + + $output = (empty($output)) ? $type : $output; + + $data = $resize->output($output, $quality); + + $cache->save($key, $data); + + $response + ->setContentType($outputs[$output]) + ->addHeader('Expires', $date) + ->addHeader('X-Appwrite-Cache', 'miss') + ->send($data) + ; + + unset($resize); + }); + +App::get('/v1/storage/files/:fileId/download') ->desc('Get File for Download') ->groups(['api', 'storage']) ->label('scope', 'files.read') @@ -452,53 +364,57 @@ $utopia->get('/v1/storage/files/:fileId/download') ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFileDownload') ->label('sdk.description', '/docs/references/storage/get-file-download.md') - ->label('sdk.response.type', '*') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', '*/*') ->label('sdk.methodType', 'location') - ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') - ->action( - function ($fileId) use ($response, $request, $projectDB) { - $file = $projectDB->getDocument($fileId); + ->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 */ - if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { - throw new Exception('File not found', 404); - } + $file = $projectDB->getDocument($fileId); - $path = $file->getAttribute('path', ''); - - if (!\file_exists($path)) { - throw new Exception('File not found in '.$path, 404); - } - - $compressor = new GZIP(); - $device = Storage::getDevice('local'); - - $source = $device->read($path); - - if (!empty($file->getAttribute('fileOpenSSLCipher'))) { // Decrypt - $source = OpenSSL::decrypt( - $source, - $file->getAttribute('fileOpenSSLCipher'), - $request->getServer('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')), - 0, - \hex2bin($file->getAttribute('fileOpenSSLIV')), - \hex2bin($file->getAttribute('fileOpenSSLTag')) - ); - } - - $source = $compressor->decompress($source); - - // Response - $response - ->setContentType($file->getAttribute('mimeType')) - ->addHeader('Content-Disposition', 'attachment; filename="'.$file->getAttribute('name', '').'"') - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache - ->addHeader('X-Peak', \memory_get_peak_usage()) - ->send($source) - ; + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + throw new Exception('File not found', 404); } - ); -$utopia->get('/v1/storage/files/:fileId/view') + $path = $file->getAttribute('path', ''); + + if (!\file_exists($path)) { + throw new Exception('File not found in '.$path, 404); + } + + $compressor = new GZIP(); + $device = Storage::getDevice('files'); + + $source = $device->read($path); + + if (!empty($file->getAttribute('fileOpenSSLCipher'))) { // Decrypt + $source = OpenSSL::decrypt( + $source, + $file->getAttribute('fileOpenSSLCipher'), + App::getEnv('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')), + 0, + \hex2bin($file->getAttribute('fileOpenSSLIV')), + \hex2bin($file->getAttribute('fileOpenSSLTag')) + ); + } + + $source = $compressor->decompress($source); + + // Response + $response + ->setContentType($file->getAttribute('mimeType')) + ->addHeader('Content-Disposition', 'attachment; filename="'.$file->getAttribute('name', '').'"') + ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache + ->addHeader('X-Peak', \memory_get_peak_usage()) + ->send($source) + ; + }); + +App::get('/v1/storage/files/:fileId/view') ->desc('Get File for View') ->groups(['api', 'storage']) ->label('scope', 'files.read') @@ -506,159 +422,170 @@ $utopia->get('/v1/storage/files/:fileId/view') ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFileView') ->label('sdk.description', '/docs/references/storage/get-file-view.md') - ->label('sdk.response.type', '*') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', '*/*') ->label('sdk.methodType', 'location') - ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') - ->param('as', '', function () { return new WhiteList(['pdf', /*'html',*/ 'text']); }, 'Choose a file format to convert your file to. Currently you can only convert word and pdf files to pdf or txt. This option is currently experimental only, use at your own risk.', true) - ->action( - function ($fileId, $as) use ($response, $request, $projectDB, $mimes) { - $file = $projectDB->getDocument($fileId); + ->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 */ - if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { - throw new Exception('File not found', 404); - } + $file = $projectDB->getDocument($fileId); + $mimes = Config::getParam('storage-mimes'); - $path = $file->getAttribute('path', ''); - - if (!\file_exists($path)) { - throw new Exception('File not found in '.$path, 404); - } - - $compressor = new GZIP(); - $device = Storage::getDevice('local'); - - $contentType = 'text/plain'; - - if (\in_array($file->getAttribute('mimeType'), $mimes)) { - $contentType = $file->getAttribute('mimeType'); - } - - $source = $device->read($path); - - if (!empty($file->getAttribute('fileOpenSSLCipher'))) { // Decrypt - $source = OpenSSL::decrypt( - $source, - $file->getAttribute('fileOpenSSLCipher'), - $request->getServer('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')), - 0, - \hex2bin($file->getAttribute('fileOpenSSLIV')), - \hex2bin($file->getAttribute('fileOpenSSLTag')) - ); - } - - $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) - ->addHeader('Content-Security-Policy', 'script-src none;') - ->addHeader('X-Content-Type-Options', 'nosniff') - ->addHeader('Content-Disposition', 'inline; filename="'.$fileName.'"') - ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache - ->addHeader('X-Peak', \memory_get_peak_usage()) - ->send($output) - ; + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + throw new Exception('File not found', 404); } - ); -$utopia->put('/v1/storage/files/:fileId') + $path = $file->getAttribute('path', ''); + + if (!\file_exists($path)) { + throw new Exception('File not found in '.$path, 404); + } + + $compressor = new GZIP(); + $device = Storage::getDevice('files'); + + $contentType = 'text/plain'; + + if (\in_array($file->getAttribute('mimeType'), $mimes)) { + $contentType = $file->getAttribute('mimeType'); + } + + $source = $device->read($path); + + if (!empty($file->getAttribute('fileOpenSSLCipher'))) { // Decrypt + $source = OpenSSL::decrypt( + $source, + $file->getAttribute('fileOpenSSLCipher'), + App::getEnv('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')), + 0, + \hex2bin($file->getAttribute('fileOpenSSLIV')), + \hex2bin($file->getAttribute('fileOpenSSLTag')) + ); + } + + $output = $compressor->decompress($source); + $fileName = $file->getAttribute('name', ''); + + // Response + $response + ->setContentType($contentType) + ->addHeader('Content-Security-Policy', 'script-src none;') + ->addHeader('X-Content-Type-Options', 'nosniff') + ->addHeader('Content-Disposition', 'inline; filename="'.$fileName.'"') + ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache + ->addHeader('X-Peak', \memory_get_peak_usage()) + ->send($output) + ; + }); + +App::put('/v1/storage/files/:fileId') ->desc('Update File') ->groups(['api', 'storage']) ->label('scope', 'files.write') - ->label('webhook', 'storage.files.update') + ->label('event', 'storage.files.update') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'updateFile') ->label('sdk.description', '/docs/references/storage/update-file.md') - ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') - ->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - //->param('folderId', '', function () { return new UID(); }, 'Folder to associate files with.', true) - ->action( - function ($fileId, $read, $write, $folderId = '') use ($response, $projectDB, $audit, $webhook) { - $file = $projectDB->getDocument($fileId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_FILE) + ->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 */ + /** @var Appwrite\Event\Event $audits */ - if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { - throw new Exception('File not found', 404); - } + $file = $projectDB->getDocument($fileId); - $file = $projectDB->updateDocument(\array_merge($file->getArrayCopy(), [ - '$permissions' => [ - 'read' => $read, - 'write' => $write, - ], - 'folderId' => $folderId, - ])); - - if (false === $file) { - throw new Exception('Failed saving file to DB', 500); - } - - $webhook - ->setParam('payload', $file->getArrayCopy()) - ; - - $audit - ->setParam('event', 'storage.files.update') - ->setParam('resource', 'storage/files/'.$file->getId()) - ; - - $response->json($file->getArrayCopy()); + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + throw new Exception('File not found', 404); } - ); -$utopia->delete('/v1/storage/files/:fileId') + $file = $projectDB->updateDocument(\array_merge($file->getArrayCopy(), [ + '$permissions' => [ + 'read' => $read, + 'write' => $write, + ], + 'folderId' => '', + ])); + + if (false === $file) { + throw new Exception('Failed saving file to DB', 500); + } + + $audits + ->setParam('event', 'storage.files.update') + ->setParam('resource', 'storage/files/'.$file->getId()) + ; + + $response->dynamic($file, Response::MODEL_FILE); + }); + +App::delete('/v1/storage/files/:fileId') ->desc('Delete File') ->groups(['api', 'storage']) ->label('scope', 'files.write') - ->label('webhook', 'storage.files.delete') + ->label('event', 'storage.files.delete') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'deleteFile') ->label('sdk.description', '/docs/references/storage/delete-file.md') - ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') - ->action( - function ($fileId) use ($response, $projectDB, $webhook, $audit, $usage) { - $file = $projectDB->getDocument($fileId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Event\Event $events */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $usage */ + + $file = $projectDB->getDocument($fileId); - if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { - throw new Exception('File not found', 404); - } - - $device = Storage::getDevice('local'); - - if ($device->delete($file->getAttribute('path', ''))) { - if (!$projectDB->deleteDocument($fileId)) { - throw new Exception('Failed to remove file from DB', 500); - } - } - - $webhook - ->setParam('payload', $file->getArrayCopy()) - ; - - $audit - ->setParam('event', 'storage.files.delete') - ->setParam('resource', 'storage/files/'.$file->getId()) - ; - - $usage - ->setParam('storage', $file->getAttribute('size', 0) * -1) - ; - - $response->noContent(); + if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) { + throw new Exception('File not found', 404); } - ); -// $utopia->get('/v1/storage/files/:fileId/scan') + $device = Storage::getDevice('files'); + + if ($device->delete($file->getAttribute('path', ''))) { + if (!$projectDB->deleteDocument($fileId)) { + throw new Exception('Failed to remove file from DB', 500); + } + } + + $audits + ->setParam('event', 'storage.files.delete') + ->setParam('resource', 'storage/files/'.$file->getId()) + ; + + $usage + ->setParam('storage', $file->getAttribute('size', 0) * -1) + ; + + $events + ->setParam('payload', $response->output($file, Response::MODEL_FILE)) + ; + + $response->noContent(); + }); + +// App::get('/v1/storage/files/:fileId/scan') // ->desc('Scan Storage') // ->groups(['api', 'storage']) // ->label('scope', 'god') @@ -666,8 +593,8 @@ $utopia->delete('/v1/storage/files/:fileId') // ->label('sdk.namespace', 'storage') // ->label('sdk.method', 'getFileScan') // ->label('sdk.hide', true) -// ->param('fileId', '', function () { return new UID(); }, 'File unique ID.') -// ->param('storage', 'local', function () { return new WhiteList(['local']);}) +// ->param('fileId', '', new UID(), 'File unique ID.') +// ->param('storage', 'files', new WhiteList(['files']);}) // ->action( // function ($fileId, $storage) use ($response, $request, $projectDB) { // $file = $projectDB->getDocument($fileId); @@ -691,7 +618,7 @@ $utopia->delete('/v1/storage/files/:fileId') // $source = OpenSSL::decrypt( // $source, // $file->getAttribute('fileOpenSSLCipher'), -// $request->getServer('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')), +// App::getEnv('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')), // 0, // hex2bin($file->getAttribute('fileOpenSSLIV')), // hex2bin($file->getAttribute('fileOpenSSLTag')) @@ -706,6 +633,5 @@ $utopia->delete('/v1/storage/files/:fileId') // //var_dump($antiVirus->version()); // //var_dump($antiVirus->fileScan('/storage/uploads/app-1/5/9/f/e/59fecaed49645.pdf')); -// //$response->json($antiVirus->continueScan($device->getRoot())); // } // ); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index d2e8cda0ea..0d1340eea8 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1,9 +1,7 @@ post('/v1/teams') +App::post('/v1/teams') ->desc('Create Team') ->groups(['api', 'teams']) + ->label('event', 'teams.create') ->label('scope', 'teams.write') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') ->label('sdk.method', 'create') ->label('sdk.description', '/docs/references/teams/create-team.md') - ->param('name', null, function () { return new Text(100); }, 'Team name.') - ->param('roles', ['owner'], function () { return new ArrayList(new 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.') - ->action( - function ($name, $roles) use ($response, $projectDB, $user, $mode) { - Authorization::disable(); + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ + /** @var Appwrite\Database\Database $projectDB */ - $team = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_TEAMS, + Authorization::disable(); + + $isPreviliggedUser = Auth::isPreviliggedUser(Authorization::$roles); + $isAppUser = Auth::isAppUser(Authorization::$roles); + + $team = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_TEAMS, + '$permissions' => [ + 'read' => ['team:{self}'], + 'write' => ['team:{self}/owner'], + ], + 'name' => $name, + 'sum' => ($isPreviliggedUser || $isAppUser) ? 0 : 1, + 'dateCreated' => \time(), + ]); + + Authorization::reset(); + + if (false === $team) { + throw new Exception('Failed saving team to DB', 500); + } + + if (!$isPreviliggedUser && !$isAppUser) { // Don't add user on server mode + $membership = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, '$permissions' => [ - 'read' => ['team:{self}'], - 'write' => ['team:{self}/owner'], + 'read' => ['user:'.$user->getId(), 'team:'.$team->getId()], + 'write' => ['user:'.$user->getId(), 'team:'.$team->getId().'/owner'], ], - 'name' => $name, - 'sum' => ($mode !== APP_MODE_ADMIN && $user->getId()) ? 1 : 0, - 'dateCreated' => \time(), + 'userId' => $user->getId(), + 'teamId' => $team->getId(), + 'roles' => $roles, + 'invited' => \time(), + 'joined' => \time(), + 'confirm' => true, + 'secret' => '', ]); - Authorization::reset(); + // Attach user to team + $user->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND); - if (false === $team) { - throw new Exception('Failed saving team to DB', 500); + $user = $projectDB->updateDocument($user->getArrayCopy()); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); } - - if ($mode !== APP_MODE_ADMIN && $user->getId()) { // Don't add user on app/server mode - $membership = new Document([ - '$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, - '$permissions' => [ - 'read' => ['user:'.$user->getId(), 'team:'.$team->getId()], - 'write' => ['user:'.$user->getId(), 'team:'.$team->getId().'/owner'], - ], - 'userId' => $user->getId(), - 'teamId' => $team->getId(), - 'roles' => $roles, - 'invited' => \time(), - 'joined' => \time(), - 'confirm' => true, - 'secret' => '', - ]); - - // Attach user to team - $user->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND); - - $user = $projectDB->updateDocument($user->getArrayCopy()); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($team->getArrayCopy()) - ; } - ); -$utopia->get('/v1/teams') + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($team, Response::MODEL_TEAM) + ; + }); + +App::get('/v1/teams') ->desc('List Teams') ->groups(['api', 'teams']) ->label('scope', 'teams.read') @@ -93,29 +104,36 @@ $utopia->get('/v1/teams') ->label('sdk.namespace', 'teams') ->label('sdk.method', 'list') ->label('sdk.description', '/docs/references/teams/list-teams.md') - ->param('search', '', function () { return new Text(256); }, 'Search term to filter your list results.', true) - ->param('limit', 25, function () { return new Range(0, 100); }, 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0, function () { return new Range(0, 2000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true) - ->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true) - ->action( - function ($search, $limit, $offset, $orderType) use ($response, $projectDB) { - $results = $projectDB->getCollection([ - 'limit' => $limit, - 'offset' => $offset, - 'orderField' => 'dateCreated', - 'orderType' => $orderType, - 'orderCast' => 'int', - 'search' => $search, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_TEAMS, - ], - ]); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TEAM_LIST) + ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) + ->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 */ - $response->json(['sum' => $projectDB->getSum(), 'teams' => $results]); - } - ); + $results = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderType' => $orderType, + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_TEAMS, + ], + ]); -$utopia->get('/v1/teams/:teamId') + $response->dynamic(new Document([ + 'sum' => $projectDB->getSum(), + 'teams' => $results + ]), Response::MODEL_TEAM_LIST); + }); + +App::get('/v1/teams/:teamId') ->desc('Get Team') ->groups(['api', 'teams']) ->label('scope', 'teams.read') @@ -123,280 +141,318 @@ $utopia->get('/v1/teams/:teamId') ->label('sdk.namespace', 'teams') ->label('sdk.method', 'get') ->label('sdk.description', '/docs/references/teams/get-team.md') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->action( - function ($teamId) use ($response, $projectDB) { - $team = $projectDB->getDocument($teamId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ - if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } + $team = $projectDB->getDocument($teamId); - $response->json($team->getArrayCopy([])); + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + throw new Exception('Team not found', 404); } - ); -$utopia->put('/v1/teams/:teamId') + $response->dynamic($team, Response::MODEL_TEAM); + }); + +App::put('/v1/teams/:teamId') ->desc('Update Team') ->groups(['api', 'teams']) + ->label('event', 'teams.update') ->label('scope', 'teams.write') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') ->label('sdk.method', 'update') ->label('sdk.description', '/docs/references/teams/update-team.md') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('name', null, function () { return new Text(100); }, 'Team name.') - ->action( - function ($teamId, $name) use ($response, $projectDB) { - $team = $projectDB->getDocument($teamId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ - if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } + $team = $projectDB->getDocument($teamId); - $team = $projectDB->updateDocument(\array_merge($team->getArrayCopy(), [ - 'name' => $name, - ])); - - if (false === $team) { - throw new Exception('Failed saving team to DB', 500); - } - - $response->json($team->getArrayCopy()); + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + throw new Exception('Team not found', 404); } - ); -$utopia->delete('/v1/teams/:teamId') + $team = $projectDB->updateDocument(\array_merge($team->getArrayCopy(), [ + 'name' => $name, + ])); + + if (false === $team) { + throw new Exception('Failed saving team to DB', 500); + } + + $response->dynamic($team, Response::MODEL_TEAM); + }); + +App::delete('/v1/teams/:teamId') ->desc('Delete Team') ->groups(['api', 'teams']) + ->label('event', 'teams.delete') ->label('scope', 'teams.write') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') ->label('sdk.method', 'delete') ->label('sdk.description', '/docs/references/teams/delete-team.md') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->action( - function ($teamId) use ($response, $projectDB) { - $team = $projectDB->getDocument($teamId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Event\Event $events */ - if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } + $team = $projectDB->getDocument($teamId); - $memberships = $projectDB->getCollection([ - 'limit' => 2000, // TODO add members limit - 'offset' => 0, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS, - 'teamId='.$teamId, - ], - ]); - - foreach ($memberships as $member) { - if (!$projectDB->deleteDocument($member->getId())) { - throw new Exception('Failed to remove membership for team from DB', 500); - } - } - - if (!$projectDB->deleteDocument($teamId)) { - throw new Exception('Failed to remove team from DB', 500); - } - - $response->noContent(); + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + throw new Exception('Team not found', 404); } - ); -$utopia->post('/v1/teams/:teamId/memberships') + $memberships = $projectDB->getCollection([ + 'limit' => 2000, // TODO add members limit + 'offset' => 0, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS, + 'teamId='.$teamId, + ], + ]); + + foreach ($memberships as $member) { + if (!$projectDB->deleteDocument($member->getId())) { + throw new Exception('Failed to remove membership for team from DB', 500); + } + } + + if (!$projectDB->deleteDocument($teamId)) { + throw new Exception('Failed to remove team from DB', 500); + } + + $events + ->setParam('payload', $response->output($team, Response::MODEL_TEAM)) + ; + + $response->noContent(); + }); + +App::post('/v1/teams/:teamId/memberships') ->desc('Create Team Membership') ->groups(['api', 'teams']) + ->label('event', 'teams.memberships.create') ->label('scope', 'teams.write') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') ->label('sdk.method', 'createMembership') ->label('sdk.description', '/docs/references/teams/create-team-membership.md') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('email', '', function () { return new Email(); }, 'New team member email.') - ->param('name', '', function () { return new Text(100); }, 'New team member name.', true) - ->param('roles', [], function () { return 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 () use ($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.') // TODO add our own built-in confirm page - ->action( - function ($teamId, $email, $name, $roles, $url) use ($response, $mail, $project, $user, $audit, $projectDB, &$mode) { - $name = (empty($name)) ? $email : $name; - $team = $projectDB->getDocument($teamId); + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_MEMBERSHIP) + ->param('teamId', '', new UID(), 'Team unique ID.') + ->param('email', '', new Email(), 'New team member email.') + ->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 */ + /** @var Appwrite\Database\Document $user */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $mails */ - if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } + $isPreviliggedUser = Auth::isPreviliggedUser(Authorization::$roles); + $isAppUser = Auth::isAppUser(Authorization::$roles); - $memberships = $projectDB->getCollection([ - 'limit' => 50, - 'offset' => 0, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS, - 'teamId='.$team->getId(), - ], - ]); + $name = (empty($name)) ? $email : $name; + $team = $projectDB->getDocument($teamId); - $invitee = $projectDB->getCollectionFirst([ // Get user by email address - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + throw new Exception('Team not found', 404); + } - if (empty($invitee)) { // Create new user if no user with same email found + $memberships = $projectDB->getCollection([ + 'limit' => 50, + 'offset' => 0, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS, + 'teamId='.$team->getId(), + ], + ]); - Authorization::disable(); + $invitee = $projectDB->getCollectionFirst([ // Get user by email address + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); - try { - $invitee = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_USERS, - '$permissions' => [ - 'read' => ['user:{self}', '*'], - 'write' => ['user:{self}'], - ], - 'email' => $email, - 'emailVerification' => false, - 'status' => Auth::USER_STATUS_UNACTIVATED, - 'password' => Auth::passwordHash(Auth::passwordGenerator()), - 'password-update' => \time(), - 'registration' => \time(), - 'reset' => false, - 'name' => $name, - 'tokens' => [], - ], ['email' => $email]); - } catch (Duplicate $th) { - throw new Exception('Account already exists', 409); - } + if (empty($invitee)) { // Create new user if no user with same email found - Authorization::reset(); + Authorization::disable(); - if (false === $invitee) { - throw new Exception('Failed saving user to DB', 500); - } - } - - $isOwner = false; - - foreach ($memberships as $member) { - if ($member->getAttribute('userId') == $invitee->getId()) { - throw new Exception('User has already been invited or is already a member of this team', 409); - } - - if ($member->getAttribute('userId') == $user->getId() && \in_array('owner', $member->getAttribute('roles', []))) { - $isOwner = true; - } - } - - if (!$isOwner && APP_MODE_ADMIN !== $mode && $user->getId()) { // Not owner, not admin, not app (server) - throw new Exception('User is not allowed to send invitations for this team', 401); - } - - $secret = Auth::tokenGenerator(); - - $membership = new Document([ - '$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, - '$permissions' => [ - 'read' => ['*'], - 'write' => ['user:'.$invitee->getId(), 'team:'.$team->getId().'/owner'], - ], - 'userId' => $invitee->getId(), - 'teamId' => $team->getId(), - 'roles' => $roles, - 'invited' => \time(), - 'joined' => (APP_MODE_ADMIN === $mode || !$user->getId()) ? \time() : 0, - 'confirm' => (APP_MODE_ADMIN === $mode || !$user->getId()), - 'secret' => Auth::hash($secret), - ]); - - if (APP_MODE_ADMIN === $mode || !$user->getId()) { // Allow admin to create membership - Authorization::disable(); - $membership = $projectDB->createDocument($membership->getArrayCopy()); - - $team = $projectDB->updateDocument(\array_merge($team->getArrayCopy(), [ - 'sum' => $team->getAttribute('sum', 0) + 1, - ])); - - // Attach user to team - $invitee->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND); - - $invitee = $projectDB->updateDocument($invitee->getArrayCopy()); - - if (false === $invitee) { - throw new Exception('Failed saving user to DB', 500); - } - - Authorization::reset(); - } else { - $membership = $projectDB->createDocument($membership->getArrayCopy()); - } - - if (false === $membership) { - throw new Exception('Failed saving membership to DB', 500); - } - - $url = Template::parseURL($url); - $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['inviteId' => $membership->getId(), 'teamId' => $team->getId(), 'userId' => $invitee->getId(), 'secret' => $secret, 'teamId' => $teamId]); - $url = Template::unParseURL($url); - - $body = new Template(__DIR__.'/../../config/locales/templates/_base.tpl'); - $content = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.invitation.body')); - $cta = new Template(__DIR__.'/../../config/locales/templates/_cta.tpl'); - - $body - ->setParam('{{content}}', $content->render()) - ->setParam('{{cta}}', $cta->render()) - ->setParam('{{title}}', Locale::getText('account.emails.invitation.title')) - ->setParam('{{direction}}', Locale::getText('settings.direction')) - ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) - ->setParam('{{team}}', $team->getAttribute('name', '[TEAM-NAME]')) - ->setParam('{{owner}}', $user->getAttribute('name', '')) - ->setParam('{{redirect}}', $url) - ->setParam('{{bg-body}}', '#f6f6f6') - ->setParam('{{bg-content}}', '#ffffff') - ->setParam('{{bg-cta}}', '#3498db') - ->setParam('{{bg-cta-hover}}', '#34495e') - ->setParam('{{text-content}}', '#000000') - ->setParam('{{text-cta}}', '#ffffff') - ; - - if (APP_MODE_ADMIN !== $mode && $user->getId()) { // No need in comfirmation when in admin or app mode - $mail - ->setParam('event', 'teams.membership.create') - ->setParam('recipient', $email) - ->setParam('name', $name) - ->setParam('subject', \sprintf(Locale::getText('account.emails.invitation.title'), $team->getAttribute('name', '[TEAM-NAME]'), $project->getAttribute('name', ['[APP-NAME]']))) - ->setParam('body', $body->render()) - ->trigger(); - ; - } - - $audit - ->setParam('userId', $invitee->getId()) - ->setParam('event', 'teams.membership.create') - ->setParam('resource', 'teams/'.$teamId) - ; - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) // TODO change response of this endpoint - ->json(\array_merge($membership->getArrayCopy([ - '$id', - 'userId', - 'teamId', - 'roles', - 'invited', - 'joined', - 'confirm', - ]), [ + try { + $invitee = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_USERS, + '$permissions' => [ + 'read' => ['user:{self}', '*'], + 'write' => ['user:{self}'], + ], 'email' => $email, + 'emailVerification' => false, + 'status' => Auth::USER_STATUS_UNACTIVATED, + 'password' => Auth::passwordHash(Auth::passwordGenerator()), + 'passwordUpdate' => \time(), + 'registration' => \time(), + 'reset' => false, 'name' => $name, - ])) + 'tokens' => [], + ], ['email' => $email]); + } catch (Duplicate $th) { + throw new Exception('Account already exists', 409); + } + + Authorization::reset(); + + if (false === $invitee) { + throw new Exception('Failed saving user to DB', 500); + } + } + + $isOwner = false; + + foreach ($memberships as $member) { + if ($member->getAttribute('userId') == $invitee->getId()) { + throw new Exception('User has already been invited or is already a member of this team', 409); + } + + if ($member->getAttribute('userId') == $user->getId() && \in_array('owner', $member->getAttribute('roles', []))) { + $isOwner = true; + } + } + + if (!$isOwner && !$isPreviliggedUser && !$isAppUser) { // Not owner, not admin, not app (server) + throw new Exception('User is not allowed to send invitations for this team', 401); + } + + $secret = Auth::tokenGenerator(); + + $membership = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, + '$permissions' => [ + 'read' => ['*'], + 'write' => ['user:'.$invitee->getId(), 'team:'.$team->getId().'/owner'], + ], + 'userId' => $invitee->getId(), + 'teamId' => $team->getId(), + 'roles' => $roles, + 'invited' => \time(), + 'joined' => ($isPreviliggedUser || $isAppUser) ? \time() : 0, + 'confirm' => ($isPreviliggedUser || $isAppUser), + 'secret' => Auth::hash($secret), + ]); + + if ($isPreviliggedUser || $isAppUser) { // Allow admin to create membership + Authorization::disable(); + $membership = $projectDB->createDocument($membership->getArrayCopy()); + + $team = $projectDB->updateDocument(\array_merge($team->getArrayCopy(), [ + 'sum' => $team->getAttribute('sum', 0) + 1, + ])); + + // Attach user to team + $invitee->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND); + + $invitee = $projectDB->updateDocument($invitee->getArrayCopy()); + + if (false === $invitee) { + throw new Exception('Failed saving user to DB', 500); + } + + Authorization::reset(); + } else { + $membership = $projectDB->createDocument($membership->getArrayCopy()); + } + + if (false === $membership) { + throw new Exception('Failed saving membership to DB', 500); + } + + $url = Template::parseURL($url); + $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['inviteId' => $membership->getId(), 'teamId' => $team->getId(), 'userId' => $invitee->getId(), 'secret' => $secret, 'teamId' => $teamId]); + $url = Template::unParseURL($url); + + $body = new Template(__DIR__.'/../../config/locale/templates/email-base.tpl'); + $content = new Template(__DIR__.'/../../config/locale/translations/templates/'.$locale->getText('account.emails.invitation.body')); + $cta = new Template(__DIR__.'/../../config/locale/templates/email-cta.tpl'); + $title = \sprintf($locale->getText('account.emails.invitation.title'), $team->getAttribute('name', '[TEAM-NAME]'), $project->getAttribute('name', ['[APP-NAME]'])); + + $body + ->setParam('{{content}}', $content->render()) + ->setParam('{{cta}}', $cta->render()) + ->setParam('{{title}}', $title) + ->setParam('{{direction}}', $locale->getText('settings.direction')) + ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) + ->setParam('{{team}}', $team->getAttribute('name', '[TEAM-NAME]')) + ->setParam('{{owner}}', $user->getAttribute('name', '')) + ->setParam('{{redirect}}', $url) + ->setParam('{{bg-body}}', '#f6f6f6') + ->setParam('{{bg-content}}', '#ffffff') + ->setParam('{{bg-cta}}', '#3498db') + ->setParam('{{bg-cta-hover}}', '#34495e') + ->setParam('{{text-content}}', '#000000') + ->setParam('{{text-cta}}', '#ffffff') + ; + + if (!$isPreviliggedUser && !$isAppUser) { // No need in comfirmation when in admin or app mode + $mails + ->setParam('event', 'teams.membership.create') + ->setParam('from', ($project->getId() === 'console') ? '' : \sprintf($locale->getText('account.emails.team'), $project->getAttribute('name'))) + ->setParam('recipient', $email) + ->setParam('name', $name) + ->setParam('subject', $title) + ->setParam('body', $body->render()) + ->trigger() ; } - ); -$utopia->get('/v1/teams/:teamId/memberships') + $audits + ->setParam('userId', $invitee->getId()) + ->setParam('event', 'teams.membership.create') + ->setParam('resource', 'teams/'.$teamId) + ; + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic(new Document(\array_merge($membership->getArrayCopy(), [ + 'email' => $email, + 'name' => $name, + ])), Response::MODEL_MEMBERSHIP) + ; + }); + +App::get('/v1/teams/:teamId/memberships') ->desc('Get Team Memberships') ->groups(['api', 'teams']) ->label('scope', 'teams.read') @@ -404,236 +460,299 @@ $utopia->get('/v1/teams/:teamId/memberships') ->label('sdk.namespace', 'teams') ->label('sdk.method', 'getMemberships') ->label('sdk.description', '/docs/references/teams/get-team-members.md') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('search', '', function () { return new Text(256); }, 'Search term to filter your list results.', true) - ->param('limit', 25, function () { return new Range(0, 100); }, 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0, function () { return new Range(0, 2000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true) - ->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true) - ->action( - function ($teamId, $search, $limit, $offset, $orderType) use ($response, $projectDB) { - $team = $projectDB->getDocument($teamId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_MEMBERSHIP_LIST) + ->param('teamId', '', new UID(), 'Team unique ID.') + ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) + ->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 */ - if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } + $team = $projectDB->getDocument($teamId); - $memberships = $projectDB->getCollection([ - 'limit' => $limit, - 'offset' => $offset, - 'orderField' => 'joined', - 'orderType' => $orderType, - 'orderCast' => 'int', - 'search' => $search, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS, - 'teamId='.$teamId, - ], - ]); - - $users = []; - - foreach ($memberships as $membership) { - if (empty($membership->getAttribute('userId', null))) { - continue; - } - - $temp = $projectDB->getDocument($membership->getAttribute('userId', null))->getArrayCopy(['email', 'name']); - - $users[] = \array_merge($temp, $membership->getArrayCopy([ - '$id', - 'userId', - 'teamId', - 'roles', - 'invited', - 'joined', - 'confirm', - ])); - } - - $response->json(['sum' => $projectDB->getSum(), 'memberships' => $users]); + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + throw new Exception('Team not found', 404); } - ); -$utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status') + $memberships = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderType' => $orderType, + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS, + 'teamId='.$teamId, + ], + ]); + $users = []; + + foreach ($memberships as $membership) { + if (empty($membership->getAttribute('userId', null))) { + continue; + } + + $temp = $projectDB->getDocument($membership->getAttribute('userId', null))->getArrayCopy(['email', 'name']); + + $users[] = new Document(\array_merge($temp, $membership->getArrayCopy())); + } + + $response->dynamic(new Document(['sum' => $projectDB->getSum(), 'memberships' => $users]), Response::MODEL_MEMBERSHIP_LIST); + }); + +App::patch('/v1/teams/:teamId/memberships/:inviteId/status') ->desc('Update Team Membership Status') ->groups(['api', 'teams']) + ->label('event', 'teams.memberships.update.status') ->label('scope', 'public') ->label('sdk.platform', [APP_PLATFORM_CLIENT]) ->label('sdk.namespace', 'teams') ->label('sdk.method', 'updateMembershipStatus') ->label('sdk.description', '/docs/references/teams/update-team-membership-status.md') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('inviteId', '', function () { return new UID(); }, 'Invite unique ID.') - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->param('secret', '', function () { return new Text(256); }, 'Secret key.') - ->action( - function ($teamId, $inviteId, $userId, $secret) use ($response, $request, $user, $audit, $projectDB) { - $protocol = Config::getParam('protocol'); - $membership = $projectDB->getDocument($inviteId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_MEMBERSHIP) + ->param('teamId', '', new UID(), 'Team unique ID.') + ->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 */ + /** @var Appwrite\Database\Document $user */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var MaxMind\Db\Reader $geodb */ + /** @var Appwrite\Event\Event $audits */ - if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) { - throw new Exception('Invite not found', 404); - } + $protocol = $request->getProtocol(); + $membership = $projectDB->getDocument($inviteId); - if ($membership->getAttribute('teamId') !== $teamId) { - throw new Exception('Team IDs don\'t match', 404); - } + if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) { + throw new Exception('Invite not found', 404); + } - Authorization::disable(); + if ($membership->getAttribute('teamId') !== $teamId) { + throw new Exception('Team IDs don\'t match', 404); + } - $team = $projectDB->getDocument($teamId); - - Authorization::reset(); + Authorization::disable(); - if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } + $team = $projectDB->getDocument($teamId); + + Authorization::reset(); - if (Auth::hash($secret) !== $membership->getAttribute('secret')) { - throw new Exception('Secret key not valid', 401); - } + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + throw new Exception('Team not found', 404); + } - if ($userId != $membership->getAttribute('userId')) { - throw new Exception('Invite not belong to current user ('.$user->getAttribute('email').')', 401); - } + if (Auth::hash($secret) !== $membership->getAttribute('secret')) { + throw new Exception('Secret key not valid', 401); + } - if (empty($user->getId())) { - $user = $projectDB->getCollectionFirst([ // Get user - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - '$id='.$userId, - ], - ]); - } + if ($userId != $membership->getAttribute('userId')) { + throw new Exception('Invite not belong to current user ('.$user->getAttribute('email').')', 401); + } - if ($membership->getAttribute('userId') !== $user->getId()) { - throw new Exception('Invite not belong to current user ('.$user->getAttribute('email').')', 401); - } + if (empty($user->getId())) { + $user = $projectDB->getCollectionFirst([ // Get user + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + '$id='.$userId, + ], + ]); + } - $membership // Attach user to team - ->setAttribute('joined', \time()) - ->setAttribute('confirm', true) + if ($membership->getAttribute('userId') !== $user->getId()) { + throw new Exception('Invite not belong to current user ('.$user->getAttribute('email').')', 401); + } + + $membership // Attach user to team + ->setAttribute('joined', \time()) + ->setAttribute('confirm', true) + ; + + $user + ->setAttribute('emailVerification', true) + ->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND) + ; + + // Log user in + + $dd = new DeviceDetector($request->getUserAgent('UNKNOWN')); + + $dd->parse(); + + $os = $dd->getOs(); + $osCode = (isset($os['short_name'])) ? $os['short_name'] : ''; + $osName = (isset($os['name'])) ? $os['name'] : ''; + $osVersion = (isset($os['version'])) ? $os['version'] : ''; + + $client = $dd->getClient(); + $clientType = (isset($client['type'])) ? $client['type'] : ''; + $clientCode = (isset($client['short_name'])) ? $client['short_name'] : ''; + $clientName = (isset($client['name'])) ? $client['name'] : ''; + $clientVersion = (isset($client['version'])) ? $client['version'] : ''; + $clientEngine = (isset($client['engine'])) ? $client['engine'] : ''; + $clientEngineVersion = (isset($client['engine_version'])) ? $client['engine_version'] : ''; + + $expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; + $secret = Auth::tokenGenerator(); + + $session = new Document([ + '$collection' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['user:'.$user->getId()], 'write' => ['user:'.$user->getId()]], + 'userId' => $user->getId(), + 'type' => Auth::TOKEN_TYPE_LOGIN, + 'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak + 'expire' => $expiry, + 'userAgent' => $request->getUserAgent('UNKNOWN'), + 'ip' => $request->getIP(), + + 'osCode' => $osCode, + 'osName' => $osName, + 'osVersion' => $osVersion, + 'clientType' => $clientType, + 'clientCode' => $clientCode, + 'clientName' => $clientName, + 'clientVersion' => $clientVersion, + 'clientEngine' => $clientEngine, + 'clientEngineVersion' => $clientEngineVersion, + 'deviceName' => $dd->getDeviceName(), + 'deviceBrand' => $dd->getBrandName(), + 'deviceModel' => $dd->getModel(), + ]); + + $record = $geodb->get($request->getIP()); + + if($record) { + $session + ->setAttribute('countryCode', \strtolower($record['country']['iso_code'])) ; - - $user - ->setAttribute('emailVerification', true) - ->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND) - ; - - // Log user in - $expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG; - $secret = Auth::tokenGenerator(); - - $user->setAttribute('tokens', new Document([ - '$collection' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['user:'.$user->getId()], 'write' => ['user:'.$user->getId()]], - 'type' => Auth::TOKEN_TYPE_LOGIN, - 'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak - 'expire' => $expiry, - 'userAgent' => $request->getServer('HTTP_USER_AGENT', 'UNKNOWN'), - 'ip' => $request->getIP(), - ]), Document::SET_TYPE_APPEND); - - Authorization::setRole('user:'.$userId); - - $user = $projectDB->updateDocument($user->getArrayCopy()); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - Authorization::disable(); - - $team = $projectDB->updateDocument(\array_merge($team->getArrayCopy(), [ - 'sum' => $team->getAttribute('sum', 0) + 1, - ])); - - Authorization::reset(); - - if (false === $team) { - throw new Exception('Failed saving team to DB', 500); - } - - $audit - ->setParam('userId', $user->getId()) - ->setParam('event', 'teams.membership.update') - ->setParam('resource', 'teams/'.$teamId) - ; - - if (!Config::getParam('domainVerification')) { - $response - ->addHeader('X-Fallback-Cookies', \json_encode([Auth::$cookieName => Auth::encodeSession($user->getId(), $secret)])) - ; - } - - $response - ->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $protocol), true, null) - ->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $protocol), true, COOKIE_SAMESITE) - ->json(\array_merge($membership->getArrayCopy([ - '$id', - 'userId', - 'teamId', - 'roles', - 'invited', - 'joined', - 'confirm', - ]), [ - 'email' => $user->getAttribute('email'), - 'name' => $user->getAttribute('name'), - ])) + } else { + $session + ->setAttribute('countryCode', '--') ; } - ); -$utopia->delete('/v1/teams/:teamId/memberships/:inviteId') + $user->setAttribute('tokens', $session, Document::SET_TYPE_APPEND); + + Authorization::setRole('user:'.$userId); + + $user = $projectDB->updateDocument($user->getArrayCopy()); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + Authorization::disable(); + + $team = $projectDB->updateDocument(\array_merge($team->getArrayCopy(), [ + 'sum' => $team->getAttribute('sum', 0) + 1, + ])); + + Authorization::reset(); + + if (false === $team) { + throw new Exception('Failed saving team to DB', 500); + } + + $audits + ->setParam('userId', $user->getId()) + ->setParam('event', 'teams.membership.update') + ->setParam('resource', 'teams/'.$teamId) + ; + + if (!Config::getParam('domainVerification')) { + $response + ->addHeader('X-Fallback-Cookies', \json_encode([Auth::$cookieName => Auth::encodeSession($user->getId(), $secret)])) + ; + } + + $response + ->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getId(), $secret), $expiry, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, null) + ->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite')) + ; + + $response->dynamic(new Document(\array_merge($membership->getArrayCopy(), [ + 'email' => $user->getAttribute('email'), + 'name' => $user->getAttribute('name'), + ])), Response::MODEL_MEMBERSHIP); + }); + +App::delete('/v1/teams/:teamId/memberships/:inviteId') ->desc('Delete Team Membership') ->groups(['api', 'teams']) + ->label('event', 'teams.memberships.delete') ->label('scope', 'teams.write') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'teams') ->label('sdk.method', 'deleteMembership') ->label('sdk.description', '/docs/references/teams/delete-team-membership.md') - ->param('teamId', '', function () { return new UID(); }, 'Team unique ID.') - ->param('inviteId', '', function () { return new UID(); }, 'Invite unique ID.') - ->action( - function ($teamId, $inviteId) use ($response, $projectDB, $audit) { - $membership = $projectDB->getDocument($inviteId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->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 */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $events */ - if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) { - throw new Exception('Invite not found', 404); - } + $membership = $projectDB->getDocument($inviteId); - if ($membership->getAttribute('teamId') !== $teamId) { - throw new Exception('Team IDs don\'t match', 404); - } - - $team = $projectDB->getDocument($teamId); - - if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { - throw new Exception('Team not found', 404); - } - - if (!$projectDB->deleteDocument($membership->getId())) { - throw new Exception('Failed to remove membership from DB', 500); - } - - if ($membership->getAttribute('confirm')) { // Count only confirmed members - $team = $projectDB->updateDocument(\array_merge($team->getArrayCopy(), [ - 'sum' => $team->getAttribute('sum', 0) - 1, - ])); - } - - if (false === $team) { - throw new Exception('Failed saving team to DB', 500); - } - - $audit - ->setParam('userId', $membership->getAttribute('userId')) - ->setParam('event', 'teams.membership.delete') - ->setParam('resource', 'teams/'.$teamId) - ; - - $response->noContent(); + if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) { + throw new Exception('Invite not found', 404); } - ); + + if ($membership->getAttribute('teamId') !== $teamId) { + throw new Exception('Team IDs don\'t match', 404); + } + + $team = $projectDB->getDocument($teamId); + + if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) { + throw new Exception('Team not found', 404); + } + + if (!$projectDB->deleteDocument($membership->getId())) { + throw new Exception('Failed to remove membership from DB', 500); + } + + if ($membership->getAttribute('confirm')) { // Count only confirmed members + $team = $projectDB->updateDocument(\array_merge($team->getArrayCopy(), [ + 'sum' => $team->getAttribute('sum', 0) - 1, + ])); + } + + if (false === $team) { + throw new Exception('Failed saving team to DB', 500); + } + + $audits + ->setParam('userId', $membership->getAttribute('userId')) + ->setParam('event', 'teams.membership.delete') + ->setParam('resource', 'teams/'.$teamId) + ; + + $events + ->setParam('payload', $response->output($membership, Response::MODEL_MEMBERSHIP)) + ; + + $response->noContent(); + }); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 74a257d299..efb0041cee 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -1,9 +1,7 @@ post('/v1/users') +App::post('/v1/users') ->desc('Create User') ->groups(['api', 'users']) + ->label('event', 'users.create') ->label('scope', 'users.write') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') ->label('sdk.method', 'create') ->label('sdk.description', '/docs/references/users/create-user.md') - ->param('email', '', function () { return new Email(); }, 'User email.') - ->param('password', '', function () { return new Password(); }, 'User password. Must be between 6 to 32 chars.') - ->param('name', '', function () { return new Text(100); }, 'User name.', true) - ->action( - function ($email, $password, $name) use ($response, $projectDB) { - $profile = $projectDB->getCollectionFirst([ // Get user by email address - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - 'email='.$email, - ], - ]); + ->label('sdk.response.code', Response::STATUS_CODE_CREATED) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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.') + ->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 */ - if (!empty($profile)) { - throw new Exception('User already registered', 409); - } + $profile = $projectDB->getCollectionFirst([ // Get user by email address + 'limit' => 1, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + 'email='.$email, + ], + ]); - try { - $user = $projectDB->createDocument([ - '$collection' => Database::SYSTEM_COLLECTION_USERS, - '$permissions' => [ - 'read' => ['*'], - 'write' => ['user:{self}'], - ], - 'email' => $email, - 'emailVerification' => false, - 'status' => Auth::USER_STATUS_UNACTIVATED, - 'password' => Auth::passwordHash($password), - 'password-update' => \time(), - 'registration' => \time(), - 'reset' => false, - 'name' => $name, - ], ['email' => $email]); - } catch (Duplicate $th) { - throw new Exception('Account already exists', 409); - } - - $oauth2Keys = []; - - foreach (Config::getParam('providers') as $key => $provider) { - if (!$provider['enabled']) { - continue; - } - - $oauth2Keys[] = 'oauth2'.\ucfirst($key); - $oauth2Keys[] = 'oauth2'.\ucfirst($key).'AccessToken'; - } - - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json(\array_merge($user->getArrayCopy(\array_merge([ - '$id', - 'status', - 'email', - 'registration', - 'emailVerification', - 'name', - ], $oauth2Keys)), ['roles' => []])); + if (!empty($profile)) { + throw new Exception('User already registered', 409); } - ); - -$utopia->get('/v1/users') + + try { + $user = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_USERS, + '$permissions' => [ + 'read' => ['*'], + 'write' => ['user:{self}'], + ], + 'email' => $email, + 'emailVerification' => false, + 'status' => Auth::USER_STATUS_UNACTIVATED, + 'password' => Auth::passwordHash($password), + 'passwordUpdate' => \time(), + 'registration' => \time(), + 'reset' => false, + 'name' => $name, + ], ['email' => $email]); + } catch (Duplicate $th) { + throw new Exception('Account already exists', 409); + } + + $response + ->setStatusCode(Response::STATUS_CODE_CREATED) + ->dynamic($user, Response::MODEL_USER) + ; + }); + +App::get('/v1/users') ->desc('List Users') ->groups(['api', 'users']) ->label('scope', 'users.read') @@ -98,54 +85,36 @@ $utopia->get('/v1/users') ->label('sdk.namespace', 'users') ->label('sdk.method', 'list') ->label('sdk.description', '/docs/references/users/list-users.md') - ->param('search', '', function () { return new Text(256); }, 'Search term to filter your list results.', true) - ->param('limit', 25, function () { return new Range(0, 100); }, 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0, function () { return new Range(0, 2000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true) - ->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true) - ->action( - function ($search, $limit, $offset, $orderType) use ($response, $projectDB) { - $results = $projectDB->getCollection([ - 'limit' => $limit, - 'offset' => $offset, - 'orderField' => 'registration', - 'orderType' => $orderType, - 'orderCast' => 'int', - 'search' => $search, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_USERS, - ], - ]); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_USER_LIST) + ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) + ->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 */ - $oauth2Keys = []; + $results = $projectDB->getCollection([ + 'limit' => $limit, + 'offset' => $offset, + 'orderType' => $orderType, + 'search' => $search, + 'filters' => [ + '$collection='.Database::SYSTEM_COLLECTION_USERS, + ], + ]); - foreach (Config::getParam('providers') as $key => $provider) { - if (!$provider['enabled']) { - continue; - } + $response->dynamic(new Document([ + 'sum' => $projectDB->getSum(), + 'users' => $results + ]), Response::MODEL_USER_LIST); + }); - $oauth2Keys[] = 'oauth2'.\ucfirst($key); - $oauth2Keys[] = 'oauth2'.\ucfirst($key).'AccessToken'; - } - - $results = \array_map(function ($value) use ($oauth2Keys) { /* @var $value \Database\Document */ - return $value->getArrayCopy(\array_merge( - [ - '$id', - 'status', - 'email', - 'registration', - 'emailVerification', - 'name', - ], - $oauth2Keys - )); - }, $results); - - $response->json(['sum' => $projectDB->getSum(), 'users' => $results]); - } - ); - -$utopia->get('/v1/users/:userId') +App::get('/v1/users/:userId') ->desc('Get User') ->groups(['api', 'users']) ->label('scope', 'users.read') @@ -153,41 +122,26 @@ $utopia->get('/v1/users/:userId') ->label('sdk.namespace', 'users') ->label('sdk.method', 'get') ->label('sdk.description', '/docs/references/users/get-user.md') - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->action( - function ($userId) use ($response, $projectDB) { - $user = $projectDB->getDocument($userId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ - if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { - throw new Exception('User not found', 404); - } + $user = $projectDB->getDocument($userId); - $oauth2Keys = []; - - foreach (Config::getParam('providers') as $key => $provider) { - if (!$provider['enabled']) { - continue; - } - - $oauth2Keys[] = 'oauth2'.\ucfirst($key); - $oauth2Keys[] = 'oauth2'.\ucfirst($key).'AccessToken'; - } - - $response->json(\array_merge($user->getArrayCopy(\array_merge( - [ - '$id', - 'status', - 'email', - 'registration', - 'emailVerification', - 'name', - ], - $oauth2Keys - )), ['roles' => []])); + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + throw new Exception('User not found', 404); } - ); -$utopia->get('/v1/users/:userId/prefs') + $response->dynamic($user, Response::MODEL_USER); + }); + +App::get('/v1/users/:userId/prefs') ->desc('Get User Preferences') ->groups(['api', 'users']) ->label('scope', 'users.read') @@ -195,29 +149,28 @@ $utopia->get('/v1/users/:userId/prefs') ->label('sdk.namespace', 'users') ->label('sdk.method', 'getPrefs') ->label('sdk.description', '/docs/references/users/get-user-prefs.md') - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->action( - function ($userId) use ($response, $projectDB) { - $user = $projectDB->getDocument($userId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ - if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { - throw new Exception('User not found', 404); - } + $user = $projectDB->getDocument($userId); - $prefs = $user->getAttribute('prefs', ''); - - try { - $prefs = \json_decode($prefs, true); - $prefs = ($prefs) ? $prefs : []; - } catch (\Exception $error) { - throw new Exception('Failed to parse prefs', 500); - } - - $response->json($prefs); + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + throw new Exception('User not found', 404); } - ); -$utopia->get('/v1/users/:userId/sessions') + $prefs = $user->getAttribute('prefs', new \stdClass()); + + $response->dynamic(new Document($prefs), Response::MODEL_ANY); + }); + +App::get('/v1/users/:userId/sessions') ->desc('Get User Sessions') ->groups(['api', 'users']) ->label('scope', 'users.read') @@ -225,63 +178,48 @@ $utopia->get('/v1/users/:userId/sessions') ->label('sdk.namespace', 'users') ->label('sdk.method', 'getSessions') ->label('sdk.description', '/docs/references/users/get-user-sessions.md') - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->action( - function ($userId) use ($response, $projectDB) { - $user = $projectDB->getDocument($userId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ + /** @var Utopia\Locale\Locale $locale */ - if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { - throw new Exception('User not found', 404); - } + $user = $projectDB->getDocument($userId); - $tokens = $user->getAttribute('tokens', []); - $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); - $sessions = []; - $index = 0; - $countries = Locale::getText('countries'); - - foreach ($tokens as $token) { /* @var $token Document */ - if (Auth::TOKEN_TYPE_LOGIN != $token->getAttribute('type')) { - continue; - } - - $userAgent = (!empty($token->getAttribute('userAgent'))) ? $token->getAttribute('userAgent') : 'UNKNOWN'; - - $dd = new DeviceDetector($userAgent); - - // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) - // $dd->skipBotDetection(); - - $dd->parse(); - - $sessions[$index] = [ - '$id' => $token->getId(), - 'OS' => $dd->getOs(), - 'client' => $dd->getClient(), - 'device' => $dd->getDevice(), - 'brand' => $dd->getBrand(), - 'model' => $dd->getModel(), - 'ip' => $token->getAttribute('ip', ''), - 'geo' => [], - ]; - - try { - $record = $reader->country($token->getAttribute('ip', '')); - $sessions[$index]['geo']['isoCode'] = \strtolower($record->country->isoCode); - $sessions[$index]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); - } catch (\Exception $e) { - $sessions[$index]['geo']['isoCode'] = '--'; - $sessions[$index]['geo']['country'] = Locale::getText('locale.country.unknown'); - } - - ++$index; - } - - $response->json($sessions); + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + throw new Exception('User not found', 404); } - ); -$utopia->get('/v1/users/:userId/logs') + $tokens = $user->getAttribute('tokens', []); + $sessions = []; + $countries = $locale->getText('countries'); + + foreach ($tokens as $token) { /* @var $token Document */ + if (Auth::TOKEN_TYPE_LOGIN != $token->getAttribute('type')) { + continue; + } + + $token->setAttribute('countryName', (isset($countries[$token->getAttribute('contryCode')])) + ? $countries[$token->getAttribute('contryCode')] + : $locale->getText('locale.country.unknown')); + $token->setAttribute('current', false); + + $sessions[] = $token; + } + + $response->dynamic(new Document([ + 'sum' => count($sessions), + 'sessions' => $sessions + ]), Response::MODEL_SESSION_LIST); + }, ['response', 'projectDB', 'locale']); + +App::get('/v1/users/:userId/logs') ->desc('Get User Logs') ->groups(['api', 'users']) ->label('scope', 'users.read') @@ -289,129 +227,150 @@ $utopia->get('/v1/users/:userId/logs') ->label('sdk.namespace', 'users') ->label('sdk.method', 'getLogs') ->label('sdk.description', '/docs/references/users/get-user-logs.md') - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->action( - function ($userId) use ($response, $register, $projectDB, $project) { - $user = $projectDB->getDocument($userId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->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 */ + /** @var Appwrite\Database\Document $project */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var Utopia\Locale\Locale $locale */ + /** @var MaxMind\Db\Reader $geodb */ + + $user = $projectDB->getDocument($userId); - if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { - throw new Exception('User not found', 404); - } + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + throw new Exception('User not found', 404); + } - $adapter = new AuditAdapter($register->get('db')); - $adapter->setNamespace('app_'.$project->getId()); + $adapter = new AuditAdapter($register->get('db')); + $adapter->setNamespace('app_'.$project->getId()); - $audit = new Audit($adapter); - - $countries = Locale::getText('countries'); + $audit = new Audit($adapter); + + $countries = $locale->getText('countries'); - $logs = $audit->getLogsByUserAndActions($user->getId(), [ - 'account.create', - 'account.delete', - 'account.update.name', - 'account.update.email', - 'account.update.password', - 'account.update.prefs', - 'account.sessions.create', - 'account.sessions.delete', - 'account.recovery.create', - 'account.recovery.update', - 'account.verification.create', - 'account.verification.update', - 'teams.membership.create', - 'teams.membership.update', - 'teams.membership.delete', + $logs = $audit->getLogsByUserAndActions($user->getId(), [ + 'account.create', + 'account.delete', + 'account.update.name', + 'account.update.email', + 'account.update.password', + 'account.update.prefs', + 'account.sessions.create', + 'account.sessions.delete', + 'account.recovery.create', + 'account.recovery.update', + 'account.verification.create', + 'account.verification.update', + 'teams.membership.create', + 'teams.membership.update', + 'teams.membership.delete', + ]); + + $output = []; + + foreach ($logs as $i => &$log) { + $log['userAgent'] = (!empty($log['userAgent'])) ? $log['userAgent'] : 'UNKNOWN'; + + $dd = new DeviceDetector($log['userAgent']); + + $dd->skipBotDetection(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) + + $dd->parse(); + + $os = $dd->getOs(); + $osCode = (isset($os['short_name'])) ? $os['short_name'] : ''; + $osName = (isset($os['name'])) ? $os['name'] : ''; + $osVersion = (isset($os['version'])) ? $os['version'] : ''; + + $client = $dd->getClient(); + $clientType = (isset($client['type'])) ? $client['type'] : ''; + $clientCode = (isset($client['short_name'])) ? $client['short_name'] : ''; + $clientName = (isset($client['name'])) ? $client['name'] : ''; + $clientVersion = (isset($client['version'])) ? $client['version'] : ''; + $clientEngine = (isset($client['engine'])) ? $client['engine'] : ''; + $clientEngineVersion = (isset($client['engine_version'])) ? $client['engine_version'] : ''; + + $output[$i] = new Document([ + 'event' => $log['event'], + 'ip' => $log['ip'], + 'time' => \strtotime($log['time']), + + 'osCode' => $osCode, + 'osName' => $osName, + 'osVersion' => $osVersion, + 'clientType' => $clientType, + 'clientCode' => $clientCode, + 'clientName' => $clientName, + 'clientVersion' => $clientVersion, + 'clientEngine' => $clientEngine, + 'clientEngineVersion' => $clientEngineVersion, + 'deviceName' => $dd->getDeviceName(), + 'deviceBrand' => $dd->getBrandName(), + 'deviceModel' => $dd->getModel(), ]); - $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); - $output = []; + $record = $geodb->get($log['ip']); - foreach ($logs as $i => &$log) { - $log['userAgent'] = (!empty($log['userAgent'])) ? $log['userAgent'] : 'UNKNOWN'; - - $dd = new DeviceDetector($log['userAgent']); - - $dd->skipBotDetection(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) - - $dd->parse(); - - $output[$i] = [ - 'event' => $log['event'], - 'ip' => $log['ip'], - 'time' => \strtotime($log['time']), - 'OS' => $dd->getOs(), - 'client' => $dd->getClient(), - 'device' => $dd->getDevice(), - 'brand' => $dd->getBrand(), - 'model' => $dd->getModel(), - 'geo' => [], - ]; - - try { - $record = $reader->country($log['ip']); - $output[$i]['geo']['isoCode'] = \strtolower($record->country->isoCode); - $output[$i]['geo']['country'] = $record->country->name; - $output[$i]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); - } catch (\Exception $e) { - $output[$i]['geo']['isoCode'] = '--'; - $output[$i]['geo']['country'] = Locale::getText('locale.country.unknown'); - } + if ($record) { + $output[$i]['countryCode'] = (isset($countries[$record['country']['iso_code']])) ? \strtolower($record['country']['iso_code']) : '--'; + $output[$i]['countryName'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); + } else { + $output[$i]['countryCode'] = '--'; + $output[$i]['countryName'] = $locale->getText('locale.country.unknown'); } - - $response->json($output); } - ); -$utopia->patch('/v1/users/:userId/status') + $response->dynamic(new Document(['logs' => $output]), Response::MODEL_LOG_LIST); + }); + +App::patch('/v1/users/:userId/status') ->desc('Update User Status') ->groups(['api', 'users']) + ->label('event', 'users.update.status') ->label('scope', 'users.write') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') ->label('sdk.method', 'updateStatus') ->label('sdk.description', '/docs/references/users/update-user-status.md') - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->param('status', '', function () { return new WhiteList([Auth::USER_STATUS_ACTIVATED, Auth::USER_STATUS_BLOCKED, Auth::USER_STATUS_UNACTIVATED]); }, 'User Status code. To activate the user pass '.Auth::USER_STATUS_ACTIVATED.', to block the user pass '.Auth::USER_STATUS_BLOCKED.' and for disabling the user pass '.Auth::USER_STATUS_UNACTIVATED) - ->action( - function ($userId, $status) use ($response, $projectDB) { - $user = $projectDB->getDocument($userId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ - if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { - throw new Exception('User not found', 404); - } + $user = $projectDB->getDocument($userId); - $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ - 'status' => (int)$status, - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $oauth2Keys = []; - - foreach (Config::getParam('providers') as $key => $provider) { - if (!$provider['enabled']) { - continue; - } - - $oauth2Keys[] = 'oauth2'.\ucfirst($key); - $oauth2Keys[] = 'oauth2'.\ucfirst($key).'AccessToken'; - } - - $response - ->json(\array_merge($user->getArrayCopy(\array_merge([ - '$id', - 'status', - 'email', - 'registration', - 'emailVerification', - 'name', - ], $oauth2Keys)), ['roles' => []])); + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + throw new Exception('User not found', 404); } - ); -$utopia->patch('/v1/users/:userId/prefs') + $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ + 'status' => (int)$status, + ])); + + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $response->dynamic($user, Response::MODEL_USER); + }); + +App::patch('/v1/users/:userId/prefs') ->desc('Update User Preferences') ->groups(['api', 'users']) ->label('scope', 'users.write') @@ -419,100 +378,177 @@ $utopia->patch('/v1/users/:userId/prefs') ->label('sdk.namespace', 'users') ->label('sdk.method', 'updatePrefs') ->label('sdk.description', '/docs/references/users/update-user-prefs.md') - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->param('prefs', '', function () { return new Assoc();}, 'Prefs key-value JSON object.') - ->action( - function ($userId, $prefs) use ($response, $projectDB) { - $user = $projectDB->getDocument($userId); + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->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 */ - if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { - throw new Exception('User not found', 404); - } + $user = $projectDB->getDocument($userId); - $old = \json_decode($user->getAttribute('prefs', '{}'), true); - $old = ($old) ? $old : []; - - $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ - 'prefs' => \json_encode(\array_merge($old, $prefs)), - ])); - - if (false === $user) { - throw new Exception('Failed saving user to DB', 500); - } - - $prefs = $user->getAttribute('prefs', ''); - - try { - $prefs = \json_decode($prefs, true); - $prefs = ($prefs) ? $prefs : []; - } catch (\Exception $error) { - throw new Exception('Failed to parse prefs', 500); - } - - $response->json($prefs); + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + throw new Exception('User not found', 404); } - ); + $user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [ + 'prefs' => $prefs, + ])); -$utopia->delete('/v1/users/:userId/sessions/:sessionId') + if (false === $user) { + throw new Exception('Failed saving user to DB', 500); + } + + $response->dynamic(new Document($prefs), Response::MODEL_ANY); + }); + +App::delete('/v1/users/:userId/sessions/:sessionId') ->desc('Delete User Session') ->groups(['api', 'users']) + ->label('event', 'users.sessions.delete') ->label('scope', 'users.write') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') ->label('sdk.method', 'deleteSession') ->label('sdk.description', '/docs/references/users/delete-user-session.md') - ->label('abuse-limit', 100) - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->param('sessionId', null, function () { return new UID(); }, 'User unique session ID.') - ->action( - function ($userId, $sessionId) use ($response, $request, $projectDB) { - $user = $projectDB->getDocument($userId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->label('sdk.response.model', Response::MODEL_NONE) + ->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 */ + /** @var Appwrite\Event\Event $events */ - if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { - throw new Exception('User not found', 404); - } + $user = $projectDB->getDocument($userId); - $tokens = $user->getAttribute('tokens', []); - - foreach ($tokens as $token) { /* @var $token Document */ - if ($sessionId == $token->getId()) { - if (!$projectDB->deleteDocument($token->getId())) { - throw new Exception('Failed to remove token from DB', 500); - } - } - } - - $response->json(array('result' => 'success')); + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + throw new Exception('User not found', 404); } - ); -$utopia->delete('/v1/users/:userId/sessions') + $tokens = $user->getAttribute('tokens', []); + + foreach ($tokens as $token) { /* @var $token Document */ + if ($sessionId == $token->getId()) { + if (!$projectDB->deleteDocument($token->getId())) { + throw new Exception('Failed to remove token from DB', 500); + } + + $events + ->setParam('payload', $response->output($user, Response::MODEL_USER)) + ; + } + } + + // TODO : Response filter implementation + $response->noContent(); + }); + +App::delete('/v1/users/:userId/sessions') ->desc('Delete User Sessions') ->groups(['api', 'users']) + ->label('event', 'users.sessions.delete') ->label('scope', 'users.write') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'users') ->label('sdk.method', 'deleteSessions') ->label('sdk.description', '/docs/references/users/delete-user-sessions.md') - ->label('abuse-limit', 100) - ->param('userId', '', function () { return new UID(); }, 'User unique ID.') - ->action( - function ($userId) use ($response, $request, $projectDB) { - $user = $projectDB->getDocument($userId); + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->label('sdk.response.model', Response::MODEL_NONE) + ->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 */ + /** @var Appwrite\Event\Event $events */ - if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { - throw new Exception('User not found', 404); - } + $user = $projectDB->getDocument($userId); - $tokens = $user->getAttribute('tokens', []); - - foreach ($tokens as $token) { /* @var $token Document */ - if (!$projectDB->deleteDocument($token->getId())) { - throw new Exception('Failed to remove token from DB', 500); - } - } - - $response->json(array('result' => 'success')); + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + throw new Exception('User not found', 404); } - ); + + $tokens = $user->getAttribute('tokens', []); + + foreach ($tokens as $token) { /* @var $token Document */ + if (!$projectDB->deleteDocument($token->getId())) { + throw new Exception('Failed to remove token from DB', 500); + } + } + + $events + ->setParam('payload', $response->output($user, Response::MODEL_USER)) + ; + + // TODO : Response filter implementation + $response->noContent(); + }); + +App::delete('/v1/users/:userId') + ->desc('Delete User') + ->groups(['api', 'users']) + ->label('event', 'users.delete') + ->label('scope', 'users.write') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'users') + ->label('sdk.method', 'deleteUser') + ->label('sdk.description', '/docs/references/users/delete-user.md') + ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) + ->label('sdk.response.model', Response::MODEL_NONE) + ->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 */ + /** @var Appwrite\Event\Event $events */ + /** @var Appwrite\Event\Event $deletes */ + + $user = $projectDB->getDocument($userId); + + if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) { + throw new Exception('User not found', 404); + } + if (!$projectDB->deleteDocument($userId)) { + throw new Exception('Failed to remove user from DB', 500); + } + + if (!$projectDB->deleteUniqueKey(md5('users:email='.$user->getAttribute('email', null)))) { + throw new Exception('Failed to remove unique key from DB', 500); + } + + $reservedId = $projectDB->createDocument([ + '$collection' => Database::SYSTEM_COLLECTION_RESERVED, + '$id' => $userId, + '$permissions' => [ + 'read' => ['*'], + ], + ]); + + if (false === $reservedId) { + throw new Exception('Failed saving reserved id to DB', 500); + } + + $deletes + ->setParam('type', DELETE_TYPE_DOCUMENT) + ->setParam('document', $user) + ; + + $events + ->setParam('payload', $response->output($user, Response::MODEL_USER)) + ; + + // TODO : Response filter implementation + $response->noContent(); + }); diff --git a/app/controllers/general.php b/app/controllers/general.php new file mode 100644 index 0000000000..614c400048 --- /dev/null +++ b/app/controllers/general.php @@ -0,0 +1,424 @@ +getParam('locale', $request->getHeader('x-appwrite-locale', '')); + + if (\in_array($localeParam, Config::getParam('locale-codes'))) { + $locale->setDefault($localeParam); + }; + + $route = $utopia->match($request); + + if (!empty($route->getLabel('sdk.platform', [])) && empty($project->getId()) && ($route->getLabel('scope', '') !== 'public')) { + throw new Exception('Missing or unknown project ID', 400); + } + + $referrer = $request->getReferer(); + $origin = \parse_url($request->getOrigin($referrer), PHP_URL_HOST); + $protocol = \parse_url($request->getOrigin($referrer), PHP_URL_SCHEME); + $port = \parse_url($request->getOrigin($referrer), PHP_URL_PORT); + + $refDomain = (!empty($protocol) ? $protocol : $request->getProtocol()).'://'.((\in_array($origin, $clients)) + ? $origin : 'localhost').(!empty($port) ? ':'.$port : ''); + + $refDomain = (!$route->getLabel('origin', false)) // This route is publicly accessible + ? $refDomain + : (!empty($protocol) ? $protocol : $request->getProtocol()).'://'.$origin.(!empty($port) ? ':'.$port : ''); + + $selfDomain = new Domain($request->getHostname()); + $endDomain = new Domain((string)$origin); + + // var_dump('referer', $referrer); + // var_dump('origin', $origin); + // var_dump('port', $request->getPort()); + // var_dump('hostname', $request->getHostname()); + // var_dump('protocol', $request->getProtocol()); + // var_dump('method', $request->getMethod()); + // var_dump('ip', $request->getIP()); + // var_dump('-----------------'); + // var_dump($request->debug()); + + Config::setParam('domainVerification', + ($selfDomain->getRegisterable() === $endDomain->getRegisterable()) && + $endDomain->getRegisterable() !== ''); + + Config::setParam('cookieDomain', ( + $request->getHostname() === 'localhost' || + $request->getHostname() === 'localhost:'.$request->getPort() || + (\filter_var($request->getHostname(), FILTER_VALIDATE_IP) !== false) + ) + ? null + : '.'.$request->getHostname() + ); + + /* + * Response format + */ + $responseFormat = $request->getHeader('x-appwrite-response-format', App::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', '')); + if ($responseFormat) { + switch($responseFormat) { + case version_compare ($responseFormat , '0.6.2', '<=') : + Response::setFilter(new V06()); + break; + default: + Response::setFilter(null); + } + } else { + Response::setFilter(null); + } + + /* + * Security Headers + * + * As recommended at: + * @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers + */ + if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS + if ($request->getProtocol() !== 'https') { + return $response->redirect('https://'.$request->getHostname().$request->getURI()); + } + + $response->addHeader('Strict-Transport-Security', 'max-age='.(60 * 60 * 24 * 126)); // 126 days + } + + $response + ->addHeader('Server', 'Appwrite') + ->addHeader('X-Content-Type-Options', 'nosniff') + ->addHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE') + ->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-Appwrite-JWT, X-SDK-Version, Cache-Control, Expires, Pragma') + ->addHeader('Access-Control-Expose-Headers', 'X-Fallback-Cookies') + ->addHeader('Access-Control-Allow-Origin', $refDomain) + ->addHeader('Access-Control-Allow-Credentials', 'true') + ; + + /* + * Validate Client Domain - Check to avoid CSRF attack + * Adding Appwrite API domains to allow XDOMAIN communication + * Skip this check for non-web platforms which are not required to send an origin header + */ + $origin = $request->getOrigin($request->getReferer('')); + $originValidator = new Origin(\array_merge($project->getAttribute('platforms', []), $console->getAttribute('platforms', []))); + + if (!$originValidator->isValid($origin) + && \in_array($request->getMethod(), [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE]) + && $route->getLabel('origin', false) !== '*' + && empty($request->getHeader('x-appwrite-key', ''))) { + throw new Exception($originValidator->getDescription(), 403); + } + + /* + * ACL Check + */ + $role = ($user->isEmpty()) ? Auth::USER_ROLE_GUEST : Auth::USER_ROLE_MEMBER; + + // Add user roles + $membership = $user->search('teamId', $project->getAttribute('teamId', null), $user->getAttribute('memberships', [])); + + if ($membership) { + foreach ($membership->getAttribute('roles', []) as $memberRole) { + switch ($memberRole) { + case 'owner': + $role = Auth::USER_ROLE_OWNER; + break; + case 'admin': + $role = Auth::USER_ROLE_ADMIN; + break; + case 'developer': + $role = Auth::USER_ROLE_DEVELOPER; + break; + } + } + } + + $roles = Config::getParam('roles', []); + $scope = $route->getLabel('scope', 'none'); // Allowed scope for chosen route + $scopes = $roles[$role]['scopes']; // Allowed scopes for user role + + $authKey = $request->getHeader('x-appwrite-key', ''); + + if (!empty($authKey)) { // API Key authentication + // Check if given key match project API keys + $key = $project->search('secret', $authKey, $project->getAttribute('keys', [])); + + /* + * Try app auth when we have project key and no user + * Mock user to app and grant API key scopes in addition to default app scopes + */ + if ($key && $user->isEmpty()) { + $user = new Document([ + '$id' => '', + 'status' => Auth::USER_STATUS_ACTIVATED, + 'email' => 'app.'.$project->getId().'@service.'.$request->getHostname(), + 'password' => '', + 'name' => $project->getAttribute('name', 'Untitled'), + ]); + + $role = Auth::USER_ROLE_APP; + $scopes = \array_merge($roles[$role]['scopes'], $key->getAttribute('scopes', [])); + + Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys. + } + } + + if ($user->getId()) { + Authorization::setRole('user:'.$user->getId()); + } + + Authorization::setRole('role:'.$role); + + \array_map(function ($node) { + if (isset($node['teamId']) && isset($node['roles'])) { + Authorization::setRole('team:'.$node['teamId']); + + foreach ($node['roles'] as $nodeRole) { // Set all team roles + Authorization::setRole('team:'.$node['teamId'].'/'.$nodeRole); + } + } + }, $user->getAttribute('memberships', [])); + + // TDOO Check if user is god + + if (!\in_array($scope, $scopes)) { + if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) { // Check if permission is denied because project is missing + throw new Exception('Project not found', 404); + } + + throw new Exception($user->getAttribute('email', 'User').' (role: '.\strtolower($roles[$role]['label']).') missing scope ('.$scope.')', 401); + } + + if (Auth::USER_STATUS_BLOCKED == $user->getAttribute('status')) { // Account has not been activated + throw new Exception('Invalid credentials. User is blocked', 401); // User is in status blocked + } + + if ($user->getAttribute('reset')) { + throw new Exception('Password reset is required', 412); + } + +}, ['utopia', 'request', 'response', 'console', 'project', 'user', 'locale', 'clients']); + +App::options(function ($request, $response) { + /** @var Utopia\Swoole\Request $request */ + /** @var Appwrite\Utopia\Response $response */ + + $origin = $request->getOrigin(); + + $response + ->addHeader('Server', 'Appwrite') + ->addHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE') + ->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-Appwrite-JWT, X-SDK-Version, Cache-Control, Expires, Pragma, X-Fallback-Cookies') + ->addHeader('Access-Control-Expose-Headers', 'X-Fallback-Cookies') + ->addHeader('Access-Control-Allow-Origin', $origin) + ->addHeader('Access-Control-Allow-Credentials', 'true') + ->noContent(); +}, ['request', 'response']); + +App::error(function ($error, $utopia, $request, $response, $layout, $project) { + /** @var Exception $error */ + /** @var Utopia\App $utopia */ + /** @var Utopia\Swoole\Request $request */ + /** @var Appwrite\Utopia\Response $response */ + /** @var Utopia\View $layout */ + /** @var Appwrite\Database\Document $project */ + + $route = $utopia->match($request); + $template = ($route) ? $route->getLabel('error', null) : null; + + if (php_sapi_name() === 'cli') { + if($route) { + Console::error('[Error] Method: '.$route->getMethod()); + Console::error('[Error] URL: '.$route->getURL()); + } + + Console::error('[Error] Type: '.get_class($error)); + Console::error('[Error] Message: '.$error->getMessage()); + Console::error('[Error] File: '.$error->getFile()); + Console::error('[Error] Line: '.$error->getLine()); + } + + $version = App::getEnv('_APP_VERSION', 'UNKNOWN'); + + switch ($error->getCode()) { + case 400: // Error allowed publicly + case 401: // Error allowed publicly + case 402: // Error allowed publicly + case 403: // Error allowed publicly + case 404: // Error allowed publicly + case 409: // Error allowed publicly + case 412: // Error allowed publicly + case 429: // Error allowed publicly + $code = $error->getCode(); + $message = $error->getMessage(); + break; + default: + $code = 500; // All other errors get the generic 500 server error status code + $message = 'Server Error'; + } + + //$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised + + $output = ((App::isDevelopment())) ? [ + 'message' => $error->getMessage(), + 'code' => $error->getCode(), + 'file' => $error->getFile(), + 'line' => $error->getLine(), + 'trace' => $error->getTrace(), + 'version' => $version, + ] : [ + 'message' => $message, + 'code' => $code, + 'version' => $version, + ]; + + $response + ->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate') + ->addHeader('Expires', '0') + ->addHeader('Pragma', 'no-cache') + ->setStatusCode($code) + ; + + if ($template) { + $comp = new View($template); + + $comp + ->setParam('projectName', $project->getAttribute('name')) + ->setParam('projectURL', $project->getAttribute('url')) + ->setParam('message', $error->getMessage()) + ->setParam('code', $code) + ; + + $layout + ->setParam('title', $project->getAttribute('name').' - Error') + ->setParam('description', 'No Description') + ->setParam('body', $comp) + ->setParam('version', $version) + ->setParam('litespeed', false) + ; + + $response->html($layout->render()); + } + + $response->dynamic(new Document($output), + $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 */ + + $response->json([ + 'name' => APP_NAME, + 'short_name' => APP_NAME, + 'start_url' => '.', + 'url' => 'https://appwrite.io/', + 'display' => 'standalone', + 'background_color' => '#fff', + 'theme_color' => '#f02e65', + 'description' => 'End to end backend server for frontend and mobile apps. 👩‍💻👨‍💻', + 'icons' => [ + [ + 'src' => 'images/favicon.png', + 'sizes' => '256x256', + 'type' => 'image/png', + ], + ], + ]); + }); + +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)); + }); + +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)); + }); + +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->getURI()); + $absolute = \realpath($base.'/.well-known/acme-challenge/'.$path); + + if (!$base) { + throw new Exception('Storage error', 500); + } + + if (!$absolute) { + throw new Exception('Unknown path', 404); + } + + if (!\substr($absolute, 0, \strlen($base)) === $base) { + throw new Exception('Invalid path', 401); + } + + if (!\file_exists($absolute)) { + throw new Exception('Unknown path', 404); + } + + $content = @\file_get_contents($absolute); + + if (!$content) { + throw new Exception('Failed to get contents', 500); + } + + $response->text($content); + }); + +include_once __DIR__ . '/shared/api.php'; +include_once __DIR__ . '/shared/web.php'; + +foreach (Config::getParam('services', []) as $service) { + include_once $service['controller']; +} \ No newline at end of file diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 097501fbba..4c9f3faf9f 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -2,339 +2,385 @@ global $utopia, $request, $response; +use Utopia\App; +use Utopia\Response; use Utopia\Validator\Numeric; use Utopia\Validator\Text; use Utopia\Validator\ArrayList; -use Utopia\Response; use Utopia\Validator\Host; -use Appwrite\Storage\Validator\File; +use Utopia\Storage\Validator\File; -$result = []; - -$utopia->get('/v1/mock/tests/foo') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->post('/v1/mock/tests/foo') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->patch('/v1/mock/tests/foo') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->put('/v1/mock/tests/foo') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->delete('/v1/mock/tests/foo') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->get('/v1/mock/tests/bar') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->post('/v1/mock/tests/bar') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->patch('/v1/mock/tests/bar') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->put('/v1/mock/tests/bar') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->delete('/v1/mock/tests/bar') +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') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->action( - function ($x, $y, $z) { - } - ); + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->param('y', '', new Numeric(), 'Sample numeric param') + ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') + ->action(function ($x, $y, $z) { + }); -$utopia->post('/v1/mock/tests/general/upload') +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') - ->label('sdk.consumes', 'multipart/form-data') - ->param('x', '', function () { return new Text(100); }, 'Sample string param') - ->param('y', '', function () { return new Numeric(); }, 'Sample numeric param') - ->param('z', null, function () { return new ArrayList(new Text(256)); }, 'Sample array param') - ->param('file', [], function () { return new File(); }, 'Sample file param', false) - ->action( - function ($x, $y, $z, $file) use ($request) { - $file = $request->getFiles('file'); - $file['tmp_name'] = (\is_array($file['tmp_name'])) ? $file['tmp_name'] : [$file['tmp_name']]; - $file['name'] = (\is_array($file['name'])) ? $file['name'] : [$file['name']]; - $file['size'] = (\is_array($file['size'])) ? $file['size'] : [$file['size']]; + ->label('sdk.request.type', 'multipart/form-data') + ->label('sdk.mock', true) + ->param('x', '', new Text(100), 'Sample string param') + ->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 */ + + $file = $request->getFiles('file'); + $file['tmp_name'] = (\is_array($file['tmp_name'])) ? $file['tmp_name'] : [$file['tmp_name']]; + $file['name'] = (\is_array($file['name'])) ? $file['name'] : [$file['name']]; + $file['size'] = (\is_array($file['size'])) ? $file['size'] : [$file['size']]; - foreach ($file['name'] as $i => $name) { - if ($name !== 'file.png') { - throw new Exception('Wrong file name', 400); - } - } - - foreach ($file['size'] as $i => $size) { - if ($size !== 38756) { - throw new Exception('Wrong file size', 400); - } - } - - foreach ($file['tmp_name'] as $i => $tmpName) { - if (\md5(\file_get_contents($tmpName)) !== 'd80e7e6999a3eb2ae0d631a96fe135a4') { - throw new Exception('Wrong file uploaded', 400); - } + foreach ($file['name'] as $i => $name) { + if ($name !== 'file.png') { + throw new Exception('Wrong file name', 400); } } - ); -$utopia->get('/v1/mock/tests/general/redirect') + foreach ($file['size'] as $i => $size) { + if ($size !== 38756) { + throw new Exception('Wrong file size', 400); + } + } + + foreach ($file['tmp_name'] as $i => $tmpName) { + if (\md5(\file_get_contents($tmpName)) !== 'd80e7e6999a3eb2ae0d631a96fe135a4') { + throw new Exception('Wrong file uploaded', 400); + } + } + }); + +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') - ->action( - function () use ($response) { - $response->redirect('/v1/mock/tests/general/redirected'); - } - ); + ->label('sdk.mock', true) + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/mock/tests/general/redirected') + $response->redirect('/v1/mock/tests/general/redirect/done'); + }); + +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') - ->action( - function () { - } - ); + ->label('sdk.mock', true) + ->action(function () { + }); -$utopia->get('/v1/mock/tests/general/set-cookie') +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') - ->action( - function () use ($response) { - $response->addCookie('cookieName', 'cookieValue', \time() + 31536000, '/', 'localhost', true, true); - } - ); + ->label('sdk.mock', true) + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/mock/tests/general/get-cookie') + $response->addCookie('cookieName', 'cookieValue', \time() + 31536000, '/', 'localhost', true, true); + }); + +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') - ->action( - function () use ($request) { - if ($request->getCookie('cookieName', '') !== 'cookieValue') { - throw new Exception('Missing cookie value', 400); - } - } - ); + ->label('sdk.mock', true) + ->inject('request') + ->action(function ($request) { + /** @var Utopia\Swoole\Request $request */ -$utopia->get('/v1/mock/tests/general/empty') + if ($request->getCookie('cookieName', '') !== 'cookieValue') { + throw new Exception('Missing cookie value', 400); + } + }); + +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') - ->action( - function () use ($response) { - $response->noContent(); - exit(); - } - ); + ->label('sdk.mock', true) + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/mock/tests/general/oauth2') + $response->noContent(); + }); + +App::get('/v1/mock/tests/general/oauth2') ->desc('Mock an OAuth2 login route') + ->groups(['mock']) ->label('scope', 'public') ->label('docs', false) - ->param('client_id', '', function () { return new Text(100); }, 'OAuth2 Client ID.') - ->param('redirect_uri', '', function () { return new Host(['localhost']); }, 'OAuth2 Redirect URI.') // Important to deny an open redirect attack - ->param('scope', '', function () { return new Text(100); }, 'OAuth2 scope list.') - ->param('state', '', function () { return new Text(1024); }, 'OAuth2 state.') - ->action( - function ($clientId, $redirectURI, $scope, $state) use ($response) { - $response->redirect($redirectURI.'?'.\http_build_query(['code' => 'abcdef', 'state' => $state])); - } - ); + ->label('sdk.mock', true) + ->param('client_id', '', new Text(100), 'OAuth2 Client ID.') + ->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 */ -$utopia->get('/v1/mock/tests/general/oauth2/token') + $response->redirect($redirectURI.'?'.\http_build_query(['code' => 'abcdef', 'state' => $state])); + }); + +App::get('/v1/mock/tests/general/oauth2/token') ->desc('Mock an OAuth2 login route') + ->groups(['mock']) ->label('scope', 'public') ->label('docs', false) - ->param('client_id', '', function () { return new Text(100); }, 'OAuth2 Client ID.') - ->param('redirect_uri', '', function () { return new Host(['localhost']); }, 'OAuth2 Redirect URI.') - ->param('client_secret', '', function () { return new Text(100); }, 'OAuth2 scope list.') - ->param('code', '', function () { return new Text(100); }, 'OAuth2 state.') - ->action( - function ($clientId, $redirectURI, $clientSecret, $code) use ($response) { - if ($clientId != '1') { - throw new Exception('Invalid client ID'); - } + ->label('sdk.mock', true) + ->param('client_id', '', new Text(100), 'OAuth2 Client ID.') + ->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 */ - if ($clientSecret != '123456') { - throw new Exception('Invalid client secret'); - } - - if ($code != 'abcdef') { - throw new Exception('Invalid token'); - } - - $response->json(['access_token' => '123456']); + if ($clientId != '1') { + throw new Exception('Invalid client ID'); } - ); -$utopia->get('/v1/mock/tests/general/oauth2/user') + if ($clientSecret != '123456') { + throw new Exception('Invalid client secret'); + } + + if ($code != 'abcdef') { + throw new Exception('Invalid token'); + } + + $response->json(['access_token' => '123456']); + }); + +App::get('/v1/mock/tests/general/oauth2/user') ->desc('Mock an OAuth2 user route') + ->groups(['mock']) ->label('scope', 'public') ->label('docs', false) - ->param('token', '', function () { return new Text(100); }, 'OAuth2 Access Token.') - ->action( - function ($token) use ($response) { - if ($token != '123456') { - throw new Exception('Invalid token'); - } + ->param('token', '', new Text(100), 'OAuth2 Access Token.') + ->inject('response') + ->action(function ($token, $response) { + /** @var Appwrite\Utopia\Response $response */ - $response->json([ - 'id' => 1, - 'name' => 'User Name', - 'email' => 'user@localhost.test', + if ($token != '123456') { + throw new Exception('Invalid token'); + } + + $response->json([ + 'id' => 1, + 'name' => 'User Name', + 'email' => 'user@localhost.test', + ]); + }); + +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', + ]); + }); + +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 */ + + $response + ->setStatusCode(Response::STATUS_CODE_BAD_REQUEST) + ->json([ + 'result' => 'failure', ]); - } - ); + }); -$utopia->get('/v1/mock/tests/general/oauth2/success') - ->label('scope', 'public') - ->label('docs', false) - ->action( - function () use ($response) { - $response->json([ - 'result' => 'success', - ]); - } - ); +App::shutdown(function($utopia, $response, $request) { + /** @var Utopia\App $utopia */ + /** @var Utopia\Swoole\Request $request */ + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/v1/mock/tests/general/oauth2/failure') - ->label('scope', 'public') - ->label('docs', false) - ->action( - function () use ($response) { - $response - ->setStatusCode(Response::STATUS_CODE_BAD_REQUEST) - ->json([ - 'result' => 'failure', - ]); - } - ); - -$utopia->shutdown(function() use ($response, $request, &$result, $utopia) { + $result = []; $route = $utopia->match($request); $path = APP_STORAGE_CACHE.'/tests.json'; $tests = (\file_exists($path)) ? \json_decode(\file_get_contents($path), true) : []; @@ -352,4 +398,4 @@ $utopia->shutdown(function() use ($response, $request, &$result, $utopia) { } $response->json(['result' => $route->getMethod() . ':' . $route->getURL() . ':passed']); -}, 'mock'); \ No newline at end of file +}, ['utopia', 'response', 'request'], 'mock'); \ No newline at end of file diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index e911c2c556..8dc0c097c7 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -1,12 +1,30 @@ getId())); + Storage::setDevice('functions', new Local(APP_STORAGE_FUNCTIONS.'/app-'.$project->getId())); -$utopia->init(function () use ($utopia, $request, $response, $register, $user, $project) { $route = $utopia->match($request); if (empty($project->getId()) && $route->getLabel('abuse-limit', 0) > 0) { // Abuse limit requires an active project scope @@ -22,9 +40,9 @@ $utopia->init(function () use ($utopia, $request, $response, $register, $user, $ $timeLimit->setNamespace('app_'.$project->getId()); $timeLimit ->setParam('{userId}', $user->getId()) - ->setParam('{userAgent}', $request->getServer('HTTP_USER_AGENT', '')) + ->setParam('{userAgent}', $request->getUserAgent('')) ->setParam('{ip}', $request->getIP()) - ->setParam('{url}', $request->getServer('HTTP_HOST', '').$route->getURL()) + ->setParam('{url}', $request->getHostname().$route->getURL()) ; //TODO make sure we get array here @@ -43,7 +61,105 @@ $utopia->init(function () use ($utopia, $request, $response, $register, $user, $ ; } - if ($abuse->check() && $request->getServer('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') { + $isPreviliggedUser = Auth::isPreviliggedUser(Authorization::$roles); + $isAppUser = Auth::isAppUser(Authorization::$roles); + + if (($abuse->check() // Route is rate-limited + && App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') // Abuse is not diabled + && (!$isAppUser && !$isPreviliggedUser)) // User is not an admin or API key + { throw new Exception('Too many requests', 429); } -}, 'api'); \ No newline at end of file + + /* + * 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 + ->setParam('projectId', $project->getId()) + ->setParam('userId', $user->getId()) + ->setParam('event', '') + ->setParam('resource', '') + ->setParam('userAgent', $request->getUserAgent('')) + ->setParam('ip', $request->getIP()) + ->setParam('data', []) + ; + + $usage + ->setParam('projectId', $project->getId()) + ->setParam('httpRequest', 1) + ->setParam('httpUrl', $request->getHostname().$request->getURI()) + ->setParam('httpMethod', $request->getMethod()) + ->setParam('networkRequestSize', 0) + ->setParam('networkResponseSize', 0) + ->setParam('storage', 0) + ; + + $deletes + ->setParam('projectId', $project->getId()) + ; + +}, ['utopia', 'request', 'response', 'project', 'user', 'register', 'events', 'audits', 'usage', 'deletes'], 'api'); + +App::shutdown(function ($utopia, $request, $response, $project, $events, $audits, $usage, $deletes, $mode) { + /** @var Utopia\App $utopia */ + /** @var Utopia\Swoole\Request $request */ + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Document $project */ + /** @var Appwrite\Event\Event $events */ + /** @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'))) { + if(empty($events->getParam('payload'))) { + $events->setParam('payload', $response->getPayload()); + } + + $webhooks = clone $events; + $functions = clone $events; + + $webhooks + ->setQueue('v1-webhooks') + ->setClass('WebhooksV1') + ->trigger(); + + $functions + ->setQueue('v1-functions') + ->setClass('FunctionsV1') + ->trigger(); + } + + if (!empty($audits->getParam('event'))) { + $audits->trigger(); + } + + if (!empty($deletes->getParam('type')) && !empty($deletes->getParam('document'))) { + $deletes->trigger(); + } + + $route = $utopia->match($request); + if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled' + && $project->getId() + && $mode !== APP_MODE_ADMIN //TODO: add check to make sure user is admin + && !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage on admin mode + + $usage + ->setParam('networkRequestSize', $request->getSize() + $usage->getParam('storage')) + ->setParam('networkResponseSize', $response->getSize()) + ->trigger() + ; + } + +}, ['utopia', 'request', 'response', 'project', 'events', 'audits', 'usage', 'deletes', 'mode'], 'api'); diff --git a/app/controllers/shared/web.php b/app/controllers/shared/web.php index a2f85bcb0a..43eaf74d09 100644 --- a/app/controllers/shared/web.php +++ b/app/controllers/shared/web.php @@ -1,22 +1,25 @@ init(function () use ($utopia, $response, $request, $layout) { +App::init(function ($utopia, $request, $response, $layout) { + /** @var Utopia\App $utopia */ + /** @var Utopia\Swoole\Request $request */ + /** @var Appwrite\Utopia\Response $response */ + /** @var Utopia\View $layout */ /* AJAX check */ if (!empty($request->getQuery('version', ''))) { $layout->setPath(__DIR__.'/../../views/layouts/empty.phtml'); } + $layout ->setParam('title', APP_NAME) - ->setParam('protocol', Config::getParam('protocol')) - ->setParam('domain', Config::getParam('domain')) - ->setParam('home', $request->getServer('_APP_HOME')) - ->setParam('setup', $request->getServer('_APP_SETUP')) + ->setParam('protocol', $request->getProtocol()) + ->setParam('domain', $request->getHostname()) + ->setParam('home', App::getEnv('_APP_HOME')) + ->setParam('setup', App::getEnv('_APP_SETUP')) ->setParam('class', 'unknown') ->setParam('icon', '/images/favicon.png') ->setParam('roles', [ @@ -24,22 +27,25 @@ $utopia->init(function () use ($utopia, $response, $request, $layout) { ['type' => 'developer', 'label' => 'Developer'], ['type' => 'admin', 'label' => 'Admin'], ]) - ->setParam('env', $utopia->getMode()) + ->setParam('environments', Config::getParam('environments')) + ->setParam('mode', App::getMode()) ; $time = (60 * 60 * 24 * 45); // 45 days cache - $isDev = (\Utopia\App::MODE_TYPE_DEVELOPMENT == Config::getParam('env')); $response ->addHeader('Cache-Control', 'public, max-age='.$time) ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache - ->addHeader('X-UA-Compatible', 'IE=Edge'); // Deny IE browsers from going into quirks mode + ->addHeader('X-Frame-Options', 'SAMEORIGIN') // Avoid console and homepage from showing in iframes + ->addHeader('X-XSS-Protection', '1; mode=block; report=/v1/xss?url='.\urlencode($request->getURI())) + ->addHeader('X-UA-Compatible', 'IE=Edge') // Deny IE browsers from going into quirks mode + ; $route = $utopia->match($request); $scope = $route->getLabel('scope', ''); $layout - ->setParam('version', Config::getParam('version')) - ->setParam('isDev', $isDev) + ->setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN')) + ->setParam('isDev', App::isDevelopment()) ->setParam('class', $scope) ; -}, 'web'); +}, ['utopia', 'request', 'response', 'layout'], 'web'); diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index 595d36d33a..6b3e105aa3 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -1,29 +1,33 @@ init(function () use ($layout) { $layout ->setParam('description', 'Appwrite Console allows you to easily manage, monitor, and control your entire backend API and tools.') ->setParam('analytics', 'UA-26264668-5') ; -}, 'console'); +}, ['layout'], 'console'); + +App::shutdown(function ($response, $layout) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Utopia\View $layout */ -$utopia->shutdown(function () use ($response, $request, $layout) { $header = new View(__DIR__.'/../../views/console/comps/header.phtml'); $footer = new View(__DIR__.'/../../views/console/comps/footer.phtml'); $footer - ->setParam('home', $request->getServer('_APP_HOME', '')) - ->setParam('version', Config::getParam('version')) + ->setParam('home', App::getEnv('_APP_HOME', '')) + ->setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN')) ; $layout @@ -31,15 +35,18 @@ $utopia->shutdown(function () use ($response, $request, $layout) { ->setParam('footer', [$footer]) ; - $response->send($layout->render()); -}, 'console'); + $response->html($layout->render()); +}, ['response', 'layout'], 'console'); -$utopia->get('/error/:code') +App::get('/error/:code') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'home') ->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false) - ->action(function ($code) use ($layout) { + ->inject('layout') + ->action(function ($code, $layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/error.phtml'); $page @@ -51,15 +58,18 @@ $utopia->get('/error/:code') ->setParam('body', $page); }); -$utopia->get('/console') +App::get('/console') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout, $request) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/console/index.phtml'); $page - ->setParam('home', $request->getServer('_APP_HOME', '')) + ->setParam('home', App::getEnv('_APP_HOME', '')) ; $layout @@ -67,11 +77,14 @@ $utopia->get('/console') ->setParam('body', $page); }); -$utopia->get('/console/account') +App::get('/console/account') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/console/account/index.phtml'); $cc = new View(__DIR__.'/../../views/console/forms/credit-card.phtml'); @@ -85,11 +98,14 @@ $utopia->get('/console/account') ->setParam('body', $page); }); -$utopia->get('/console/notifications') +App::get('/console/notifications') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/v1/console/notifications/index.phtml'); $layout @@ -97,24 +113,31 @@ $utopia->get('/console/notifications') ->setParam('body', $page); }); -$utopia->get('/console/home') +App::get('/console/home') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { - $page = new View(__DIR__.'/../../views/console/home/index.phtml'); + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/console/home/index.phtml'); + $page + ->setParam('usageStatsEnabled',App::getEnv('_APP_USAGE_STATS','enabled') == 'enabled'); $layout ->setParam('title', APP_NAME.' - Console') ->setParam('body', $page); }); -$utopia->get('/console/settings') +App::get('/console/settings') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($request, $layout) { - $target = new Domain($request->getServer('_APP_DOMAIN_TARGET', '')); + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + + $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); $page = new View(__DIR__.'/../../views/console/settings/index.phtml'); @@ -128,13 +151,16 @@ $utopia->get('/console/settings') ->setParam('body', $page); }); -$utopia->get('/console/webhooks') +App::get('/console/webhooks') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/console/webhooks/index.phtml'); - + $page ->setParam('events', Config::getParam('events', [])) ; @@ -144,12 +170,15 @@ $utopia->get('/console/webhooks') ->setParam('body', $page); }); -$utopia->get('/console/keys') +App::get('/console/keys') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { - $scopes = include __DIR__.'/../../../app/config/scopes.php'; + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + + $scopes = array_keys(Config::getParam('scopes')); $page = new View(__DIR__.'/../../views/console/keys/index.phtml'); $page->setParam('scopes', $scopes); @@ -159,11 +188,14 @@ $utopia->get('/console/keys') ->setParam('body', $page); }); -$utopia->get('/console/tasks') +App::get('/console/tasks') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/console/tasks/index.phtml'); $layout @@ -171,11 +203,14 @@ $utopia->get('/console/tasks') ->setParam('body', $page); }); -$utopia->get('/console/database') +App::get('/console/database') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/console/database/index.phtml'); $layout @@ -183,12 +218,19 @@ $utopia->get('/console/database') ->setParam('body', $page); }); -$utopia->get('/console/database/collection') +App::get('/console/database/collection') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->param('id', '', function () { return new UID(); }, 'Collection unique ID.') - ->action(function ($id) use ($response, $layout, $projectDB) { + ->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 */ + /** @var Appwrite\Database\Database $projectDB */ + Authorization::disable(); $collection = $projectDB->getDocument($id, false); Authorization::reset(); @@ -215,12 +257,17 @@ $utopia->get('/console/database/collection') ; }); -$utopia->get('/console/database/document') +App::get('/console/database/document') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->param('collection', '', function () { return new UID(); }, 'Collection unique ID.') - ->action(function ($collection) use ($layout, $projectDB) { + ->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 */ + Authorization::disable(); $collection = $projectDB->getDocument($collection, false); Authorization::reset(); @@ -245,17 +292,19 @@ $utopia->get('/console/database/document') ->setParam('body', $page); }); -$utopia->get('/console/storage') +App::get('/console/storage') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($request, $layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ $page = new View(__DIR__.'/../../views/console/storage/index.phtml'); $page - ->setParam('home', $request->getServer('_APP_HOME', 0)) - ->setParam('fileLimit', $request->getServer('_APP_STORAGE_LIMIT', 0)) - ->setParam('fileLimitHuman', Storage::human($request->getServer('_APP_STORAGE_LIMIT', 0))) + ->setParam('home', App::getEnv('_APP_HOME', 0)) + ->setParam('fileLimit', App::getEnv('_APP_STORAGE_LIMIT', 0)) + ->setParam('fileLimitHuman', Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0))) ; $layout @@ -263,11 +312,14 @@ $utopia->get('/console/storage') ->setParam('body', $page); }); -$utopia->get('/console/users') +App::get('/console/users') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/console/users/index.phtml'); $page->setParam('providers', Config::getParam('providers')); @@ -277,11 +329,14 @@ $utopia->get('/console/users') ->setParam('body', $page); }); -$utopia->get('/console/users/user') +App::get('/console/users/user') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/console/users/user.phtml'); $layout @@ -289,14 +344,77 @@ $utopia->get('/console/users/user') ->setParam('body', $page); }); -$utopia->get('/console/users/teams/team') +App::get('/console/users/teams/team') ->groups(['web', 'console']) ->label('permission', 'public') ->label('scope', 'console') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/console/users/team.phtml'); $layout ->setParam('title', APP_NAME.' - Team') ->setParam('body', $page); }); + +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'); + + $page + ->setParam('environments', Config::getParam('environments')) + ; + + $layout + ->setParam('title', APP_NAME.' - Functions') + ->setParam('body', $page); + }); + +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'); + + $page + ->setParam('events', Config::getParam('events', [])) + ->setParam('fileLimit', App::getEnv('_APP_STORAGE_LIMIT', 0)) + ->setParam('fileLimitHuman', Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0))) + ->setParam('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)) + ->setParam('usageStatsEnabled',App::getEnv('_APP_USAGE_STATS','enabled') == 'enabled'); + ; + + $layout + ->setParam('title', APP_NAME.' - Function') + ->setParam('body', $page); + }); + +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); + + if ($version && isset($version['version'])) { + return $response->json(['version' => $version['version']]); + } else { + throw new Exception('Failed to check for a newer version', 500); + } + } catch (\Throwable $th) { + throw new Exception('Failed to check for a newer version', 500); + } + }); \ No newline at end of file diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index 5d8a7aefc2..f302f0af33 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -1,18 +1,23 @@ init(function () use ($layout) { $header = new View(__DIR__.'/../../views/home/comps/header.phtml'); $footer = new View(__DIR__.'/../../views/home/comps/footer.phtml'); $footer - ->setParam('version', Config::getParam('version')) + ->setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN')) ; $layout @@ -23,27 +28,34 @@ $utopia->init(function () use ($layout) { ->setParam('header', [$header]) ->setParam('footer', [$footer]) ; -}, 'home'); +}, ['layout'], 'home'); -$utopia->shutdown(function () use ($response, $layout) { - $response->send($layout->render()); -}, 'home'); +App::shutdown(function ($response, $layout) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Utopia\View $layout */ -$utopia->get('/') + $response->html($layout->render()); +}, ['response', 'layout'], 'home'); + +App::get('/') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') - ->action( - function () use ($response) { - $response->redirect('/auth/signin'); - } - ); + ->inject('response') + ->action(function ($response) { + /** @var Appwrite\Utopia\Response $response */ -$utopia->get('/auth/signin') + $response->redirect('/auth/signin'); + }); + +App::get('/auth/signin') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/home/auth/signin.phtml'); $layout @@ -51,11 +63,13 @@ $utopia->get('/auth/signin') ->setParam('body', $page); }); -$utopia->get('/auth/signup') +App::get('/auth/signup') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ $page = new View(__DIR__.'/../../views/home/auth/signup.phtml'); $layout @@ -63,11 +77,14 @@ $utopia->get('/auth/signup') ->setParam('body', $page); }); -$utopia->get('/auth/recovery') +App::get('/auth/recovery') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') - ->action(function () use ($request, $layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/home/auth/recovery.phtml'); $layout @@ -75,11 +92,14 @@ $utopia->get('/auth/recovery') ->setParam('body', $page); }); -$utopia->get('/auth/confirm') +App::get('/auth/confirm') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/home/auth/confirm.phtml'); $layout @@ -87,11 +107,14 @@ $utopia->get('/auth/confirm') ->setParam('body', $page); }); -$utopia->get('/auth/join') +App::get('/auth/join') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/home/auth/join.phtml'); $layout @@ -99,11 +122,14 @@ $utopia->get('/auth/join') ->setParam('body', $page); }); -$utopia->get('/auth/recovery/reset') +App::get('/auth/recovery/reset') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/home/auth/recovery/reset.phtml'); $layout @@ -111,12 +137,14 @@ $utopia->get('/auth/recovery/reset') ->setParam('body', $page); }); - -$utopia->get('/auth/oauth2/success') +App::get('/auth/oauth2/success') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/home/auth/oauth2.phtml'); $layout @@ -127,11 +155,14 @@ $utopia->get('/auth/oauth2/success') ; }); -$utopia->get('/auth/oauth2/failure') +App::get('/auth/oauth2/failure') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') - ->action(function () use ($layout) { + ->inject('layout') + ->action(function ($layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/home/auth/oauth2.phtml'); $layout @@ -142,12 +173,15 @@ $utopia->get('/auth/oauth2/failure') ; }); -$utopia->get('/error/:code') +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) - ->action(function ($code) use ($layout) { + ->inject('layout') + ->action(function ($code, $layout) { + /** @var Utopia\View $layout */ + $page = new View(__DIR__.'/../../views/error.phtml'); $page @@ -159,408 +193,186 @@ $utopia->get('/error/:code') ->setParam('body', $page); }); -$utopia->get('/open-api-2.json') +App::get('/specs/:format') ->groups(['web', 'home']) ->label('scope', 'public') ->label('docs', false) - ->param('platform', APP_PLATFORM_CLIENT, function () {return new WhiteList([APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER, APP_PLATFORM_CONSOLE]);}, 'Choose target platform.', true) - ->param('extensions', 0, function () {return new Range(0, 1);}, 'Show extra data.', true) + ->param('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) ->param('tests', 0, function () {return new Range(0, 1);}, 'Include only test services.', true) - ->action( - function ($platform, $extensions, $tests) use ($response, $request, $utopia) { - $services = Config::getParam('services', []); - - function fromCamelCase($input) - { - \preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); - $ret = $matches[0]; - foreach ($ret as &$match) { - $match = $match == \strtoupper($match) ? \strtolower($match) : \lcfirst($match); - } + ->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 */ - return \implode('_', $ret); - } + $platforms = [ + 'client' => APP_PLATFORM_CLIENT, + 'server' => APP_PLATFORM_SERVER, + 'console' => APP_PLATFORM_CONSOLE, + ]; - function fromCamelCaseToDash($input) - { - return \str_replace([' ', '_'], '-', \strtolower(\preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $input))); - } + $routes = []; + $models = []; + $services = []; - foreach ($services as $service) { /* @noinspection PhpIncludeInspection */ - if ($tests && !isset($service['tests'])) { + $keys = [ + APP_PLATFORM_CLIENT => [ + 'Project' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Project', + 'description' => 'Your project ID', + 'in' => 'header', + ], + 'Locale' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Locale', + 'description' => '', + 'in' => 'header', + ], + ], + APP_PLATFORM_SERVER => [ + 'Project' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Project', + 'description' => 'Your project ID', + 'in' => 'header', + ], + 'Key' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Key', + 'description' => 'Your secret API key', + 'in' => 'header', + ], + 'Locale' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Locale', + 'description' => '', + 'in' => 'header', + ], + ], + APP_PLATFORM_CONSOLE => [ + 'Project' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Project', + 'description' => 'Your project ID', + 'in' => 'header', + ], + 'Key' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Key', + 'description' => 'Your secret API key', + 'in' => 'header', + ], + 'Locale' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Locale', + 'description' => '', + 'in' => 'header', + ], + 'Mode' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Mode', + 'description' => '', + 'in' => 'header', + ], + ], + ]; + + $security = [ + APP_PLATFORM_CLIENT => ['Project' => []], + APP_PLATFORM_SERVER => ['Project' => [], 'Key' => []], + APP_PLATFORM_CONSOLE => ['Project' => [], 'Key' => []], + ]; + + foreach ($utopia->getRoutes() as $key => $method) { + foreach ($method as $route) { /** @var \Utopia\Route $route */ + if (!$route->getLabel('docs', true)) { continue; } - if ($tests && !$service['tests']) { + if ($route->getLabel('sdk.mock', false) && !$tests) { continue; } - - if (!$tests && !$service['sdk']) { + + if (!$route->getLabel('sdk.mock', false) && $tests) { continue; } - - /** @noinspection PhpIncludeInspection */ - include_once \realpath(__DIR__.'/../../'.$service['controller']); - } - $security = [ - APP_PLATFORM_CLIENT => ['Project' => []], - APP_PLATFORM_SERVER => ['Project' => [], 'Key' => []], - APP_PLATFORM_CONSOLE => ['Project' => [], 'Key' => []], - ]; - - $platforms = [ - 'client' => APP_PLATFORM_CLIENT, - 'server' => APP_PLATFORM_SERVER, - 'all' => APP_PLATFORM_CONSOLE, - ]; - - $keys = [ - APP_PLATFORM_CLIENT => [ - 'Project' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Project', - 'description' => 'Your project ID', - 'in' => 'header', - ], - 'Locale' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Locale', - 'description' => '', - 'in' => 'header', - ], - ], - APP_PLATFORM_SERVER => [ - 'Project' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Project', - 'description' => 'Your project ID', - 'in' => 'header', - ], - 'Key' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Key', - 'description' => 'Your secret API key', - 'in' => 'header', - ], - 'Locale' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Locale', - 'description' => '', - 'in' => 'header', - ], - ], - APP_PLATFORM_CONSOLE => [ - 'Project' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Project', - 'description' => 'Your project ID', - 'in' => 'header', - ], - 'Key' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Key', - 'description' => 'Your secret API key', - 'in' => 'header', - ], - 'Locale' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Locale', - 'description' => '', - 'in' => 'header', - ], - 'Mode' => [ - 'type' => 'apiKey', - 'name' => 'X-Appwrite-Mode', - 'description' => '', - 'in' => 'header', - ], - ], - ]; - - /* - * Specifications (v3.0.0): - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md - */ - $output = [ - 'swagger' => '2.0', - 'info' => [ - 'version' => APP_VERSION_STABLE, - 'title' => APP_NAME, - 'description' => 'Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)', - 'termsOfService' => 'https://appwrite.io/policy/terms', - 'contact' => [ - 'name' => 'Appwrite Team', - 'url' => 'https://appwrite.io/support', - 'email' => $request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), - ], - 'license' => [ - 'name' => 'BSD-3-Clause', - 'url' => 'https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE', - ], - ], - 'host' => \parse_url($request->getServer('_APP_HOME', Config::getParam('domain')), PHP_URL_HOST), - 'basePath' => '/v1', - 'schemes' => ['https'], - 'consumes' => ['application/json', 'multipart/form-data'], - 'produces' => ['application/json'], - 'securityDefinitions' => $keys[$platform], - 'paths' => [], - 'definitions' => [ - // 'Pet' => [ - // 'required' => ['id', 'name'], - // 'properties' => [ - // 'id' => [ - // 'type' => 'integer', - // 'format' => 'int64', - // ], - // 'name' => [ - // 'type' => 'string', - // ], - // 'tag' => [ - // 'type' => 'string', - // ], - // ], - // ], - // 'Pets' => array( - // 'type' => 'array', - // 'items' => array( - // '$ref' => '#/definitions/Pet', - // ), - // ), - 'Error' => array( - 'required' => array( - 0 => 'code', - 1 => 'message', - ), - 'properties' => array( - 'code' => array( - 'type' => 'integer', - 'format' => 'int32', - ), - 'message' => array( - 'type' => 'string', - ), - ), - ), - ], - 'externalDocs' => [ - 'description' => 'Full API docs, specs and tutorials', - 'url' => Config::getParam('protocol').'://'.Config::getParam('domain').'/docs', - ], - ]; - - if ($extensions) { - if (isset($output['securityDefinitions']['Project'])) { - $output['securityDefinitions']['Project']['extensions'] = ['demo' => '5df5acd0d48c2']; + if (empty($route->getLabel('sdk.namespace', null))) { + continue; } + + if ($platform !== APP_PLATFORM_CONSOLE && !\in_array($platforms[$platform], $route->getLabel('sdk.platform', []))) { + continue; + } + + $routes[] = $route; + $model = $response->getModel($route->getLabel('sdk.response.model', 'none')); - if (isset($output['securityDefinitions']['Key'])) { - $output['securityDefinitions']['Key']['extensions'] = ['demo' => '919c2d18fb5d4...a2ae413da83346ad2']; - } - - if (isset($output['securityDefinitions']['Locale'])) { - $output['securityDefinitions']['Locale']['extensions'] = ['demo' => 'en']; - } - - if (isset($output['securityDefinitions']['Mode'])) { - $output['securityDefinitions']['Mode']['extensions'] = ['demo' => '']; + if($model) { + $models[$model->getType()] = $model; } } - - foreach ($utopia->getRoutes() as $key => $method) { - foreach ($method as $route) { /* @var $route \Utopia\Route */ - if (!$route->getLabel('docs', true)) { - continue; - } - - if (empty($route->getLabel('sdk.namespace', null))) { - continue; - } - - if ($platform !== APP_PLATFORM_CONSOLE && !\in_array($platforms[$platform], $route->getLabel('sdk.platform', []))) { - continue; - } - - $url = \str_replace('/v1', '', $route->getURL()); - $scope = $route->getLabel('scope', ''); - $hide = $route->getLabel('sdk.hide', false); - $consumes = ['application/json']; - - if ($hide) { - continue; - } - - $desc = (!empty($route->getLabel('sdk.description', ''))) ? \realpath('../'.$route->getLabel('sdk.description', '')) : null; - - $temp = [ - 'summary' => $route->getDesc(), - 'operationId' => $route->getLabel('sdk.method', \uniqid()), - 'consumes' => [], - 'tags' => [$route->getLabel('sdk.namespace', 'default')], - 'description' => ($desc) ? \file_get_contents($desc) : '', - - // 'responses' => [ - // 200 => [ - // 'description' => 'An paged array of pets', - // 'schema' => [ - // '$ref' => '#/definitions/Pet', - // ], - // ], - // ], - ]; - - if ($extensions) { - $platformList = $route->getLabel('sdk.platform', []); - - $temp['extensions'] = [ - 'weight' => $route->getOrder(), - 'cookies' => $route->getLabel('sdk.cookies', false), - 'type' => $route->getLabel('sdk.methodType', ''), - 'demo' => 'docs/examples/'.fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')).'/'.fromCamelCaseToDash($temp['operationId']).'.md', - 'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $route->getLabel('sdk.description', ''), - 'rate-limit' => $route->getLabel('abuse-limit', 0), - 'rate-time' => $route->getLabel('abuse-time', 3600), - 'rate-key' => $route->getLabel('abuse-key', 'url:{url},ip:{ip}'), - 'scope' => $route->getLabel('scope', ''), - 'platforms' => $platformList, - ]; - } - - if ((!empty($scope))) { // && 'public' != $scope - $temp['security'][] = $route->getLabel('sdk.security', $security[$platform]); - } - - $requestBody = [ - 'content' => [ - 'application/x-www-form-urlencoded' => [ - 'schema' => [ - 'type' => 'object', - 'properties' => [], - ], - 'required' => [], - ], - ], - ]; - - foreach ($route->getParams() as $name => $param) { - $validator = (\is_callable($param['validator'])) ? $param['validator']() : $param['validator']; /* @var $validator \Utopia\Validator */ - - $node = [ - 'name' => $name, - 'description' => $param['description'], - 'required' => !$param['optional'], - ]; - - switch ((!empty($validator)) ? \get_class($validator) : '') { - case 'Utopia\Validator\Text': - $node['type'] = 'string'; - $node['x-example'] = '['.\strtoupper(fromCamelCase($node['name'])).']'; - break; - case 'Utopia\Validator\Boolean': - $node['type'] = 'boolean'; - $node['x-example'] = false; - break; - case 'Appwrite\Database\Validator\UID': - $node['type'] = 'string'; - $node['x-example'] = '['.\strtoupper(fromCamelCase($node['name'])).']'; - break; - case 'Utopia\Validator\Email': - $node['type'] = 'string'; - $node['format'] = 'email'; - $node['x-example'] = 'email@example.com'; - break; - case 'Utopia\Validator\URL': - $node['type'] = 'string'; - $node['format'] = 'url'; - $node['x-example'] = 'https://example.com'; - break; - case 'Utopia\Validator\JSON': - case 'Utopia\Validator\Mock': - case 'Utopia\Validator\Assoc': - $node['type'] = 'object'; - $node['type'] = 'object'; - $node['x-example'] = '{}'; - //$node['format'] = 'json'; - break; - case 'Appwrite\Storage\Validator\File': - $consumes = ['multipart/form-data']; - $node['type'] = 'file'; - break; - case 'Utopia\Validator\ArrayList': - $node['type'] = 'array'; - $node['collectionFormat'] = 'multi'; - $node['items'] = [ - 'type' => 'string', - ]; - break; - case 'Appwrite\Auth\Validator\Password': - $node['type'] = 'string'; - $node['format'] = 'format'; - $node['x-example'] = 'password'; - break; - case 'Utopia\Validator\Range': /* @var $validator \Utopia\Validator\Range */ - $node['type'] = 'integer'; - $node['format'] = 'int32'; - $node['x-example'] = $validator->getMin(); - break; - case 'Utopia\Validator\Numeric': - $node['type'] = 'integer'; - $node['format'] = 'int32'; - break; - case 'Utopia\Validator\Length': - $node['type'] = 'string'; - break; - case 'Utopia\Validator\Host': - $node['type'] = 'string'; - $node['format'] = 'url'; - $node['x-example'] = 'https://example.com'; - break; - case 'Utopia\Validator\WhiteList': /* @var $validator \Utopia\Validator\WhiteList */ - $node['type'] = 'string'; - $node['x-example'] = $validator->getList()[0]; - break; - default: - $node['type'] = 'string'; - break; - } - - if ($param['optional'] && !\is_null($param['default'])) { // Param has default value - $node['default'] = $param['default']; - } - - if (false !== \strpos($url, ':'.$name)) { // Param is in URL path - $node['in'] = 'path'; - $temp['parameters'][] = $node; - } elseif ($key == 'GET') { // Param is in query - $node['in'] = 'query'; - $temp['parameters'][] = $node; - } else { // Param is in payload - $node['in'] = 'formData'; - $temp['parameters'][] = $node; - $requestBody['content']['application/x-www-form-urlencoded']['schema']['properties'][] = $node; - - if (!$param['optional']) { - $requestBody['content']['application/x-www-form-urlencoded']['required'][] = $name; - } - } - - $url = \str_replace(':'.$name, '{'.$name.'}', $url); - } - - $temp['consumes'] = $consumes; - - $output['paths'][$url][\strtolower($route->getMethod())] = $temp; - } - } - - /*foreach ($consoleDB->getMocks() as $mock) { - var_dump($mock['name']); - }*/ - - \ksort($output['paths']); - - $response - ->json($output); } - ); \ No newline at end of file + + foreach (Config::getParam('services', []) as $key => $service) { + if(!isset($service['docs']) // Skip service if not part of the public API + || !isset($service['sdk']) + || !$service['docs'] + || !$service['sdk']) { + continue; + } + + $services[] = [ + 'name' => $service['key'] ?? '', + 'description' => $service['subtitle'] ?? '', + ]; + } + + $models = $response->getModels(); + + foreach ($models as $key => $value) { + if($platform !== APP_PLATFORM_CONSOLE && !$value->isPublic()) { + unset($models[$key]); + } + } + + switch ($format) { + case 'swagger2': + $format = new Swagger2($utopia, $services, $routes, $models, $keys[$platform], $security[$platform]); + break; + + case 'open-api3': + $format = new OpenAPI3($utopia, $services, $routes, $models, $keys[$platform], $security[$platform]); + break; + + default: + throw new Exception('Format not found', 404); + break; + } + + $specs = new Specification($format); + + $format + ->setParam('name', APP_NAME) + ->setParam('description', 'Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)') + ->setParam('endpoint', App::getEnv('_APP_HOME', $request->getProtocol().'://'.$request->getHostname()).'/v1') + ->setParam('version', APP_VERSION_STABLE) + ->setParam('terms', App::getEnv('_APP_HOME', $request->getProtocol().'://'.$request->getHostname()).'/policy/terms') + ->setParam('support.email', App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM)) + ->setParam('support.url', App::getEnv('_APP_HOME', $request->getProtocol().'://'.$request->getHostname()).'/support') + ->setParam('contact.name', APP_NAME.' Team') + ->setParam('contact.email', App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM)) + ->setParam('contact.url', App::getEnv('_APP_HOME', $request->getProtocol().'://'.$request->getHostname()).'/support') + ->setParam('license.name', 'BSD-3-Clause') + ->setParam('license.url', 'https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE') + ->setParam('docs.description', 'Full API docs, specs and tutorials') + ->setParam('docs.url', App::getEnv('_APP_HOME', $request->getProtocol().'://'.$request->getHostname()).'/docs') + ; + + $response + ->json($specs->parse()); + }); \ No newline at end of file diff --git a/app/db/DBIP/dbip-country-lite-2020-01.mmdb b/app/db/DBIP/dbip-country-lite-2020-01.mmdb deleted file mode 100644 index 133c896227..0000000000 Binary files a/app/db/DBIP/dbip-country-lite-2020-01.mmdb and /dev/null differ diff --git a/app/db/DBIP/dbip-country-lite-2021-02.mmdb b/app/db/DBIP/dbip-country-lite-2021-02.mmdb new file mode 100644 index 0000000000..6434c220f9 Binary files /dev/null and b/app/db/DBIP/dbip-country-lite-2021-02.mmdb differ diff --git a/app/http.php b/app/http.php new file mode 100644 index 0000000000..9e45bc3b52 --- /dev/null +++ b/app/http.php @@ -0,0 +1,119 @@ +set([ + 'open_http2_protocol' => true, + // 'document_root' => __DIR__.'/../public', + // 'enable_static_handler' => true, + 'http_compression' => true, + 'http_compression_level' => 6, + 'package_max_length' => $payloadSize, + ]) +; + +$http->on('WorkerStart', function($serv, $workerId) { + Console::success('Worker '.++$workerId.' started succefully'); +}); + +$http->on('BeforeReload', function($serv, $workerId) { + Console::success('Starting reload...'); +}); + +$http->on('AfterReload', function($serv, $workerId) { + Console::success('Reload completed...'); +}); + +$http->on('start', function (Server $http) use ($payloadSize) { + + Console::success('Server started succefully (max payload is '.number_format($payloadSize).' bytes)'); + + Console::info("Master pid {$http->master_pid}, manager pid {$http->manager_pid}"); + + // listen ctrl + c + Process::signal(2, function () use ($http) { + Console::log('Stop by Ctrl+C'); + $http->shutdown(); + }); +}); + +Files::load(__DIR__ . '/../public'); + +include __DIR__ . '/controllers/general.php'; + +$domain = App::getEnv('_APP_DOMAIN', ''); + +Console::info('Issuing a TLS certificate for the master domain ('.$domain.') in 30 seconds. + Make sure your domain points to your server IP or restart your Appwrite server to try again.'); // TODO move this to installation script + +ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [ + 'document' => [], + 'domain' => $domain, + 'validateTarget' => false, + 'validateCNAME' => false, +]); + +$http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) { + $request = new Request($swooleRequest); + $response = new Response($swooleResponse); + + if(Files::isFileLoaded($request->getURI())) { + $time = (60 * 60 * 24 * 365 * 2); // 45 days cache + + $response + ->setContentType(Files::getFileMimeType($request->getURI())) + ->addHeader('Cache-Control', 'public, max-age='.$time) + ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache + ->send(Files::getFileContents($request->getURI())) + ; + + return; + } + + $app = new App('America/New_York'); + + try { + Authorization::cleanRoles(); + Authorization::setRole('*'); + + $app->run($request, $response); + } catch (\Throwable $th) { + Console::error('[Error] Type: '.get_class($th)); + Console::error('[Error] Message: '.$th->getMessage()); + Console::error('[Error] File: '.$th->getFile()); + Console::error('[Error] Line: '.$th->getLine()); + + if(App::isDevelopment()) { + $swooleResponse->end('error: '.$th->getMessage()); + } + else { + $swooleResponse->end('500: Server Error'); + } + } +}); + +$http->start(); \ No newline at end of file diff --git a/app/init.php b/app/init.php index 7c4c03fa1e..bf7a26f912 100644 --- a/app/init.php +++ b/app/init.php @@ -4,37 +4,45 @@ * 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')) { require_once __DIR__.'/../vendor/autoload.php'; } +use Ahc\Jwt\JWT; +use Ahc\Jwt\JWTException; +use Appwrite\Auth\Auth; +use Appwrite\Database\Database; +use Appwrite\Database\Adapter\MySQL as MySQLAdapter; +use Appwrite\Database\Adapter\Redis as RedisAdapter; +use Appwrite\Database\Document; +use Appwrite\Database\Validator\Authorization; +use Appwrite\Event\Event; +use Appwrite\Extend\PDO; +use Appwrite\OpenSSL\OpenSSL; use Utopia\App; -use Utopia\Request; -use Utopia\Response; +use Utopia\View; use Utopia\Config\Config; use Utopia\Locale\Locale; use Utopia\Registry\Registry; -use Appwrite\Auth\Auth; -use Appwrite\Database\Database; -use Appwrite\Database\Document; -use Appwrite\Database\Validator\Authorization; -use Appwrite\Database\Adapter\MySQL as MySQLAdapter; -use Appwrite\Database\Adapter\Redis as RedisAdapter; +use MaxMind\Db\Reader; use PHPMailer\PHPMailer\PHPMailer; +use PDO as PDONative; const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; const APP_EMAIL_TEAM = 'team@localhost.test'; // Default email address const APP_EMAIL_SECURITY = 'security@localhost.test'; // Default security email address 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 = 15; -const APP_CACHE_BUSTER = 125; -const APP_VERSION_STABLE = '0.6.2'; +const APP_PAGING_LIMIT = 12; +const APP_CACHE_BUSTER = 143; +const APP_VERSION_STABLE = '0.7.0'; const APP_STORAGE_UPLOADS = '/storage/uploads'; +const APP_STORAGE_FUNCTIONS = '/storage/functions'; const APP_STORAGE_CACHE = '/storage/cache'; const APP_STORAGE_CERTIFICATES = '/storage/certificates'; const APP_STORAGE_CONFIG = '/storage/config'; @@ -44,72 +52,109 @@ const APP_SOCIAL_FACEBOOK = 'https://www.facebook.com/appwrite.io'; const APP_SOCIAL_LINKEDIN = 'https://www.linkedin.com/company/appwrite'; const APP_SOCIAL_INSTAGRAM = 'https://www.instagram.com/appwrite.io'; const APP_SOCIAL_GITHUB = 'https://github.com/appwrite'; -const APP_SOCIAL_DISCORD = 'https://discord.gg/GSeTUeA'; +const APP_SOCIAL_DISCORD = 'https://appwrite.io/discord'; const APP_SOCIAL_DEV = 'https://dev.to/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'; +const DELETE_TYPE_CERTIFICATES = 'certificates'; $register = new Registry(); -$request = new Request(); -$response = new Response(); -$utopia = new App('Asia/Tel_Aviv'); -$utopia->setMode($utopia->getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION)); +App::setMode(App::getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION)); /* * ENV vars */ -Config::load('events', __DIR__.'/../app/config/events.php'); -Config::load('providers', __DIR__.'/../app/config/providers.php'); -Config::load('platforms', __DIR__.'/../app/config/platforms.php'); -Config::load('locales', __DIR__.'/../app/config/locales.php'); -Config::load('collections', __DIR__.'/../app/config/collections.php'); -Config::load('roles', __DIR__.'/../app/config/roles.php'); // User roles and scopes -Config::load('services', __DIR__.'/../app/config/services.php'); // List of services +Config::load('events', __DIR__.'/config/events.php'); +Config::load('providers', __DIR__.'/config/providers.php'); +Config::load('platforms', __DIR__.'/config/platforms.php'); +Config::load('collections', __DIR__.'/config/collections.php'); +Config::load('environments', __DIR__.'/config/environments.php'); +Config::load('roles', __DIR__.'/config/roles.php'); // User roles and scopes +Config::load('scopes', __DIR__.'/config/scopes.php'); // User roles and scopes +Config::load('services', __DIR__.'/config/services.php'); // List of services +Config::load('variables', __DIR__.'/config/variables.php'); // List of env variables +Config::load('avatar-browsers', __DIR__.'/config/avatars/browsers.php'); +Config::load('avatar-credit-cards', __DIR__.'/config/avatars/credit-cards.php'); +Config::load('avatar-flags', __DIR__.'/config/avatars/flags.php'); +Config::load('locale-codes', __DIR__.'/config/locale/codes.php'); +Config::load('locale-currencies', __DIR__.'/config/locale/currencies.php'); +Config::load('locale-eu', __DIR__.'/config/locale/eu.php'); +Config::load('locale-languages', __DIR__.'/config/locale/languages.php'); +Config::load('locale-phones', __DIR__.'/config/locale/phones.php'); +Config::load('storage-logos', __DIR__.'/config/storage/logos.php'); +Config::load('storage-mimes', __DIR__.'/config/storage/mimes.php'); +Config::load('storage-inputs', __DIR__.'/config/storage/inputs.php'); +Config::load('storage-outputs', __DIR__.'/config/storage/outputs.php'); -Config::setParam('env', $utopia->getMode()); -Config::setParam('domain', $request->getServer('HTTP_HOST', '')); -Config::setParam('domainVerification', false); -Config::setParam('version', $request->getServer('_APP_VERSION', 'UNKNOWN')); -Config::setParam('protocol', $request->getServer('HTTP_X_FORWARDED_PROTO', $request->getServer('REQUEST_SCHEME', 'https'))); -Config::setParam('port', (string) \parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_PORT)); -Config::setParam('hostname', \parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', null), PHP_URL_HOST)); +Resque::setBackend(App::getEnv('_APP_REDIS_HOST', '') + .':'.App::getEnv('_APP_REDIS_PORT', '')); -Resque::setBackend($request->getServer('_APP_REDIS_HOST', '') - .':'.$request->getServer('_APP_REDIS_PORT', '')); +/** + * DB Filters + */ +Database::addFilter('json', + function($value) { + if(!is_array($value)) { + return $value; + } + return json_encode($value); + }, + function($value) { + return json_decode($value, true); + } +); -\define('COOKIE_DOMAIN', - ( - $request->getServer('HTTP_HOST', null) === 'localhost' || - $request->getServer('HTTP_HOST', null) === 'localhost:'.Config::getParam('port') || - (\filter_var(Config::getParam('hostname'), FILTER_VALIDATE_IP) !== false) - ) - ? null - : '.'.Config::getParam('hostname') - ); -\define('COOKIE_SAMESITE', Response::COOKIE_SAMESITE_NONE); +Database::addFilter('encrypt', + function($value) { + $key = App::getEnv('_APP_OPENSSL_KEY_V1'); + $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); + $tag = null; + + return json_encode([ + 'data' => OpenSSL::encrypt($value, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), + 'method' => OpenSSL::CIPHER_AES_128_GCM, + 'iv' => bin2hex($iv), + 'tag' => bin2hex($tag), + 'version' => '1', + ]); + }, + function($value) { + $value = json_decode($value, true); + $key = App::getEnv('_APP_OPENSSL_KEY_V'.$value['version']); + + return OpenSSL::decrypt($value['data'], $value['method'], $key, 0, hex2bin($value['iv']), hex2bin($value['tag'])); + } +); /* * Registry */ -$register->set('db', function () use ($request) { // Register DB connection - $dbHost = $request->getServer('_APP_DB_HOST', ''); - $dbUser = $request->getServer('_APP_DB_USER', ''); - $dbPass = $request->getServer('_APP_DB_PASS', ''); - $dbScheme = $request->getServer('_APP_DB_SCHEMA', ''); +$register->set('db', function () { // Register DB connection + $dbHost = App::getEnv('_APP_DB_HOST', ''); + $dbUser = App::getEnv('_APP_DB_USER', ''); + $dbPass = App::getEnv('_APP_DB_PASS', ''); + $dbScheme = App::getEnv('_APP_DB_SCHEMA', ''); $pdo = new PDO("mysql:host={$dbHost};dbname={$dbScheme};charset=utf8mb4", $dbUser, $dbPass, array( - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', - PDO::ATTR_TIMEOUT => 5, // Seconds + PDONative::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', + PDONative::ATTR_TIMEOUT => 3, // Seconds + PDONative::ATTR_PERSISTENT => true )); // Connection settings - $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); // Return arrays - $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Handle all errors with exceptions + $pdo->setAttribute(PDONative::ATTR_DEFAULT_FETCH_MODE, PDONative::FETCH_ASSOC); // Return arrays + $pdo->setAttribute(PDONative::ATTR_ERRMODE, PDONative::ERRMODE_EXCEPTION); // Handle all errors with exceptions return $pdo; }); -$register->set('influxdb', function () use ($request) { // Register DB connection - $host = $request->getServer('_APP_INFLUXDB_HOST', ''); - $port = $request->getServer('_APP_INFLUXDB_PORT', ''); +$register->set('influxdb', function () { // Register DB connection + $host = App::getEnv('_APP_INFLUXDB_HOST', ''); + $port = App::getEnv('_APP_INFLUXDB_PORT', ''); if (empty($host) || empty($port)) { return; @@ -119,43 +164,42 @@ $register->set('influxdb', function () use ($request) { // Register DB connectio return $client; }); -$register->set('statsd', function () use ($request) { // Register DB connection - $host = $request->getServer('_APP_STATSD_HOST', 'telegraf'); - $port = $request->getServer('_APP_STATSD_PORT', 8125); +$register->set('statsd', function () { // Register DB connection + $host = App::getEnv('_APP_STATSD_HOST', 'telegraf'); + $port = App::getEnv('_APP_STATSD_PORT', 8125); $connection = new \Domnikl\Statsd\Connection\UdpSocket($host, $port); $statsd = new \Domnikl\Statsd\Client($connection); return $statsd; }); -$register->set('cache', function () use ($request) { // Register cache connection +$register->set('cache', function () { // Register cache connection $redis = new Redis(); - - $redis->connect($request->getServer('_APP_REDIS_HOST', ''), - $request->getServer('_APP_REDIS_PORT', '')); + $redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''), App::getEnv('_APP_REDIS_PORT', '')); + $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); return $redis; }); -$register->set('smtp', function () use ($request) { +$register->set('smtp', function () { $mail = new PHPMailer(true); $mail->isSMTP(); - $username = $request->getServer('_APP_SMTP_USERNAME', null); - $password = $request->getServer('_APP_SMTP_PASSWORD', null); + $username = App::getEnv('_APP_SMTP_USERNAME', null); + $password = App::getEnv('_APP_SMTP_PASSWORD', null); $mail->XMailer = 'Appwrite Mailer'; - $mail->Host = $request->getServer('_APP_SMTP_HOST', 'smtp'); - $mail->Port = $request->getServer('_APP_SMTP_PORT', 25); + $mail->Host = App::getEnv('_APP_SMTP_HOST', 'smtp'); + $mail->Port = App::getEnv('_APP_SMTP_PORT', 25); $mail->SMTPAuth = (!empty($username) && !empty($password)); $mail->Username = $username; $mail->Password = $password; - $mail->SMTPSecure = $request->getServer('_APP_SMTP_SECURE', false); + $mail->SMTPSecure = App::getEnv('_APP_SMTP_SECURE', false); $mail->SMTPAutoTLS = false; $mail->CharSet = 'UTF-8'; - $from = \urldecode($request->getServer('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server')); - $email = $request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); + $from = \urldecode(App::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server')); + $email = App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM); $mail->setFrom($email, $from); $mail->addReplyTo($email, $from); @@ -164,154 +208,281 @@ $register->set('smtp', function () use ($request) { return $mail; }); +$register->set('geodb', function () { + return new Reader(__DIR__.'/db/DBIP/dbip-country-lite-2021-02.mmdb'); +}); /* * Localization */ -$locale = $request->getParam('locale', $request->getHeader('X-Appwrite-Locale', '')); - Locale::$exceptions = false; - -Locale::setLanguage('af', include __DIR__.'/config/locales/af.php'); -Locale::setLanguage('ar', include __DIR__.'/config/locales/ar.php'); -Locale::setLanguage('bn', include __DIR__.'/config/locales/bn.php'); -Locale::setLanguage('cat', include __DIR__.'/config/locales/cat.php'); -Locale::setLanguage('cz', include __DIR__.'/config/locales/cz.php'); -Locale::setLanguage('de', include __DIR__.'/config/locales/de.php'); -Locale::setLanguage('en', include __DIR__.'/config/locales/en.php'); -Locale::setLanguage('es', include __DIR__.'/config/locales/es.php'); -Locale::setLanguage('fi', include __DIR__.'/config/locales/fi.php'); -Locale::setLanguage('fo', include __DIR__.'/config/locales/fo.php'); -Locale::setLanguage('fr', include __DIR__.'/config/locales/fr.php'); -Locale::setLanguage('gr', include __DIR__.'/config/locales/gr.php'); -Locale::setLanguage('he', include __DIR__.'/config/locales/he.php'); -Locale::setLanguage('hi', include __DIR__.'/config/locales/hi.php'); -Locale::setLanguage('hu', include __DIR__.'/config/locales/hu.php'); -Locale::setLanguage('hy', include __DIR__.'/config/locales/hy.php'); -Locale::setLanguage('id', include __DIR__.'/config/locales/id.php'); -Locale::setLanguage('is', include __DIR__.'/config/locales/is.php'); -Locale::setLanguage('it', include __DIR__.'/config/locales/it.php'); -Locale::setLanguage('ja', include __DIR__.'/config/locales/ja.php'); -Locale::setLanguage('jv', include __DIR__.'/config/locales/jv.php'); -Locale::setLanguage('km', include __DIR__.'/config/locales/km.php'); -Locale::setLanguage('ko', include __DIR__.'/config/locales/ko.php'); -Locale::setLanguage('lt', include __DIR__.'/config/locales/lt.php'); -Locale::setLanguage('ml', include __DIR__.'/config/locales/ml.php'); -Locale::setLanguage('ms', include __DIR__.'/config/locales/ms.php'); -Locale::setLanguage('nl', include __DIR__.'/config/locales/nl.php'); -Locale::setLanguage('no', include __DIR__.'/config/locales/no.php'); -Locale::setLanguage('ph', include __DIR__.'/config/locales/ph.php'); -Locale::setLanguage('pl', include __DIR__.'/config/locales/pl.php'); -Locale::setLanguage('pt-br', include __DIR__.'/config/locales/pt-br.php'); -Locale::setLanguage('pt-pt', include __DIR__.'/config/locales/pt-pt.php'); -Locale::setLanguage('ro', include __DIR__.'/config/locales/ro.php'); -Locale::setLanguage('ru', include __DIR__ . '/config/locales/ru.php'); -Locale::setLanguage('si', include __DIR__ . '/config/locales/si.php'); -Locale::setLanguage('sl', include __DIR__ . '/config/locales/sl.php'); -Locale::setLanguage('sq', include __DIR__ . '/config/locales/sq.php'); -Locale::setLanguage('sv', include __DIR__ . '/config/locales/sv.php'); -Locale::setLanguage('ta', include __DIR__ . '/config/locales/ta.php'); -Locale::setLanguage('th', include __DIR__.'/config/locales/th.php'); -Locale::setLanguage('tr', include __DIR__.'/config/locales/tr.php'); -Locale::setLanguage('ua', include __DIR__.'/config/locales/ua.php'); -Locale::setLanguage('vi', include __DIR__.'/config/locales/vi.php'); -Locale::setLanguage('zh-cn', include __DIR__.'/config/locales/zh-cn.php'); -Locale::setLanguage('zh-tw', include __DIR__.'/config/locales/zh-tw.php'); - -Locale::setDefault('en'); - -if (\in_array($locale, Config::getParam('locales'))) { - Locale::setDefault($locale); -} +Locale::setLanguage('af', include __DIR__.'/config/locale/translations/af.php'); +Locale::setLanguage('ar', include __DIR__.'/config/locale/translations/ar.php'); +Locale::setLanguage('ba', include __DIR__.'/config/locale/translations/ba.php'); +Locale::setLanguage('be', include __DIR__.'/config/locale/translations/be.php'); +Locale::setLanguage('bg', include __DIR__.'/config/locale/translations/bg.php'); +Locale::setLanguage('bn', include __DIR__.'/config/locale/translations/bn.php'); +Locale::setLanguage('cat', include __DIR__.'/config/locale/translations/cat.php'); +Locale::setLanguage('cz', include __DIR__.'/config/locale/translations/cz.php'); +Locale::setLanguage('de', include __DIR__.'/config/locale/translations/de.php'); +Locale::setLanguage('en', include __DIR__.'/config/locale/translations/en.php'); +Locale::setLanguage('es', include __DIR__.'/config/locale/translations/es.php'); +Locale::setLanguage('fa', include __DIR__.'/config/locale/translations/fa.php'); +Locale::setLanguage('fi', include __DIR__.'/config/locale/translations/fi.php'); +Locale::setLanguage('fo', include __DIR__.'/config/locale/translations/fo.php'); +Locale::setLanguage('fr', include __DIR__.'/config/locale/translations/fr.php'); +Locale::setLanguage('gr', include __DIR__.'/config/locale/translations/gr.php'); +Locale::setLanguage('gu', include __DIR__.'/config/locale/translations/gu.php'); +Locale::setLanguage('he', include __DIR__.'/config/locale/translations/he.php'); +Locale::setLanguage('hi', include __DIR__.'/config/locale/translations/hi.php'); +Locale::setLanguage('hu', include __DIR__.'/config/locale/translations/hu.php'); +Locale::setLanguage('hy', include __DIR__.'/config/locale/translations/hy.php'); +Locale::setLanguage('id', include __DIR__.'/config/locale/translations/id.php'); +Locale::setLanguage('is', include __DIR__.'/config/locale/translations/is.php'); +Locale::setLanguage('it', include __DIR__.'/config/locale/translations/it.php'); +Locale::setLanguage('ja', include __DIR__.'/config/locale/translations/ja.php'); +Locale::setLanguage('jv', include __DIR__.'/config/locale/translations/jv.php'); +Locale::setLanguage('ka', include __DIR__.'/config/locale/translations/ka.php'); +Locale::setLanguage('km', include __DIR__.'/config/locale/translations/km.php'); +Locale::setLanguage('ko', include __DIR__.'/config/locale/translations/ko.php'); +Locale::setLanguage('lt', include __DIR__.'/config/locale/translations/lt.php'); +Locale::setLanguage('ml', include __DIR__.'/config/locale/translations/ml.php'); +Locale::setLanguage('mr', include __DIR__.'/config/locale/translations/mr.php'); +Locale::setLanguage('ms', include __DIR__.'/config/locale/translations/ms.php'); +Locale::setLanguage('nl', include __DIR__.'/config/locale/translations/nl.php'); +Locale::setLanguage('no', include __DIR__.'/config/locale/translations/no.php'); +Locale::setLanguage('np', include __DIR__.'/config/locale/translations/np.php'); +Locale::setLanguage('od', include __DIR__.'/config/locale/translations/od.php'); +Locale::setLanguage('ph', include __DIR__.'/config/locale/translations/ph.php'); +Locale::setLanguage('pl', include __DIR__.'/config/locale/translations/pl.php'); +Locale::setLanguage('pt-br', include __DIR__.'/config/locale/translations/pt-br.php'); +Locale::setLanguage('pt-pt', include __DIR__.'/config/locale/translations/pt-pt.php'); +Locale::setLanguage('pa', include __DIR__.'/config/locale/translations/pa.php'); +Locale::setLanguage('ro', include __DIR__.'/config/locale/translations/ro.php'); +Locale::setLanguage('ru', include __DIR__ . '/config/locale/translations/ru.php'); +Locale::setLanguage('si', include __DIR__ . '/config/locale/translations/si.php'); +Locale::setLanguage('sl', include __DIR__ . '/config/locale/translations/sl.php'); +Locale::setLanguage('sq', include __DIR__ . '/config/locale/translations/sq.php'); +Locale::setLanguage('sv', include __DIR__ . '/config/locale/translations/sv.php'); +Locale::setLanguage('ta', include __DIR__ . '/config/locale/translations/ta.php'); +Locale::setLanguage('th', include __DIR__.'/config/locale/translations/th.php'); +Locale::setLanguage('tr', include __DIR__.'/config/locale/translations/tr.php'); +Locale::setLanguage('ua', include __DIR__.'/config/locale/translations/ua.php'); +Locale::setLanguage('ur', include __DIR__.'/config/locale/translations/ur.php'); +Locale::setLanguage('vi', include __DIR__.'/config/locale/translations/vi.php'); +Locale::setLanguage('zh-cn', include __DIR__.'/config/locale/translations/zh-cn.php'); +Locale::setLanguage('zh-tw', include __DIR__.'/config/locale/translations/zh-tw.php'); \stream_context_set_default([ // Set global user agent and http settings 'http' => [ 'method' => 'GET', 'user_agent' => \sprintf(APP_USERAGENT, - Config::getParam('version'), - $request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)), + App::getEnv('_APP_VERSION', 'UNKNOWN'), + App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)), 'timeout' => 2, ], ]); -/* - * Auth & Project Scope - */ -$consoleDB = new Database(); -$consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); -$consoleDB->setNamespace('app_console'); // Should be replaced with param if we want to have parent projects +// Runtime Execution -$consoleDB->setMocks(Config::getParam('collections', [])); -Authorization::disable(); +App::setResource('register', function() use ($register) { + return $register; +}); -$project = $consoleDB->getDocument($request->getParam('project', $request->getHeader('X-Appwrite-Project', ''))); +App::setResource('layout', function($locale) { + $layout = new View(__DIR__.'/views/layouts/default.phtml'); + $layout->setParam('locale', $locale); -Authorization::enable(); + return $layout; +}, ['locale']); -$console = $consoleDB->getDocument('console'); +App::setResource('locale', function() { + return new Locale('en'); +}); -$mode = $request->getParam('mode', $request->getHeader('X-Appwrite-Mode', 'default')); +// Queues +App::setResource('events', function($register) { + return new Event('', ''); +}, ['register']); -Auth::setCookieName('a_session_'.$project->getId()); +App::setResource('audits', function($register) { + return new Event(Event::AUDITS_QUEUE_NAME, Event::AUDITS_CLASS_NAME); +}, ['register']); -if (APP_MODE_ADMIN === $mode) { - Auth::setCookieName('a_session_'.$console->getId()); -} +App::setResource('usage', function($register) { + return new Event(Event::USAGE_QUEUE_NAME, Event::USAGE_CLASS_NAME); +}, ['register']); -$session = Auth::decodeSession( - $request->getCookie(Auth::$cookieName, // Get sessions - $request->getCookie(Auth::$cookieName.'_legacy', // Get fallback session from old clients (no SameSite support) - $request->getHeader('X-Appwrite-Key', '')))); // Get API Key +App::setResource('mails', function($register) { + return new Event(Event::MAILS_QUEUE_NAME, Event::MAILS_CLASS_NAME); +}, ['register']); -// Get fallback session from clients who block 3rd-party cookies -$response->addHeader('X-Debug-Fallback', 'false'); +App::setResource('deletes', function($register) { + return new Event(Event::DELETE_QUEUE_NAME, Event::DELETE_CLASS_NAME); +}, ['register']); -if(empty($session['id']) && empty($session['secret'])) { - $response->addHeader('X-Debug-Fallback', 'true'); - $fallback = $request->getHeader('X-Fallback-Cookies', ''); - $fallback = \json_decode($fallback, true); - $session = Auth::decodeSession(((isset($fallback[Auth::$cookieName])) ? $fallback[Auth::$cookieName] : '')); -} +// Test Mock +App::setResource('clients', function($request, $console, $project) { + $console->setAttribute('platforms', [ // Allways allow current host + '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, + 'name' => 'Current Host', + 'type' => 'web', + 'hostname' => $request->getHostname(), + ], Document::SET_TYPE_APPEND); + + /** + * Get All verified client URLs for both console and current projects + * + Filter for duplicated entries + */ + $clientsConsole = \array_map(function ($node) { + return $node['hostname']; + }, \array_filter($console->getAttribute('platforms', []), function ($node) { + if (isset($node['type']) && $node['type'] === 'web' && isset($node['hostname']) && !empty($node['hostname'])) { + return true; + } -Auth::$unique = $session['id']; -Auth::$secret = $session['secret']; + return false; + })); -$projectDB = new Database(); -$projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); -$projectDB->setNamespace('app_'.$project->getId()); -$projectDB->setMocks(Config::getParam('collections', [])); + $clients = \array_unique(\array_merge($clientsConsole, \array_map(function ($node) { + return $node['hostname']; + }, \array_filter($project->getAttribute('platforms', []), function ($node) { + if (isset($node['type']) && $node['type'] === 'web' && isset($node['hostname']) && !empty($node['hostname'])) { + return true; + } -if (APP_MODE_ADMIN !== $mode) { - $user = $projectDB->getDocument(Auth::$unique); -} -else { - $user = $consoleDB->getDocument(Auth::$unique); + return false; + })))); - $user - ->setAttribute('$id', 'admin-'.$user->getAttribute('$id')) - ; -} + return $clients; +}, ['request', 'console', 'project']); -if (empty($user->getId()) // Check a document has been found in the DB - || Database::SYSTEM_COLLECTION_USERS !== $user->getCollection() // Validate returned document is really a user document - || !Auth::tokenVerify($user->getAttribute('tokens', []), Auth::TOKEN_TYPE_LOGIN, Auth::$secret)) { // Validate user has valid login token - $user = new Document(['$id' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]); -} +App::setResource('user', function($mode, $project, $console, $request, $response, $projectDB, $consoleDB) { + /** @var Utopia\Swoole\Request $request */ + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Document $project */ + /** @var Appwrite\Database\Database $consoleDB */ + /** @var Appwrite\Database\Database $projectDB */ + /** @var bool $mode */ -if (APP_MODE_ADMIN === $mode) { - if (!empty($user->search('teamId', $project->getAttribute('teamId'), $user->getAttribute('memberships')))) { - Authorization::disable(); - } else { + Authorization::setDefaultStatus(true); + + Auth::setCookieName('a_session_'.$project->getId()); + + if (APP_MODE_ADMIN === $mode) { + Auth::setCookieName('a_session_'.$console->getId()); + } + + $session = Auth::decodeSession( + $request->getCookie(Auth::$cookieName, // Get sessions + $request->getCookie(Auth::$cookieName.'_legacy', '')));// Get fallback session from old clients (no SameSite support) + + // Get fallback session from clients who block 3rd-party cookies + $response->addHeader('X-Debug-Fallback', 'false'); + + if(empty($session['id']) && empty($session['secret'])) { + $response->addHeader('X-Debug-Fallback', 'true'); + $fallback = $request->getHeader('x-fallback-cookies', ''); + $fallback = \json_decode($fallback, true); + $session = Auth::decodeSession(((isset($fallback[Auth::$cookieName])) ? $fallback[Auth::$cookieName] : '')); + } + + Auth::$unique = $session['id']; + Auth::$secret = $session['secret']; + + if (APP_MODE_ADMIN !== $mode) { + $user = $projectDB->getDocument(Auth::$unique); + } + else { + $user = $consoleDB->getDocument(Auth::$unique); + + $user + ->setAttribute('$id', 'admin-'.$user->getAttribute('$id')) + ; + } + + if (empty($user->getId()) // Check a document has been found in the DB + || Database::SYSTEM_COLLECTION_USERS !== $user->getCollection() // Validate returned document is really a user document + || !Auth::tokenVerify($user->getAttribute('tokens', []), Auth::TOKEN_TYPE_LOGIN, Auth::$secret)) { // Validate user has valid login token $user = new Document(['$id' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]); } -} -// Set project mail -$register->get('smtp') - ->setFrom( - $request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), - ($project->getId() === 'console') - ? \urldecode($request->getServer('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server')) - : \sprintf(Locale::getText('account.emails.team'), $project->getAttribute('name') - ) - ); + if (APP_MODE_ADMIN === $mode) { + if (!empty($user->search('teamId', $project->getAttribute('teamId'), $user->getAttribute('memberships')))) { + Authorization::setDefaultStatus(false); // Cancel security segmentation for admin users. + } else { + $user = new Document(['$id' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]); + } + } + + $authJWT = $request->getHeader('x-appwrite-jwt', ''); + + if (!empty($authJWT)) { // JWT authentication + $jwt = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway. + + try { + $payload = $jwt->decode($authJWT); + } catch (JWTException $error) { + throw new Exception('Failed to verify JWT. '.$error->getMessage(), 401); + } + + $jwtUserId = $payload['userId'] ?? ''; + $jwtSessionId = $payload['sessionId'] ?? ''; + + if($jwtUserId && $jwtSessionId) { + $user = $projectDB->getDocument($jwtUserId); + } + + if (empty($user->search('$id', $jwtSessionId, $user->getAttribute('tokens')))) { // Match JWT to active token + $user = new Document(['$id' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]); + } + } + + return $user; +}, ['mode', 'project', 'console', 'request', 'response', 'projectDB', 'consoleDB']); + +App::setResource('project', function($consoleDB, $request) { + /** @var Utopia\Swoole\Request $request */ + /** @var Appwrite\Database\Database $consoleDB */ + + Authorization::disable(); + + $project = $consoleDB->getDocument($request->getParam('project', + $request->getHeader('x-appwrite-project', ''))); + + Authorization::reset(); + + return $project; +}, ['consoleDB', 'request']); + +App::setResource('console', function($consoleDB) { + return $consoleDB->getDocument('console'); +}, ['consoleDB']); + +App::setResource('consoleDB', function($register) { + $consoleDB = new Database(); + $consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); + $consoleDB->setNamespace('app_console'); // Should be replaced with param if we want to have parent projects + $consoleDB->setMocks(Config::getParam('collections', [])); + + return $consoleDB; +}, ['register']); + +App::setResource('projectDB', function($register, $project) { + $projectDB = new Database(); + $projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)); + $projectDB->setNamespace('app_'.$project->getId()); + $projectDB->setMocks(Config::getParam('collections', [])); + + return $projectDB; +}, ['register', 'project']); + +App::setResource('mode', function($request) { + /** @var Utopia\Swoole\Request $request */ + return $request->getParam('mode', $request->getHeader('x-appwrite-mode', APP_MODE_DEFAULT)); +}, ['request']); + +App::setResource('geodb', function($register) { + /** @var Utopia\Registry\Registry $register */ + return $register->get('geodb'); +}, ['register']); diff --git a/app/preload.php b/app/preload.php new file mode 100644 index 0000000000..f73aaea61a --- /dev/null +++ b/app/preload.php @@ -0,0 +1,46 @@ + $value) { + if($value !== false) { + $preloader->ignore($value); + } +} + +$preloader + ->paths(realpath(__DIR__ . '/../app/config')) + ->paths(realpath(__DIR__ . '/../app/controllers')) + ->paths(realpath(__DIR__ . '/../src')) + ->load(); diff --git a/app/sdks/client-flutter-dev/CHANGELOG.md b/app/sdks/client-flutter-dev/CHANGELOG.md deleted file mode 100644 index 2e9b0e0a91..0000000000 --- a/app/sdks/client-flutter-dev/CHANGELOG.md +++ /dev/null @@ -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 \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/LICENSE b/app/sdks/client-flutter-dev/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/client-flutter-dev/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/README.md b/app/sdks/client-flutter-dev/README.md deleted file mode 100644 index 2c0ba754c3..0000000000 --- a/app/sdks/client-flutter-dev/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Appwrite Flutter (Dev Channel) SDK - -[![pub package](https://img.shields.io/pub/v/appwrite.svg)](https://pub.dartlang.org/packages/appwrite) -![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter-dev.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1) - -**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) - - - -![Appwrite](https://appwrite.io/images/github.png) - -## 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. \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/delete-sessions.md b/app/sdks/client-flutter-dev/docs/examples/account/delete-sessions.md deleted file mode 100644 index b9cbb46fd2..0000000000 --- a/app/sdks/client-flutter-dev/docs/examples/account/delete-sessions.md +++ /dev/null @@ -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); - }); -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/delete.md b/app/sdks/client-flutter-dev/docs/examples/account/delete.md deleted file mode 100644 index 8c99b2ac61..0000000000 --- a/app/sdks/client-flutter-dev/docs/examples/account/delete.md +++ /dev/null @@ -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); - }); -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/get-logs.md b/app/sdks/client-flutter-dev/docs/examples/account/get-logs.md deleted file mode 100644 index 2ed66d88ce..0000000000 --- a/app/sdks/client-flutter-dev/docs/examples/account/get-logs.md +++ /dev/null @@ -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); - }); -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/get-prefs.md b/app/sdks/client-flutter-dev/docs/examples/account/get-prefs.md deleted file mode 100644 index 961a24dc19..0000000000 --- a/app/sdks/client-flutter-dev/docs/examples/account/get-prefs.md +++ /dev/null @@ -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); - }); -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/get-sessions.md b/app/sdks/client-flutter-dev/docs/examples/account/get-sessions.md deleted file mode 100644 index 76a566b959..0000000000 --- a/app/sdks/client-flutter-dev/docs/examples/account/get-sessions.md +++ /dev/null @@ -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); - }); -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/example/README.md b/app/sdks/client-flutter-dev/example/README.md deleted file mode 100644 index f6768a5f85..0000000000 --- a/app/sdks/client-flutter-dev/example/README.md +++ /dev/null @@ -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) \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/appwrite.dart b/app/sdks/client-flutter-dev/lib/appwrite.dart deleted file mode 100644 index 95d0b72cfe..0000000000 --- a/app/sdks/client-flutter-dev/lib/appwrite.dart +++ /dev/null @@ -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'; diff --git a/app/sdks/client-flutter-dev/lib/appwrite_dev.dart b/app/sdks/client-flutter-dev/lib/appwrite_dev.dart deleted file mode 100644 index 95d0b72cfe..0000000000 --- a/app/sdks/client-flutter-dev/lib/appwrite_dev.dart +++ /dev/null @@ -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'; diff --git a/app/sdks/client-flutter-dev/lib/client.dart b/app/sdks/client-flutter-dev/lib/client.dart deleted file mode 100644 index a5583fcd00..0000000000 --- a/app/sdks/client-flutter-dev/lib/client.dart +++ /dev/null @@ -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 headers; - Map 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 _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 call(HttpMethod method, {String path = '', Map headers = const {}, Map 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); - } - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/enums.dart b/app/sdks/client-flutter-dev/lib/enums.dart deleted file mode 100644 index 2757f6073e..0000000000 --- a/app/sdks/client-flutter-dev/lib/enums.dart +++ /dev/null @@ -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(); - } -} diff --git a/app/sdks/client-flutter-dev/lib/service.dart b/app/sdks/client-flutter-dev/lib/service.dart deleted file mode 100644 index 1ae319b705..0000000000 --- a/app/sdks/client-flutter-dev/lib/service.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'client.dart'; - -class Service { - final Client client; - - const Service(this.client); -} diff --git a/app/sdks/client-flutter-dev/lib/services/account.dart b/app/sdks/client-flutter-dev/lib/services/account.dart deleted file mode 100644 index 02fc33400e..0000000000 --- a/app/sdks/client-flutter-dev/lib/services/account.dart +++ /dev/null @@ -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 get() { - final String path = '/account'; - - final Map params = { - }; - - final Map 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 create({@required String email, @required String password, String name = ''}) { - final String path = '/account'; - - final Map params = { - 'email': email, - 'password': password, - 'name': name, - }; - - final Map 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 delete() { - final String path = '/account'; - - final Map params = { - }; - - final Map 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 updateEmail({@required String email, @required String password}) { - final String path = '/account/email'; - - final Map params = { - 'email': email, - 'password': password, - }; - - final Map 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 getLogs() { - final String path = '/account/logs'; - - final Map params = { - }; - - final Map 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 updateName({@required String name}) { - final String path = '/account/name'; - - final Map params = { - 'name': name, - }; - - final Map 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 updatePassword({@required String password, @required String oldPassword}) { - final String path = '/account/password'; - - final Map params = { - 'password': password, - 'oldPassword': oldPassword, - }; - - final Map 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 getPrefs() { - final String path = '/account/prefs'; - - final Map params = { - }; - - final Map 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 updatePrefs({@required dynamic prefs}) { - final String path = '/account/prefs'; - - final Map params = { - 'prefs': prefs, - }; - - final Map 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 createRecovery({@required String email, @required String url}) { - final String path = '/account/recovery'; - - final Map params = { - 'email': email, - 'url': url, - }; - - final Map 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 updateRecovery({@required String userId, @required String secret, @required String password, @required String passwordAgain}) { - final String path = '/account/recovery'; - - final Map params = { - 'userId': userId, - 'secret': secret, - 'password': password, - 'passwordAgain': passwordAgain, - }; - - final Map 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 getSessions() { - final String path = '/account/sessions'; - - final Map params = { - }; - - final Map 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 createSession({@required String email, @required String password}) { - final String path = '/account/sessions'; - - final Map params = { - 'email': email, - 'password': password, - }; - - final Map 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 deleteSessions() { - final String path = '/account/sessions'; - - final Map params = { - }; - - final Map 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 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 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 deleteSession({@required String sessionId}) { - final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId); - - final Map params = { - }; - - final Map 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 createVerification({@required String url}) { - final String path = '/account/verification'; - - final Map params = { - 'url': url, - }; - - final Map 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 updateVerification({@required String userId, @required String secret}) { - final String path = '/account/verification'; - - final Map params = { - 'userId': userId, - 'secret': secret, - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.put, path: path, params: params, headers: headers); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/avatars.dart b/app/sdks/client-flutter-dev/lib/services/avatars.dart deleted file mode 100644 index 828ea7dfb0..0000000000 --- a/app/sdks/client-flutter-dev/lib/services/avatars.dart +++ /dev/null @@ -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 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 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 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 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 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 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(); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/database.dart b/app/sdks/client-flutter-dev/lib/services/database.dart deleted file mode 100644 index 88082feef7..0000000000 --- a/app/sdks/client-flutter-dev/lib/services/database.dart +++ /dev/null @@ -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 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 params = { - 'filters': filters, - 'offset': offset, - 'limit': limit, - 'orderField': orderField, - 'orderType': orderType.name(), - 'orderCast': orderCast, - 'search': search, - 'first': first, - 'last': last, - }; - - final Map 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 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 params = { - 'data': data, - 'read': read, - 'write': write, - 'parentDocument': parentDocument, - 'parentProperty': parentProperty, - 'parentPropertyType': parentPropertyType, - }; - - final Map 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 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 params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.get, path: path, params: params, headers: headers); - } - - /// Update Document - Future 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 params = { - 'data': data, - 'read': read, - 'write': write, - }; - - final Map 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 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 params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.delete, path: path, params: params, headers: headers); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/locale.dart b/app/sdks/client-flutter-dev/lib/services/locale.dart deleted file mode 100644 index 91ea1567ef..0000000000 --- a/app/sdks/client-flutter-dev/lib/services/locale.dart +++ /dev/null @@ -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 get() { - final String path = '/locale'; - - final Map params = { - }; - - final Map 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 getContinents() { - final String path = '/locale/continents'; - - final Map params = { - }; - - final Map 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 getCountries() { - final String path = '/locale/countries'; - - final Map params = { - }; - - final Map 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 getCountriesEU() { - final String path = '/locale/countries/eu'; - - final Map params = { - }; - - final Map 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 getCountriesPhones() { - final String path = '/locale/countries/phones'; - - final Map params = { - }; - - final Map 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 getCurrencies() { - final String path = '/locale/currencies'; - - final Map params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.get, path: path, params: params, headers: headers); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/storage.dart b/app/sdks/client-flutter-dev/lib/services/storage.dart deleted file mode 100644 index 51f9345050..0000000000 --- a/app/sdks/client-flutter-dev/lib/services/storage.dart +++ /dev/null @@ -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 listFiles({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) { - final String path = '/storage/files'; - - final Map params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType.name(), - }; - - final Map 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 createFile({@required MultipartFile file, @required List read, @required List write}) { - final String path = '/storage/files'; - - final Map params = { - 'file': file, - 'read': read, - 'write': write, - }; - - final Map 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 getFile({@required String fileId}) { - final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); - - final Map params = { - }; - - final Map 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 updateFile({@required String fileId, @required List read, @required List write}) { - final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); - - final Map params = { - 'read': read, - 'write': write, - }; - - final Map 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 deleteFile({@required String fileId}) { - final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); - - final Map params = { - }; - - final Map 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 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 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 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(); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/teams.dart b/app/sdks/client-flutter-dev/lib/services/teams.dart deleted file mode 100644 index b98590b33d..0000000000 --- a/app/sdks/client-flutter-dev/lib/services/teams.dart +++ /dev/null @@ -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 list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) { - final String path = '/teams'; - - final Map params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType.name(), - }; - - final Map 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 create({@required String name, List roles = const ["owner"]}) { - final String path = '/teams'; - - final Map params = { - 'name': name, - 'roles': roles, - }; - - final Map 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 get({@required String teamId}) { - final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); - - final Map params = { - }; - - final Map 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 update({@required String teamId, @required String name}) { - final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); - - final Map params = { - 'name': name, - }; - - final Map 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 delete({@required String teamId}) { - final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); - - final Map params = { - }; - - final Map 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 getMemberships({@required String teamId}) { - final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); - - final Map params = { - }; - - final Map 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 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 params = { - 'email': email, - 'name': name, - 'roles': roles, - 'url': url, - }; - - final Map 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 deleteMembership({@required String teamId, @required String inviteId}) { - final String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); - - final Map params = { - }; - - final Map 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 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 params = { - 'userId': userId, - 'secret': secret, - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.patch, path: path, params: params, headers: headers); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/pubspec.yaml b/app/sdks/client-flutter-dev/pubspec.yaml deleted file mode 100644 index 7d3646b8ee..0000000000 --- a/app/sdks/client-flutter-dev/pubspec.yaml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/app/sdks/client-flutter/CHANGELOG.md b/app/sdks/client-flutter/CHANGELOG.md deleted file mode 100644 index 638d0882d2..0000000000 --- a/app/sdks/client-flutter/CHANGELOG.md +++ /dev/null @@ -1,56 +0,0 @@ -## 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 \ No newline at end of file diff --git a/app/sdks/client-flutter/LICENSE b/app/sdks/client-flutter/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/client-flutter/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/client-flutter/README.md b/app/sdks/client-flutter/README.md deleted file mode 100644 index 95cdeae642..0000000000 --- a/app/sdks/client-flutter/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Appwrite Flutter SDK - -[![pub package](https://img.shields.io/pub/v/appwrite.svg)](https://pub.dartlang.org/packages/appwrite) -![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1) - -**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) - - - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -Add this to your package's `pubspec.yaml` file: - -```yml -dependencies: - appwrite: ^0.3.0-dev.1 -``` - -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. \ No newline at end of file diff --git a/app/sdks/client-flutter/example/README.md b/app/sdks/client-flutter/example/README.md deleted file mode 100644 index f6768a5f85..0000000000 --- a/app/sdks/client-flutter/example/README.md +++ /dev/null @@ -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) \ No newline at end of file diff --git a/app/sdks/client-flutter/lib/appwrite.dart b/app/sdks/client-flutter/lib/appwrite.dart deleted file mode 100644 index 95d0b72cfe..0000000000 --- a/app/sdks/client-flutter/lib/appwrite.dart +++ /dev/null @@ -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'; diff --git a/app/sdks/client-flutter/lib/client.dart b/app/sdks/client-flutter/lib/client.dart deleted file mode 100644 index 1cf3ac8f0d..0000000000 --- a/app/sdks/client-flutter/lib/client.dart +++ /dev/null @@ -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 headers; - Map 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.1', - }; - - this.config = {}; - - assert(endPoint.startsWith(RegExp("http://|https://")), "endPoint $endPoint must start with 'http'"); - } - - Future _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 call(HttpMethod method, {String path = '', Map headers = const {}, Map 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); - } - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter/lib/enums.dart b/app/sdks/client-flutter/lib/enums.dart deleted file mode 100644 index 2757f6073e..0000000000 --- a/app/sdks/client-flutter/lib/enums.dart +++ /dev/null @@ -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(); - } -} diff --git a/app/sdks/client-flutter/lib/service.dart b/app/sdks/client-flutter/lib/service.dart deleted file mode 100644 index 1ae319b705..0000000000 --- a/app/sdks/client-flutter/lib/service.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'client.dart'; - -class Service { - final Client client; - - const Service(this.client); -} diff --git a/app/sdks/client-flutter/lib/services/account.dart b/app/sdks/client-flutter/lib/services/account.dart deleted file mode 100644 index 617ea83b98..0000000000 --- a/app/sdks/client-flutter/lib/services/account.dart +++ /dev/null @@ -1,425 +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 get() { - final String path = '/account'; - - final Map params = { - }; - - final Map 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 create({@required String email, @required String password, String name = ''}) { - final String path = '/account'; - - final Map params = { - 'email': email, - 'password': password, - 'name': name, - }; - - final Map 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 delete() { - final String path = '/account'; - - final Map params = { - }; - - final Map 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 updateEmail({@required String email, @required String password}) { - final String path = '/account/email'; - - final Map params = { - 'email': email, - 'password': password, - }; - - final Map 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 getLogs() { - final String path = '/account/logs'; - - final Map params = { - }; - - final Map 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 updateName({@required String name}) { - final String path = '/account/name'; - - final Map params = { - 'name': name, - }; - - final Map 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 updatePassword({@required String password, @required String oldPassword}) { - final String path = '/account/password'; - - final Map params = { - 'password': password, - 'oldPassword': oldPassword, - }; - - final Map 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 getPrefs() { - final String path = '/account/prefs'; - - final Map params = { - }; - - final Map 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 updatePrefs({@required dynamic prefs}) { - final String path = '/account/prefs'; - - final Map params = { - 'prefs': prefs, - }; - - final Map 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 createRecovery({@required String email, @required String url}) { - final String path = '/account/recovery'; - - final Map params = { - 'email': email, - 'url': url, - }; - - final Map 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 updateRecovery({@required String userId, @required String secret, @required String password, @required String passwordAgain}) { - final String path = '/account/recovery'; - - final Map params = { - 'userId': userId, - 'secret': secret, - 'password': password, - 'passwordAgain': passwordAgain, - }; - - final Map 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 getSessions() { - final String path = '/account/sessions'; - - final Map params = { - }; - - final Map 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 createSession({@required String email, @required String password}) { - final String path = '/account/sessions'; - - final Map params = { - 'email': email, - 'password': password, - }; - - final Map 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 deleteSessions() { - final String path = '/account/sessions'; - - final Map params = { - }; - - final Map 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 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('&') - ); - - 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 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 deleteSession({@required String sessionId}) { - final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId); - - final Map params = { - }; - - final Map 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 createVerification({@required String url}) { - final String path = '/account/verification'; - - final Map params = { - 'url': url, - }; - - final Map 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 updateVerification({@required String userId, @required String secret}) { - final String path = '/account/verification'; - - final Map params = { - 'userId': userId, - 'secret': secret, - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.put, path: path, params: params, headers: headers); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter/lib/services/avatars.dart b/app/sdks/client-flutter/lib/services/avatars.dart deleted file mode 100644 index a57b3b564c..0000000000 --- a/app/sdks/client-flutter/lib/services/avatars.dart +++ /dev/null @@ -1,234 +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 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 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 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 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 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 params = { - 'name': name, - 'width': width, - 'height': height, - 'color': color, - 'background': background, - 'project': client.config['project'], - }; - - 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 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(); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter/lib/services/database.dart b/app/sdks/client-flutter/lib/services/database.dart deleted file mode 100644 index 88082feef7..0000000000 --- a/app/sdks/client-flutter/lib/services/database.dart +++ /dev/null @@ -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 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 params = { - 'filters': filters, - 'offset': offset, - 'limit': limit, - 'orderField': orderField, - 'orderType': orderType.name(), - 'orderCast': orderCast, - 'search': search, - 'first': first, - 'last': last, - }; - - final Map 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 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 params = { - 'data': data, - 'read': read, - 'write': write, - 'parentDocument': parentDocument, - 'parentProperty': parentProperty, - 'parentPropertyType': parentPropertyType, - }; - - final Map 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 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 params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.get, path: path, params: params, headers: headers); - } - - /// Update Document - Future 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 params = { - 'data': data, - 'read': read, - 'write': write, - }; - - final Map 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 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 params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.delete, path: path, params: params, headers: headers); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter/lib/services/locale.dart b/app/sdks/client-flutter/lib/services/locale.dart deleted file mode 100644 index 095af4792c..0000000000 --- a/app/sdks/client-flutter/lib/services/locale.dart +++ /dev/null @@ -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 get() { - final String path = '/locale'; - - final Map params = { - }; - - final Map 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 getContinents() { - final String path = '/locale/continents'; - - final Map params = { - }; - - final Map 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 getCountries() { - final String path = '/locale/countries'; - - final Map params = { - }; - - final Map 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 getCountriesEU() { - final String path = '/locale/countries/eu'; - - final Map params = { - }; - - final Map 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 getCountriesPhones() { - final String path = '/locale/countries/phones'; - - final Map params = { - }; - - final Map 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 getCurrencies() { - final String path = '/locale/currencies'; - - final Map params = { - }; - - final Map 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 getLanguages() { - final String path = '/locale/languages'; - - final Map params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.get, path: path, params: params, headers: headers); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter/lib/services/storage.dart b/app/sdks/client-flutter/lib/services/storage.dart deleted file mode 100644 index 51f9345050..0000000000 --- a/app/sdks/client-flutter/lib/services/storage.dart +++ /dev/null @@ -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 listFiles({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) { - final String path = '/storage/files'; - - final Map params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType.name(), - }; - - final Map 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 createFile({@required MultipartFile file, @required List read, @required List write}) { - final String path = '/storage/files'; - - final Map params = { - 'file': file, - 'read': read, - 'write': write, - }; - - final Map 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 getFile({@required String fileId}) { - final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); - - final Map params = { - }; - - final Map 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 updateFile({@required String fileId, @required List read, @required List write}) { - final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); - - final Map params = { - 'read': read, - 'write': write, - }; - - final Map 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 deleteFile({@required String fileId}) { - final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); - - final Map params = { - }; - - final Map 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 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 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 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(); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter/lib/services/teams.dart b/app/sdks/client-flutter/lib/services/teams.dart deleted file mode 100644 index b9205da455..0000000000 --- a/app/sdks/client-flutter/lib/services/teams.dart +++ /dev/null @@ -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 list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) { - final String path = '/teams'; - - final Map params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType.name(), - }; - - final Map 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 create({@required String name, List roles = const ["owner"]}) { - final String path = '/teams'; - - final Map params = { - 'name': name, - 'roles': roles, - }; - - final Map 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 get({@required String teamId}) { - final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); - - final Map params = { - }; - - final Map 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 update({@required String teamId, @required String name}) { - final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); - - final Map params = { - 'name': name, - }; - - final Map 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 delete({@required String teamId}) { - final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); - - final Map params = { - }; - - final Map 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 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 params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType.name(), - }; - - final Map 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 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 params = { - 'email': email, - 'name': name, - 'roles': roles, - 'url': url, - }; - - final Map 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 deleteMembership({@required String teamId, @required String inviteId}) { - final String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); - - final Map params = { - }; - - final Map 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 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 params = { - 'userId': userId, - 'secret': secret, - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - return client.call(HttpMethod.patch, path: path, params: params, headers: headers); - } -} \ No newline at end of file diff --git a/app/sdks/client-flutter/pubspec.yaml b/app/sdks/client-flutter/pubspec.yaml deleted file mode 100644 index 2d0c2fe412..0000000000 --- a/app/sdks/client-flutter/pubspec.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: appwrite -version: 0.3.0-dev.1 -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 - flutter: - sdk: flutter - -dev_dependencies: - flutter_test: - sdk: flutter \ No newline at end of file diff --git a/app/sdks/client-web/LICENSE b/app/sdks/client-web/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/client-web/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/client-web/README.md b/app/sdks/client-web/README.md deleted file mode 100644 index 093783ab41..0000000000 --- a/app/sdks/client-web/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Appwrite Web SDK - -![License](https://img.shields.io/github/license/appwrite/sdk-for-js.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1) - -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 Web 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) - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -### NPM - -To install via [NPM](https://www.npmjs.com/): - -```bash -npm install appwrite --save -``` - -If you're using a bundler (like [Browserify](http://browserify.org/) or [webpack](https://webpack.js.org/)), you can import the Appwrite module when you need it: - -```js -import * as Appwrite from "appwrite"; -``` - -### CDN - -To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: - -```html - -``` - - - -## 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. \ No newline at end of file diff --git a/app/sdks/client-web/package.json b/app/sdks/client-web/package.json deleted file mode 100644 index 26dd06fb94..0000000000 --- a/app/sdks/client-web/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "appwrite", - "homepage": "https://appwrite.io/support", - "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", - "version": "1.1.0", - "license": "BSD-3-Clause", - "main": "src/sdk.js", - "types": "types/index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/appwrite/sdk-for-js" - }, - "devDependencies": { - "typescript": "^3.6.4" - }, - "dependencies": {} -} \ No newline at end of file diff --git a/app/sdks/client-web/src/sdk.js b/app/sdks/client-web/src/sdk.js deleted file mode 100644 index 5c98ea89b3..0000000000 --- a/app/sdks/client-web/src/sdk.js +++ /dev/null @@ -1,2395 +0,0 @@ -(function (window) { - - 'use strict'; - - window.Appwrite = function () { - - let config = { - endpoint: 'https://appwrite.io/v1', - project: '', - locale: '', - }; - - /** - * @param {string} endpoint - * @returns {this} - */ - let setEndpoint = function(endpoint) { - config.endpoint = endpoint; - - return this; - }; - - /** - * Set Project - * - * Your project ID - * - * @param value string - * - * @return this - */ - let setProject = function (value) - { - http.addGlobalHeader('X-Appwrite-Project', value); - - config.project = value; - - return this; - }; - - /** - * Set Locale - * - * @param value string - * - * @return this - */ - let setLocale = function (value) - { - http.addGlobalHeader('X-Appwrite-Locale', value); - - config.locale = value; - - return this; - }; - - let http = function(document) { - let globalParams = [], - globalHeaders = []; - - let addParam = function (url, param, value) { - let a = document.createElement('a'), regex = /(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g; - let match, str = []; - a.href = url; - param = encodeURIComponent(param); - - while (match = regex.exec(a.search)) if (param !== match[1]) str.push(match[1] + (match[2] ? "=" + match[2] : "")); - - str.push(param + (value ? "=" + encodeURIComponent(value) : "")); - - a.search = str.join("&"); - - return a.href; - }; - - /** - * @param {Object} params - * @returns {string} - */ - let buildQuery = function(params) { - let str = []; - - for (let p in params) { - if(Array.isArray(params[p])) { - for (let index = 0; index < params[p].length; index++) { - let param = params[p][index]; - str.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(params[p])); - } - } - - return str.join("&"); - }; - - let addGlobalHeader = function(key, value) { - globalHeaders[key] = {key: key.toLowerCase(), value: value.toLowerCase()}; - }; - - let addGlobalParam = function(key, value) { - globalParams.push({key: key, value: value}); - }; - - addGlobalHeader('x-sdk-version', 'appwrite:javascript:1.1.0'); - addGlobalHeader('content-type', ''); - - /** - * @param {string} method - * @param {string} path string - * @param {Object} headers - * @param {Object} params - * @param {function} progress - * @returns {Promise} - */ - let call = function (method, path, headers = {}, params = {}, progress = null) { - let i; - - path = config.endpoint + path; - - if (-1 === ['GET', 'POST', 'PUT', 'DELETE', 'TRACE', 'HEAD', 'OPTIONS', 'CONNECT', 'PATCH'].indexOf(method)) { - throw new Error('var method must contain a valid HTTP method name'); - } - - if (typeof path !== 'string') { - throw new Error('var path must be of type string'); - } - - if (typeof headers !== 'object') { - throw new Error('var headers must be of type object'); - } - - for (i = 0; i < globalParams.length; i++) { // Add global params to URL - path = addParam(path, globalParams[i].key, globalParams[i].value); - } - - if(window.localStorage && window.localStorage.getItem('cookieFallback')) { - headers['X-Fallback-Cookies'] = window.localStorage.getItem('cookieFallback'); - } - - for (let key in globalHeaders) { // Add Global Headers - if (globalHeaders.hasOwnProperty(key)) { - if (!headers[globalHeaders[key].key]) { - headers[globalHeaders[key].key] = globalHeaders[key].value; - } - } - } - - if(method === 'GET') { - for (let param in params) { - if (param.hasOwnProperty(key)) { - path = addParam(path, key + (Array.isArray(param) ? '[]' : ''), params[key]); - } - } - } - - switch (headers['content-type']) { // Parse request by content type - case 'application/json': - params = JSON.stringify(params); - break; - - case 'multipart/form-data': - let formData = new FormData(); - - Object.keys(params).forEach(function(key) { - let param = params[key]; - formData.append(key + (Array.isArray(param) ? '[]' : ''), param); - }); - - params = formData; - break; - } - - return new Promise(function (resolve, reject) { - - let request = new XMLHttpRequest(), key; - - request.withCredentials = true; - request.open(method, path, true); - - for (key in headers) { // Set Headers - if (headers.hasOwnProperty(key)) { - if (key === 'content-type' && headers[key] === 'multipart/form-data') { // Skip to avoid missing boundary - continue; - } - - request.setRequestHeader(key, headers[key]); - } - } - - request.onload = function () { - let data = request.response; - let contentType = this.getResponseHeader('content-type') || ''; - contentType = contentType.substring(0, contentType.indexOf(';')); - - switch (contentType) { - case 'application/json': - data = JSON.parse(data); - break; - } - - let cookieFallback = this.getResponseHeader('X-Fallback-Cookies') || ''; - - if(window.localStorage && cookieFallback) { - window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.'); - window.localStorage.setItem('cookieFallback', cookieFallback); - } - - if (4 === request.readyState && 399 >= request.status) { - resolve(data); - } else { - reject(data); - } - }; - - if (progress) { - request.addEventListener('progress', progress); - request.upload.addEventListener('progress', progress, false); - } - - // Handle network errors - request.onerror = function () { - reject(new Error("Network Error")); - }; - - request.send(params); - }) - }; - - return { - 'get': function(path, headers = {}, params = {}) { - return call('GET', path + ((Object.keys(params).length > 0) ? '?' + buildQuery(params) : ''), headers, {}); - }, - 'post': function(path, headers = {}, params = {}, progress = null) { - return call('POST', path, headers, params, progress); - }, - 'put': function(path, headers = {}, params = {}, progress = null) { - return call('PUT', path, headers, params, progress); - }, - 'patch': function(path, headers = {}, params = {}, progress = null) { - return call('PATCH', path, headers, params, progress); - }, - 'delete': function(path, headers = {}, params = {}, progress = null) { - return call('DELETE', path, headers, params, progress); - }, - 'addGlobalParam': addGlobalParam, - 'addGlobalHeader': addGlobalHeader - } - }(window.document); - - let account = { - - /** - * Get Account - * - * Get currently logged in user data as JSON object. - * - * @throws {Error} - * @return {Promise} - */ - get: function() { - let path = '/account'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Account - * - * Use this endpoint to allow a new user to register a new account in your - * project. After the user registration completes successfully, you can use - * the [/account/verfication](/docs/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 {Error} - * @return {Promise} - */ - create: function(email, password, name = '') { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/account'; - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(password) { - payload['password'] = password; - } - - if(name) { - payload['name'] = name; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @throws {Error} - * @return {Promise} - */ - delete: function() { - let path = '/account'; - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Email - * - * Update currently logged in user account email address. After changing user - * address, user confirmation status is being reset and a new confirmation - * mail is sent. For security measures, user password is required to complete - * this request. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - updateEmail: function(email, password) { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/account/email'; - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(password) { - payload['password'] = password; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Account Logs - * - * Get currently logged in user list of latest security activity logs. Each - * log returns user IP address, location and date and time of log. - * - * @throws {Error} - * @return {Promise} - */ - getLogs: function() { - let path = '/account/logs'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Name - * - * Update currently logged in user account name. - * - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - updateName: function(name) { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/account/name'; - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Password - * - * Update currently logged in user password. For validation, user is required - * to pass the password twice. - * - * @param {string} password - * @param {string} oldPassword - * @throws {Error} - * @return {Promise} - */ - updatePassword: function(password, oldPassword) { - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - if(oldPassword === undefined) { - throw new Error('Missing required parameter: "oldPassword"'); - } - - let path = '/account/password'; - - let payload = {}; - - if(password) { - payload['password'] = password; - } - - if(oldPassword) { - payload['oldPassword'] = oldPassword; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Account Preferences - * - * Get currently logged in user preferences as a key-value object. - * - * @throws {Error} - * @return {Promise} - */ - getPrefs: function() { - let path = '/account/prefs'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Preferences - * - * Update currently logged in user account preferences. You can pass only the - * specific settings you wish to update. - * - * @param {object} prefs - * @throws {Error} - * @return {Promise} - */ - updatePrefs: function(prefs) { - if(prefs === undefined) { - throw new Error('Missing required parameter: "prefs"'); - } - - let path = '/account/prefs'; - - let payload = {}; - - if(prefs) { - payload['prefs'] = prefs; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Password Recovery - * - * Sends the user an email with a temporary secret key for password reset. - * When the user clicks the confirmation link he is redirected back to your - * app password reset URL with the secret key and email address values - * attached to the URL query string. Use the query string params to submit a - * request to the [PUT /account/recovery](/docs/client/account#updateRecovery) - * endpoint to complete the process. - * - * @param {string} email - * @param {string} url - * @throws {Error} - * @return {Promise} - */ - createRecovery: function(email, url) { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/account/recovery'; - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(url) { - payload['url'] = url; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Complete Password Recovery - * - * Use this endpoint to complete the user account password reset. Both the - * **userId** and **secret** arguments will be passed as query parameters to - * the redirect URL you have provided when sending your request to the [POST - * /account/recovery](/docs/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 {Error} - * @return {Promise} - */ - updateRecovery: function(userId, secret, password, passwordAgain) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(secret === undefined) { - throw new Error('Missing required parameter: "secret"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - if(passwordAgain === undefined) { - throw new Error('Missing required parameter: "passwordAgain"'); - } - - let path = '/account/recovery'; - - let payload = {}; - - if(userId) { - payload['userId'] = userId; - } - - if(secret) { - payload['secret'] = secret; - } - - if(password) { - payload['password'] = password; - } - - if(passwordAgain) { - payload['passwordAgain'] = passwordAgain; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Account Sessions - * - * Get currently logged in user list of active sessions across different - * devices. - * - * @throws {Error} - * @return {Promise} - */ - getSessions: function() { - let path = '/account/sessions'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Account Session - * - * Allow the user to login into his account by providing a valid email and - * password combination. This route will create a new session for the user. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - createSession: function(email, password) { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/account/sessions'; - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(password) { - payload['password'] = password; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete All Account Sessions - * - * Delete all sessions from the user account and remove any sessions cookies - * from the end client. - * - * @throws {Error} - * @return {Promise} - */ - deleteSessions: function() { - let path = '/account/sessions'; - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Account Session with OAuth2 - * - * Allow the user to login to his account using the 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 {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - createOAuth2Session: function(provider, success = 'https://appwrite.io/auth/oauth2/success', failure = 'https://appwrite.io/auth/oauth2/failure', scopes = []) { - if(provider === undefined) { - throw new Error('Missing required parameter: "provider"'); - } - - let path = '/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}', 'g'), provider); - - let payload = {}; - - if(success) { - payload['success'] = success; - } - - if(failure) { - payload['failure'] = failure; - } - - if(scopes) { - payload['scopes'] = scopes; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - window.location = config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Delete Account Session - * - * Use this endpoint to log out the currently logged in user from all his - * account sessions across all his different devices. When using the option id - * argument, only the session unique ID provider will be deleted. - * - * @param {string} sessionId - * @throws {Error} - * @return {Promise} - */ - deleteSession: function(sessionId) { - if(sessionId === undefined) { - throw new Error('Missing required parameter: "sessionId"'); - } - - let path = '/account/sessions/{sessionId}'.replace(new RegExp('{sessionId}', 'g'), sessionId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Email Verification - * - * Use this endpoint to send a verification message to your user email address - * to confirm they are the valid owners of that address. Both the **userId** - * and **secret** arguments will be passed as query parameters to the URL you - * have provider to be attached to the verification email. The provided URL - * should redirect the user back for your app and allow you to complete the - * verification process by verifying both the **userId** and **secret** - * parameters. Learn more about how to [complete the verification - * process](/docs/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 {Error} - * @return {Promise} - */ - createVerification: function(url) { - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/account/verification'; - - let payload = {}; - - if(url) { - payload['url'] = url; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Complete Email Verification - * - * Use this endpoint to complete the user email verification process. Use both - * the **userId** and **secret** parameters that were attached to your app URL - * to verify the user email ownership. If confirmed this route will return a - * 200 status code. - * - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateVerification: function(userId, secret) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(secret === undefined) { - throw new Error('Missing required parameter: "secret"'); - } - - let path = '/account/verification'; - - let payload = {}; - - if(userId) { - payload['userId'] = userId; - } - - if(secret) { - payload['secret'] = secret; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let avatars = { - - /** - * Get Browser Icon - * - * You can use this endpoint to show different browser icons to your users. - * The code argument receives the browser code as it appears in your user - * /account/sessions endpoint. Use width, height and quality arguments to - * change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getBrowser: function(code, width = 100, height = 100, quality = 100) { - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/avatars/browsers/{code}'.replace(new RegExp('{code}', 'g'), code); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Credit Card Icon - * - * Need to display your users with your billing method or their payment - * methods? The credit card endpoint will return you the icon of the credit - * card provider you need. Use width, height and quality arguments to change - * the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getCreditCard: function(code, width = 100, height = 100, quality = 100) { - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/avatars/credit-cards/{code}'.replace(new RegExp('{code}', 'g'), code); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Favicon - * - * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote - * website URL. - * - * @param {string} url - * @throws {Error} - * @return {string} - */ - getFavicon: function(url) { - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/avatars/favicon'; - - let payload = {}; - - if(url) { - payload['url'] = url; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Country Flag - * - * You can use this endpoint to show different country flags icons to your - * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getFlag: function(code, width = 100, height = 100, quality = 100) { - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/avatars/flags/{code}'.replace(new RegExp('{code}', 'g'), code); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Image from URL - * - * Use this endpoint to fetch a remote image URL and crop it to any image size - * you want. This endpoint is very useful if you need to crop and display - * remote images in your app or in case you want to make sure a 3rd party - * image is properly served using a TLS protocol. - * - * @param {string} url - * @param {number} width - * @param {number} height - * @throws {Error} - * @return {string} - */ - getImage: function(url, width = 400, height = 400) { - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/avatars/image'; - - let payload = {}; - - if(url) { - payload['url'] = url; - } - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get User Initials - * - * Use this endpoint to show your user initials avatar icon on your website or - * app. By default, this route will try to print your logged-in user name or - * email initials. You can also overwrite the user name if you pass the 'name' - * parameter. If no name is given and no user is logged, an empty avatar will - * be returned. - * - * You can use the color and background params to change the avatar colors. By - * default, a random theme will be selected. The random theme will persist for - * the user's initials when reloading the same theme will always return for - * the same initials. - * - * @param {string} name - * @param {number} width - * @param {number} height - * @param {string} color - * @param {string} background - * @throws {Error} - * @return {string} - */ - getInitials: function(name = '', width = 500, height = 500, color = '', background = '') { - let path = '/avatars/initials'; - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(color) { - payload['color'] = color; - } - - if(background) { - payload['background'] = background; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get QR Code - * - * Converts a given plain text to a QR code image. You can use the query - * parameters to change the size and style of the resulting image. - * - * @param {string} text - * @param {number} size - * @param {number} margin - * @param {number} download - * @throws {Error} - * @return {string} - */ - getQR: function(text, size = 400, margin = 1, download = 0) { - if(text === undefined) { - throw new Error('Missing required parameter: "text"'); - } - - let path = '/avatars/qr'; - - let payload = {}; - - if(text) { - payload['text'] = text; - } - - if(size) { - payload['size'] = size; - } - - if(margin) { - payload['margin'] = margin; - } - - if(download) { - payload['download'] = download; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - } - }; - - let database = { - - /** - * List Documents - * - * Get a list of all the user documents. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project documents. [Learn more about different API - * modes](/docs/admin). - * - * @param {string} collectionId - * @param {string[]} filters - * @param {number} offset - * @param {number} limit - * @param {string} orderField - * @param {string} orderType - * @param {string} orderCast - * @param {string} search - * @param {number} first - * @param {number} last - * @throws {Error} - * @return {Promise} - */ - listDocuments: function(collectionId, filters = [], offset = 0, limit = 50, orderField = '$id', orderType = 'ASC', orderCast = 'string', search = '', first = 0, last = 0) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - if(filters) { - payload['filters'] = filters; - } - - if(offset) { - payload['offset'] = offset; - } - - if(limit) { - payload['limit'] = limit; - } - - if(orderField) { - payload['orderField'] = orderField; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - if(orderCast) { - payload['orderCast'] = orderCast; - } - - if(search) { - payload['search'] = search; - } - - if(first) { - payload['first'] = first; - } - - if(last) { - payload['last'] = last; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Document - * - * Create a new Document. 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 {string[]} read - * @param {string[]} write - * @param {string} parentDocument - * @param {string} parentProperty - * @param {string} parentPropertyType - * @throws {Error} - * @return {Promise} - */ - createDocument: function(collectionId, data, read, write, parentDocument = '', parentProperty = '', parentPropertyType = 'assign') { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(data === undefined) { - throw new Error('Missing required parameter: "data"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - if(data) { - payload['data'] = data; - } - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - if(parentDocument) { - payload['parentDocument'] = parentDocument; - } - - if(parentProperty) { - payload['parentProperty'] = parentProperty; - } - - if(parentPropertyType) { - payload['parentPropertyType'] = parentPropertyType; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Document - * - * Get document by its unique ID. This endpoint response returns a JSON object - * with the document data. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - getDocument: function(collectionId, documentId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(documentId === undefined) { - throw new Error('Missing required parameter: "documentId"'); - } - - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Document - * - * - * @param {string} collectionId - * @param {string} documentId - * @param {object} data - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateDocument: function(collectionId, documentId, data, read, write) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(documentId === undefined) { - throw new Error('Missing required parameter: "documentId"'); - } - - if(data === undefined) { - throw new Error('Missing required parameter: "data"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - let payload = {}; - - if(data) { - payload['data'] = data; - } - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Document - * - * Delete document by its unique ID. This endpoint deletes only the parent - * documents, his attributes and relations to other documents. Child documents - * **will not** be deleted. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - deleteDocument: function(collectionId, documentId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(documentId === undefined) { - throw new Error('Missing required parameter: "documentId"'); - } - - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let locale = { - - /** - * Get User Locale - * - * Get the current user location based on IP. Returns an object with user - * country code, country name, continent name, continent code, ip address and - * suggested currency. You can use the locale header to get the data in a - * supported language. - * - * ([IP Geolocation by DB-IP](https://db-ip.com)) - * - * @throws {Error} - * @return {Promise} - */ - get: function() { - let path = '/locale'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Continents - * - * List of all continents. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getContinents: function() { - let path = '/locale/continents'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Countries - * - * List of all countries. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountries: function() { - let path = '/locale/countries'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List EU Countries - * - * List of all countries that are currently members of the EU. You can use the - * locale header to get the data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesEU: function() { - let path = '/locale/countries/eu'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Countries Phone Codes - * - * List of all countries phone codes. You can use the locale header to get the - * data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesPhones: function() { - let path = '/locale/countries/phones'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Currencies - * - * List of all currencies, including currency 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 {Error} - * @return {Promise} - */ - getCurrencies: function() { - let path = '/locale/currencies'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * 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 {Error} - * @return {Promise} - */ - getLanguages: function() { - let path = '/locale/languages'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let storage = { - - /** - * List Files - * - * Get a list of all the user files. You can use the query params to filter - * your results. On admin mode, this endpoint will return a list of all of the - * project files. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listFiles: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/storage/files'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create File - * - * Create a new file. The user who creates the file will automatically be - * assigned to read and write access unless he has passed custom values for - * read and write arguments. - * - * @param {File} file - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - createFile: function(file, read, write) { - if(file === undefined) { - throw new Error('Missing required parameter: "file"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/storage/files'; - - let payload = {}; - - if(file) { - payload['file'] = file; - } - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - return http - .post(path, { - 'content-type': 'multipart/form-data', - }, payload); - }, - - /** - * Get File - * - * Get file by its unique ID. This endpoint response returns a JSON object - * with the file metadata. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - getFile: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update File - * - * Update file by its unique ID. Only users with write permissions have access - * to update this resource. - * - * @param {string} fileId - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateFile: function(fileId, read, write) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete File - * - * Delete a file by its unique ID. Only users with write permissions have - * access to delete this resource. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - deleteFile: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get File for Download - * - * Get file content by its unique ID. The endpoint response return with a - * 'Content-Disposition: attachment' header that tells the browser to start - * downloading the file to user downloads directory. - * - * @param {string} fileId - * @throws {Error} - * @return {string} - */ - getFileDownload: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}/download'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get File Preview - * - * Get a file preview image. Currently, this method supports preview for image - * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets, will return the file icon image. You can also pass query - * string arguments for cutting and resizing your preview image. - * - * @param {string} fileId - * @param {number} width - * @param {number} height - * @param {number} quality - * @param {string} background - * @param {string} output - * @throws {Error} - * @return {string} - */ - getFilePreview: function(fileId, width = 0, height = 0, quality = 100, background = '', output = '') { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - if(background) { - payload['background'] = background; - } - - if(output) { - payload['output'] = output; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get File for View - * - * Get file content by its unique ID. This endpoint is similar to the download - * method but returns with no 'Content-Disposition: attachment' header. - * - * @param {string} fileId - * @param {string} as - * @throws {Error} - * @return {string} - */ - getFileView: function(fileId, as = '') { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}/view'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - if(as) { - payload['as'] = as; - } - - payload['project'] = config.project; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - } - }; - - let teams = { - - /** - * List Teams - * - * Get a list of all the current user teams. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project teams. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/teams'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Team - * - * Create a new team. The user who creates the team will automatically be - * assigned as the owner of the team. The team owner can invite new members, - * who will be able add new owners and update or delete the team from your - * project. - * - * @param {string} name - * @param {string[]} roles - * @throws {Error} - * @return {Promise} - */ - create: function(name, roles = ["owner"]) { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/teams'; - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(roles) { - payload['roles'] = roles; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Team - * - * Get team by its unique ID. All team members have read access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - get: function(teamId) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Team - * - * Update team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - update: function(teamId, name) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Team - * - * Delete team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - delete: function(teamId) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Team Memberships - * - * Get team members by the team unique ID. All team members have read access - * for this list of resources. - * - * @param {string} teamId - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - getMemberships: function(teamId, search = '', limit = 25, offset = 0, orderType = 'ASC') { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Team 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 {string[]} roles - * @param {string} url - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - createMembership: function(teamId, email, roles, url, name = '') { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(roles === undefined) { - throw new Error('Missing required parameter: "roles"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(name) { - payload['name'] = name; - } - - if(roles) { - payload['roles'] = roles; - } - - if(url) { - payload['url'] = url; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Team Membership - * - * This endpoint allows a user to leave a team or for a team owner to delete - * the membership of any other team member. You can also use this endpoint to - * delete a user membership even if he didn't accept it. - * - * @param {string} teamId - * @param {string} inviteId - * @throws {Error} - * @return {Promise} - */ - deleteMembership: function(teamId, inviteId) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(inviteId === undefined) { - throw new Error('Missing required parameter: "inviteId"'); - } - - let path = '/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Team Membership Status - * - * Use this endpoint to allow a user to accept an invitation to join a team - * after he is being redirected back to your app from the invitation email he - * was sent. - * - * @param {string} teamId - * @param {string} inviteId - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateMembershipStatus: function(teamId, inviteId, userId, secret) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(inviteId === undefined) { - throw new Error('Missing required parameter: "inviteId"'); - } - - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(secret === undefined) { - throw new Error('Missing required parameter: "secret"'); - } - - let path = '/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - let payload = {}; - - if(userId) { - payload['userId'] = userId; - } - - if(secret) { - payload['secret'] = secret; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - return { - setEndpoint: setEndpoint, - setProject: setProject, - setLocale: setLocale, - account: account, - avatars: avatars, - database: database, - locale: locale, - storage: storage, - teams: teams - }; - }; - - if(typeof module !== "undefined") { - module.exports = window.Appwrite; - } - -})((typeof window !== "undefined") ? window : {}); \ No newline at end of file diff --git a/app/sdks/client-web/src/sdk.min.js b/app/sdks/client-web/src/sdk.min.js deleted file mode 100644 index 7b470dc380..0000000000 --- a/app/sdks/client-web/src/sdk.min.js +++ /dev/null @@ -1,189 +0,0 @@ -(function(window){'use strict';window.Appwrite=function(){let config={endpoint:'https://appwrite.io/v1',project:'',locale:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;index=request.status){resolve(data)}else{reject(data)}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,!1)} -request.onerror=function(){reject(new Error("Network Error"))};request.send(params)})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{})},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress)},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress)},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress)},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress)},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -let path='/account';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -if(name){payload.name=name} -return http.post(path,{'content-type':'application/json',},payload)},delete:function(){let path='/account';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateEmail:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -let path='/account/email';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -return http.patch(path,{'content-type':'application/json',},payload)},getLogs:function(){let path='/account/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateName:function(name){if(name===undefined){throw new Error('Missing required parameter: "name"')} -let path='/account/name';let payload={};if(name){payload.name=name} -return http.patch(path,{'content-type':'application/json',},payload)},updatePassword:function(password,oldPassword){if(password===undefined){throw new Error('Missing required parameter: "password"')} -if(oldPassword===undefined){throw new Error('Missing required parameter: "oldPassword"')} -let path='/account/password';let payload={};if(password){payload.password=password} -if(oldPassword){payload.oldPassword=oldPassword} -return http.patch(path,{'content-type':'application/json',},payload)},getPrefs:function(){let path='/account/prefs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},updatePrefs:function(prefs){if(prefs===undefined){throw new Error('Missing required parameter: "prefs"')} -let path='/account/prefs';let payload={};if(prefs){payload.prefs=prefs} -return http.patch(path,{'content-type':'application/json',},payload)},createRecovery:function(email,url){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(url===undefined){throw new Error('Missing required parameter: "url"')} -let path='/account/recovery';let payload={};if(email){payload.email=email} -if(url){payload.url=url} -return http.post(path,{'content-type':'application/json',},payload)},updateRecovery:function(userId,secret,password,passwordAgain){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -if(secret===undefined){throw new Error('Missing required parameter: "secret"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -if(passwordAgain===undefined){throw new Error('Missing required parameter: "passwordAgain"')} -let path='/account/recovery';let payload={};if(userId){payload.userId=userId} -if(secret){payload.secret=secret} -if(password){payload.password=password} -if(passwordAgain){payload.passwordAgain=passwordAgain} -return http.put(path,{'content-type':'application/json',},payload)},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json',},payload)},createSession:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -let path='/account/sessions';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success='https://appwrite.io/auth/oauth2/success',failure='https://appwrite.io/auth/oauth2/failure',scopes=[]){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} -let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success} -if(failure){payload.failure=failure} -if(scopes){payload.scopes=scopes} -payload.project=config.project;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index; - - /** - * 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 {Error} - * @return {Promise} - */ - create(email: string, password: string, name: string): Promise; - - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @throws {Error} - * @return {Promise} - */ - delete(): Promise; - - /** - * Update Account Email - * - * Update currently logged in user account email address. After changing user - * address, user confirmation status is being reset and a new confirmation - * mail is sent. For security measures, user password is required to complete - * this request. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - updateEmail(email: string, password: string): Promise; - - /** - * Get Account Logs - * - * Get currently logged in user list of latest security activity logs. Each - * log returns user IP address, location and date and time of log. - * - * @throws {Error} - * @return {Promise} - */ - getLogs(): Promise; - - /** - * Update Account Name - * - * Update currently logged in user account name. - * - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - updateName(name: string): Promise; - - /** - * Update Account Password - * - * Update currently logged in user password. For validation, user is required - * to pass the password twice. - * - * @param {string} password - * @param {string} oldPassword - * @throws {Error} - * @return {Promise} - */ - updatePassword(password: string, oldPassword: string): Promise; - - /** - * Get Account Preferences - * - * Get currently logged in user preferences as a key-value object. - * - * @throws {Error} - * @return {Promise} - */ - getPrefs(): Promise; - - /** - * Update Account Preferences - * - * Update currently logged in user account preferences. You can pass only the - * specific settings you wish to update. - * - * @param {object} prefs - * @throws {Error} - * @return {Promise} - */ - updatePrefs(prefs: object): Promise; - - /** - * 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 {Error} - * @return {Promise} - */ - createRecovery(email: string, url: string): Promise; - - /** - * 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 {Error} - * @return {Promise} - */ - updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise; - - /** - * Get Account Sessions - * - * Get currently logged in user list of active sessions across different - * devices. - * - * @throws {Error} - * @return {Promise} - */ - getSessions(): Promise; - - /** - * Create Account Session - * - * Allow the user to login into his account by providing a valid email and - * password combination. This route will create a new session for the user. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - createSession(email: string, password: string): Promise; - - /** - * Delete All Account Sessions - * - * Delete all sessions from the user account and remove any sessions cookies - * from the end client. - * - * @throws {Error} - * @return {Promise} - */ - deleteSessions(): Promise; - - /** - * 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 {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - createOAuth2Session(provider: string, success: string, failure: string, scopes: string[]): Promise; - - /** - * Delete Account Session - * - * Use this endpoint to log out the currently logged in user from all his - * account sessions across all his different devices. When using the option id - * argument, only the session unique ID provider will be deleted. - * - * @param {string} sessionId - * @throws {Error} - * @return {Promise} - */ - deleteSession(sessionId: string): Promise; - - /** - * 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. - * - * @param {string} url - * @throws {Error} - * @return {Promise} - */ - createVerification(url: string): Promise; - - /** - * Complete Email Verification - * - * Use this endpoint to complete the user email verification process. Use both - * the **userId** and **secret** parameters that were attached to your app URL - * to verify the user email ownership. If confirmed this route will return a - * 200 status code. - * - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateVerification(userId: string, secret: string): Promise; - - } - - export interface Avatars { - - /** - * Get Browser Icon - * - * You can use this endpoint to show different browser icons to your users. - * The code argument receives the browser code as it appears in your user - * /account/sessions endpoint. Use width, height and quality arguments to - * change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getBrowser(code: string, width: number, height: number, quality: number): string; - - /** - * Get Credit Card Icon - * - * Need to display your users with your billing method or their payment - * methods? The credit card endpoint will return you the icon of the credit - * card provider you need. Use width, height and quality arguments to change - * the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getCreditCard(code: string, width: number, height: number, quality: number): string; - - /** - * Get Favicon - * - * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote - * website URL. - * - * @param {string} url - * @throws {Error} - * @return {string} - */ - getFavicon(url: string): string; - - /** - * Get Country Flag - * - * You can use this endpoint to show different country flags icons to your - * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getFlag(code: string, width: number, height: number, quality: number): string; - - /** - * Get Image from URL - * - * Use this endpoint to fetch a remote image URL and crop it to any image size - * you want. This endpoint is very useful if you need to crop and display - * remote images in your app or in case you want to make sure a 3rd party - * image is properly served using a TLS protocol. - * - * @param {string} url - * @param {number} width - * @param {number} height - * @throws {Error} - * @return {string} - */ - getImage(url: string, width: number, height: number): string; - - /** - * Get User Initials - * - * Use this endpoint to show your user initials avatar icon on your website or - * app. By default, this route will try to print your logged-in user name or - * email initials. You can also overwrite the user name if you pass the 'name' - * parameter. If no name is given and no user is logged, an empty avatar will - * be returned. - * - * You can use the color and background params to change the avatar colors. By - * default, a random theme will be selected. The random theme will persist for - * the user's initials when reloading the same theme will always return for - * the same initials. - * - * @param {string} name - * @param {number} width - * @param {number} height - * @param {string} color - * @param {string} background - * @throws {Error} - * @return {string} - */ - getInitials(name: string, width: number, height: number, color: string, background: string): string; - - /** - * Get QR Code - * - * Converts a given plain text to a QR code image. You can use the query - * parameters to change the size and style of the resulting image. - * - * @param {string} text - * @param {number} size - * @param {number} margin - * @param {number} download - * @throws {Error} - * @return {string} - */ - getQR(text: string, size: number, margin: number, download: number): string; - - } - - export interface Database { - - /** - * List Documents - * - * Get a list of all the user documents. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project documents. [Learn more about different API - * modes](/docs/admin). - * - * @param {string} collectionId - * @param {string[]} filters - * @param {number} offset - * @param {number} limit - * @param {string} orderField - * @param {string} orderType - * @param {string} orderCast - * @param {string} search - * @param {number} first - * @param {number} last - * @throws {Error} - * @return {Promise} - */ - listDocuments(collectionId: string, filters: string[], offset: number, limit: number, orderField: string, orderType: string, orderCast: string, search: string, first: number, last: number): Promise; - - /** - * 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 {string[]} read - * @param {string[]} write - * @param {string} parentDocument - * @param {string} parentProperty - * @param {string} parentPropertyType - * @throws {Error} - * @return {Promise} - */ - createDocument(collectionId: string, data: object, read: string[], write: string[], parentDocument: string, parentProperty: string, parentPropertyType: string): Promise; - - /** - * Get Document - * - * Get document by its unique ID. This endpoint response returns a JSON object - * with the document data. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - getDocument(collectionId: string, documentId: string): Promise; - - /** - * Update Document - * - * - * @param {string} collectionId - * @param {string} documentId - * @param {object} data - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateDocument(collectionId: string, documentId: string, data: object, read: string[], write: string[]): Promise; - - /** - * Delete Document - * - * Delete document by its unique ID. This endpoint deletes only the parent - * documents, his attributes and relations to other documents. Child documents - * **will not** be deleted. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - deleteDocument(collectionId: string, documentId: string): Promise; - - } - - export interface Locale { - - /** - * Get User Locale - * - * Get the current user location based on IP. Returns an object with user - * country code, country name, continent name, continent code, ip address and - * suggested currency. You can use the locale header to get the data in a - * supported language. - * - * ([IP Geolocation by DB-IP](https://db-ip.com)) - * - * @throws {Error} - * @return {Promise} - */ - get(): Promise; - - /** - * List Continents - * - * List of all continents. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getContinents(): Promise; - - /** - * List Countries - * - * List of all countries. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountries(): Promise; - - /** - * List EU Countries - * - * List of all countries that are currently members of the EU. You can use the - * locale header to get the data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesEU(): Promise; - - /** - * List Countries Phone Codes - * - * List of all countries phone codes. You can use the locale header to get the - * data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesPhones(): Promise; - - /** - * 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 {Error} - * @return {Promise} - */ - getCurrencies(): Promise; - - /** - * 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 {Error} - * @return {Promise} - */ - getLanguages(): Promise; - - } - - export interface Storage { - - /** - * List Files - * - * Get a list of all the user files. You can use the query params to filter - * your results. On admin mode, this endpoint will return a list of all of the - * project files. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listFiles(search: string, limit: number, offset: number, orderType: string): Promise; - - /** - * Create File - * - * Create a new file. The user who creates the file will automatically be - * assigned to read and write access unless he has passed custom values for - * read and write arguments. - * - * @param {File} file - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - createFile(file: File, read: string[], write: string[]): Promise; - - /** - * Get File - * - * Get file by its unique ID. This endpoint response returns a JSON object - * with the file metadata. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - getFile(fileId: string): Promise; - - /** - * Update File - * - * Update file by its unique ID. Only users with write permissions have access - * to update this resource. - * - * @param {string} fileId - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateFile(fileId: string, read: string[], write: string[]): Promise; - - /** - * Delete File - * - * Delete a file by its unique ID. Only users with write permissions have - * access to delete this resource. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - deleteFile(fileId: string): Promise; - - /** - * Get File for Download - * - * Get file content by its unique ID. The endpoint response return with a - * 'Content-Disposition: attachment' header that tells the browser to start - * downloading the file to user downloads directory. - * - * @param {string} fileId - * @throws {Error} - * @return {string} - */ - getFileDownload(fileId: string): string; - - /** - * Get File Preview - * - * Get a file preview image. Currently, this method supports preview for image - * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets, will return the file icon image. You can also pass query - * string arguments for cutting and resizing your preview image. - * - * @param {string} fileId - * @param {number} width - * @param {number} height - * @param {number} quality - * @param {string} background - * @param {string} output - * @throws {Error} - * @return {string} - */ - getFilePreview(fileId: string, width: number, height: number, quality: number, background: string, output: string): string; - - /** - * Get File for View - * - * Get file content by its unique ID. This endpoint is similar to the download - * method but returns with no 'Content-Disposition: attachment' header. - * - * @param {string} fileId - * @param {string} as - * @throws {Error} - * @return {string} - */ - getFileView(fileId: string, as: string): string; - - } - - export interface Teams { - - /** - * List Teams - * - * Get a list of all the current user teams. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project teams. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list(search: string, limit: number, offset: number, orderType: string): Promise; - - /** - * 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 {string[]} roles - * @throws {Error} - * @return {Promise} - */ - create(name: string, roles: string[]): Promise; - - /** - * Get Team - * - * Get team by its unique ID. All team members have read access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - get(teamId: string): Promise; - - /** - * Update Team - * - * Update team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - update(teamId: string, name: string): Promise; - - /** - * Delete Team - * - * Delete team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - delete(teamId: string): Promise; - - /** - * 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 {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - getMemberships(teamId: string, search: string, limit: number, offset: number, orderType: string): Promise; - - /** - * 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 {string[]} roles - * @param {string} url - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - createMembership(teamId: string, email: string, roles: string[], url: string, name: string): Promise; - - /** - * Delete Team Membership - * - * This endpoint allows a user to leave a team or for a team owner to delete - * the membership of any other team member. You can also use this endpoint to - * delete a user membership even if he didn't accept it. - * - * @param {string} teamId - * @param {string} inviteId - * @throws {Error} - * @return {Promise} - */ - deleteMembership(teamId: string, inviteId: string): Promise; - - /** - * Update Team Membership Status - * - * Use this endpoint to allow a user to accept an invitation to join a team - * after he is being redirected back to your app from the invitation email he - * was sent. - * - * @param {string} teamId - * @param {string} inviteId - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateMembershipStatus(teamId: string, inviteId: string, userId: string, secret: string): Promise; - - } - - -} \ No newline at end of file diff --git a/app/sdks/console-web/CHANGELOG.md b/app/sdks/console-web/CHANGELOG.md deleted file mode 100644 index fa4d35e687..0000000000 --- a/app/sdks/console-web/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -# Change Log \ No newline at end of file diff --git a/app/sdks/console-web/LICENSE b/app/sdks/console-web/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/console-web/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/console-web/README.md b/app/sdks/console-web/README.md deleted file mode 100644 index 68b7e8ff9c..0000000000 --- a/app/sdks/console-web/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Appwrite Console SDK - -![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1) - -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 Console 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) - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -### NPM - -To install via [NPM](https://www.npmjs.com/): - -```bash -npm install appwrite --save -``` - -If you're using a bundler (like [Browserify](http://browserify.org/) or [webpack](https://webpack.js.org/)), you can import the Appwrite module when you need it: - -```js -import * as Appwrite from "appwrite"; -``` - -### CDN - -To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: - -```html - -``` - - - -## 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. \ No newline at end of file diff --git a/app/sdks/console-web/package.json b/app/sdks/console-web/package.json deleted file mode 100644 index 6c53a70307..0000000000 --- a/app/sdks/console-web/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "appwrite", - "homepage": "https://appwrite.io/support", - "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", - "version": "1.0.0", - "license": "BSD-3-Clause", - "main": "src/sdk.js", - "types": "types/index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/appwrite/sdk-for-console" - }, - "devDependencies": { - "typescript": "^3.6.4" - }, - "dependencies": {} -} \ No newline at end of file diff --git a/app/sdks/console-web/src/sdk.js b/app/sdks/console-web/src/sdk.js deleted file mode 100644 index 27eb23b742..0000000000 --- a/app/sdks/console-web/src/sdk.js +++ /dev/null @@ -1,4514 +0,0 @@ -(function (window) { - - 'use strict'; - - window.Appwrite = function () { - - let config = { - endpoint: 'https://appwrite.io/v1', - project: '', - key: '', - locale: '', - mode: '', - }; - - /** - * @param {string} endpoint - * @returns {this} - */ - let setEndpoint = function(endpoint) { - config.endpoint = endpoint; - - return this; - }; - - /** - * Set Project - * - * Your project ID - * - * @param value string - * - * @return this - */ - let setProject = function (value) - { - http.addGlobalHeader('X-Appwrite-Project', value); - - config.project = value; - - return this; - }; - - /** - * Set Key - * - * Your secret API key - * - * @param value string - * - * @return this - */ - let setKey = function (value) - { - http.addGlobalHeader('X-Appwrite-Key', value); - - config.key = value; - - return this; - }; - - /** - * Set Locale - * - * @param value string - * - * @return this - */ - let setLocale = function (value) - { - http.addGlobalHeader('X-Appwrite-Locale', value); - - config.locale = value; - - return this; - }; - - /** - * Set Mode - * - * @param value string - * - * @return this - */ - let setMode = function (value) - { - http.addGlobalHeader('X-Appwrite-Mode', value); - - config.mode = value; - - return this; - }; - - let http = function(document) { - let globalParams = [], - globalHeaders = []; - - let addParam = function (url, param, value) { - let a = document.createElement('a'), regex = /(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g; - let match, str = []; - a.href = url; - param = encodeURIComponent(param); - - while (match = regex.exec(a.search)) if (param !== match[1]) str.push(match[1] + (match[2] ? "=" + match[2] : "")); - - str.push(param + (value ? "=" + encodeURIComponent(value) : "")); - - a.search = str.join("&"); - - return a.href; - }; - - /** - * @param {Object} params - * @returns {string} - */ - let buildQuery = function(params) { - let str = []; - - for (let p in params) { - if(Array.isArray(params[p])) { - for (let index = 0; index < params[p].length; index++) { - let param = params[p][index]; - str.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(params[p])); - } - } - - return str.join("&"); - }; - - let addGlobalHeader = function(key, value) { - globalHeaders[key] = {key: key.toLowerCase(), value: value.toLowerCase()}; - }; - - let addGlobalParam = function(key, value) { - globalParams.push({key: key, value: value}); - }; - - addGlobalHeader('x-sdk-version', 'appwrite:javascript:1.0.0'); - addGlobalHeader('content-type', ''); - - /** - * @param {string} method - * @param {string} path string - * @param {Object} headers - * @param {Object} params - * @param {function} progress - * @returns {Promise} - */ - let call = function (method, path, headers = {}, params = {}, progress = null) { - let i; - - path = config.endpoint + path; - - if (-1 === ['GET', 'POST', 'PUT', 'DELETE', 'TRACE', 'HEAD', 'OPTIONS', 'CONNECT', 'PATCH'].indexOf(method)) { - throw new Error('var method must contain a valid HTTP method name'); - } - - if (typeof path !== 'string') { - throw new Error('var path must be of type string'); - } - - if (typeof headers !== 'object') { - throw new Error('var headers must be of type object'); - } - - for (i = 0; i < globalParams.length; i++) { // Add global params to URL - path = addParam(path, globalParams[i].key, globalParams[i].value); - } - - if(window.localStorage && window.localStorage.getItem('cookieFallback')) { - headers['X-Fallback-Cookies'] = window.localStorage.getItem('cookieFallback'); - } - - for (let key in globalHeaders) { // Add Global Headers - if (globalHeaders.hasOwnProperty(key)) { - if (!headers[globalHeaders[key].key]) { - headers[globalHeaders[key].key] = globalHeaders[key].value; - } - } - } - - if(method === 'GET') { - for (let param in params) { - if (param.hasOwnProperty(key)) { - path = addParam(path, key + (Array.isArray(param) ? '[]' : ''), params[key]); - } - } - } - - switch (headers['content-type']) { // Parse request by content type - case 'application/json': - params = JSON.stringify(params); - break; - - case 'multipart/form-data': - let formData = new FormData(); - - Object.keys(params).forEach(function(key) { - let param = params[key]; - formData.append(key + (Array.isArray(param) ? '[]' : ''), param); - }); - - params = formData; - break; - } - - return new Promise(function (resolve, reject) { - - let request = new XMLHttpRequest(), key; - - request.withCredentials = true; - request.open(method, path, true); - - for (key in headers) { // Set Headers - if (headers.hasOwnProperty(key)) { - if (key === 'content-type' && headers[key] === 'multipart/form-data') { // Skip to avoid missing boundary - continue; - } - - request.setRequestHeader(key, headers[key]); - } - } - - request.onload = function () { - let data = request.response; - let contentType = this.getResponseHeader('content-type') || ''; - contentType = contentType.substring(0, contentType.indexOf(';')); - - switch (contentType) { - case 'application/json': - data = JSON.parse(data); - break; - } - - let cookieFallback = this.getResponseHeader('X-Fallback-Cookies') || ''; - - if(window.localStorage && cookieFallback) { - window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.'); - window.localStorage.setItem('cookieFallback', cookieFallback); - } - - if (4 === request.readyState && 399 >= request.status) { - resolve(data); - } else { - reject(data); - } - }; - - if (progress) { - request.addEventListener('progress', progress); - request.upload.addEventListener('progress', progress, false); - } - - // Handle network errors - request.onerror = function () { - reject(new Error("Network Error")); - }; - - request.send(params); - }) - }; - - return { - 'get': function(path, headers = {}, params = {}) { - return call('GET', path + ((Object.keys(params).length > 0) ? '?' + buildQuery(params) : ''), headers, {}); - }, - 'post': function(path, headers = {}, params = {}, progress = null) { - return call('POST', path, headers, params, progress); - }, - 'put': function(path, headers = {}, params = {}, progress = null) { - return call('PUT', path, headers, params, progress); - }, - 'patch': function(path, headers = {}, params = {}, progress = null) { - return call('PATCH', path, headers, params, progress); - }, - 'delete': function(path, headers = {}, params = {}, progress = null) { - return call('DELETE', path, headers, params, progress); - }, - 'addGlobalParam': addGlobalParam, - 'addGlobalHeader': addGlobalHeader - } - }(window.document); - - let account = { - - /** - * Get Account - * - * Get currently logged in user data as JSON object. - * - * @throws {Error} - * @return {Promise} - */ - get: function() { - let path = '/account'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Account - * - * Use this endpoint to allow a new user to register a new account in your - * project. After the user registration completes successfully, you can use - * the [/account/verfication](/docs/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 {Error} - * @return {Promise} - */ - create: function(email, password, name = '') { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/account'; - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(password) { - payload['password'] = password; - } - - if(name) { - payload['name'] = name; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @throws {Error} - * @return {Promise} - */ - delete: function() { - let path = '/account'; - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Email - * - * Update currently logged in user account email address. After changing user - * address, user confirmation status is being reset and a new confirmation - * mail is sent. For security measures, user password is required to complete - * this request. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - updateEmail: function(email, password) { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/account/email'; - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(password) { - payload['password'] = password; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Account Logs - * - * Get currently logged in user list of latest security activity logs. Each - * log returns user IP address, location and date and time of log. - * - * @throws {Error} - * @return {Promise} - */ - getLogs: function() { - let path = '/account/logs'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Name - * - * Update currently logged in user account name. - * - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - updateName: function(name) { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/account/name'; - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Password - * - * Update currently logged in user password. For validation, user is required - * to pass the password twice. - * - * @param {string} password - * @param {string} oldPassword - * @throws {Error} - * @return {Promise} - */ - updatePassword: function(password, oldPassword) { - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - if(oldPassword === undefined) { - throw new Error('Missing required parameter: "oldPassword"'); - } - - let path = '/account/password'; - - let payload = {}; - - if(password) { - payload['password'] = password; - } - - if(oldPassword) { - payload['oldPassword'] = oldPassword; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Account Preferences - * - * Get currently logged in user preferences as a key-value object. - * - * @throws {Error} - * @return {Promise} - */ - getPrefs: function() { - let path = '/account/prefs'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Preferences - * - * Update currently logged in user account preferences. You can pass only the - * specific settings you wish to update. - * - * @param {object} prefs - * @throws {Error} - * @return {Promise} - */ - updatePrefs: function(prefs) { - if(prefs === undefined) { - throw new Error('Missing required parameter: "prefs"'); - } - - let path = '/account/prefs'; - - let payload = {}; - - if(prefs) { - payload['prefs'] = prefs; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Password Recovery - * - * Sends the user an email with a temporary secret key for password reset. - * When the user clicks the confirmation link he is redirected back to your - * app password reset URL with the secret key and email address values - * attached to the URL query string. Use the query string params to submit a - * request to the [PUT /account/recovery](/docs/client/account#updateRecovery) - * endpoint to complete the process. - * - * @param {string} email - * @param {string} url - * @throws {Error} - * @return {Promise} - */ - createRecovery: function(email, url) { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/account/recovery'; - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(url) { - payload['url'] = url; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Complete Password Recovery - * - * Use this endpoint to complete the user account password reset. Both the - * **userId** and **secret** arguments will be passed as query parameters to - * the redirect URL you have provided when sending your request to the [POST - * /account/recovery](/docs/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 {Error} - * @return {Promise} - */ - updateRecovery: function(userId, secret, password, passwordAgain) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(secret === undefined) { - throw new Error('Missing required parameter: "secret"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - if(passwordAgain === undefined) { - throw new Error('Missing required parameter: "passwordAgain"'); - } - - let path = '/account/recovery'; - - let payload = {}; - - if(userId) { - payload['userId'] = userId; - } - - if(secret) { - payload['secret'] = secret; - } - - if(password) { - payload['password'] = password; - } - - if(passwordAgain) { - payload['passwordAgain'] = passwordAgain; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Account Sessions - * - * Get currently logged in user list of active sessions across different - * devices. - * - * @throws {Error} - * @return {Promise} - */ - getSessions: function() { - let path = '/account/sessions'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Account Session - * - * Allow the user to login into his account by providing a valid email and - * password combination. This route will create a new session for the user. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - createSession: function(email, password) { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/account/sessions'; - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(password) { - payload['password'] = password; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete All Account Sessions - * - * Delete all sessions from the user account and remove any sessions cookies - * from the end client. - * - * @throws {Error} - * @return {Promise} - */ - deleteSessions: function() { - let path = '/account/sessions'; - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Account Session with OAuth2 - * - * Allow the user to login to his account using the 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 {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - createOAuth2Session: function(provider, success = 'https://appwrite.io/auth/oauth2/success', failure = 'https://appwrite.io/auth/oauth2/failure', scopes = []) { - if(provider === undefined) { - throw new Error('Missing required parameter: "provider"'); - } - - let path = '/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}', 'g'), provider); - - let payload = {}; - - if(success) { - payload['success'] = success; - } - - if(failure) { - payload['failure'] = failure; - } - - if(scopes) { - payload['scopes'] = scopes; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - window.location = config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Delete Account Session - * - * Use this endpoint to log out the currently logged in user from all his - * account sessions across all his different devices. When using the option id - * argument, only the session unique ID provider will be deleted. - * - * @param {string} sessionId - * @throws {Error} - * @return {Promise} - */ - deleteSession: function(sessionId) { - if(sessionId === undefined) { - throw new Error('Missing required parameter: "sessionId"'); - } - - let path = '/account/sessions/{sessionId}'.replace(new RegExp('{sessionId}', 'g'), sessionId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Email Verification - * - * Use this endpoint to send a verification message to your user email address - * to confirm they are the valid owners of that address. Both the **userId** - * and **secret** arguments will be passed as query parameters to the URL you - * have provider to be attached to the verification email. The provided URL - * should redirect the user back for your app and allow you to complete the - * verification process by verifying both the **userId** and **secret** - * parameters. Learn more about how to [complete the verification - * process](/docs/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 {Error} - * @return {Promise} - */ - createVerification: function(url) { - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/account/verification'; - - let payload = {}; - - if(url) { - payload['url'] = url; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Complete Email Verification - * - * Use this endpoint to complete the user email verification process. Use both - * the **userId** and **secret** parameters that were attached to your app URL - * to verify the user email ownership. If confirmed this route will return a - * 200 status code. - * - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateVerification: function(userId, secret) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(secret === undefined) { - throw new Error('Missing required parameter: "secret"'); - } - - let path = '/account/verification'; - - let payload = {}; - - if(userId) { - payload['userId'] = userId; - } - - if(secret) { - payload['secret'] = secret; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let avatars = { - - /** - * Get Browser Icon - * - * You can use this endpoint to show different browser icons to your users. - * The code argument receives the browser code as it appears in your user - * /account/sessions endpoint. Use width, height and quality arguments to - * change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getBrowser: function(code, width = 100, height = 100, quality = 100) { - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/avatars/browsers/{code}'.replace(new RegExp('{code}', 'g'), code); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Credit Card Icon - * - * Need to display your users with your billing method or their payment - * methods? The credit card endpoint will return you the icon of the credit - * card provider you need. Use width, height and quality arguments to change - * the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getCreditCard: function(code, width = 100, height = 100, quality = 100) { - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/avatars/credit-cards/{code}'.replace(new RegExp('{code}', 'g'), code); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Favicon - * - * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote - * website URL. - * - * @param {string} url - * @throws {Error} - * @return {string} - */ - getFavicon: function(url) { - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/avatars/favicon'; - - let payload = {}; - - if(url) { - payload['url'] = url; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Country Flag - * - * You can use this endpoint to show different country flags icons to your - * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getFlag: function(code, width = 100, height = 100, quality = 100) { - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/avatars/flags/{code}'.replace(new RegExp('{code}', 'g'), code); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Image from URL - * - * Use this endpoint to fetch a remote image URL and crop it to any image size - * you want. This endpoint is very useful if you need to crop and display - * remote images in your app or in case you want to make sure a 3rd party - * image is properly served using a TLS protocol. - * - * @param {string} url - * @param {number} width - * @param {number} height - * @throws {Error} - * @return {string} - */ - getImage: function(url, width = 400, height = 400) { - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/avatars/image'; - - let payload = {}; - - if(url) { - payload['url'] = url; - } - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get User Initials - * - * Use this endpoint to show your user initials avatar icon on your website or - * app. By default, this route will try to print your logged-in user name or - * email initials. You can also overwrite the user name if you pass the 'name' - * parameter. If no name is given and no user is logged, an empty avatar will - * be returned. - * - * You can use the color and background params to change the avatar colors. By - * default, a random theme will be selected. The random theme will persist for - * the user's initials when reloading the same theme will always return for - * the same initials. - * - * @param {string} name - * @param {number} width - * @param {number} height - * @param {string} color - * @param {string} background - * @throws {Error} - * @return {string} - */ - getInitials: function(name = '', width = 500, height = 500, color = '', background = '') { - let path = '/avatars/initials'; - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(color) { - payload['color'] = color; - } - - if(background) { - payload['background'] = background; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get QR Code - * - * Converts a given plain text to a QR code image. You can use the query - * parameters to change the size and style of the resulting image. - * - * @param {string} text - * @param {number} size - * @param {number} margin - * @param {number} download - * @throws {Error} - * @return {string} - */ - getQR: function(text, size = 400, margin = 1, download = 0) { - if(text === undefined) { - throw new Error('Missing required parameter: "text"'); - } - - let path = '/avatars/qr'; - - let payload = {}; - - if(text) { - payload['text'] = text; - } - - if(size) { - payload['size'] = size; - } - - if(margin) { - payload['margin'] = margin; - } - - if(download) { - payload['download'] = download; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - } - }; - - let database = { - - /** - * List Collections - * - * Get a list of all the user collections. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project collections. [Learn more about different API - * modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listCollections: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/database/collections'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Collection - * - * Create a new Collection. - * - * @param {string} name - * @param {string[]} read - * @param {string[]} write - * @param {string[]} rules - * @throws {Error} - * @return {Promise} - */ - createCollection: function(name, read, write, rules) { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - if(rules === undefined) { - throw new Error('Missing required parameter: "rules"'); - } - - let path = '/database/collections'; - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - if(rules) { - payload['rules'] = rules; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Collection - * - * Get collection by its unique ID. This endpoint response returns a JSON - * object with the collection metadata. - * - * @param {string} collectionId - * @throws {Error} - * @return {Promise} - */ - getCollection: function(collectionId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Collection - * - * Update collection by its unique ID. - * - * @param {string} collectionId - * @param {string} name - * @param {string[]} read - * @param {string[]} write - * @param {string[]} rules - * @throws {Error} - * @return {Promise} - */ - updateCollection: function(collectionId, name, read, write, rules = []) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - if(rules) { - payload['rules'] = rules; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Collection - * - * Delete a collection by its unique ID. Only users with write permissions - * have access to delete this resource. - * - * @param {string} collectionId - * @throws {Error} - * @return {Promise} - */ - deleteCollection: function(collectionId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * 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 {string[]} filters - * @param {number} offset - * @param {number} limit - * @param {string} orderField - * @param {string} orderType - * @param {string} orderCast - * @param {string} search - * @param {number} first - * @param {number} last - * @throws {Error} - * @return {Promise} - */ - listDocuments: function(collectionId, filters = [], offset = 0, limit = 50, orderField = '$id', orderType = 'ASC', orderCast = 'string', search = '', first = 0, last = 0) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - if(filters) { - payload['filters'] = filters; - } - - if(offset) { - payload['offset'] = offset; - } - - if(limit) { - payload['limit'] = limit; - } - - if(orderField) { - payload['orderField'] = orderField; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - if(orderCast) { - payload['orderCast'] = orderCast; - } - - if(search) { - payload['search'] = search; - } - - if(first) { - payload['first'] = first; - } - - if(last) { - payload['last'] = last; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Document - * - * Create a new Document. 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 {string[]} read - * @param {string[]} write - * @param {string} parentDocument - * @param {string} parentProperty - * @param {string} parentPropertyType - * @throws {Error} - * @return {Promise} - */ - createDocument: function(collectionId, data, read, write, parentDocument = '', parentProperty = '', parentPropertyType = 'assign') { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(data === undefined) { - throw new Error('Missing required parameter: "data"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - if(data) { - payload['data'] = data; - } - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - if(parentDocument) { - payload['parentDocument'] = parentDocument; - } - - if(parentProperty) { - payload['parentProperty'] = parentProperty; - } - - if(parentPropertyType) { - payload['parentPropertyType'] = parentPropertyType; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Document - * - * Get document by its unique ID. This endpoint response returns a JSON object - * with the document data. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - getDocument: function(collectionId, documentId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(documentId === undefined) { - throw new Error('Missing required parameter: "documentId"'); - } - - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Document - * - * - * @param {string} collectionId - * @param {string} documentId - * @param {object} data - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateDocument: function(collectionId, documentId, data, read, write) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(documentId === undefined) { - throw new Error('Missing required parameter: "documentId"'); - } - - if(data === undefined) { - throw new Error('Missing required parameter: "data"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - let payload = {}; - - if(data) { - payload['data'] = data; - } - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Document - * - * Delete document by its unique ID. This endpoint deletes only the parent - * documents, his attributes and relations to other documents. Child documents - * **will not** be deleted. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - deleteDocument: function(collectionId, documentId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(documentId === undefined) { - throw new Error('Missing required parameter: "documentId"'); - } - - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Collection Logs - * - * - * @param {string} collectionId - * @throws {Error} - * @return {Promise} - */ - getCollectionLogs: function(collectionId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - let path = '/database/collections/{collectionId}/logs'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let health = { - - /** - * Get HTTP - * - * Check the Appwrite HTTP server is up and responsive. - * - * @throws {Error} - * @return {Promise} - */ - get: function() { - let path = '/health'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Anti virus - * - * Check the Appwrite Anti Virus server is up and connection is successful. - * - * @throws {Error} - * @return {Promise} - */ - getAntiVirus: function() { - let path = '/health/anti-virus'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Cache - * - * Check the Appwrite in-memory cache server is up and connection is - * successful. - * - * @throws {Error} - * @return {Promise} - */ - getCache: function() { - let path = '/health/cache'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get DB - * - * Check the Appwrite database server is up and connection is successful. - * - * @throws {Error} - * @return {Promise} - */ - getDB: function() { - let path = '/health/db'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Certificate Queue - * - * Get the number of certificates that are waiting to be issued against - * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - * server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueCertificates: function() { - let path = '/health/queue/certificates'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Functions Queue - * - * - * @throws {Error} - * @return {Promise} - */ - getQueueFunctions: function() { - let path = '/health/queue/functions'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Logs Queue - * - * Get the number of logs that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueLogs: function() { - let path = '/health/queue/logs'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Tasks Queue - * - * Get the number of tasks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueTasks: function() { - let path = '/health/queue/tasks'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Usage Queue - * - * Get the number of usage stats that are waiting to be processed in the - * Appwrite internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueUsage: function() { - let path = '/health/queue/usage'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Webhooks Queue - * - * Get the number of webhooks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueWebhooks: function() { - let path = '/health/queue/webhooks'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Local Storage - * - * Check the Appwrite local storage device is up and connection is successful. - * - * @throws {Error} - * @return {Promise} - */ - getStorageLocal: function() { - let path = '/health/storage/local'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Time - * - * Check the Appwrite server time is synced with Google remote NTP server. We - * use this technology to smoothly handle leap seconds with no disruptive - * events. The [Network Time - * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - * used by hundreds of millions of computers and devices to synchronize their - * clocks over the Internet. If your computer sets its own clock, it likely - * uses NTP. - * - * @throws {Error} - * @return {Promise} - */ - getTime: function() { - let path = '/health/time'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let locale = { - - /** - * Get User Locale - * - * Get the current user location based on IP. Returns an object with user - * country code, country name, continent name, continent code, ip address and - * suggested currency. You can use the locale header to get the data in a - * supported language. - * - * ([IP Geolocation by DB-IP](https://db-ip.com)) - * - * @throws {Error} - * @return {Promise} - */ - get: function() { - let path = '/locale'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Continents - * - * List of all continents. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getContinents: function() { - let path = '/locale/continents'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Countries - * - * List of all countries. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountries: function() { - let path = '/locale/countries'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List EU Countries - * - * List of all countries that are currently members of the EU. You can use the - * locale header to get the data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesEU: function() { - let path = '/locale/countries/eu'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Countries Phone Codes - * - * List of all countries phone codes. You can use the locale header to get the - * data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesPhones: function() { - let path = '/locale/countries/phones'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Currencies - * - * List of all currencies, including currency 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 {Error} - * @return {Promise} - */ - getCurrencies: function() { - let path = '/locale/currencies'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * 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 {Error} - * @return {Promise} - */ - getLanguages: function() { - let path = '/locale/languages'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let projects = { - - /** - * List Projects - * - * - * @throws {Error} - * @return {Promise} - */ - list: function() { - let path = '/projects'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Project - * - * - * @param {string} name - * @param {string} teamId - * @param {string} description - * @param {string} logo - * @param {string} url - * @param {string} legalName - * @param {string} legalCountry - * @param {string} legalState - * @param {string} legalCity - * @param {string} legalAddress - * @param {string} legalTaxId - * @throws {Error} - * @return {Promise} - */ - create: function(name, teamId, description = '', logo = '', url = '', legalName = '', legalCountry = '', legalState = '', legalCity = '', legalAddress = '', legalTaxId = '') { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/projects'; - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(teamId) { - payload['teamId'] = teamId; - } - - if(description) { - payload['description'] = description; - } - - if(logo) { - payload['logo'] = logo; - } - - if(url) { - payload['url'] = url; - } - - if(legalName) { - payload['legalName'] = legalName; - } - - if(legalCountry) { - payload['legalCountry'] = legalCountry; - } - - if(legalState) { - payload['legalState'] = legalState; - } - - if(legalCity) { - payload['legalCity'] = legalCity; - } - - if(legalAddress) { - payload['legalAddress'] = legalAddress; - } - - if(legalTaxId) { - payload['legalTaxId'] = legalTaxId; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Project - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - get: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Project - * - * - * @param {string} projectId - * @param {string} name - * @param {string} description - * @param {string} logo - * @param {string} url - * @param {string} legalName - * @param {string} legalCountry - * @param {string} legalState - * @param {string} legalCity - * @param {string} legalAddress - * @param {string} legalTaxId - * @throws {Error} - * @return {Promise} - */ - update: function(projectId, name, description = '', logo = '', url = '', legalName = '', legalCountry = '', legalState = '', legalCity = '', legalAddress = '', legalTaxId = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/projects/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(description) { - payload['description'] = description; - } - - if(logo) { - payload['logo'] = logo; - } - - if(url) { - payload['url'] = url; - } - - if(legalName) { - payload['legalName'] = legalName; - } - - if(legalCountry) { - payload['legalCountry'] = legalCountry; - } - - if(legalState) { - payload['legalState'] = legalState; - } - - if(legalCity) { - payload['legalCity'] = legalCity; - } - - if(legalAddress) { - payload['legalAddress'] = legalAddress; - } - - if(legalTaxId) { - payload['legalTaxId'] = legalTaxId; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Project - * - * - * @param {string} projectId - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - delete: function(projectId, password) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/projects/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(password) { - payload['password'] = password; - } - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Domains - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listDomains: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/domains'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Domain - * - * - * @param {string} projectId - * @param {string} domain - * @throws {Error} - * @return {Promise} - */ - createDomain: function(projectId, domain) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(domain === undefined) { - throw new Error('Missing required parameter: "domain"'); - } - - let path = '/projects/{projectId}/domains'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(domain) { - payload['domain'] = domain; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Domain - * - * - * @param {string} projectId - * @param {string} domainId - * @throws {Error} - * @return {Promise} - */ - getDomain: function(projectId, domainId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(domainId === undefined) { - throw new Error('Missing required parameter: "domainId"'); - } - - let path = '/projects/{projectId}/domains/{domainId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{domainId}', 'g'), domainId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Domain - * - * - * @param {string} projectId - * @param {string} domainId - * @throws {Error} - * @return {Promise} - */ - deleteDomain: function(projectId, domainId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(domainId === undefined) { - throw new Error('Missing required parameter: "domainId"'); - } - - let path = '/projects/{projectId}/domains/{domainId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{domainId}', 'g'), domainId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Domain Verification Status - * - * - * @param {string} projectId - * @param {string} domainId - * @throws {Error} - * @return {Promise} - */ - updateDomainVerification: function(projectId, domainId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(domainId === undefined) { - throw new Error('Missing required parameter: "domainId"'); - } - - let path = '/projects/{projectId}/domains/{domainId}/verification'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{domainId}', 'g'), domainId); - - let payload = {}; - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Keys - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listKeys: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/keys'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Key - * - * - * @param {string} projectId - * @param {string} name - * @param {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - createKey: function(projectId, name, scopes) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(scopes === undefined) { - throw new Error('Missing required parameter: "scopes"'); - } - - let path = '/projects/{projectId}/keys'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(scopes) { - payload['scopes'] = scopes; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Key - * - * - * @param {string} projectId - * @param {string} keyId - * @throws {Error} - * @return {Promise} - */ - getKey: function(projectId, keyId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(keyId === undefined) { - throw new Error('Missing required parameter: "keyId"'); - } - - let path = '/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{keyId}', 'g'), keyId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Key - * - * - * @param {string} projectId - * @param {string} keyId - * @param {string} name - * @param {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - updateKey: function(projectId, keyId, name, scopes) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(keyId === undefined) { - throw new Error('Missing required parameter: "keyId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(scopes === undefined) { - throw new Error('Missing required parameter: "scopes"'); - } - - let path = '/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{keyId}', 'g'), keyId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(scopes) { - payload['scopes'] = scopes; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Key - * - * - * @param {string} projectId - * @param {string} keyId - * @throws {Error} - * @return {Promise} - */ - deleteKey: function(projectId, keyId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(keyId === undefined) { - throw new Error('Missing required parameter: "keyId"'); - } - - let path = '/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{keyId}', 'g'), keyId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Project OAuth2 - * - * - * @param {string} projectId - * @param {string} provider - * @param {string} appId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateOAuth2: function(projectId, provider, appId = '', secret = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(provider === undefined) { - throw new Error('Missing required parameter: "provider"'); - } - - let path = '/projects/{projectId}/oauth2'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(provider) { - payload['provider'] = provider; - } - - if(appId) { - payload['appId'] = appId; - } - - if(secret) { - payload['secret'] = secret; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Platforms - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listPlatforms: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/platforms'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Platform - * - * - * @param {string} projectId - * @param {string} type - * @param {string} name - * @param {string} key - * @param {string} store - * @param {string} hostname - * @throws {Error} - * @return {Promise} - */ - createPlatform: function(projectId, type, name, key = '', store = '', hostname = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(type === undefined) { - throw new Error('Missing required parameter: "type"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/projects/{projectId}/platforms'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(type) { - payload['type'] = type; - } - - if(name) { - payload['name'] = name; - } - - if(key) { - payload['key'] = key; - } - - if(store) { - payload['store'] = store; - } - - if(hostname) { - payload['hostname'] = hostname; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Platform - * - * - * @param {string} projectId - * @param {string} platformId - * @throws {Error} - * @return {Promise} - */ - getPlatform: function(projectId, platformId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(platformId === undefined) { - throw new Error('Missing required parameter: "platformId"'); - } - - let path = '/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{platformId}', 'g'), platformId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Platform - * - * - * @param {string} projectId - * @param {string} platformId - * @param {string} name - * @param {string} key - * @param {string} store - * @param {string} hostname - * @throws {Error} - * @return {Promise} - */ - updatePlatform: function(projectId, platformId, name, key = '', store = '', hostname = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(platformId === undefined) { - throw new Error('Missing required parameter: "platformId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{platformId}', 'g'), platformId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(key) { - payload['key'] = key; - } - - if(store) { - payload['store'] = store; - } - - if(hostname) { - payload['hostname'] = hostname; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Platform - * - * - * @param {string} projectId - * @param {string} platformId - * @throws {Error} - * @return {Promise} - */ - deletePlatform: function(projectId, platformId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(platformId === undefined) { - throw new Error('Missing required parameter: "platformId"'); - } - - let path = '/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{platformId}', 'g'), platformId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Tasks - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listTasks: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/tasks'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Task - * - * - * @param {string} projectId - * @param {string} name - * @param {string} status - * @param {string} schedule - * @param {number} security - * @param {string} httpMethod - * @param {string} httpUrl - * @param {string[]} httpHeaders - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - createTask: function(projectId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = [], httpUser = '', httpPass = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(status === undefined) { - throw new Error('Missing required parameter: "status"'); - } - - if(schedule === undefined) { - throw new Error('Missing required parameter: "schedule"'); - } - - if(security === undefined) { - throw new Error('Missing required parameter: "security"'); - } - - if(httpMethod === undefined) { - throw new Error('Missing required parameter: "httpMethod"'); - } - - if(httpUrl === undefined) { - throw new Error('Missing required parameter: "httpUrl"'); - } - - let path = '/projects/{projectId}/tasks'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(status) { - payload['status'] = status; - } - - if(schedule) { - payload['schedule'] = schedule; - } - - if(security) { - payload['security'] = security; - } - - if(httpMethod) { - payload['httpMethod'] = httpMethod; - } - - if(httpUrl) { - payload['httpUrl'] = httpUrl; - } - - if(httpHeaders) { - payload['httpHeaders'] = httpHeaders; - } - - if(httpUser) { - payload['httpUser'] = httpUser; - } - - if(httpPass) { - payload['httpPass'] = httpPass; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Task - * - * - * @param {string} projectId - * @param {string} taskId - * @throws {Error} - * @return {Promise} - */ - getTask: function(projectId, taskId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(taskId === undefined) { - throw new Error('Missing required parameter: "taskId"'); - } - - let path = '/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{taskId}', 'g'), taskId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Task - * - * - * @param {string} projectId - * @param {string} taskId - * @param {string} name - * @param {string} status - * @param {string} schedule - * @param {number} security - * @param {string} httpMethod - * @param {string} httpUrl - * @param {string[]} httpHeaders - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - updateTask: function(projectId, taskId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = [], httpUser = '', httpPass = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(taskId === undefined) { - throw new Error('Missing required parameter: "taskId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(status === undefined) { - throw new Error('Missing required parameter: "status"'); - } - - if(schedule === undefined) { - throw new Error('Missing required parameter: "schedule"'); - } - - if(security === undefined) { - throw new Error('Missing required parameter: "security"'); - } - - if(httpMethod === undefined) { - throw new Error('Missing required parameter: "httpMethod"'); - } - - if(httpUrl === undefined) { - throw new Error('Missing required parameter: "httpUrl"'); - } - - let path = '/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{taskId}', 'g'), taskId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(status) { - payload['status'] = status; - } - - if(schedule) { - payload['schedule'] = schedule; - } - - if(security) { - payload['security'] = security; - } - - if(httpMethod) { - payload['httpMethod'] = httpMethod; - } - - if(httpUrl) { - payload['httpUrl'] = httpUrl; - } - - if(httpHeaders) { - payload['httpHeaders'] = httpHeaders; - } - - if(httpUser) { - payload['httpUser'] = httpUser; - } - - if(httpPass) { - payload['httpPass'] = httpPass; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Task - * - * - * @param {string} projectId - * @param {string} taskId - * @throws {Error} - * @return {Promise} - */ - deleteTask: function(projectId, taskId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(taskId === undefined) { - throw new Error('Missing required parameter: "taskId"'); - } - - let path = '/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{taskId}', 'g'), taskId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Project - * - * - * @param {string} projectId - * @param {string} range - * @throws {Error} - * @return {Promise} - */ - getUsage: function(projectId, range = 'last30') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/usage'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(range) { - payload['range'] = range; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Webhooks - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listWebhooks: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Webhook - * - * - * @param {string} projectId - * @param {string} name - * @param {string[]} events - * @param {string} url - * @param {number} security - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - createWebhook: function(projectId, name, events, url, security, httpUser = '', httpPass = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(events === undefined) { - throw new Error('Missing required parameter: "events"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - if(security === undefined) { - throw new Error('Missing required parameter: "security"'); - } - - let path = '/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(events) { - payload['events'] = events; - } - - if(url) { - payload['url'] = url; - } - - if(security) { - payload['security'] = security; - } - - if(httpUser) { - payload['httpUser'] = httpUser; - } - - if(httpPass) { - payload['httpPass'] = httpPass; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Webhook - * - * - * @param {string} projectId - * @param {string} webhookId - * @throws {Error} - * @return {Promise} - */ - getWebhook: function(projectId, webhookId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(webhookId === undefined) { - throw new Error('Missing required parameter: "webhookId"'); - } - - let path = '/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{webhookId}', 'g'), webhookId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Webhook - * - * - * @param {string} projectId - * @param {string} webhookId - * @param {string} name - * @param {string[]} events - * @param {string} url - * @param {number} security - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - updateWebhook: function(projectId, webhookId, name, events, url, security, httpUser = '', httpPass = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(webhookId === undefined) { - throw new Error('Missing required parameter: "webhookId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(events === undefined) { - throw new Error('Missing required parameter: "events"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - if(security === undefined) { - throw new Error('Missing required parameter: "security"'); - } - - let path = '/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{webhookId}', 'g'), webhookId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(events) { - payload['events'] = events; - } - - if(url) { - payload['url'] = url; - } - - if(security) { - payload['security'] = security; - } - - if(httpUser) { - payload['httpUser'] = httpUser; - } - - if(httpPass) { - payload['httpPass'] = httpPass; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Webhook - * - * - * @param {string} projectId - * @param {string} webhookId - * @throws {Error} - * @return {Promise} - */ - deleteWebhook: function(projectId, webhookId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(webhookId === undefined) { - throw new Error('Missing required parameter: "webhookId"'); - } - - let path = '/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{webhookId}', 'g'), webhookId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let storage = { - - /** - * List Files - * - * Get a list of all the user files. You can use the query params to filter - * your results. On admin mode, this endpoint will return a list of all of the - * project files. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listFiles: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/storage/files'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create File - * - * Create a new file. The user who creates the file will automatically be - * assigned to read and write access unless he has passed custom values for - * read and write arguments. - * - * @param {File} file - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - createFile: function(file, read, write) { - if(file === undefined) { - throw new Error('Missing required parameter: "file"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/storage/files'; - - let payload = {}; - - if(file) { - payload['file'] = file; - } - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - return http - .post(path, { - 'content-type': 'multipart/form-data', - }, payload); - }, - - /** - * Get File - * - * Get file by its unique ID. This endpoint response returns a JSON object - * with the file metadata. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - getFile: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update File - * - * Update file by its unique ID. Only users with write permissions have access - * to update this resource. - * - * @param {string} fileId - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateFile: function(fileId, read, write) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - if(read) { - payload['read'] = read; - } - - if(write) { - payload['write'] = write; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete File - * - * Delete a file by its unique ID. Only users with write permissions have - * access to delete this resource. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - deleteFile: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get File for Download - * - * Get file content by its unique ID. The endpoint response return with a - * 'Content-Disposition: attachment' header that tells the browser to start - * downloading the file to user downloads directory. - * - * @param {string} fileId - * @throws {Error} - * @return {string} - */ - getFileDownload: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}/download'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get File Preview - * - * Get a file preview image. Currently, this method supports preview for image - * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets, will return the file icon image. You can also pass query - * string arguments for cutting and resizing your preview image. - * - * @param {string} fileId - * @param {number} width - * @param {number} height - * @param {number} quality - * @param {string} background - * @param {string} output - * @throws {Error} - * @return {string} - */ - getFilePreview: function(fileId, width = 0, height = 0, quality = 100, background = '', output = '') { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - if(background) { - payload['background'] = background; - } - - if(output) { - payload['output'] = output; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get File for View - * - * Get file content by its unique ID. This endpoint is similar to the download - * method but returns with no 'Content-Disposition: attachment' header. - * - * @param {string} fileId - * @param {string} as - * @throws {Error} - * @return {string} - */ - getFileView: function(fileId, as = '') { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}/view'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - if(as) { - payload['as'] = as; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - } - }; - - let teams = { - - /** - * List Teams - * - * Get a list of all the current user teams. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project teams. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/teams'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Team - * - * Create a new team. The user who creates the team will automatically be - * assigned as the owner of the team. The team owner can invite new members, - * who will be able add new owners and update or delete the team from your - * project. - * - * @param {string} name - * @param {string[]} roles - * @throws {Error} - * @return {Promise} - */ - create: function(name, roles = ["owner"]) { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/teams'; - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(roles) { - payload['roles'] = roles; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Team - * - * Get team by its unique ID. All team members have read access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - get: function(teamId) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Team - * - * Update team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - update: function(teamId, name) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Team - * - * Delete team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - delete: function(teamId) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Team Memberships - * - * Get team members by the team unique ID. All team members have read access - * for this list of resources. - * - * @param {string} teamId - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - getMemberships: function(teamId, search = '', limit = 25, offset = 0, orderType = 'ASC') { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Team 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 {string[]} roles - * @param {string} url - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - createMembership: function(teamId, email, roles, url, name = '') { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(roles === undefined) { - throw new Error('Missing required parameter: "roles"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(name) { - payload['name'] = name; - } - - if(roles) { - payload['roles'] = roles; - } - - if(url) { - payload['url'] = url; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Team Membership - * - * This endpoint allows a user to leave a team or for a team owner to delete - * the membership of any other team member. You can also use this endpoint to - * delete a user membership even if he didn't accept it. - * - * @param {string} teamId - * @param {string} inviteId - * @throws {Error} - * @return {Promise} - */ - deleteMembership: function(teamId, inviteId) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(inviteId === undefined) { - throw new Error('Missing required parameter: "inviteId"'); - } - - let path = '/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Team Membership Status - * - * Use this endpoint to allow a user to accept an invitation to join a team - * after he is being redirected back to your app from the invitation email he - * was sent. - * - * @param {string} teamId - * @param {string} inviteId - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateMembershipStatus: function(teamId, inviteId, userId, secret) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(inviteId === undefined) { - throw new Error('Missing required parameter: "inviteId"'); - } - - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(secret === undefined) { - throw new Error('Missing required parameter: "secret"'); - } - - let path = '/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - let payload = {}; - - if(userId) { - payload['userId'] = userId; - } - - if(secret) { - payload['secret'] = secret; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let users = { - - /** - * List Users - * - * Get a list of all the project users. You can use the query params to filter - * your results. - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/users'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create User - * - * Create a new user. - * - * @param {string} email - * @param {string} password - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - create: function(email, password, name = '') { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/users'; - - let payload = {}; - - if(email) { - payload['email'] = email; - } - - if(password) { - payload['password'] = password; - } - - if(name) { - payload['name'] = name; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get User - * - * Get user by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - get: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get User Logs - * - * Get user activity logs list by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - getLogs: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}/logs'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get User Preferences - * - * Get user preferences by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - getPrefs: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update User Preferences - * - * Update user preferences by its unique ID. You can pass only the specific - * settings you wish to update. - * - * @param {string} userId - * @param {object} prefs - * @throws {Error} - * @return {Promise} - */ - updatePrefs: function(userId, prefs) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(prefs === undefined) { - throw new Error('Missing required parameter: "prefs"'); - } - - let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - if(prefs) { - payload['prefs'] = prefs; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get User Sessions - * - * Get user sessions list by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - getSessions: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete User Sessions - * - * Delete all user sessions by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - deleteSessions: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete User Session - * - * Delete user sessions by its unique ID. - * - * @param {string} userId - * @param {string} sessionId - * @throws {Error} - * @return {Promise} - */ - deleteSession: function(userId, sessionId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(sessionId === undefined) { - throw new Error('Missing required parameter: "sessionId"'); - } - - let path = '/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}', 'g'), userId).replace(new RegExp('{sessionId}', 'g'), sessionId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update User Status - * - * Update user status by its unique ID. - * - * @param {string} userId - * @param {string} status - * @throws {Error} - * @return {Promise} - */ - updateStatus: function(userId, status) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(status === undefined) { - throw new Error('Missing required parameter: "status"'); - } - - let path = '/users/{userId}/status'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - if(status) { - payload['status'] = status; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - return { - setEndpoint: setEndpoint, - setProject: setProject, - setKey: setKey, - setLocale: setLocale, - setMode: setMode, - account: account, - avatars: avatars, - database: database, - health: health, - locale: locale, - projects: projects, - storage: storage, - teams: teams, - users: users - }; - }; - - if(typeof module !== "undefined") { - module.exports = window.Appwrite; - } - -})((typeof window !== "undefined") ? window : {}); \ No newline at end of file diff --git a/app/sdks/console-web/src/sdk.min.js b/app/sdks/console-web/src/sdk.min.js deleted file mode 100644 index f6a2781f21..0000000000 --- a/app/sdks/console-web/src/sdk.min.js +++ /dev/null @@ -1,382 +0,0 @@ -(function(window){'use strict';window.Appwrite=function(){let config={endpoint:'https://appwrite.io/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;index=request.status){resolve(data)}else{reject(data)}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,!1)} -request.onerror=function(){reject(new Error("Network Error"))};request.send(params)})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{})},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress)},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress)},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress)},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress)},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -let path='/account';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -if(name){payload.name=name} -return http.post(path,{'content-type':'application/json',},payload)},delete:function(){let path='/account';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateEmail:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -let path='/account/email';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -return http.patch(path,{'content-type':'application/json',},payload)},getLogs:function(){let path='/account/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateName:function(name){if(name===undefined){throw new Error('Missing required parameter: "name"')} -let path='/account/name';let payload={};if(name){payload.name=name} -return http.patch(path,{'content-type':'application/json',},payload)},updatePassword:function(password,oldPassword){if(password===undefined){throw new Error('Missing required parameter: "password"')} -if(oldPassword===undefined){throw new Error('Missing required parameter: "oldPassword"')} -let path='/account/password';let payload={};if(password){payload.password=password} -if(oldPassword){payload.oldPassword=oldPassword} -return http.patch(path,{'content-type':'application/json',},payload)},getPrefs:function(){let path='/account/prefs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},updatePrefs:function(prefs){if(prefs===undefined){throw new Error('Missing required parameter: "prefs"')} -let path='/account/prefs';let payload={};if(prefs){payload.prefs=prefs} -return http.patch(path,{'content-type':'application/json',},payload)},createRecovery:function(email,url){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(url===undefined){throw new Error('Missing required parameter: "url"')} -let path='/account/recovery';let payload={};if(email){payload.email=email} -if(url){payload.url=url} -return http.post(path,{'content-type':'application/json',},payload)},updateRecovery:function(userId,secret,password,passwordAgain){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} -if(secret===undefined){throw new Error('Missing required parameter: "secret"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -if(passwordAgain===undefined){throw new Error('Missing required parameter: "passwordAgain"')} -let path='/account/recovery';let payload={};if(userId){payload.userId=userId} -if(secret){payload.secret=secret} -if(password){payload.password=password} -if(passwordAgain){payload.passwordAgain=passwordAgain} -return http.put(path,{'content-type':'application/json',},payload)},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json',},payload)},createSession:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"')} -if(password===undefined){throw new Error('Missing required parameter: "password"')} -let path='/account/sessions';let payload={};if(email){payload.email=email} -if(password){payload.password=password} -return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success='https://appwrite.io/auth/oauth2/success',failure='https://appwrite.io/auth/oauth2/failure',scopes=[]){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} -let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success} -if(failure){payload.failure=failure} -if(scopes){payload.scopes=scopes} -payload.project=config.project;payload.key=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index; - - /** - * 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 {Error} - * @return {Promise} - */ - create(email: string, password: string, name: string): Promise; - - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @throws {Error} - * @return {Promise} - */ - delete(): Promise; - - /** - * Update Account Email - * - * Update currently logged in user account email address. After changing user - * address, user confirmation status is being reset and a new confirmation - * mail is sent. For security measures, user password is required to complete - * this request. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - updateEmail(email: string, password: string): Promise; - - /** - * Get Account Logs - * - * Get currently logged in user list of latest security activity logs. Each - * log returns user IP address, location and date and time of log. - * - * @throws {Error} - * @return {Promise} - */ - getLogs(): Promise; - - /** - * Update Account Name - * - * Update currently logged in user account name. - * - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - updateName(name: string): Promise; - - /** - * Update Account Password - * - * Update currently logged in user password. For validation, user is required - * to pass the password twice. - * - * @param {string} password - * @param {string} oldPassword - * @throws {Error} - * @return {Promise} - */ - updatePassword(password: string, oldPassword: string): Promise; - - /** - * Get Account Preferences - * - * Get currently logged in user preferences as a key-value object. - * - * @throws {Error} - * @return {Promise} - */ - getPrefs(): Promise; - - /** - * Update Account Preferences - * - * Update currently logged in user account preferences. You can pass only the - * specific settings you wish to update. - * - * @param {object} prefs - * @throws {Error} - * @return {Promise} - */ - updatePrefs(prefs: object): Promise; - - /** - * 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 {Error} - * @return {Promise} - */ - createRecovery(email: string, url: string): Promise; - - /** - * 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 {Error} - * @return {Promise} - */ - updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise; - - /** - * Get Account Sessions - * - * Get currently logged in user list of active sessions across different - * devices. - * - * @throws {Error} - * @return {Promise} - */ - getSessions(): Promise; - - /** - * Create Account Session - * - * Allow the user to login into his account by providing a valid email and - * password combination. This route will create a new session for the user. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - createSession(email: string, password: string): Promise; - - /** - * Delete All Account Sessions - * - * Delete all sessions from the user account and remove any sessions cookies - * from the end client. - * - * @throws {Error} - * @return {Promise} - */ - deleteSessions(): Promise; - - /** - * 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 {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - createOAuth2Session(provider: string, success: string, failure: string, scopes: string[]): Promise; - - /** - * Delete Account Session - * - * Use this endpoint to log out the currently logged in user from all his - * account sessions across all his different devices. When using the option id - * argument, only the session unique ID provider will be deleted. - * - * @param {string} sessionId - * @throws {Error} - * @return {Promise} - */ - deleteSession(sessionId: string): Promise; - - /** - * 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. - * - * @param {string} url - * @throws {Error} - * @return {Promise} - */ - createVerification(url: string): Promise; - - /** - * Complete Email Verification - * - * Use this endpoint to complete the user email verification process. Use both - * the **userId** and **secret** parameters that were attached to your app URL - * to verify the user email ownership. If confirmed this route will return a - * 200 status code. - * - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateVerification(userId: string, secret: string): Promise; - - } - - export interface Avatars { - - /** - * Get Browser Icon - * - * You can use this endpoint to show different browser icons to your users. - * The code argument receives the browser code as it appears in your user - * /account/sessions endpoint. Use width, height and quality arguments to - * change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getBrowser(code: string, width: number, height: number, quality: number): string; - - /** - * Get Credit Card Icon - * - * Need to display your users with your billing method or their payment - * methods? The credit card endpoint will return you the icon of the credit - * card provider you need. Use width, height and quality arguments to change - * the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getCreditCard(code: string, width: number, height: number, quality: number): string; - - /** - * Get Favicon - * - * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote - * website URL. - * - * @param {string} url - * @throws {Error} - * @return {string} - */ - getFavicon(url: string): string; - - /** - * Get Country Flag - * - * You can use this endpoint to show different country flags icons to your - * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getFlag(code: string, width: number, height: number, quality: number): string; - - /** - * Get Image from URL - * - * Use this endpoint to fetch a remote image URL and crop it to any image size - * you want. This endpoint is very useful if you need to crop and display - * remote images in your app or in case you want to make sure a 3rd party - * image is properly served using a TLS protocol. - * - * @param {string} url - * @param {number} width - * @param {number} height - * @throws {Error} - * @return {string} - */ - getImage(url: string, width: number, height: number): string; - - /** - * Get User Initials - * - * Use this endpoint to show your user initials avatar icon on your website or - * app. By default, this route will try to print your logged-in user name or - * email initials. You can also overwrite the user name if you pass the 'name' - * parameter. If no name is given and no user is logged, an empty avatar will - * be returned. - * - * You can use the color and background params to change the avatar colors. By - * default, a random theme will be selected. The random theme will persist for - * the user's initials when reloading the same theme will always return for - * the same initials. - * - * @param {string} name - * @param {number} width - * @param {number} height - * @param {string} color - * @param {string} background - * @throws {Error} - * @return {string} - */ - getInitials(name: string, width: number, height: number, color: string, background: string): string; - - /** - * Get QR Code - * - * Converts a given plain text to a QR code image. You can use the query - * parameters to change the size and style of the resulting image. - * - * @param {string} text - * @param {number} size - * @param {number} margin - * @param {number} download - * @throws {Error} - * @return {string} - */ - getQR(text: string, size: number, margin: number, download: number): string; - - } - - export interface Database { - - /** - * List Collections - * - * Get a list of all the user collections. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project collections. [Learn more about different API - * modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listCollections(search: string, limit: number, offset: number, orderType: string): Promise; - - /** - * Create Collection - * - * Create a new Collection. - * - * @param {string} name - * @param {string[]} read - * @param {string[]} write - * @param {string[]} rules - * @throws {Error} - * @return {Promise} - */ - createCollection(name: string, read: string[], write: string[], rules: string[]): Promise; - - /** - * Get Collection - * - * Get collection by its unique ID. This endpoint response returns a JSON - * object with the collection metadata. - * - * @param {string} collectionId - * @throws {Error} - * @return {Promise} - */ - getCollection(collectionId: string): Promise; - - /** - * Update Collection - * - * Update collection by its unique ID. - * - * @param {string} collectionId - * @param {string} name - * @param {string[]} read - * @param {string[]} write - * @param {string[]} rules - * @throws {Error} - * @return {Promise} - */ - updateCollection(collectionId: string, name: string, read: string[], write: string[], rules: string[]): Promise; - - /** - * Delete Collection - * - * Delete a collection by its unique ID. Only users with write permissions - * have access to delete this resource. - * - * @param {string} collectionId - * @throws {Error} - * @return {Promise} - */ - deleteCollection(collectionId: string): Promise; - - /** - * 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 {string[]} filters - * @param {number} offset - * @param {number} limit - * @param {string} orderField - * @param {string} orderType - * @param {string} orderCast - * @param {string} search - * @param {number} first - * @param {number} last - * @throws {Error} - * @return {Promise} - */ - listDocuments(collectionId: string, filters: string[], offset: number, limit: number, orderField: string, orderType: string, orderCast: string, search: string, first: number, last: number): Promise; - - /** - * 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 {string[]} read - * @param {string[]} write - * @param {string} parentDocument - * @param {string} parentProperty - * @param {string} parentPropertyType - * @throws {Error} - * @return {Promise} - */ - createDocument(collectionId: string, data: object, read: string[], write: string[], parentDocument: string, parentProperty: string, parentPropertyType: string): Promise; - - /** - * Get Document - * - * Get document by its unique ID. This endpoint response returns a JSON object - * with the document data. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - getDocument(collectionId: string, documentId: string): Promise; - - /** - * Update Document - * - * - * @param {string} collectionId - * @param {string} documentId - * @param {object} data - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateDocument(collectionId: string, documentId: string, data: object, read: string[], write: string[]): Promise; - - /** - * Delete Document - * - * Delete document by its unique ID. This endpoint deletes only the parent - * documents, his attributes and relations to other documents. Child documents - * **will not** be deleted. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - deleteDocument(collectionId: string, documentId: string): Promise; - - /** - * Get Collection Logs - * - * - * @param {string} collectionId - * @throws {Error} - * @return {Promise} - */ - getCollectionLogs(collectionId: string): Promise; - - } - - export interface Health { - - /** - * Get HTTP - * - * Check the Appwrite HTTP server is up and responsive. - * - * @throws {Error} - * @return {Promise} - */ - get(): Promise; - - /** - * Get Anti virus - * - * Check the Appwrite Anti Virus server is up and connection is successful. - * - * @throws {Error} - * @return {Promise} - */ - getAntiVirus(): Promise; - - /** - * Get Cache - * - * Check the Appwrite in-memory cache server is up and connection is - * successful. - * - * @throws {Error} - * @return {Promise} - */ - getCache(): Promise; - - /** - * Get DB - * - * Check the Appwrite database server is up and connection is successful. - * - * @throws {Error} - * @return {Promise} - */ - getDB(): Promise; - - /** - * Get Certificate Queue - * - * Get the number of certificates that are waiting to be issued against - * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - * server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueCertificates(): Promise; - - /** - * Get Functions Queue - * - * - * @throws {Error} - * @return {Promise} - */ - getQueueFunctions(): Promise; - - /** - * Get Logs Queue - * - * Get the number of logs that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueLogs(): Promise; - - /** - * Get Tasks Queue - * - * Get the number of tasks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueTasks(): Promise; - - /** - * Get Usage Queue - * - * Get the number of usage stats that are waiting to be processed in the - * Appwrite internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueUsage(): Promise; - - /** - * Get Webhooks Queue - * - * Get the number of webhooks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueWebhooks(): Promise; - - /** - * Get Local Storage - * - * Check the Appwrite local storage device is up and connection is successful. - * - * @throws {Error} - * @return {Promise} - */ - getStorageLocal(): Promise; - - /** - * Get Time - * - * Check the Appwrite server time is synced with Google remote NTP server. We - * use this technology to smoothly handle leap seconds with no disruptive - * events. The [Network Time - * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - * used by hundreds of millions of computers and devices to synchronize their - * clocks over the Internet. If your computer sets its own clock, it likely - * uses NTP. - * - * @throws {Error} - * @return {Promise} - */ - getTime(): Promise; - - } - - export interface Locale { - - /** - * Get User Locale - * - * Get the current user location based on IP. Returns an object with user - * country code, country name, continent name, continent code, ip address and - * suggested currency. You can use the locale header to get the data in a - * supported language. - * - * ([IP Geolocation by DB-IP](https://db-ip.com)) - * - * @throws {Error} - * @return {Promise} - */ - get(): Promise; - - /** - * List Continents - * - * List of all continents. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getContinents(): Promise; - - /** - * List Countries - * - * List of all countries. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountries(): Promise; - - /** - * List EU Countries - * - * List of all countries that are currently members of the EU. You can use the - * locale header to get the data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesEU(): Promise; - - /** - * List Countries Phone Codes - * - * List of all countries phone codes. You can use the locale header to get the - * data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesPhones(): Promise; - - /** - * 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 {Error} - * @return {Promise} - */ - getCurrencies(): Promise; - - /** - * 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 {Error} - * @return {Promise} - */ - getLanguages(): Promise; - - } - - export interface Projects { - - /** - * List Projects - * - * - * @throws {Error} - * @return {Promise} - */ - list(): Promise; - - /** - * Create Project - * - * - * @param {string} name - * @param {string} teamId - * @param {string} description - * @param {string} logo - * @param {string} url - * @param {string} legalName - * @param {string} legalCountry - * @param {string} legalState - * @param {string} legalCity - * @param {string} legalAddress - * @param {string} legalTaxId - * @throws {Error} - * @return {Promise} - */ - create(name: string, teamId: string, description: string, logo: string, url: string, legalName: string, legalCountry: string, legalState: string, legalCity: string, legalAddress: string, legalTaxId: string): Promise; - - /** - * Get Project - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - get(projectId: string): Promise; - - /** - * Update Project - * - * - * @param {string} projectId - * @param {string} name - * @param {string} description - * @param {string} logo - * @param {string} url - * @param {string} legalName - * @param {string} legalCountry - * @param {string} legalState - * @param {string} legalCity - * @param {string} legalAddress - * @param {string} legalTaxId - * @throws {Error} - * @return {Promise} - */ - update(projectId: string, name: string, description: string, logo: string, url: string, legalName: string, legalCountry: string, legalState: string, legalCity: string, legalAddress: string, legalTaxId: string): Promise; - - /** - * Delete Project - * - * - * @param {string} projectId - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - delete(projectId: string, password: string): Promise; - - /** - * List Domains - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listDomains(projectId: string): Promise; - - /** - * Create Domain - * - * - * @param {string} projectId - * @param {string} domain - * @throws {Error} - * @return {Promise} - */ - createDomain(projectId: string, domain: string): Promise; - - /** - * Get Domain - * - * - * @param {string} projectId - * @param {string} domainId - * @throws {Error} - * @return {Promise} - */ - getDomain(projectId: string, domainId: string): Promise; - - /** - * Delete Domain - * - * - * @param {string} projectId - * @param {string} domainId - * @throws {Error} - * @return {Promise} - */ - deleteDomain(projectId: string, domainId: string): Promise; - - /** - * Update Domain Verification Status - * - * - * @param {string} projectId - * @param {string} domainId - * @throws {Error} - * @return {Promise} - */ - updateDomainVerification(projectId: string, domainId: string): Promise; - - /** - * List Keys - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listKeys(projectId: string): Promise; - - /** - * Create Key - * - * - * @param {string} projectId - * @param {string} name - * @param {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - createKey(projectId: string, name: string, scopes: string[]): Promise; - - /** - * Get Key - * - * - * @param {string} projectId - * @param {string} keyId - * @throws {Error} - * @return {Promise} - */ - getKey(projectId: string, keyId: string): Promise; - - /** - * Update Key - * - * - * @param {string} projectId - * @param {string} keyId - * @param {string} name - * @param {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - updateKey(projectId: string, keyId: string, name: string, scopes: string[]): Promise; - - /** - * Delete Key - * - * - * @param {string} projectId - * @param {string} keyId - * @throws {Error} - * @return {Promise} - */ - deleteKey(projectId: string, keyId: string): Promise; - - /** - * Update Project OAuth2 - * - * - * @param {string} projectId - * @param {string} provider - * @param {string} appId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateOAuth2(projectId: string, provider: string, appId: string, secret: string): Promise; - - /** - * List Platforms - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listPlatforms(projectId: string): Promise; - - /** - * Create Platform - * - * - * @param {string} projectId - * @param {string} type - * @param {string} name - * @param {string} key - * @param {string} store - * @param {string} hostname - * @throws {Error} - * @return {Promise} - */ - createPlatform(projectId: string, type: string, name: string, key: string, store: string, hostname: string): Promise; - - /** - * Get Platform - * - * - * @param {string} projectId - * @param {string} platformId - * @throws {Error} - * @return {Promise} - */ - getPlatform(projectId: string, platformId: string): Promise; - - /** - * Update Platform - * - * - * @param {string} projectId - * @param {string} platformId - * @param {string} name - * @param {string} key - * @param {string} store - * @param {string} hostname - * @throws {Error} - * @return {Promise} - */ - updatePlatform(projectId: string, platformId: string, name: string, key: string, store: string, hostname: string): Promise; - - /** - * Delete Platform - * - * - * @param {string} projectId - * @param {string} platformId - * @throws {Error} - * @return {Promise} - */ - deletePlatform(projectId: string, platformId: string): Promise; - - /** - * List Tasks - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listTasks(projectId: string): Promise; - - /** - * Create Task - * - * - * @param {string} projectId - * @param {string} name - * @param {string} status - * @param {string} schedule - * @param {number} security - * @param {string} httpMethod - * @param {string} httpUrl - * @param {string[]} httpHeaders - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - createTask(projectId: string, name: string, status: string, schedule: string, security: number, httpMethod: string, httpUrl: string, httpHeaders: string[], httpUser: string, httpPass: string): Promise; - - /** - * Get Task - * - * - * @param {string} projectId - * @param {string} taskId - * @throws {Error} - * @return {Promise} - */ - getTask(projectId: string, taskId: string): Promise; - - /** - * Update Task - * - * - * @param {string} projectId - * @param {string} taskId - * @param {string} name - * @param {string} status - * @param {string} schedule - * @param {number} security - * @param {string} httpMethod - * @param {string} httpUrl - * @param {string[]} httpHeaders - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - updateTask(projectId: string, taskId: string, name: string, status: string, schedule: string, security: number, httpMethod: string, httpUrl: string, httpHeaders: string[], httpUser: string, httpPass: string): Promise; - - /** - * Delete Task - * - * - * @param {string} projectId - * @param {string} taskId - * @throws {Error} - * @return {Promise} - */ - deleteTask(projectId: string, taskId: string): Promise; - - /** - * Get Project - * - * - * @param {string} projectId - * @param {string} range - * @throws {Error} - * @return {Promise} - */ - getUsage(projectId: string, range: string): Promise; - - /** - * List Webhooks - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listWebhooks(projectId: string): Promise; - - /** - * Create Webhook - * - * - * @param {string} projectId - * @param {string} name - * @param {string[]} events - * @param {string} url - * @param {number} security - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - createWebhook(projectId: string, name: string, events: string[], url: string, security: number, httpUser: string, httpPass: string): Promise; - - /** - * Get Webhook - * - * - * @param {string} projectId - * @param {string} webhookId - * @throws {Error} - * @return {Promise} - */ - getWebhook(projectId: string, webhookId: string): Promise; - - /** - * Update Webhook - * - * - * @param {string} projectId - * @param {string} webhookId - * @param {string} name - * @param {string[]} events - * @param {string} url - * @param {number} security - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - updateWebhook(projectId: string, webhookId: string, name: string, events: string[], url: string, security: number, httpUser: string, httpPass: string): Promise; - - /** - * Delete Webhook - * - * - * @param {string} projectId - * @param {string} webhookId - * @throws {Error} - * @return {Promise} - */ - deleteWebhook(projectId: string, webhookId: string): Promise; - - } - - export interface Storage { - - /** - * List Files - * - * Get a list of all the user files. You can use the query params to filter - * your results. On admin mode, this endpoint will return a list of all of the - * project files. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listFiles(search: string, limit: number, offset: number, orderType: string): Promise; - - /** - * Create File - * - * Create a new file. The user who creates the file will automatically be - * assigned to read and write access unless he has passed custom values for - * read and write arguments. - * - * @param {File} file - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - createFile(file: File, read: string[], write: string[]): Promise; - - /** - * Get File - * - * Get file by its unique ID. This endpoint response returns a JSON object - * with the file metadata. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - getFile(fileId: string): Promise; - - /** - * Update File - * - * Update file by its unique ID. Only users with write permissions have access - * to update this resource. - * - * @param {string} fileId - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateFile(fileId: string, read: string[], write: string[]): Promise; - - /** - * Delete File - * - * Delete a file by its unique ID. Only users with write permissions have - * access to delete this resource. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - deleteFile(fileId: string): Promise; - - /** - * Get File for Download - * - * Get file content by its unique ID. The endpoint response return with a - * 'Content-Disposition: attachment' header that tells the browser to start - * downloading the file to user downloads directory. - * - * @param {string} fileId - * @throws {Error} - * @return {string} - */ - getFileDownload(fileId: string): string; - - /** - * Get File Preview - * - * Get a file preview image. Currently, this method supports preview for image - * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets, will return the file icon image. You can also pass query - * string arguments for cutting and resizing your preview image. - * - * @param {string} fileId - * @param {number} width - * @param {number} height - * @param {number} quality - * @param {string} background - * @param {string} output - * @throws {Error} - * @return {string} - */ - getFilePreview(fileId: string, width: number, height: number, quality: number, background: string, output: string): string; - - /** - * Get File for View - * - * Get file content by its unique ID. This endpoint is similar to the download - * method but returns with no 'Content-Disposition: attachment' header. - * - * @param {string} fileId - * @param {string} as - * @throws {Error} - * @return {string} - */ - getFileView(fileId: string, as: string): string; - - } - - export interface Teams { - - /** - * List Teams - * - * Get a list of all the current user teams. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project teams. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list(search: string, limit: number, offset: number, orderType: string): Promise; - - /** - * 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 {string[]} roles - * @throws {Error} - * @return {Promise} - */ - create(name: string, roles: string[]): Promise; - - /** - * Get Team - * - * Get team by its unique ID. All team members have read access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - get(teamId: string): Promise; - - /** - * Update Team - * - * Update team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - update(teamId: string, name: string): Promise; - - /** - * Delete Team - * - * Delete team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - delete(teamId: string): Promise; - - /** - * 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 {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - getMemberships(teamId: string, search: string, limit: number, offset: number, orderType: string): Promise; - - /** - * 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 {string[]} roles - * @param {string} url - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - createMembership(teamId: string, email: string, roles: string[], url: string, name: string): Promise; - - /** - * Delete Team Membership - * - * This endpoint allows a user to leave a team or for a team owner to delete - * the membership of any other team member. You can also use this endpoint to - * delete a user membership even if he didn't accept it. - * - * @param {string} teamId - * @param {string} inviteId - * @throws {Error} - * @return {Promise} - */ - deleteMembership(teamId: string, inviteId: string): Promise; - - /** - * Update Team Membership Status - * - * Use this endpoint to allow a user to accept an invitation to join a team - * after he is being redirected back to your app from the invitation email he - * was sent. - * - * @param {string} teamId - * @param {string} inviteId - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateMembershipStatus(teamId: string, inviteId: string, userId: string, secret: string): Promise; - - } - - export interface Users { - - /** - * List Users - * - * Get a list of all the project users. You can use the query params to filter - * your results. - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list(search: string, limit: number, offset: number, orderType: string): Promise; - - /** - * Create User - * - * Create a new user. - * - * @param {string} email - * @param {string} password - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - create(email: string, password: string, name: string): Promise; - - /** - * Get User - * - * Get user by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - get(userId: string): Promise; - - /** - * Get User Logs - * - * Get user activity logs list by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - getLogs(userId: string): Promise; - - /** - * Get User Preferences - * - * Get user preferences by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - getPrefs(userId: string): Promise; - - /** - * Update User Preferences - * - * Update user preferences by its unique ID. You can pass only the specific - * settings you wish to update. - * - * @param {string} userId - * @param {object} prefs - * @throws {Error} - * @return {Promise} - */ - updatePrefs(userId: string, prefs: object): Promise; - - /** - * Get User Sessions - * - * Get user sessions list by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - getSessions(userId: string): Promise; - - /** - * Delete User Sessions - * - * Delete all user sessions by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - deleteSessions(userId: string): Promise; - - /** - * Delete User Session - * - * Delete user sessions by its unique ID. - * - * @param {string} userId - * @param {string} sessionId - * @throws {Error} - * @return {Promise} - */ - deleteSession(userId: string, sessionId: string): Promise; - - /** - * Update User Status - * - * Update user status by its unique ID. - * - * @param {string} userId - * @param {string} status - * @throws {Error} - * @return {Promise} - */ - updateStatus(userId: string, status: string): Promise; - - } - - -} \ No newline at end of file diff --git a/app/sdks/server-deno/CHANGELOG.md b/app/sdks/server-deno/CHANGELOG.md deleted file mode 100644 index fa4d35e687..0000000000 --- a/app/sdks/server-deno/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -# Change Log \ No newline at end of file diff --git a/app/sdks/server-deno/LICENSE b/app/sdks/server-deno/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/server-deno/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/server-deno/README.md b/app/sdks/server-deno/README.md deleted file mode 100644 index 82bd02c8ef..0000000000 --- a/app/sdks/server-deno/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# Appwrite Deno SDK - -![License](https://img.shields.io/github/license/appwrite/sdk-for-deno.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1) - -**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 Deno 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) - - - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -```javascript -import * as sdk from "https://deno.land/x/appwrite/mod.ts"; -``` - -## 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. \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/database/get-collection-logs.md b/app/sdks/server-deno/docs/examples/database/get-collection-logs.md deleted file mode 100644 index a72c17bc16..0000000000 --- a/app/sdks/server-deno/docs/examples/database/get-collection-logs.md +++ /dev/null @@ -1,20 +0,0 @@ -import * as sdk from "https://deno.land/x/appwrite/mod.ts"; - -// Init SDK -let client = new sdk.Client(); - -let database = new sdk.Database(client); - -client - .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key -; - - -let promise = database.getCollectionLogs('[COLLECTION_ID]'); - -promise.then(function (response) { - console.log(response); -}, function (error) { - console.log(error); -}); \ No newline at end of file diff --git a/app/sdks/server-deno/mod.ts b/app/sdks/server-deno/mod.ts deleted file mode 100644 index 3e51466fe6..0000000000 --- a/app/sdks/server-deno/mod.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Client } from "./src/client.ts"; -import { Avatars } from "./src/services/avatars.ts"; -import { Database } from "./src/services/database.ts"; -import { Health } from "./src/services/health.ts"; -import { Locale } from "./src/services/locale.ts"; -import { Storage } from "./src/services/storage.ts"; -import { Teams } from "./src/services/teams.ts"; -import { Users } from "./src/services/users.ts"; - -export { - Client, - Avatars, - Database, - Health, - Locale, - Storage, - Teams, - Users, -}; \ No newline at end of file diff --git a/app/sdks/server-deno/src/client.ts b/app/sdks/server-deno/src/client.ts deleted file mode 100644 index 3bf22034b8..0000000000 --- a/app/sdks/server-deno/src/client.ts +++ /dev/null @@ -1,138 +0,0 @@ -export interface DocumentData { - [key: string]: any; -} - -export class Client { - - endpoint: string = 'https://appwrite.io/v1'; - headers: DocumentData = { - 'content-type': '', - 'x-sdk-version': 'appwrite:deno:0.0.2', - }; - - /** - * Set Project - * - * Your project ID - * - * @param string value - * - * @return self - */ - setProject(value: string): this { - this.addHeader('X-Appwrite-Project', value); - - return this; - } - - /** - * Set Key - * - * Your secret API key - * - * @param string value - * - * @return self - */ - setKey(value: string): this { - this.addHeader('X-Appwrite-Key', value); - - return this; - } - - /** - * Set Locale - * - * @param string value - * - * @return self - */ - setLocale(value: string): this { - this.addHeader('X-Appwrite-Locale', value); - - return this; - } - - - /*** - * @param endpoint - * @return this - */ - setEndpoint(endpoint: string): this { - this.endpoint = endpoint; - - return this; - } - - /** - * @param key string - * @param value string - */ - addHeader(key: string, value: string): this { - this.headers[key.toLowerCase()] = value.toLowerCase(); - - return this; - } - - withoutHeader(key: string, headers: DocumentData): DocumentData { - return Object.keys(headers).reduce((acc: DocumentData, cv) => { - if (cv == 'content-type') return acc - acc[cv] = headers[cv] - return acc - }, {}) - } - - async call(method: string, path: string = '', headers: DocumentData = {}, params: DocumentData = {}) { - headers = Object.assign(this.headers, headers); - - let body; - const url = new URL(this.endpoint + path) - if (method.toUpperCase() === 'GET') { - url.search = new URLSearchParams(this.flatten(params)).toString() - body = null - } else if (headers['content-type'].toLowerCase().startsWith('multipart/form-data')) { - headers = this.withoutHeader('content-type', headers) - const formData = new FormData() - const flatParams = this.flatten(params) - for (const key in flatParams) { - formData.append(key, flatParams[key]); - } - body = formData - } else { - body = JSON.stringify(params) - } - - const options = { - method: method.toUpperCase(), - headers: headers, - body: body, - }; - - let response = await fetch(url.toString(), options); - const contentType = response.headers.get('content-type'); - - if (contentType && contentType.includes('application/json')) { - return response.json() - } - - return response; - } - - flatten(data: DocumentData, prefix = '') { - let output: DocumentData = {}; - - for (const key in data) { - let value = data[key]; - let finalKey = prefix ? prefix + '[' + key +']' : key; - - if (Array.isArray(value)) { - output = Object.assign(output, this.flatten(value, finalKey)); // @todo: handle name collision here if needed - } - else { - output[finalKey] = value; - } - } - - return output; - } -} \ No newline at end of file diff --git a/app/sdks/server-deno/src/service.ts b/app/sdks/server-deno/src/service.ts deleted file mode 100644 index ceedf1a0c3..0000000000 --- a/app/sdks/server-deno/src/service.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Client } from "./client.ts"; - -export abstract class Service { - - client: Client; - - /** - * @param client - */ - constructor(client: Client) { - this.client = client; - } -} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/avatars.ts b/app/sdks/server-deno/src/services/avatars.ts deleted file mode 100644 index f70e950bed..0000000000 --- a/app/sdks/server-deno/src/services/avatars.ts +++ /dev/null @@ -1,163 +0,0 @@ -import { Service } from "../service.ts"; -import { DocumentData } from '../client.ts' - -export class Avatars extends 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 number width - * @param number height - * @param number quality - * @throws Exception - * @return Promise - */ - async getBrowser(code: string, width: number = 100, height: number = 100, quality: number = 100): Promise { - let path = '/avatars/browsers/{code}'.replace(new RegExp('{code}', 'g'), code); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'width': width, - 'height': height, - 'quality': quality - }); - } - - /** - * Get Credit Card Icon - * - * Need to display your users with your billing method or their payment - * methods? The credit card endpoint will return you the icon of the credit - * card provider you need. Use width, height and quality arguments to change - * the output settings. - * - * @param string code - * @param number width - * @param number height - * @param number quality - * @throws Exception - * @return Promise - */ - async getCreditCard(code: string, width: number = 100, height: number = 100, quality: number = 100): Promise { - let path = '/avatars/credit-cards/{code}'.replace(new RegExp('{code}', 'g'), code); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'width': width, - 'height': height, - 'quality': quality - }); - } - - /** - * Get Favicon - * - * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote - * website URL. - * - * @param string url - * @throws Exception - * @return Promise - */ - async getFavicon(url: string): Promise { - let path = '/avatars/favicon'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'url': url - }); - } - - /** - * Get Country Flag - * - * You can use this endpoint to show different country flags icons to your - * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. - * - * @param string code - * @param number width - * @param number height - * @param number quality - * @throws Exception - * @return Promise - */ - async getFlag(code: string, width: number = 100, height: number = 100, quality: number = 100): Promise { - let path = '/avatars/flags/{code}'.replace(new RegExp('{code}', 'g'), code); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'width': width, - 'height': height, - 'quality': quality - }); - } - - /** - * Get Image from URL - * - * Use this endpoint to fetch a remote image URL and crop it to any image size - * you want. This endpoint is very useful if you need to crop and display - * remote images in your app or in case you want to make sure a 3rd party - * image is properly served using a TLS protocol. - * - * @param string url - * @param number width - * @param number height - * @throws Exception - * @return Promise - */ - async getImage(url: string, width: number = 400, height: number = 400): Promise { - let path = '/avatars/image'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'url': url, - 'width': width, - 'height': height - }); - } - - /** - * Get QR Code - * - * Converts a given plain text to a QR code image. You can use the query - * parameters to change the size and style of the resulting image. - * - * @param string text - * @param number size - * @param number margin - * @param number download - * @throws Exception - * @return Promise - */ - async getQR(text: string, size: number = 400, margin: number = 1, download: number = 0): Promise { - let path = '/avatars/qr'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download - }); - } -} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/database.ts b/app/sdks/server-deno/src/services/database.ts deleted file mode 100644 index 164145ef82..0000000000 --- a/app/sdks/server-deno/src/services/database.ts +++ /dev/null @@ -1,285 +0,0 @@ -import { Service } from "../service.ts"; -import { DocumentData } from '../client.ts' - -export class Database extends Service { - - /** - * List Collections - * - * Get a list of all the user collections. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project collections. [Learn more about different API - * modes](/docs/admin). - * - * @param string search - * @param number limit - * @param number offset - * @param string orderType - * @throws Exception - * @return Promise - */ - async listCollections(search: string = '', limit: number = 25, offset: number = 0, orderType: string = 'ASC'): Promise { - let path = '/database/collections'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType - }); - } - - /** - * Create Collection - * - * Create a new Collection. - * - * @param string name - * @param Array read - * @param Array write - * @param Array rules - * @throws Exception - * @return Promise - */ - async createCollection(name: string, read: Array, write: Array, rules: Array): Promise { - let path = '/database/collections'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules - }); - } - - /** - * Get Collection - * - * Get collection by its unique ID. This endpoint response returns a JSON - * object with the collection metadata. - * - * @param string collectionId - * @throws Exception - * @return Promise - */ - async getCollection(collectionId: string): Promise { - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Collection - * - * Update collection by its unique ID. - * - * @param string collectionId - * @param string name - * @param Array read - * @param Array write - * @param Array rules - * @throws Exception - * @return Promise - */ - async updateCollection(collectionId: string, name: string, read: Array, write: Array, rules: Array = []): Promise { - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules - }); - } - - /** - * Delete Collection - * - * Delete a collection by its unique ID. Only users with write permissions - * have access to delete this resource. - * - * @param string collectionId - * @throws Exception - * @return Promise - */ - async deleteCollection(collectionId: string): Promise { - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Documents - * - * Get a list of all the user documents. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project documents. [Learn more about different API - * modes](/docs/admin). - * - * @param string collectionId - * @param Array filters - * @param number offset - * @param number limit - * @param string orderField - * @param string orderType - * @param string orderCast - * @param string search - * @param number first - * @param number last - * @throws Exception - * @return Promise - */ - async listDocuments(collectionId: string, filters: Array = [], offset: number = 0, limit: number = 50, orderField: string = '$id', orderType: string = 'ASC', orderCast: string = 'string', search: string = '', first: number = 0, last: number = 0): Promise { - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'filters': filters, - 'offset': offset, - 'limit': limit, - 'orderField': orderField, - 'orderType': orderType, - 'orderCast': orderCast, - 'search': search, - 'first': first, - 'last': last - }); - } - - /** - * 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 DocumentData data - * @param Array read - * @param Array write - * @param string parentDocument - * @param string parentProperty - * @param string parentPropertyType - * @throws Exception - * @return Promise - */ - async createDocument(collectionId: string, data: DocumentData, read: Array, write: Array, parentDocument: string = '', parentProperty: string = '', parentPropertyType: string = 'assign'): Promise { - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'data': data, - 'read': read, - 'write': write, - 'parentDocument': parentDocument, - 'parentProperty': parentProperty, - 'parentPropertyType': parentPropertyType - }); - } - - /** - * 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 Promise - */ - async getDocument(collectionId: string, documentId: string): Promise { - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Document - * - * @param string collectionId - * @param string documentId - * @param DocumentData data - * @param Array read - * @param Array write - * @throws Exception - * @return Promise - */ - async updateDocument(collectionId: string, documentId: string, data: DocumentData, read: Array, write: Array): Promise { - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'data': data, - 'read': read, - 'write': write - }); - } - - /** - * 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 Promise - */ - async deleteDocument(collectionId: string, documentId: string): Promise { - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Collection Logs - * - * @param string collectionId - * @throws Exception - * @return Promise - */ - async getCollectionLogs(collectionId: string): Promise { - let path = '/database/collections/{collectionId}/logs'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } -} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/health.ts b/app/sdks/server-deno/src/services/health.ts deleted file mode 100644 index df5c18a2cb..0000000000 --- a/app/sdks/server-deno/src/services/health.ts +++ /dev/null @@ -1,232 +0,0 @@ -import { Service } from "../service.ts"; -import { DocumentData } from '../client.ts' - -export class Health extends Service { - - /** - * Get HTTP - * - * Check the Appwrite HTTP server is up and responsive. - * - * @throws Exception - * @return Promise - */ - async get(): Promise { - let path = '/health'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Anti virus - * - * Check the Appwrite Anti Virus server is up and connection is successful. - * - * @throws Exception - * @return Promise - */ - async getAntiVirus(): Promise { - let path = '/health/anti-virus'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Cache - * - * Check the Appwrite in-memory cache server is up and connection is - * successful. - * - * @throws Exception - * @return Promise - */ - async getCache(): Promise { - let path = '/health/cache'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get DB - * - * Check the Appwrite database server is up and connection is successful. - * - * @throws Exception - * @return Promise - */ - async getDB(): Promise { - let path = '/health/db'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Certificate Queue - * - * Get the number of certificates that are waiting to be issued against - * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - * server. - * - * @throws Exception - * @return Promise - */ - async getQueueCertificates(): Promise { - let path = '/health/queue/certificates'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Functions Queue - * - * @throws Exception - * @return Promise - */ - async getQueueFunctions(): Promise { - let path = '/health/queue/functions'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Logs Queue - * - * Get the number of logs that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws Exception - * @return Promise - */ - async getQueueLogs(): Promise { - let path = '/health/queue/logs'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Tasks Queue - * - * Get the number of tasks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws Exception - * @return Promise - */ - async getQueueTasks(): Promise { - let path = '/health/queue/tasks'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Usage Queue - * - * Get the number of usage stats that are waiting to be processed in the - * Appwrite internal queue server. - * - * @throws Exception - * @return Promise - */ - async getQueueUsage(): Promise { - let path = '/health/queue/usage'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Webhooks Queue - * - * Get the number of webhooks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws Exception - * @return Promise - */ - async getQueueWebhooks(): Promise { - let path = '/health/queue/webhooks'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Local Storage - * - * Check the Appwrite local storage device is up and connection is successful. - * - * @throws Exception - * @return Promise - */ - async getStorageLocal(): Promise { - let path = '/health/storage/local'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Time - * - * Check the Appwrite server time is synced with Google remote NTP server. We - * use this technology to smoothly handle leap seconds with no disruptive - * events. The [Network Time - * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - * used by hundreds of millions of computers and devices to synchronize their - * clocks over the Internet. If your computer sets its own clock, it likely - * uses NTP. - * - * @throws Exception - * @return Promise - */ - async getTime(): Promise { - let path = '/health/time'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } -} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/locale.ts b/app/sdks/server-deno/src/services/locale.ts deleted file mode 100644 index 0c42ac61d2..0000000000 --- a/app/sdks/server-deno/src/services/locale.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { Service } from "../service.ts"; -import { DocumentData } from '../client.ts' - -export class Locale extends 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 Promise - */ - async get(): Promise { - let path = '/locale'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Continents - * - * List of all continents. You can use the locale header to get the data in a - * supported language. - * - * @throws Exception - * @return Promise - */ - async getContinents(): Promise { - let path = '/locale/continents'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Countries - * - * List of all countries. You can use the locale header to get the data in a - * supported language. - * - * @throws Exception - * @return Promise - */ - async getCountries(): Promise { - let path = '/locale/countries'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 Promise - */ - async getCountriesEU(): Promise { - let path = '/locale/countries/eu'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 Promise - */ - async getCountriesPhones(): Promise { - let path = '/locale/countries/phones'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Currencies - * - * List of all currencies, including currency symol, name, plural, and decimal - * digits for all major and minor currencies. You can use the locale header to - * get the data in a supported language. - * - * @throws Exception - * @return Promise - */ - async getCurrencies(): Promise { - let path = '/locale/currencies'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } -} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/storage.ts b/app/sdks/server-deno/src/services/storage.ts deleted file mode 100644 index b663739e05..0000000000 --- a/app/sdks/server-deno/src/services/storage.ts +++ /dev/null @@ -1,198 +0,0 @@ -import { Service } from "../service.ts"; -import { DocumentData } from '../client.ts' - -export class Storage extends 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 number limit - * @param number offset - * @param string orderType - * @throws Exception - * @return Promise - */ - async listFiles(search: string = '', limit: number = 25, offset: number = 0, orderType: string = 'ASC'): Promise { - let path = '/storage/files'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType - }); - } - - /** - * Create File - * - * Create a new file. The user who creates the file will automatically be - * assigned to read and write access unless he has passed custom values for - * read and write arguments. - * - * @param File | Blob file - * @param Array read - * @param Array write - * @throws Exception - * @return Promise - */ - async createFile(file: File | Blob, read: Array, write: Array): Promise { - let path = '/storage/files'; - - return await this.client.call('post', path, { - 'content-type': 'multipart/form-data', - }, - { - 'file': file, - 'read': read, - 'write': write - }); - } - - /** - * 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 Promise - */ - async getFile(fileId: string): Promise { - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update File - * - * Update file by its unique ID. Only users with write permissions have access - * to update this resource. - * - * @param string fileId - * @param Array read - * @param Array write - * @throws Exception - * @return Promise - */ - async updateFile(fileId: string, read: Array, write: Array): Promise { - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'read': read, - 'write': write - }); - } - - /** - * 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 Promise - */ - async deleteFile(fileId: string): Promise { - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 Promise - */ - async getFileDownload(fileId: string): Promise { - let path = '/storage/files/{fileId}/download'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get File Preview - * - * Get a file preview image. Currently, this method supports preview for image - * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets, will return the file icon image. You can also pass query - * string arguments for cutting and resizing your preview image. - * - * @param string fileId - * @param number width - * @param number height - * @param number quality - * @param string background - * @param string output - * @throws Exception - * @return Promise - */ - async getFilePreview(fileId: string, width: number = 0, height: number = 0, quality: number = 100, background: string = '', output: string = ''): Promise { - let path = '/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'width': width, - 'height': height, - 'quality': quality, - 'background': background, - 'output': output - }); - } - - /** - * 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 Promise - */ - async getFileView(fileId: string, as: string = ''): Promise { - let path = '/storage/files/{fileId}/view'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'as': as - }); - } -} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/teams.ts b/app/sdks/server-deno/src/services/teams.ts deleted file mode 100644 index b80c2f6714..0000000000 --- a/app/sdks/server-deno/src/services/teams.ts +++ /dev/null @@ -1,201 +0,0 @@ -import { Service } from "../service.ts"; -import { DocumentData } from '../client.ts' - -export class Teams extends 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 number limit - * @param number offset - * @param string orderType - * @throws Exception - * @return Promise - */ - async list(search: string = '', limit: number = 25, offset: number = 0, orderType: string = 'ASC'): Promise { - let path = '/teams'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType - }); - } - - /** - * Create Team - * - * Create a new team. The user who creates the team will automatically be - * assigned as the owner of the team. The team owner can invite new members, - * who will be able add new owners and update or delete the team from your - * project. - * - * @param string name - * @param Array roles - * @throws Exception - * @return Promise - */ - async create(name: string, roles: Array = ["owner"]): Promise { - let path = '/teams'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'roles': roles - }); - } - - /** - * Get Team - * - * Get team by its unique ID. All team members have read access for this - * resource. - * - * @param string teamId - * @throws Exception - * @return Promise - */ - async get(teamId: string): Promise { - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 Promise - */ - async update(teamId: string, name: string): Promise { - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'name': name - }); - } - - /** - * Delete Team - * - * Delete team by its unique ID. Only team owners have write access for this - * resource. - * - * @param string teamId - * @throws Exception - * @return Promise - */ - async delete(teamId: string): Promise { - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Team Memberships - * - * Get team members by the team unique ID. All team members have read access - * for this list of resources. - * - * @param string teamId - * @throws Exception - * @return Promise - */ - async getMemberships(teamId: string): Promise { - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 roles - * @param string url - * @param string name - * @throws Exception - * @return Promise - */ - async createMembership(teamId: string, email: string, roles: Array, url: string, name: string = ''): Promise { - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'email': email, - 'name': name, - 'roles': roles, - 'url': url - }); - } - - /** - * 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 Promise - */ - async deleteMembership(teamId: string, inviteId: string): Promise { - let path = '/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } -} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/users.ts b/app/sdks/server-deno/src/services/users.ts deleted file mode 100644 index ac48507f08..0000000000 --- a/app/sdks/server-deno/src/services/users.ts +++ /dev/null @@ -1,214 +0,0 @@ -import { Service } from "../service.ts"; -import { DocumentData } from '../client.ts' - -export class Users extends Service { - - /** - * List Users - * - * Get a list of all the project users. You can use the query params to filter - * your results. - * - * @param string search - * @param number limit - * @param number offset - * @param string orderType - * @throws Exception - * @return Promise - */ - async list(search: string = '', limit: number = 25, offset: number = 0, orderType: string = 'ASC'): Promise { - let path = '/users'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType - }); - } - - /** - * Create User - * - * Create a new user. - * - * @param string email - * @param string password - * @param string name - * @throws Exception - * @return Promise - */ - async create(email: string, password: string, name: string = ''): Promise { - let path = '/users'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'email': email, - 'password': password, - 'name': name - }); - } - - /** - * Get User - * - * Get user by its unique ID. - * - * @param string userId - * @throws Exception - * @return Promise - */ - async get(userId: string): Promise { - let path = '/users/{userId}'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get User Logs - * - * Get user activity logs list by its unique ID. - * - * @param string userId - * @throws Exception - * @return Promise - */ - async getLogs(userId: string): Promise { - let path = '/users/{userId}/logs'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get User Preferences - * - * Get user preferences by its unique ID. - * - * @param string userId - * @throws Exception - * @return Promise - */ - async getPrefs(userId: string): Promise { - let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update User Preferences - * - * Update user preferences by its unique ID. You can pass only the specific - * settings you wish to update. - * - * @param string userId - * @param DocumentData prefs - * @throws Exception - * @return Promise - */ - async updatePrefs(userId: string, prefs: DocumentData): Promise { - let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'prefs': prefs - }); - } - - /** - * Get User Sessions - * - * Get user sessions list by its unique ID. - * - * @param string userId - * @throws Exception - * @return Promise - */ - async getSessions(userId: string): Promise { - let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Delete User Sessions - * - * Delete all user sessions by its unique ID. - * - * @param string userId - * @throws Exception - * @return Promise - */ - async deleteSessions(userId: string): Promise { - let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Delete User Session - * - * Delete user sessions by its unique ID. - * - * @param string userId - * @param string sessionId - * @throws Exception - * @return Promise - */ - async deleteSession(userId: string, sessionId: string): Promise { - let path = '/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}', 'g'), userId).replace(new RegExp('{sessionId}', 'g'), sessionId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update User Status - * - * Update user status by its unique ID. - * - * @param string userId - * @param string status - * @throws Exception - * @return Promise - */ - async updateStatus(userId: string, status: string): Promise { - let path = '/users/{userId}/status'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'status': status - }); - } -} \ No newline at end of file diff --git a/app/sdks/server-go/CHANGELOG.md b/app/sdks/server-go/CHANGELOG.md deleted file mode 100644 index fa4d35e687..0000000000 --- a/app/sdks/server-go/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -# Change Log \ No newline at end of file diff --git a/app/sdks/server-go/LICENSE b/app/sdks/server-go/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/server-go/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/server-go/README.md b/app/sdks/server-go/README.md deleted file mode 100644 index 3b46d51f79..0000000000 --- a/app/sdks/server-go/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Appwrite SDK for Go - -![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) - -**This SDK is compatible with Appwrite server version 0.6.0. 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 Go 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) - - - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -To install using `go get`: - -```bash -go get github.com/appwrite/sdk-for-go -``` - -## 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. \ No newline at end of file diff --git a/app/sdks/server-go/avatars.go b/app/sdks/server-go/avatars.go deleted file mode 100644 index feafa9da31..0000000000 --- a/app/sdks/server-go/avatars.go +++ /dev/null @@ -1,111 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Avatars service -type Avatars struct { - client Client -} - -func NewAvatars(clt Client) Avatars { - service := Avatars{ - client: clt, - } - - return service -} - -// GetBrowser you can use this endpoint to show different browser icons to -// 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. -func (srv *Avatars) GetBrowser(Code string, Width int, Height int, Quality int) (map[string]interface{}, error) { - r := strings.NewReplacer("{code}", Code) - path := r.Replace("/avatars/browsers/{code}") - - params := map[string]interface{}{ - "width": Width, - "height": Height, - "quality": Quality, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCreditCard 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. -func (srv *Avatars) GetCreditCard(Code string, Width int, Height int, Quality int) (map[string]interface{}, error) { - r := strings.NewReplacer("{code}", Code) - path := r.Replace("/avatars/credit-cards/{code}") - - params := map[string]interface{}{ - "width": Width, - "height": Height, - "quality": Quality, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetFavicon use this endpoint to fetch the favorite icon (AKA favicon) of a -// any remote website URL. -func (srv *Avatars) GetFavicon(Url string) (map[string]interface{}, error) { - path := "/avatars/favicon" - - params := map[string]interface{}{ - "url": Url, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetFlag 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. -func (srv *Avatars) GetFlag(Code string, Width int, Height int, Quality int) (map[string]interface{}, error) { - r := strings.NewReplacer("{code}", Code) - path := r.Replace("/avatars/flags/{code}") - - params := map[string]interface{}{ - "width": Width, - "height": Height, - "quality": Quality, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetImage 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. -func (srv *Avatars) GetImage(Url string, Width int, Height int) (map[string]interface{}, error) { - path := "/avatars/image" - - params := map[string]interface{}{ - "url": Url, - "width": Width, - "height": Height, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetQR 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. -func (srv *Avatars) GetQR(Text string, Size int, Margin int, Download int) (map[string]interface{}, error) { - path := "/avatars/qr" - - params := map[string]interface{}{ - "text": Text, - "size": Size, - "margin": Margin, - "download": Download, - } - - return srv.client.Call("GET", path, nil, params) -} diff --git a/app/sdks/server-go/client.go b/app/sdks/server-go/client.go deleted file mode 100644 index bd21f5f347..0000000000 --- a/app/sdks/server-go/client.go +++ /dev/null @@ -1,113 +0,0 @@ -package appwrite - -import ( - "encoding/json" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// Client is the client struct to access Appwrite services -type Client struct { - client *http.Client - endpoint string - headers map[string]string - selfSigned bool -} - -// SetEndpoint sets the default endpoint to which the Client connects to -func (clt *Client) SetEndpoint(endpoint string) { - clt.endpoint = endpoint -} - -// SetSelfSigned sets the condition that specify if the Client should allow connections to a server using a self-signed certificate -func (clt *Client) SetSelfSigned(status bool) { - clt.selfSigned = status -} - -// AddHeader add a new custom header that the Client should send on each request -func (clt *Client) AddHeader(key string, value string) { - clt.headers[key] = value -} - -// Your project ID -func (clt *Client) SetProject(value string) { - clt.headers["X-Appwrite-Project"] = value -} - -// Your secret API key -func (clt *Client) SetKey(value string) { - clt.headers["X-Appwrite-Key"] = value -} - -func (clt *Client) SetLocale(value string) { - clt.headers["X-Appwrite-Locale"] = value -} - -// Call an API using Client -func (clt *Client) Call(method string, path string, headers map[string]interface{}, params map[string]interface{}) (map[string]interface{}, error) { - if clt.client == nil { - // Create HTTP client - clt.client = &http.Client{} - } - - if clt.selfSigned { - // Allow self signed requests - } - - urlPath := clt.endpoint + path - isGet := strings.ToUpper(method) == "GET" - - var reqBody *strings.Reader - if !isGet { - frm := url.Values{} - for key, val := range params { - frm.Add(key, ToString(val)) - } - reqBody = strings.NewReader(frm.Encode()) - } - - // Create and modify HTTP request before sending - req, err := http.NewRequest(method, urlPath, reqBody) - if err != nil { - return nil, err - } - - // Set Client headers - for key, val := range clt.headers { - req.Header.Set(key, ToString(val)) - } - - // Set Custom headers - for key, val := range headers { - req.Header.Set(key, ToString(val)) - } - - if isGet { - q := req.URL.Query() - for key, val := range params { - q.Add(key, ToString(val)) - } - req.URL.RawQuery = q.Encode() - } - - // Make request - response, err := clt.client.Do(req) - if err != nil { - return nil, err - } - - // Handle response - defer response.Body.Close() - - responseData, err := ioutil.ReadAll(response.Body) - if err != nil { - return nil, err - } - - var jsonResponse map[string]interface{} - json.Unmarshal(responseData, &jsonResponse) - - return jsonResponse, nil -} diff --git a/app/sdks/server-go/database.go b/app/sdks/server-go/database.go deleted file mode 100644 index d420d69fde..0000000000 --- a/app/sdks/server-go/database.go +++ /dev/null @@ -1,178 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Database service -type Database struct { - client Client -} - -func NewDatabase(clt Client) Database { - service := Database{ - client: clt, - } - - return service -} - -// ListCollections get a list of all the user collections. You can use the -// query params to filter your results. On admin mode, this endpoint will -// return a list of all of the project collections. [Learn more about -// different API modes](/docs/admin). -func (srv *Database) ListCollections(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { - path := "/database/collections" - - params := map[string]interface{}{ - "search": Search, - "limit": Limit, - "offset": Offset, - "orderType": OrderType, - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateCollection create a new Collection. -func (srv *Database) CreateCollection(Name string, Read []interface{}, Write []interface{}, Rules []interface{}) (map[string]interface{}, error) { - path := "/database/collections" - - params := map[string]interface{}{ - "name": Name, - "read": Read, - "write": Write, - "rules": Rules, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetCollection get collection by its unique ID. This endpoint response -// returns a JSON object with the collection metadata. -func (srv *Database) GetCollection(CollectionId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateCollection update collection by its unique ID. -func (srv *Database) UpdateCollection(CollectionId string, Name string, Read []interface{}, Write []interface{}, Rules []interface{}) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}") - - params := map[string]interface{}{ - "name": Name, - "read": Read, - "write": Write, - "rules": Rules, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// DeleteCollection delete a collection by its unique ID. Only users with -// write permissions have access to delete this resource. -func (srv *Database) DeleteCollection(CollectionId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// ListDocuments 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). -func (srv *Database) ListDocuments(CollectionId string, Filters []interface{}, Offset int, Limit int, OrderField string, OrderType string, OrderCast string, Search string, First int, Last int) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}/documents") - - params := map[string]interface{}{ - "filters": Filters, - "offset": Offset, - "limit": Limit, - "orderField": OrderField, - "orderType": OrderType, - "orderCast": OrderCast, - "search": Search, - "first": First, - "last": Last, - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateDocument create a new Document. -func (srv *Database) CreateDocument(CollectionId string, Data object, Read []interface{}, Write []interface{}, ParentDocument string, ParentProperty string, ParentPropertyType string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}/documents") - - params := map[string]interface{}{ - "data": Data, - "read": Read, - "write": Write, - "parentDocument": ParentDocument, - "parentProperty": ParentProperty, - "parentPropertyType": ParentPropertyType, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetDocument get document by its unique ID. This endpoint response returns a -// JSON object with the document data. -func (srv *Database) GetDocument(CollectionId string, DocumentId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId) - path := r.Replace("/database/collections/{collectionId}/documents/{documentId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateDocument -func (srv *Database) UpdateDocument(CollectionId string, DocumentId string, Data object, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId) - path := r.Replace("/database/collections/{collectionId}/documents/{documentId}") - - params := map[string]interface{}{ - "data": Data, - "read": Read, - "write": Write, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// DeleteDocument 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. -func (srv *Database) DeleteDocument(CollectionId string, DocumentId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId) - path := r.Replace("/database/collections/{collectionId}/documents/{documentId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// GetCollectionLogs -func (srv *Database) GetCollectionLogs(CollectionId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}/logs") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} diff --git a/app/sdks/server-go/docs/examples/avatars/get-browser.md b/app/sdks/server-go/docs/examples/avatars/get-browser.md deleted file mode 100644 index b307cd8dbc..0000000000 --- a/app/sdks/server-go/docs/examples/avatars/get-browser.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetBrowser("aa", 0, 0, 0) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/avatars/get-credit-card.md b/app/sdks/server-go/docs/examples/avatars/get-credit-card.md deleted file mode 100644 index ffc748d052..0000000000 --- a/app/sdks/server-go/docs/examples/avatars/get-credit-card.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetCreditCard("amex", 0, 0, 0) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/avatars/get-favicon.md b/app/sdks/server-go/docs/examples/avatars/get-favicon.md deleted file mode 100644 index 596a9d9fd3..0000000000 --- a/app/sdks/server-go/docs/examples/avatars/get-favicon.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetFavicon("https://example.com") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/avatars/get-flag.md b/app/sdks/server-go/docs/examples/avatars/get-flag.md deleted file mode 100644 index 63042ef0a6..0000000000 --- a/app/sdks/server-go/docs/examples/avatars/get-flag.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetFlag("af", 0, 0, 0) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/avatars/get-image.md b/app/sdks/server-go/docs/examples/avatars/get-image.md deleted file mode 100644 index 7095ee3658..0000000000 --- a/app/sdks/server-go/docs/examples/avatars/get-image.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetImage("https://example.com", 0, 0) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/avatars/get-q-r.md b/app/sdks/server-go/docs/examples/avatars/get-q-r.md deleted file mode 100644 index 37425a463e..0000000000 --- a/app/sdks/server-go/docs/examples/avatars/get-q-r.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetQR("[TEXT]", 0, 0, 0) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/create-collection.md b/app/sdks/server-go/docs/examples/database/create-collection.md deleted file mode 100644 index 947ce799ff..0000000000 --- a/app/sdks/server-go/docs/examples/database/create-collection.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.CreateCollection("[NAME]", [], [], []) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/create-document.md b/app/sdks/server-go/docs/examples/database/create-document.md deleted file mode 100644 index 5b63002464..0000000000 --- a/app/sdks/server-go/docs/examples/database/create-document.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.CreateDocument("[COLLECTION_ID]", , [], [], "[PARENT_DOCUMENT]", "", "assign") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/delete-collection.md b/app/sdks/server-go/docs/examples/database/delete-collection.md deleted file mode 100644 index 2b5744730b..0000000000 --- a/app/sdks/server-go/docs/examples/database/delete-collection.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.DeleteCollection("[COLLECTION_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/delete-document.md b/app/sdks/server-go/docs/examples/database/delete-document.md deleted file mode 100644 index 5dfa23e1b1..0000000000 --- a/app/sdks/server-go/docs/examples/database/delete-document.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.DeleteDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/get-collection-logs.md b/app/sdks/server-go/docs/examples/database/get-collection-logs.md deleted file mode 100644 index 4427295371..0000000000 --- a/app/sdks/server-go/docs/examples/database/get-collection-logs.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.GetCollectionLogs("[COLLECTION_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/get-collection.md b/app/sdks/server-go/docs/examples/database/get-collection.md deleted file mode 100644 index bc6d9f7746..0000000000 --- a/app/sdks/server-go/docs/examples/database/get-collection.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.GetCollection("[COLLECTION_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/get-document.md b/app/sdks/server-go/docs/examples/database/get-document.md deleted file mode 100644 index ba4b063f57..0000000000 --- a/app/sdks/server-go/docs/examples/database/get-document.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.GetDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/list-collections.md b/app/sdks/server-go/docs/examples/database/list-collections.md deleted file mode 100644 index 0dda37d5e3..0000000000 --- a/app/sdks/server-go/docs/examples/database/list-collections.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.ListCollections("[SEARCH]", 0, 0, "ASC") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/list-documents.md b/app/sdks/server-go/docs/examples/database/list-documents.md deleted file mode 100644 index 9f2e36d591..0000000000 --- a/app/sdks/server-go/docs/examples/database/list-documents.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.ListDocuments("[COLLECTION_ID]", [], 0, 0, "[ORDER_FIELD]", "DESC", "int", "[SEARCH]", 0, 0) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/update-collection.md b/app/sdks/server-go/docs/examples/database/update-collection.md deleted file mode 100644 index 2b5e7f6d37..0000000000 --- a/app/sdks/server-go/docs/examples/database/update-collection.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.UpdateCollection("[COLLECTION_ID]", "[NAME]", [], [], []) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/database/update-document.md b/app/sdks/server-go/docs/examples/database/update-document.md deleted file mode 100644 index 65a3eefa4a..0000000000 --- a/app/sdks/server-go/docs/examples/database/update-document.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.UpdateDocument("[COLLECTION_ID]", "[DOCUMENT_ID]", , [], []) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-anti-virus.md b/app/sdks/server-go/docs/examples/health/get-anti-virus.md deleted file mode 100644 index a6f363dde1..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-anti-virus.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetAntiVirus() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-cache.md b/app/sdks/server-go/docs/examples/health/get-cache.md deleted file mode 100644 index ce7b1c6f93..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-cache.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetCache() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-d-b.md b/app/sdks/server-go/docs/examples/health/get-d-b.md deleted file mode 100644 index 6d86894417..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-d-b.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetDB() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-certificates.md b/app/sdks/server-go/docs/examples/health/get-queue-certificates.md deleted file mode 100644 index 9954551580..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-queue-certificates.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetQueueCertificates() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-functions.md b/app/sdks/server-go/docs/examples/health/get-queue-functions.md deleted file mode 100644 index 5df453068b..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-queue-functions.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetQueueFunctions() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-logs.md b/app/sdks/server-go/docs/examples/health/get-queue-logs.md deleted file mode 100644 index 0b6280a42a..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-queue-logs.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetQueueLogs() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-tasks.md b/app/sdks/server-go/docs/examples/health/get-queue-tasks.md deleted file mode 100644 index 28d615dc2c..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-queue-tasks.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetQueueTasks() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-usage.md b/app/sdks/server-go/docs/examples/health/get-queue-usage.md deleted file mode 100644 index e9fe988aa2..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-queue-usage.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetQueueUsage() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-webhooks.md b/app/sdks/server-go/docs/examples/health/get-queue-webhooks.md deleted file mode 100644 index 2f92835a12..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-queue-webhooks.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetQueueWebhooks() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-storage-anti-virus.md b/app/sdks/server-go/docs/examples/health/get-storage-anti-virus.md deleted file mode 100644 index 8369b5ba07..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-storage-anti-virus.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetStorageAntiVirus() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-storage-local.md b/app/sdks/server-go/docs/examples/health/get-storage-local.md deleted file mode 100644 index db0d5a5b21..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-storage-local.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetStorageLocal() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-time.md b/app/sdks/server-go/docs/examples/health/get-time.md deleted file mode 100644 index dd8486a484..0000000000 --- a/app/sdks/server-go/docs/examples/health/get-time.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.GetTime() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get.md b/app/sdks/server-go/docs/examples/health/get.md deleted file mode 100644 index df1cb27243..0000000000 --- a/app/sdks/server-go/docs/examples/health/get.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Health{ - client: &client - } - - var response, error := service.Get() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/locale/get-continents.md b/app/sdks/server-go/docs/examples/locale/get-continents.md deleted file mode 100644 index dd9b96ca66..0000000000 --- a/app/sdks/server-go/docs/examples/locale/get-continents.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetContinents() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/locale/get-countries-e-u.md b/app/sdks/server-go/docs/examples/locale/get-countries-e-u.md deleted file mode 100644 index 01a2fedc1b..0000000000 --- a/app/sdks/server-go/docs/examples/locale/get-countries-e-u.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetCountriesEU() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/locale/get-countries-phones.md b/app/sdks/server-go/docs/examples/locale/get-countries-phones.md deleted file mode 100644 index 87de9bb2f5..0000000000 --- a/app/sdks/server-go/docs/examples/locale/get-countries-phones.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetCountriesPhones() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/locale/get-countries.md b/app/sdks/server-go/docs/examples/locale/get-countries.md deleted file mode 100644 index 58c74f5f73..0000000000 --- a/app/sdks/server-go/docs/examples/locale/get-countries.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetCountries() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/locale/get-currencies.md b/app/sdks/server-go/docs/examples/locale/get-currencies.md deleted file mode 100644 index c736db8336..0000000000 --- a/app/sdks/server-go/docs/examples/locale/get-currencies.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetCurrencies() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/locale/get.md b/app/sdks/server-go/docs/examples/locale/get.md deleted file mode 100644 index 3245b79cb5..0000000000 --- a/app/sdks/server-go/docs/examples/locale/get.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.Get() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/storage/create-file.md b/app/sdks/server-go/docs/examples/storage/create-file.md deleted file mode 100644 index 1348acb40b..0000000000 --- a/app/sdks/server-go/docs/examples/storage/create-file.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.CreateFile(file, [], []) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/storage/delete-file.md b/app/sdks/server-go/docs/examples/storage/delete-file.md deleted file mode 100644 index 6b00581d75..0000000000 --- a/app/sdks/server-go/docs/examples/storage/delete-file.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.DeleteFile("[FILE_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/storage/get-file-download.md b/app/sdks/server-go/docs/examples/storage/get-file-download.md deleted file mode 100644 index 6c68b14c3b..0000000000 --- a/app/sdks/server-go/docs/examples/storage/get-file-download.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.GetFileDownload("[FILE_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/storage/get-file-preview.md b/app/sdks/server-go/docs/examples/storage/get-file-preview.md deleted file mode 100644 index 86212c82d3..0000000000 --- a/app/sdks/server-go/docs/examples/storage/get-file-preview.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.GetFilePreview("[FILE_ID]", 0, 0, 0, "", "jpg") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/storage/get-file-view.md b/app/sdks/server-go/docs/examples/storage/get-file-view.md deleted file mode 100644 index b9ddb637de..0000000000 --- a/app/sdks/server-go/docs/examples/storage/get-file-view.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.GetFileView("[FILE_ID]", "pdf") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/storage/get-file.md b/app/sdks/server-go/docs/examples/storage/get-file.md deleted file mode 100644 index f9aaa6eb81..0000000000 --- a/app/sdks/server-go/docs/examples/storage/get-file.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.GetFile("[FILE_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/storage/list-files.md b/app/sdks/server-go/docs/examples/storage/list-files.md deleted file mode 100644 index 53e7e37d5c..0000000000 --- a/app/sdks/server-go/docs/examples/storage/list-files.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.ListFiles("[SEARCH]", 0, 0, "ASC") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/storage/update-file.md b/app/sdks/server-go/docs/examples/storage/update-file.md deleted file mode 100644 index 1ec409de9f..0000000000 --- a/app/sdks/server-go/docs/examples/storage/update-file.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.UpdateFile("[FILE_ID]", [], []) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/teams/create-membership.md b/app/sdks/server-go/docs/examples/teams/create-membership.md deleted file mode 100644 index a346deaa64..0000000000 --- a/app/sdks/server-go/docs/examples/teams/create-membership.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.CreateMembership("[TEAM_ID]", "email@example.com", [], "https://example.com", "[NAME]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/teams/create.md b/app/sdks/server-go/docs/examples/teams/create.md deleted file mode 100644 index 8e3a100573..0000000000 --- a/app/sdks/server-go/docs/examples/teams/create.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.Create("[NAME]", []) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/teams/delete-membership.md b/app/sdks/server-go/docs/examples/teams/delete-membership.md deleted file mode 100644 index 809413a3bf..0000000000 --- a/app/sdks/server-go/docs/examples/teams/delete-membership.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.DeleteMembership("[TEAM_ID]", "[INVITE_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/teams/delete.md b/app/sdks/server-go/docs/examples/teams/delete.md deleted file mode 100644 index 5cf65c2f6f..0000000000 --- a/app/sdks/server-go/docs/examples/teams/delete.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.Delete("[TEAM_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/teams/get-memberships.md b/app/sdks/server-go/docs/examples/teams/get-memberships.md deleted file mode 100644 index b59a8ff33b..0000000000 --- a/app/sdks/server-go/docs/examples/teams/get-memberships.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.GetMemberships("[TEAM_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/teams/get.md b/app/sdks/server-go/docs/examples/teams/get.md deleted file mode 100644 index 2920f547f2..0000000000 --- a/app/sdks/server-go/docs/examples/teams/get.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.Get("[TEAM_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/teams/list.md b/app/sdks/server-go/docs/examples/teams/list.md deleted file mode 100644 index 5cd9e3e29e..0000000000 --- a/app/sdks/server-go/docs/examples/teams/list.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.List("[SEARCH]", 0, 0, "ASC") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/teams/update.md b/app/sdks/server-go/docs/examples/teams/update.md deleted file mode 100644 index 40178c8424..0000000000 --- a/app/sdks/server-go/docs/examples/teams/update.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.Update("[TEAM_ID]", "[NAME]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/create.md b/app/sdks/server-go/docs/examples/users/create.md deleted file mode 100644 index 3a27b00f54..0000000000 --- a/app/sdks/server-go/docs/examples/users/create.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.Create("email@example.com", "password", "[NAME]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/delete-session.md b/app/sdks/server-go/docs/examples/users/delete-session.md deleted file mode 100644 index e1840ba133..0000000000 --- a/app/sdks/server-go/docs/examples/users/delete-session.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.DeleteSession("[USER_ID]", "[SESSION_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/delete-sessions.md b/app/sdks/server-go/docs/examples/users/delete-sessions.md deleted file mode 100644 index 682ea0cada..0000000000 --- a/app/sdks/server-go/docs/examples/users/delete-sessions.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.DeleteSessions("[USER_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/get-logs.md b/app/sdks/server-go/docs/examples/users/get-logs.md deleted file mode 100644 index 6917cc71db..0000000000 --- a/app/sdks/server-go/docs/examples/users/get-logs.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.GetLogs("[USER_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/get-prefs.md b/app/sdks/server-go/docs/examples/users/get-prefs.md deleted file mode 100644 index 17676eaa36..0000000000 --- a/app/sdks/server-go/docs/examples/users/get-prefs.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.GetPrefs("[USER_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/get-sessions.md b/app/sdks/server-go/docs/examples/users/get-sessions.md deleted file mode 100644 index cc53abfdab..0000000000 --- a/app/sdks/server-go/docs/examples/users/get-sessions.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.GetSessions("[USER_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/get.md b/app/sdks/server-go/docs/examples/users/get.md deleted file mode 100644 index 8809d1b29b..0000000000 --- a/app/sdks/server-go/docs/examples/users/get.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.Get("[USER_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/list.md b/app/sdks/server-go/docs/examples/users/list.md deleted file mode 100644 index ad37e72219..0000000000 --- a/app/sdks/server-go/docs/examples/users/list.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.List("[SEARCH]", 0, 0, "ASC") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/update-prefs.md b/app/sdks/server-go/docs/examples/users/update-prefs.md deleted file mode 100644 index 9789b90f25..0000000000 --- a/app/sdks/server-go/docs/examples/users/update-prefs.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.UpdatePrefs("[USER_ID]", ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/users/update-status.md b/app/sdks/server-go/docs/examples/users/update-status.md deleted file mode 100644 index eff2fb5072..0000000000 --- a/app/sdks/server-go/docs/examples/users/update-status.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.UpdateStatus("[USER_ID]", "1") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/app/sdks/server-go/health.go b/app/sdks/server-go/health.go deleted file mode 100644 index d3b6b3a926..0000000000 --- a/app/sdks/server-go/health.go +++ /dev/null @@ -1,153 +0,0 @@ -package appwrite - -import ( -) - -// Health service -type Health struct { - client Client -} - -func NewHealth(clt Client) Health { - service := Health{ - client: clt, - } - - return service -} - -// Get check the Appwrite HTTP server is up and responsive. -func (srv *Health) Get() (map[string]interface{}, error) { - path := "/health" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetAntiVirus check the Appwrite Anti Virus server is up and connection is -// successful. -func (srv *Health) GetAntiVirus() (map[string]interface{}, error) { - path := "/health/anti-virus" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCache check the Appwrite in-memory cache server is up and connection is -// successful. -func (srv *Health) GetCache() (map[string]interface{}, error) { - path := "/health/cache" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetDB check the Appwrite database server is up and connection is -// successful. -func (srv *Health) GetDB() (map[string]interface{}, error) { - path := "/health/db" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetQueueCertificates get the number of certificates that are waiting to be -// issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite -// internal queue server. -func (srv *Health) GetQueueCertificates() (map[string]interface{}, error) { - path := "/health/queue/certificates" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetQueueFunctions -func (srv *Health) GetQueueFunctions() (map[string]interface{}, error) { - path := "/health/queue/functions" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetQueueLogs get the number of logs that are waiting to be processed in the -// Appwrite internal queue server. -func (srv *Health) GetQueueLogs() (map[string]interface{}, error) { - path := "/health/queue/logs" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetQueueTasks get the number of tasks that are waiting to be processed in -// the Appwrite internal queue server. -func (srv *Health) GetQueueTasks() (map[string]interface{}, error) { - path := "/health/queue/tasks" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetQueueUsage get the number of usage stats that are waiting to be -// processed in the Appwrite internal queue server. -func (srv *Health) GetQueueUsage() (map[string]interface{}, error) { - path := "/health/queue/usage" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetQueueWebhooks get the number of webhooks that are waiting to be -// processed in the Appwrite internal queue server. -func (srv *Health) GetQueueWebhooks() (map[string]interface{}, error) { - path := "/health/queue/webhooks" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetStorageLocal check the Appwrite local storage device is up and -// connection is successful. -func (srv *Health) GetStorageLocal() (map[string]interface{}, error) { - path := "/health/storage/local" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetTime check the Appwrite server time is synced with Google remote NTP -// server. We use this technology to smoothly handle leap seconds with no -// disruptive events. The [Network Time -// Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is -// used by hundreds of millions of computers and devices to synchronize their -// clocks over the Internet. If your computer sets its own clock, it likely -// uses NTP. -func (srv *Health) GetTime() (map[string]interface{}, error) { - path := "/health/time" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} diff --git a/app/sdks/server-go/locale.go b/app/sdks/server-go/locale.go deleted file mode 100644 index ecadd889cb..0000000000 --- a/app/sdks/server-go/locale.go +++ /dev/null @@ -1,88 +0,0 @@ -package appwrite - -import ( -) - -// Locale service -type Locale struct { - client Client -} - -func NewLocale(clt Client) Locale { - service := Locale{ - client: clt, - } - - return service -} - -// Get get the current user location based on IP. Returns an object with user -// country code, country name, continent name, continent code, ip address and -// suggested currency. You can use the locale header to get the data in a -// supported language. -// -// ([IP Geolocation by DB-IP](https://db-ip.com)) -func (srv *Locale) Get() (map[string]interface{}, error) { - path := "/locale" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetContinents list of all continents. You can use the locale header to get -// the data in a supported language. -func (srv *Locale) GetContinents() (map[string]interface{}, error) { - path := "/locale/continents" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCountries list of all countries. You can use the locale header to get -// the data in a supported language. -func (srv *Locale) GetCountries() (map[string]interface{}, error) { - path := "/locale/countries" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCountriesEU list of all countries that are currently members of the EU. -// You can use the locale header to get the data in a supported language. -func (srv *Locale) GetCountriesEU() (map[string]interface{}, error) { - path := "/locale/countries/eu" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCountriesPhones list of all countries phone codes. You can use the -// locale header to get the data in a supported language. -func (srv *Locale) GetCountriesPhones() (map[string]interface{}, error) { - path := "/locale/countries/phones" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCurrencies 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. -func (srv *Locale) GetCurrencies() (map[string]interface{}, error) { - path := "/locale/currencies" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} diff --git a/app/sdks/server-go/main.go b/app/sdks/server-go/main.go deleted file mode 100644 index 13df7fc1b5..0000000000 --- a/app/sdks/server-go/main.go +++ /dev/null @@ -1,6 +0,0 @@ -package appwrite - -// NewClient initializes a new Appwrite client -func NewClient() Client { - return Client{} -} diff --git a/app/sdks/server-go/storage.go b/app/sdks/server-go/storage.go deleted file mode 100644 index 7ede9c3255..0000000000 --- a/app/sdks/server-go/storage.go +++ /dev/null @@ -1,134 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Storage service -type Storage struct { - client Client -} - -func NewStorage(clt Client) Storage { - service := Storage{ - client: clt, - } - - return service -} - -// ListFiles get a list of all the user files. You can use the query params to -// 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). -func (srv *Storage) ListFiles(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { - path := "/storage/files" - - params := map[string]interface{}{ - "search": Search, - "limit": Limit, - "offset": Offset, - "orderType": OrderType, - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateFile create a new file. The user who creates the file will -// automatically be assigned to read and write access unless he has passed -// custom values for read and write arguments. -func (srv *Storage) CreateFile(File string, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { - path := "/storage/files" - - params := map[string]interface{}{ - "file": File, - "read": Read, - "write": Write, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetFile get file by its unique ID. This endpoint response returns a JSON -// object with the file metadata. -func (srv *Storage) GetFile(FileId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateFile update file by its unique ID. Only users with write permissions -// have access to update this resource. -func (srv *Storage) UpdateFile(FileId string, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}") - - params := map[string]interface{}{ - "read": Read, - "write": Write, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// DeleteFile delete a file by its unique ID. Only users with write -// permissions have access to delete this resource. -func (srv *Storage) DeleteFile(FileId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// GetFileDownload 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. -func (srv *Storage) GetFileDownload(FileId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}/download") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetFilePreview get a file preview image. Currently, this method supports -// preview for image files (jpg, png, and gif), other supported formats, like -// pdf, docs, slides, and spreadsheets, will return the file icon image. You -// can also pass query string arguments for cutting and resizing your preview -// image. -func (srv *Storage) GetFilePreview(FileId string, Width int, Height int, Quality int, Background string, Output string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}/preview") - - params := map[string]interface{}{ - "width": Width, - "height": Height, - "quality": Quality, - "background": Background, - "output": Output, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetFileView get file content by its unique ID. This endpoint is similar to -// the download method but returns with no 'Content-Disposition: attachment' -// header. -func (srv *Storage) GetFileView(FileId string, As string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}/view") - - params := map[string]interface{}{ - "as": As, - } - - return srv.client.Call("GET", path, nil, params) -} diff --git a/app/sdks/server-go/teams.go b/app/sdks/server-go/teams.go deleted file mode 100644 index 14b89e0dda..0000000000 --- a/app/sdks/server-go/teams.go +++ /dev/null @@ -1,140 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Teams service -type Teams struct { - client Client -} - -func NewTeams(clt Client) Teams { - service := Teams{ - client: clt, - } - - return service -} - -// List get a list of all the current user teams. You can use the query params -// to filter your results. On admin mode, this endpoint will return a list of -// all of the project teams. [Learn more about different API -// modes](/docs/admin). -func (srv *Teams) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { - path := "/teams" - - params := map[string]interface{}{ - "search": Search, - "limit": Limit, - "offset": Offset, - "orderType": OrderType, - } - - return srv.client.Call("GET", path, nil, params) -} - -// Create create a new team. The user who creates the team will automatically -// be assigned as the owner of the team. The team owner can invite new -// members, who will be able add new owners and update or delete the team from -// your project. -func (srv *Teams) Create(Name string, Roles []interface{}) (map[string]interface{}, error) { - path := "/teams" - - params := map[string]interface{}{ - "name": Name, - "roles": Roles, - } - - return srv.client.Call("POST", path, nil, params) -} - -// Get get team by its unique ID. All team members have read access for this -// resource. -func (srv *Teams) Get(TeamId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// Update update team by its unique ID. Only team owners have write access for -// this resource. -func (srv *Teams) Update(TeamId string, Name string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}") - - params := map[string]interface{}{ - "name": Name, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// Delete delete team by its unique ID. Only team owners have write access for -// this resource. -func (srv *Teams) Delete(TeamId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// GetMemberships get team members by the team unique ID. All team members -// have read access for this list of resources. -func (srv *Teams) GetMemberships(TeamId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}/memberships") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateMembership use this endpoint to invite a new member to join your -// team. An email with a link to join the team will be sent to the new member -// email address if the member doesn't exist in the project it will be created -// automatically. -// -// Use the 'URL' parameter to redirect the user from the invitation email back -// to your app. When the user is redirected, use the [Update Team Membership -// Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to -// accept the invitation to the team. -// -// Please note that in order to avoid a [Redirect -// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) -// the only valid redirect URL's are the once from domains you have set when -// added your platforms in the console interface. -func (srv *Teams) CreateMembership(TeamId string, Email string, Roles []interface{}, Url string, Name string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}/memberships") - - params := map[string]interface{}{ - "email": Email, - "name": Name, - "roles": Roles, - "url": Url, - } - - return srv.client.Call("POST", path, nil, params) -} - -// DeleteMembership this endpoint allows a user to leave a team or for a team -// owner to delete the membership of any other team member. You can also use -// this endpoint to delete a user membership even if he didn't accept it. -func (srv *Teams) DeleteMembership(TeamId string, InviteId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId, "{inviteId}", InviteId) - path := r.Replace("/teams/{teamId}/memberships/{inviteId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} diff --git a/app/sdks/server-go/users.go b/app/sdks/server-go/users.go deleted file mode 100644 index 405b5a3209..0000000000 --- a/app/sdks/server-go/users.go +++ /dev/null @@ -1,137 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Users service -type Users struct { - client Client -} - -func NewUsers(clt Client) Users { - service := Users{ - client: clt, - } - - return service -} - -// List get a list of all the project users. You can use the query params to -// filter your results. -func (srv *Users) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { - path := "/users" - - params := map[string]interface{}{ - "search": Search, - "limit": Limit, - "offset": Offset, - "orderType": OrderType, - } - - return srv.client.Call("GET", path, nil, params) -} - -// Create create a new user. -func (srv *Users) Create(Email string, Password string, Name string) (map[string]interface{}, error) { - path := "/users" - - params := map[string]interface{}{ - "email": Email, - "password": Password, - "name": Name, - } - - return srv.client.Call("POST", path, nil, params) -} - -// Get get user by its unique ID. -func (srv *Users) Get(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetLogs get user activity logs list by its unique ID. -func (srv *Users) GetLogs(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/logs") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetPrefs get user preferences by its unique ID. -func (srv *Users) GetPrefs(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/prefs") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdatePrefs update user preferences by its unique ID. You can pass only the -// specific settings you wish to update. -func (srv *Users) UpdatePrefs(UserId string, Prefs object) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/prefs") - - params := map[string]interface{}{ - "prefs": Prefs, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// GetSessions get user sessions list by its unique ID. -func (srv *Users) GetSessions(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/sessions") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// DeleteSessions delete all user sessions by its unique ID. -func (srv *Users) DeleteSessions(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/sessions") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// DeleteSession delete user sessions by its unique ID. -func (srv *Users) DeleteSession(UserId string, SessionId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId, "{sessionId}", SessionId) - path := r.Replace("/users/{userId}/sessions/{sessionId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// UpdateStatus update user status by its unique ID. -func (srv *Users) UpdateStatus(UserId string, Status string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/status") - - params := map[string]interface{}{ - "status": Status, - } - - return srv.client.Call("PATCH", path, nil, params) -} diff --git a/app/sdks/server-go/utils.go b/app/sdks/server-go/utils.go deleted file mode 100644 index ca36149cf1..0000000000 --- a/app/sdks/server-go/utils.go +++ /dev/null @@ -1,36 +0,0 @@ -package appwrite - -import ( - "fmt" - "reflect" - "strconv" -) - -// ToString changes arg to string -func ToString(arg interface{}) string { - var tmp = reflect.Indirect(reflect.ValueOf(arg)).Interface() - switch v := tmp.(type) { - case int: - return strconv.Itoa(v) - case int8: - return strconv.FormatInt(int64(v), 10) - case int16: - return strconv.FormatInt(int64(v), 10) - case int32: - return strconv.FormatInt(int64(v), 10) - case int64: - return strconv.FormatInt(v, 10) - case string: - return v - case float32: - return strconv.FormatFloat(float64(v), 'f', -1, 32) - case float64: - return strconv.FormatFloat(v, 'f', -1, 64) - case fmt.Stringer: - return v.String() - case reflect.Value: - return ToString(v.Interface()) - default: - return "" - } -} diff --git a/app/sdks/server-java/CHANGELOG.md b/app/sdks/server-java/CHANGELOG.md deleted file mode 100644 index fa4d35e687..0000000000 --- a/app/sdks/server-java/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -# Change Log \ No newline at end of file diff --git a/app/sdks/server-java/LICENSE b/app/sdks/server-java/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/server-java/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/server-java/README.md b/app/sdks/server-java/README.md deleted file mode 100644 index 05e7d85945..0000000000 --- a/app/sdks/server-java/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Appwrite SDK for Java - -![License](https://img.shields.io/github/license/appwrite/sdk-for-java.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) - -**This SDK is compatible with Appwrite server version 0.6.0. 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 Java 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) - - - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -### Maven -Add this to your project's `pom.xml` file: - -```xml - - - com.squareup.okhttp3 - appwrite - 0.0.1 - - -``` - -You can install packages from the command line: - -```bash -mvn install 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. \ No newline at end of file diff --git a/app/sdks/server-java/pom.xml b/app/sdks/server-java/pom.xml deleted file mode 100644 index 6d3098a6ea..0000000000 --- a/app/sdks/server-java/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - - - appwrite - 0.0.1 - - Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API - https://appwrite.io - - - 1.9 - 1.9 - - - - - com.squareup.okhttp3 - okhttp - 4.5.0 - - - com.google.code.gson - gson - 2.8.2 - - - - org.junit.jupiter - junit-jupiter-api - 5.6.2 - test - - - org.junit.jupiter - junit-jupiter-engine - 5.6.2 - test - - - - - - - maven-surefire-plugin - 2.22.2 - - - maven-failsafe-plugin - 2.22.2 - - - - \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/Client.java b/app/sdks/server-java/src/main/java/Client.java deleted file mode 100644 index 51c52aebb5..0000000000 --- a/app/sdks/server-java/src/main/java/Client.java +++ /dev/null @@ -1,143 +0,0 @@ -package ; - -import com.google.gson.Gson; -import okhttp3.Call; -import okhttp3.CookieJar; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.FormBody; -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; - -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Map.entry; - -public class Client { - private final OkHttpClient http; - private final Map headers; - private final Map config; - private String endPoint; - private boolean selfSigned; - private CookieJar cookieJar = CookieJar.NO_COOKIES; - - public Client() { - this("https://appwrite.io/v1", false, new OkHttpClient()); - } - - public Client(String endPoint, boolean selfSigned, OkHttpClient http) { - this.endPoint = endPoint; - this.selfSigned = selfSigned; - this.headers = new HashMap<>(Map.ofEntries( - entry("content-type", "application/json"), - entry("x-sdk-version", "appwrite:java:0.0.1") - )); - this.config = new HashMap<>(); - this.http = http.newBuilder() - .cookieJar(cookieJar) - .build(); - } - - public String getEndPoint(){ - return endPoint; - } - - public Map getConfig(){ - return config; - } - -// private Future getCookiePath() { -// final directory = getApplicationDocumentsDirectory(); -// final path = directory.path; -// final Directory dir = new Directory("$path/cookies"); -// dir.create(); -// return dir; -// } - - /// Your project ID - public Client setProject(String value) { - config.put("project", value); - addHeader("X-Appwrite-Project", value); - return this; - } - - /// Your secret API key - public Client setKey(String value) { - config.put("key", value); - addHeader("X-Appwrite-Key", value); - return this; - } - - public Client setLocale(String value) { - config.put("locale", value); - addHeader("X-Appwrite-Locale", value); - return this; - } - - public Client setSelfSigned(boolean status) { - selfSigned = status; - return this; - } - - public Client setEndpoint(String endPoint) { - this.endPoint = endPoint; - return this; - } - - public Client addHeader(String key, String value) { - headers.put(key, value); - return this; - } - - public Call call(String method, String path, Map headers, Map params) { - if(selfSigned) { - // Allow self signed requests - - } - - Headers requestHeaders = Headers.of(this.headers).newBuilder() - .addAll(Headers.of(headers)) - .build(); - - HttpUrl.Builder httpBuilder = HttpUrl.get(endPoint + path).newBuilder(); - if("GET".equals(method)) { - params.forEach((k, v) -> { - if(v instanceof List){ - httpBuilder.addQueryParameter(k+"[]", v.toString()); - }else{ - httpBuilder.addQueryParameter(k, v.toString()); - } - }); - Request request = new Request.Builder() - .url(httpBuilder.build()) - .headers(requestHeaders) - .get() - .build(); - - return http.newCall(request); - } - - RequestBody body; - if("multipart/form-data".equals(headers.get("content-type"))) { - FormBody.Builder builder = new FormBody.Builder(); - params.forEach((k, v) -> builder.add(k, v.toString())); - body = builder.build(); - } else { - Gson gson = new Gson(); - String json = gson.toJson(params); - body = RequestBody.create(json, MediaType.get("application/json")); - } - - Request request = new Request.Builder() - .url(httpBuilder.build()) - .headers(requestHeaders) - .method(method, body) - .build(); - - return http.newCall(request); - } -} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/enums/OrderType.java b/app/sdks/server-java/src/main/java/enums/OrderType.java deleted file mode 100644 index d4a73a3886..0000000000 --- a/app/sdks/server-java/src/main/java/enums/OrderType.java +++ /dev/null @@ -1,6 +0,0 @@ -package .enums; - -public enum OrderType { - ASC, DESC -} - diff --git a/app/sdks/server-java/src/main/java/services/Avatars.java b/app/sdks/server-java/src/main/java/services/Avatars.java deleted file mode 100644 index 3c0bb4e6c8..0000000000 --- a/app/sdks/server-java/src/main/java/services/Avatars.java +++ /dev/null @@ -1,164 +0,0 @@ -package .services; - - - -import okhttp3.Call; -import .Client; -import .enums.OrderType; - -import java.io.File; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Map.entry; - -public class Avatars extends Service { - public 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. - */ - public Call getBrowser(String code, int width, int height, int quality) { - final String path = "/avatars/browsers/{code}".replace("{code}", code); - - final Map params = Map.ofEntries( - entry("width", width), - entry("height", height), - entry("quality", quality) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, 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. - */ - public Call getCreditCard(String code, int width, int height, int quality) { - final String path = "/avatars/credit-cards/{code}".replace("{code}", code); - - final Map params = Map.ofEntries( - entry("width", width), - entry("height", height), - entry("quality", quality) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Favicon - /* - * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote - * website URL. - */ - public Call getFavicon(String url) { - final String path = "/avatars/favicon"; - - final Map params = Map.ofEntries( - entry("url", url) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, 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. - */ - public Call getFlag(String code, int width, int height, int quality) { - final String path = "/avatars/flags/{code}".replace("{code}", code); - - final Map params = Map.ofEntries( - entry("width", width), - entry("height", height), - entry("quality", quality) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, 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. - */ - public Call getImage(String url, int width, int height) { - final String path = "/avatars/image"; - - final Map params = Map.ofEntries( - entry("url", url), - entry("width", width), - entry("height", height) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, 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. - */ - public Call getQR(String text, int size, int margin, int download) { - final String path = "/avatars/qr"; - - final Map params = Map.ofEntries( - entry("text", text), - entry("size", size), - entry("margin", margin), - entry("download", download) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } -} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Database.java b/app/sdks/server-java/src/main/java/services/Database.java deleted file mode 100644 index 84161de9fc..0000000000 --- a/app/sdks/server-java/src/main/java/services/Database.java +++ /dev/null @@ -1,264 +0,0 @@ -package .services; - - - -import okhttp3.Call; -import .Client; -import .enums.OrderType; - -import java.io.File; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Map.entry; - -public class Database extends Service { - public Database(Client client){ - super(client); - } - - /// List Collections - /* - * Get a list of all the user collections. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project collections. [Learn more about different API - * modes](/docs/admin). - */ - public Call listCollections(String search, int limit, int offset, OrderType orderType) { - final String path = "/database/collections"; - - final Map params = Map.ofEntries( - entry("search", search), - entry("limit", limit), - entry("offset", offset), - entry("orderType", orderType.name()) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Create Collection - /* - * Create a new Collection. - */ - public Call createCollection(String name, List read, List write, List rules) { - final String path = "/database/collections"; - - final Map params = Map.ofEntries( - entry("name", name), - entry("read", read), - entry("write", write), - entry("rules", rules) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("POST", path, headers, params); - } - - /// Get Collection - /* - * Get collection by its unique ID. This endpoint response returns a JSON - * object with the collection metadata. - */ - public Call getCollection(String collectionId) { - final String path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Update Collection - /* - * Update collection by its unique ID. - */ - public Call updateCollection(String collectionId, String name, List read, List write, List rules) { - final String path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId); - - final Map params = Map.ofEntries( - entry("name", name), - entry("read", read), - entry("write", write), - entry("rules", rules) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("PUT", path, headers, params); - } - - /// Delete Collection - /* - * Delete a collection by its unique ID. Only users with write permissions - * have access to delete this resource. - */ - public Call deleteCollection(String collectionId) { - final String path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("DELETE", path, headers, params); - } - - /// 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). - */ - public Call listDocuments(String collectionId, List filters, int offset, int limit, String orderField, OrderType orderType, String orderCast, String search, int first, int last) { - final String path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId); - - final Map params = Map.ofEntries( - entry("filters", filters), - entry("offset", offset), - entry("limit", limit), - entry("orderField", orderField), - entry("orderType", orderType.name()), - entry("orderCast", orderCast), - entry("search", search), - entry("first", first), - entry("last", last) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Create Document - /* - * Create a new Document. - */ - public Call createDocument(String collectionId, Object data, List read, List write, String parentDocument, String parentProperty, String parentPropertyType) { - final String path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId); - - final Map params = Map.ofEntries( - entry("data", data), - entry("read", read), - entry("write", write), - entry("parentDocument", parentDocument), - entry("parentProperty", parentProperty), - entry("parentPropertyType", parentPropertyType) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("POST", path, headers, params); - } - - /// Get Document - /* - * Get document by its unique ID. This endpoint response returns a JSON object - * with the document data. - */ - public Call getDocument(String collectionId, String documentId) { - final String path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Update Document - public Call updateDocument(String collectionId, String documentId, Object data, List read, List write) { - final String path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId); - - final Map params = Map.ofEntries( - entry("data", data), - entry("read", read), - entry("write", write) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("PATCH", path, headers, 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. - */ - public Call deleteDocument(String collectionId, String documentId) { - final String path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("DELETE", path, headers, params); - } - - /// Get Collection Logs - public Call getCollectionLogs(String collectionId) { - final String path = "/database/collections/{collectionId}/logs".replace("{collectionId}", collectionId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } -} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Health.java b/app/sdks/server-java/src/main/java/services/Health.java deleted file mode 100644 index 08e23433d1..0000000000 --- a/app/sdks/server-java/src/main/java/services/Health.java +++ /dev/null @@ -1,258 +0,0 @@ -package .services; - - - -import okhttp3.Call; -import .Client; -import .enums.OrderType; - -import java.io.File; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Map.entry; - -public class Health extends Service { - public Health(Client client){ - super(client); - } - - /// Get HTTP - /* - * Check the Appwrite HTTP server is up and responsive. - */ - public Call get() { - final String path = "/health"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Anti virus - /* - * Check the Appwrite Anti Virus server is up and connection is successful. - */ - public Call getAntiVirus() { - final String path = "/health/anti-virus"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Cache - /* - * Check the Appwrite in-memory cache server is up and connection is - * successful. - */ - public Call getCache() { - final String path = "/health/cache"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get DB - /* - * Check the Appwrite database server is up and connection is successful. - */ - public Call getDB() { - final String path = "/health/db"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Certificate Queue - /* - * Get the number of certificates that are waiting to be issued against - * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - * server. - */ - public Call getQueueCertificates() { - final String path = "/health/queue/certificates"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Functions Queue - public Call getQueueFunctions() { - final String path = "/health/queue/functions"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Logs Queue - /* - * Get the number of logs that are waiting to be processed in the Appwrite - * internal queue server. - */ - public Call getQueueLogs() { - final String path = "/health/queue/logs"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Tasks Queue - /* - * Get the number of tasks that are waiting to be processed in the Appwrite - * internal queue server. - */ - public Call getQueueTasks() { - final String path = "/health/queue/tasks"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Usage Queue - /* - * Get the number of usage stats that are waiting to be processed in the - * Appwrite internal queue server. - */ - public Call getQueueUsage() { - final String path = "/health/queue/usage"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Webhooks Queue - /* - * Get the number of webhooks that are waiting to be processed in the Appwrite - * internal queue server. - */ - public Call getQueueWebhooks() { - final String path = "/health/queue/webhooks"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Local Storage - /* - * Check the Appwrite local storage device is up and connection is successful. - */ - public Call getStorageLocal() { - final String path = "/health/storage/local"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get Time - /* - * Check the Appwrite server time is synced with Google remote NTP server. We - * use this technology to smoothly handle leap seconds with no disruptive - * events. The [Network Time - * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - * used by hundreds of millions of computers and devices to synchronize their - * clocks over the Internet. If your computer sets its own clock, it likely - * uses NTP. - */ - public Call getTime() { - final String path = "/health/time"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } -} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Locale.java b/app/sdks/server-java/src/main/java/services/Locale.java deleted file mode 100644 index 695b04a679..0000000000 --- a/app/sdks/server-java/src/main/java/services/Locale.java +++ /dev/null @@ -1,145 +0,0 @@ -package .services; - - - -import okhttp3.Call; -import .Client; -import .enums.OrderType; - -import java.io.File; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Map.entry; - -public class Locale extends Service { - public 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)) - */ - public Call get() { - final String path = "/locale"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// List Continents - /* - * List of all continents. You can use the locale header to get the data in a - * supported language. - */ - public Call getContinents() { - final String path = "/locale/continents"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// List Countries - /* - * List of all countries. You can use the locale header to get the data in a - * supported language. - */ - public Call getCountries() { - final String path = "/locale/countries"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, 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. - */ - public Call getCountriesEU() { - final String path = "/locale/countries/eu"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, 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. - */ - public Call getCountriesPhones() { - final String path = "/locale/countries/phones"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// 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. - */ - public Call getCurrencies() { - final String path = "/locale/currencies"; - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } -} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Service.java b/app/sdks/server-java/src/main/java/services/Service.java deleted file mode 100644 index 477b0ba724..0000000000 --- a/app/sdks/server-java/src/main/java/services/Service.java +++ /dev/null @@ -1,11 +0,0 @@ -package .services; - -import .Client; - -abstract class Service { - final Client client; - - Service(Client client) { - this.client = client; - } -} diff --git a/app/sdks/server-java/src/main/java/services/Storage.java b/app/sdks/server-java/src/main/java/services/Storage.java deleted file mode 100644 index 0233868d0d..0000000000 --- a/app/sdks/server-java/src/main/java/services/Storage.java +++ /dev/null @@ -1,204 +0,0 @@ -package .services; - - - -import okhttp3.Call; -import okhttp3.HttpUrl; -import .Client; -import .enums.OrderType; - -import java.io.File; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Map.entry; - -public class Storage extends Service { - public 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). - */ - public Call listFiles(String search, int limit, int offset, OrderType orderType) { - final String path = "/storage/files"; - - final Map params = Map.ofEntries( - entry("search", search), - entry("limit", limit), - entry("offset", offset), - entry("orderType", orderType.name()) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Create 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. - */ - public Call createFile(File file, List read, List write) { - final String path = "/storage/files"; - - final Map params = Map.ofEntries( - entry("file", file), - entry("read", read), - entry("write", write) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "multipart/form-data") - ); - - return client.call("POST", path, headers, params); - } - - /// Get File - /* - * Get file by its unique ID. This endpoint response returns a JSON object - * with the file metadata. - */ - public Call getFile(String fileId) { - final String path = "/storage/files/{fileId}".replace("{fileId}", fileId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Update File - /* - * Update file by its unique ID. Only users with write permissions have access - * to update this resource. - */ - public Call updateFile(String fileId, List read, List write) { - final String path = "/storage/files/{fileId}".replace("{fileId}", fileId); - - final Map params = Map.ofEntries( - entry("read", read), - entry("write", write) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("PUT", path, headers, params); - } - - /// Delete File - /* - * Delete a file by its unique ID. Only users with write permissions have - * access to delete this resource. - */ - public Call deleteFile(String fileId) { - final String path = "/storage/files/{fileId}".replace("{fileId}", fileId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("DELETE", path, headers, 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. - */ - public String getFileDownload(String fileId) { - final String path = "/storage/files/{fileId}/download".replace("{fileId}", fileId); - - final Map params = Map.ofEntries( - entry("project", client.getConfig().get("project")), - entry("key", client.getConfig().get("key")) - ); - - - - HttpUrl.Builder httpBuilder = new HttpUrl.Builder().build().newBuilder(client.getEndPoint() + path); - params.forEach((k, v) -> httpBuilder.addQueryParameter(k, v.toString())); - - return httpBuilder.build().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. - */ - public String getFilePreview(String fileId, int width, int height, int quality, String background, String output) { - final String path = "/storage/files/{fileId}/preview".replace("{fileId}", fileId); - - final Map params = Map.ofEntries( - entry("width", width), - entry("height", height), - entry("quality", quality), - entry("background", background), - entry("output", output), - entry("project", client.getConfig().get("project")), - entry("key", client.getConfig().get("key")) - ); - - - - HttpUrl.Builder httpBuilder = new HttpUrl.Builder().build().newBuilder(client.getEndPoint() + path); - params.forEach((k, v) -> httpBuilder.addQueryParameter(k, v.toString())); - - return httpBuilder.build().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. - */ - public String getFileView(String fileId, String as) { - final String path = "/storage/files/{fileId}/view".replace("{fileId}", fileId); - - final Map params = Map.ofEntries( - entry("as", as), - entry("project", client.getConfig().get("project")), - entry("key", client.getConfig().get("key")) - ); - - - - HttpUrl.Builder httpBuilder = new HttpUrl.Builder().build().newBuilder(client.getEndPoint() + path); - params.forEach((k, v) -> httpBuilder.addQueryParameter(k, v.toString())); - - return httpBuilder.build().toString(); - } -} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Teams.java b/app/sdks/server-java/src/main/java/services/Teams.java deleted file mode 100644 index 46cff57f8c..0000000000 --- a/app/sdks/server-java/src/main/java/services/Teams.java +++ /dev/null @@ -1,206 +0,0 @@ -package .services; - - - -import okhttp3.Call; -import .Client; -import .enums.OrderType; - -import java.io.File; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Map.entry; - -public class Teams extends Service { - public 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). - */ - public Call list(String search, int limit, int offset, OrderType orderType) { - final String path = "/teams"; - - final Map params = Map.ofEntries( - entry("search", search), - entry("limit", limit), - entry("offset", offset), - entry("orderType", orderType.name()) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Create 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. - */ - public Call create(String name, List roles) { - final String path = "/teams"; - - final Map params = Map.ofEntries( - entry("name", name), - entry("roles", roles) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("POST", path, headers, params); - } - - /// Get Team - /* - * Get team by its unique ID. All team members have read access for this - * resource. - */ - public Call get(String teamId) { - final String path = "/teams/{teamId}".replace("{teamId}", teamId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Update Team - /* - * Update team by its unique ID. Only team owners have write access for this - * resource. - */ - public Call update(String teamId, String name) { - final String path = "/teams/{teamId}".replace("{teamId}", teamId); - - final Map params = Map.ofEntries( - entry("name", name) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("PUT", path, headers, params); - } - - /// Delete Team - /* - * Delete team by its unique ID. Only team owners have write access for this - * resource. - */ - public Call delete(String teamId) { - final String path = "/teams/{teamId}".replace("{teamId}", teamId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("DELETE", path, headers, params); - } - - /// Get Team Memberships - /* - * Get team members by the team unique ID. All team members have read access - * for this list of resources. - */ - public Call getMemberships(String teamId) { - final String path = "/teams/{teamId}/memberships".replace("{teamId}", teamId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, 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/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. - */ - public Call createMembership(String teamId, String email, List roles, String url, String name) { - final String path = "/teams/{teamId}/memberships".replace("{teamId}", teamId); - - final Map params = Map.ofEntries( - entry("email", email), - entry("name", name), - entry("roles", roles), - entry("url", url) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("POST", path, headers, 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. - */ - public Call deleteMembership(String teamId, String inviteId) { - final String path = "/teams/{teamId}/memberships/{inviteId}".replace("{teamId}", teamId).replace("{inviteId}", inviteId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("DELETE", path, headers, params); - } -} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Users.java b/app/sdks/server-java/src/main/java/services/Users.java deleted file mode 100644 index 921a7c1296..0000000000 --- a/app/sdks/server-java/src/main/java/services/Users.java +++ /dev/null @@ -1,221 +0,0 @@ -package .services; - - - -import okhttp3.Call; -import .Client; -import .enums.OrderType; - -import java.io.File; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Map.entry; - -public class Users extends Service { - public Users(Client client){ - super(client); - } - - /// List Users - /* - * Get a list of all the project users. You can use the query params to filter - * your results. - */ - public Call list(String search, int limit, int offset, OrderType orderType) { - final String path = "/users"; - - final Map params = Map.ofEntries( - entry("search", search), - entry("limit", limit), - entry("offset", offset), - entry("orderType", orderType.name()) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Create User - /* - * Create a new user. - */ - public Call create(String email, String password, String name) { - final String path = "/users"; - - final Map params = Map.ofEntries( - entry("email", email), - entry("password", password), - entry("name", name) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("POST", path, headers, params); - } - - /// Get User - /* - * Get user by its unique ID. - */ - public Call get(String userId) { - final String path = "/users/{userId}".replace("{userId}", userId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get User Logs - /* - * Get user activity logs list by its unique ID. - */ - public Call getLogs(String userId) { - final String path = "/users/{userId}/logs".replace("{userId}", userId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Get User Preferences - /* - * Get user preferences by its unique ID. - */ - public Call getPrefs(String userId) { - final String path = "/users/{userId}/prefs".replace("{userId}", userId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Update User Preferences - /* - * Update user preferences by its unique ID. You can pass only the specific - * settings you wish to update. - */ - public Call updatePrefs(String userId, Object prefs) { - final String path = "/users/{userId}/prefs".replace("{userId}", userId); - - final Map params = Map.ofEntries( - entry("prefs", prefs) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("PATCH", path, headers, params); - } - - /// Get User Sessions - /* - * Get user sessions list by its unique ID. - */ - public Call getSessions(String userId) { - final String path = "/users/{userId}/sessions".replace("{userId}", userId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("GET", path, headers, params); - } - - /// Delete User Sessions - /* - * Delete all user sessions by its unique ID. - */ - public Call deleteSessions(String userId) { - final String path = "/users/{userId}/sessions".replace("{userId}", userId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("DELETE", path, headers, params); - } - - /// Delete User Session - /* - * Delete user sessions by its unique ID. - */ - public Call deleteSession(String userId, String sessionId) { - final String path = "/users/{userId}/sessions/{sessionId}".replace("{userId}", userId).replace("{sessionId}", sessionId); - - final Map params = Map.ofEntries( - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("DELETE", path, headers, params); - } - - /// Update User Status - /* - * Update user status by its unique ID. - */ - public Call updateStatus(String userId, String status) { - final String path = "/users/{userId}/status".replace("{userId}", userId); - - final Map params = Map.ofEntries( - entry("status", status) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("PATCH", path, headers, params); - } -} \ No newline at end of file diff --git a/app/sdks/server-nodejs/CHANGELOG.md b/app/sdks/server-nodejs/CHANGELOG.md deleted file mode 100644 index fa4d35e687..0000000000 --- a/app/sdks/server-nodejs/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -# Change Log \ No newline at end of file diff --git a/app/sdks/server-nodejs/LICENSE b/app/sdks/server-nodejs/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/server-nodejs/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/server-nodejs/README.md b/app/sdks/server-nodejs/README.md deleted file mode 100644 index abf67fea4e..0000000000 --- a/app/sdks/server-nodejs/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# Appwrite Node.js SDK - -![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.1-blue.svg?v=1) - -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 Node.js 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) - - - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -To install via [NPM](https://www.npmjs.com/): - -```bash -npm install node-appwrite --save -``` - -## 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. \ No newline at end of file diff --git a/app/sdks/server-nodejs/index.js b/app/sdks/server-nodejs/index.js deleted file mode 100644 index f5259f59dc..0000000000 --- a/app/sdks/server-nodejs/index.js +++ /dev/null @@ -1,19 +0,0 @@ -const Client = require('./lib/client.js'); -const Avatars = require('./lib/services/avatars.js'); -const Database = require('./lib/services/database.js'); -const Health = require('./lib/services/health.js'); -const Locale = require('./lib/services/locale.js'); -const Storage = require('./lib/services/storage.js'); -const Teams = require('./lib/services/teams.js'); -const Users = require('./lib/services/users.js'); - -module.exports = { - Client, - Avatars, - Database, - Health, - Locale, - Storage, - Teams, - Users, -}; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/client.js b/app/sdks/server-nodejs/lib/client.js deleted file mode 100644 index add1956056..0000000000 --- a/app/sdks/server-nodejs/lib/client.js +++ /dev/null @@ -1,135 +0,0 @@ -const URL = require('url').URL; -const request = require('request-promise-native'); - -class Client { - - constructor() { - this.endpoint = 'https://appwrite.io/v1'; - this.headers = { - 'content-type': '', - 'x-sdk-version': 'appwrite:nodejs:1.1.0', - }; - this.selfSigned = false; - } - - /** - * Set Project - * - * Your project ID - * - * @param string value - * - * @return self - */ - setProject(value) { - this.addHeader('X-Appwrite-Project', value); - - return this; - } - - /** - * Set Key - * - * Your secret API key - * - * @param string value - * - * @return self - */ - setKey(value) { - this.addHeader('X-Appwrite-Key', value); - - return this; - } - - /** - * Set Locale - * - * @param string value - * - * @return self - */ - setLocale(value) { - this.addHeader('X-Appwrite-Locale', value); - - return this; - } - - /*** - * @param bool status - * @return this - */ - setSelfSigned(status = true) { - this.selfSigned = status; - - return this; - } - - /*** - * @param endpoint - * @return this - */ - setEndpoint(endpoint) - { - this.endpoint = endpoint; - - return this; - } - - /** - * @param key string - * @param value string - */ - addHeader(key, value) { - this.headers[key.toLowerCase()] = value.toLowerCase(); - - return this; - } - - async call(method, path = '', headers = {}, params = {}) { - if(this.selfSigned) { // Allow self signed requests - process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; - } - - headers = Object.assign(this.headers, headers); - - let contentType = headers['content-type'].toLowerCase(); - let options = { - method: method.toUpperCase(), - uri: this.endpoint + path, - qs: (method.toUpperCase() === 'GET') ? params : {}, - headers: headers, - body: (method.toUpperCase() === 'GET' || contentType.startsWith('multipart/form-data')) ? null : params, - json: (contentType.startsWith('application/json')), - formData: (contentType.startsWith('multipart/form-data')) ? this.flatten(params) : null, - }; - - let response = await request(options); - - if(contentType.startsWith('multipart/form-data')) { - response = JSON.parse(response); - } - - return response; - } - - flatten(data, prefix = '') { - let output = {}; - - for (const key in data) { - let value = data[key]; - let finalKey = prefix ? prefix + '[' + key +']' : key; - - if (Array.isArray(value)) { - output = Object.assign(output, this.flatten(value, finalKey)); // @todo: handle name collision here if needed - } - else { - output[finalKey] = value; - } - } - - return output; - } -} - -module.exports = Client; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/service.js b/app/sdks/server-nodejs/lib/service.js deleted file mode 100644 index e799c064be..0000000000 --- a/app/sdks/server-nodejs/lib/service.js +++ /dev/null @@ -1,10 +0,0 @@ -class Service { - /** - * @param client - */ - constructor(client) { - this.client = client; - } -} - -module.exports = Service; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/avatars.js b/app/sdks/server-nodejs/lib/services/avatars.js deleted file mode 100644 index c34bdde966..0000000000 --- a/app/sdks/server-nodejs/lib/services/avatars.js +++ /dev/null @@ -1,164 +0,0 @@ -const Service = require('../service.js'); - -class Avatars extends 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 number width - * @param number height - * @param number quality - * @throws Exception - * @return {} - */ - async getBrowser(code, width = 100, height = 100, quality = 100) { - let path = '/avatars/browsers/{code}'.replace(new RegExp('{code}', 'g'), code); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'width': width, - 'height': height, - 'quality': quality - }); - } - - /** - * Get Credit Card Icon - * - * Need to display your users with your billing method or their payment - * methods? The credit card endpoint will return you the icon of the credit - * card provider you need. Use width, height and quality arguments to change - * the output settings. - * - * @param string code - * @param number width - * @param number height - * @param number quality - * @throws Exception - * @return {} - */ - async getCreditCard(code, width = 100, height = 100, quality = 100) { - let path = '/avatars/credit-cards/{code}'.replace(new RegExp('{code}', 'g'), code); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'width': width, - 'height': height, - 'quality': quality - }); - } - - /** - * Get Favicon - * - * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote - * website URL. - * - * @param string url - * @throws Exception - * @return {} - */ - async getFavicon(url) { - let path = '/avatars/favicon'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'url': url - }); - } - - /** - * Get Country Flag - * - * You can use this endpoint to show different country flags icons to your - * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. - * - * @param string code - * @param number width - * @param number height - * @param number quality - * @throws Exception - * @return {} - */ - async getFlag(code, width = 100, height = 100, quality = 100) { - let path = '/avatars/flags/{code}'.replace(new RegExp('{code}', 'g'), code); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'width': width, - 'height': height, - 'quality': quality - }); - } - - /** - * Get Image from URL - * - * Use this endpoint to fetch a remote image URL and crop it to any image size - * you want. This endpoint is very useful if you need to crop and display - * remote images in your app or in case you want to make sure a 3rd party - * image is properly served using a TLS protocol. - * - * @param string url - * @param number width - * @param number height - * @throws Exception - * @return {} - */ - async getImage(url, width = 400, height = 400) { - let path = '/avatars/image'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'url': url, - 'width': width, - 'height': height - }); - } - - /** - * Get QR Code - * - * Converts a given plain text to a QR code image. You can use the query - * parameters to change the size and style of the resulting image. - * - * @param string text - * @param number size - * @param number margin - * @param number download - * @throws Exception - * @return {} - */ - async getQR(text, size = 400, margin = 1, download = 0) { - let path = '/avatars/qr'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download - }); - } -} - -module.exports = Avatars; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/database.js b/app/sdks/server-nodejs/lib/services/database.js deleted file mode 100644 index ce1c09e391..0000000000 --- a/app/sdks/server-nodejs/lib/services/database.js +++ /dev/null @@ -1,283 +0,0 @@ -const Service = require('../service.js'); - -class Database extends Service { - - /** - * List Collections - * - * Get a list of all the user collections. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project collections. [Learn more about different API - * modes](/docs/admin). - * - * @param string search - * @param number limit - * @param number offset - * @param string orderType - * @throws Exception - * @return {} - */ - async listCollections(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/database/collections'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType - }); - } - - /** - * Create Collection - * - * Create a new Collection. - * - * @param string name - * @param string[] read - * @param string[] write - * @param string[] rules - * @throws Exception - * @return {} - */ - async createCollection(name, read, write, rules) { - let path = '/database/collections'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules - }); - } - - /** - * Get Collection - * - * Get collection by its unique ID. This endpoint response returns a JSON - * object with the collection metadata. - * - * @param string collectionId - * @throws Exception - * @return {} - */ - async getCollection(collectionId) { - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Collection - * - * Update collection by its unique ID. - * - * @param string collectionId - * @param string name - * @param string[] read - * @param string[] write - * @param string[] rules - * @throws Exception - * @return {} - */ - async updateCollection(collectionId, name, read, write, rules = []) { - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules - }); - } - - /** - * Delete Collection - * - * Delete a collection by its unique ID. Only users with write permissions - * have access to delete this resource. - * - * @param string collectionId - * @throws Exception - * @return {} - */ - async deleteCollection(collectionId) { - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 string[] filters - * @param number offset - * @param number limit - * @param string orderField - * @param string orderType - * @param string orderCast - * @param string search - * @param number first - * @param number last - * @throws Exception - * @return {} - */ - async listDocuments(collectionId, filters = [], offset = 0, limit = 50, orderField = '$id', orderType = 'ASC', orderCast = 'string', search = '', first = 0, last = 0) { - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'filters': filters, - 'offset': offset, - 'limit': limit, - 'orderField': orderField, - 'orderType': orderType, - 'orderCast': orderCast, - 'search': search, - 'first': first, - 'last': last - }); - } - - /** - * Create Document - * - * Create a new Document. - * - * @param string collectionId - * @param object data - * @param string[] read - * @param string[] write - * @param string parentDocument - * @param string parentProperty - * @param string parentPropertyType - * @throws Exception - * @return {} - */ - async createDocument(collectionId, data, read, write, parentDocument = '', parentProperty = '', parentPropertyType = 'assign') { - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'data': data, - 'read': read, - 'write': write, - 'parentDocument': parentDocument, - 'parentProperty': parentProperty, - 'parentPropertyType': parentPropertyType - }); - } - - /** - * 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 {} - */ - async getDocument(collectionId, documentId) { - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update Document - * - * @param string collectionId - * @param string documentId - * @param object data - * @param string[] read - * @param string[] write - * @throws Exception - * @return {} - */ - async updateDocument(collectionId, documentId, data, read, write) { - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'data': data, - 'read': read, - 'write': write - }); - } - - /** - * 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 {} - */ - async deleteDocument(collectionId, documentId) { - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Collection Logs - * - * @param string collectionId - * @throws Exception - * @return {} - */ - async getCollectionLogs(collectionId) { - let path = '/database/collections/{collectionId}/logs'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } -} - -module.exports = Database; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/health.js b/app/sdks/server-nodejs/lib/services/health.js deleted file mode 100644 index a0aed052ce..0000000000 --- a/app/sdks/server-nodejs/lib/services/health.js +++ /dev/null @@ -1,233 +0,0 @@ -const Service = require('../service.js'); - -class Health extends Service { - - /** - * Get HTTP - * - * Check the Appwrite HTTP server is up and responsive. - * - * @throws Exception - * @return {} - */ - async get() { - let path = '/health'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Anti virus - * - * Check the Appwrite Anti Virus server is up and connection is successful. - * - * @throws Exception - * @return {} - */ - async getAntiVirus() { - let path = '/health/anti-virus'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Cache - * - * Check the Appwrite in-memory cache server is up and connection is - * successful. - * - * @throws Exception - * @return {} - */ - async getCache() { - let path = '/health/cache'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get DB - * - * Check the Appwrite database server is up and connection is successful. - * - * @throws Exception - * @return {} - */ - async getDB() { - let path = '/health/db'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Certificate Queue - * - * Get the number of certificates that are waiting to be issued against - * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - * server. - * - * @throws Exception - * @return {} - */ - async getQueueCertificates() { - let path = '/health/queue/certificates'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Functions Queue - * - * @throws Exception - * @return {} - */ - async getQueueFunctions() { - let path = '/health/queue/functions'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Logs Queue - * - * Get the number of logs that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws Exception - * @return {} - */ - async getQueueLogs() { - let path = '/health/queue/logs'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Tasks Queue - * - * Get the number of tasks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws Exception - * @return {} - */ - async getQueueTasks() { - let path = '/health/queue/tasks'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Usage Queue - * - * Get the number of usage stats that are waiting to be processed in the - * Appwrite internal queue server. - * - * @throws Exception - * @return {} - */ - async getQueueUsage() { - let path = '/health/queue/usage'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Webhooks Queue - * - * Get the number of webhooks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws Exception - * @return {} - */ - async getQueueWebhooks() { - let path = '/health/queue/webhooks'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Local Storage - * - * Check the Appwrite local storage device is up and connection is successful. - * - * @throws Exception - * @return {} - */ - async getStorageLocal() { - let path = '/health/storage/local'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Time - * - * Check the Appwrite server time is synced with Google remote NTP server. We - * use this technology to smoothly handle leap seconds with no disruptive - * events. The [Network Time - * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - * used by hundreds of millions of computers and devices to synchronize their - * clocks over the Internet. If your computer sets its own clock, it likely - * uses NTP. - * - * @throws Exception - * @return {} - */ - async getTime() { - let path = '/health/time'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } -} - -module.exports = Health; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/locale.js b/app/sdks/server-nodejs/lib/services/locale.js deleted file mode 100644 index bc1efa4688..0000000000 --- a/app/sdks/server-nodejs/lib/services/locale.js +++ /dev/null @@ -1,125 +0,0 @@ -const Service = require('../service.js'); - -class Locale extends 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 {} - */ - async get() { - let path = '/locale'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Continents - * - * List of all continents. You can use the locale header to get the data in a - * supported language. - * - * @throws Exception - * @return {} - */ - async getContinents() { - let path = '/locale/continents'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Countries - * - * List of all countries. You can use the locale header to get the data in a - * supported language. - * - * @throws Exception - * @return {} - */ - async getCountries() { - let path = '/locale/countries'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 {} - */ - async getCountriesEU() { - let path = '/locale/countries/eu'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 {} - */ - async getCountriesPhones() { - let path = '/locale/countries/phones'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * List Currencies - * - * List of all currencies, including currency symol, name, plural, and decimal - * digits for all major and minor currencies. You can use the locale header to - * get the data in a supported language. - * - * @throws Exception - * @return {} - */ - async getCurrencies() { - let path = '/locale/currencies'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } -} - -module.exports = Locale; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/storage.js b/app/sdks/server-nodejs/lib/services/storage.js deleted file mode 100644 index 2b670db31a..0000000000 --- a/app/sdks/server-nodejs/lib/services/storage.js +++ /dev/null @@ -1,199 +0,0 @@ -const Service = require('../service.js'); - -class Storage extends 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 number limit - * @param number offset - * @param string orderType - * @throws Exception - * @return {} - */ - async listFiles(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/storage/files'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType - }); - } - - /** - * Create File - * - * Create a new file. The user who creates the file will automatically be - * assigned to read and write access unless he has passed custom values for - * read and write arguments. - * - * @param File file - * @param string[] read - * @param string[] write - * @throws Exception - * @return {} - */ - async createFile(file, read, write) { - let path = '/storage/files'; - - return await this.client.call('post', path, { - 'content-type': 'multipart/form-data', - }, - { - 'file': file, - 'read': read, - 'write': write - }); - } - - /** - * 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 {} - */ - async getFile(fileId) { - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update File - * - * Update file by its unique ID. Only users with write permissions have access - * to update this resource. - * - * @param string fileId - * @param string[] read - * @param string[] write - * @throws Exception - * @return {} - */ - async updateFile(fileId, read, write) { - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'read': read, - 'write': write - }); - } - - /** - * 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 {} - */ - async deleteFile(fileId) { - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 {} - */ - async getFileDownload(fileId) { - let path = '/storage/files/{fileId}/download'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get File Preview - * - * Get a file preview image. Currently, this method supports preview for image - * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets, will return the file icon image. You can also pass query - * string arguments for cutting and resizing your preview image. - * - * @param string fileId - * @param number width - * @param number height - * @param number quality - * @param string background - * @param string output - * @throws Exception - * @return {} - */ - async getFilePreview(fileId, width = 0, height = 0, quality = 100, background = '', output = '') { - let path = '/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'width': width, - 'height': height, - 'quality': quality, - 'background': background, - 'output': output - }); - } - - /** - * 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 {} - */ - async getFileView(fileId, as = '') { - let path = '/storage/files/{fileId}/view'.replace(new RegExp('{fileId}', 'g'), fileId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'as': as - }); - } -} - -module.exports = Storage; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/teams.js b/app/sdks/server-nodejs/lib/services/teams.js deleted file mode 100644 index a17dd50aa3..0000000000 --- a/app/sdks/server-nodejs/lib/services/teams.js +++ /dev/null @@ -1,202 +0,0 @@ -const Service = require('../service.js'); - -class Teams extends 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 number limit - * @param number offset - * @param string orderType - * @throws Exception - * @return {} - */ - async list(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/teams'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType - }); - } - - /** - * 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 string[] roles - * @throws Exception - * @return {} - */ - async create(name, roles = ["owner"]) { - let path = '/teams'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'name': name, - 'roles': roles - }); - } - - /** - * Get Team - * - * Get team by its unique ID. All team members have read access for this - * resource. - * - * @param string teamId - * @throws Exception - * @return {} - */ - async get(teamId) { - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * 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 {} - */ - async update(teamId, name) { - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('put', path, { - 'content-type': 'application/json', - }, - { - 'name': name - }); - } - - /** - * Delete Team - * - * Delete team by its unique ID. Only team owners have write access for this - * resource. - * - * @param string teamId - * @throws Exception - * @return {} - */ - async delete(teamId) { - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get Team Memberships - * - * Get team members by the team unique ID. All team members have read access - * for this list of resources. - * - * @param string teamId - * @throws Exception - * @return {} - */ - async getMemberships(teamId) { - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Create Team Membership - * - * Use this endpoint to invite a new member to join your team. An email with a - * link to join the team will be sent to the new member email address if the - * member doesn't exist in the project it will be created automatically. - * - * Use the 'URL' parameter to redirect the user from the invitation email back - * to your app. When the user is redirected, use the [Update Team Membership - * Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to - * accept the invitation to the team. - * - * Please note that in order to avoid a [Redirect - * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URL's are the once from domains you have set when - * added your platforms in the console interface. - * - * @param string teamId - * @param string email - * @param string[] roles - * @param string url - * @param string name - * @throws Exception - * @return {} - */ - async createMembership(teamId, email, roles, url, name = '') { - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'email': email, - 'name': name, - 'roles': roles, - 'url': url - }); - } - - /** - * 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 {} - */ - async deleteMembership(teamId, inviteId) { - let path = '/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } -} - -module.exports = Teams; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/users.js b/app/sdks/server-nodejs/lib/services/users.js deleted file mode 100644 index 2292fb2664..0000000000 --- a/app/sdks/server-nodejs/lib/services/users.js +++ /dev/null @@ -1,215 +0,0 @@ -const Service = require('../service.js'); - -class Users extends Service { - - /** - * List Users - * - * Get a list of all the project users. You can use the query params to filter - * your results. - * - * @param string search - * @param number limit - * @param number offset - * @param string orderType - * @throws Exception - * @return {} - */ - async list(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/users'; - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType - }); - } - - /** - * Create User - * - * Create a new user. - * - * @param string email - * @param string password - * @param string name - * @throws Exception - * @return {} - */ - async create(email, password, name = '') { - let path = '/users'; - - return await this.client.call('post', path, { - 'content-type': 'application/json', - }, - { - 'email': email, - 'password': password, - 'name': name - }); - } - - /** - * Get User - * - * Get user by its unique ID. - * - * @param string userId - * @throws Exception - * @return {} - */ - async get(userId) { - let path = '/users/{userId}'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get User Logs - * - * Get user activity logs list by its unique ID. - * - * @param string userId - * @throws Exception - * @return {} - */ - async getLogs(userId) { - let path = '/users/{userId}/logs'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Get User Preferences - * - * Get user preferences by its unique ID. - * - * @param string userId - * @throws Exception - * @return {} - */ - async getPrefs(userId) { - let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update User Preferences - * - * Update user preferences by its unique ID. You can pass only the specific - * settings you wish to update. - * - * @param string userId - * @param object prefs - * @throws Exception - * @return {} - */ - async updatePrefs(userId, prefs) { - let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'prefs': prefs - }); - } - - /** - * Get User Sessions - * - * Get user sessions list by its unique ID. - * - * @param string userId - * @throws Exception - * @return {} - */ - async getSessions(userId) { - let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('get', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Delete User Sessions - * - * Delete all user sessions by its unique ID. - * - * @param string userId - * @throws Exception - * @return {} - */ - async deleteSessions(userId) { - let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Delete User Session - * - * Delete user sessions by its unique ID. - * - * @param string userId - * @param string sessionId - * @throws Exception - * @return {} - */ - async deleteSession(userId, sessionId) { - let path = '/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}', 'g'), userId).replace(new RegExp('{sessionId}', 'g'), sessionId); - - return await this.client.call('delete', path, { - 'content-type': 'application/json', - }, - { - }); - } - - /** - * Update User Status - * - * Update user status by its unique ID. - * - * @param string userId - * @param string status - * @throws Exception - * @return {} - */ - async updateStatus(userId, status) { - let path = '/users/{userId}/status'.replace(new RegExp('{userId}', 'g'), userId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'status': status - }); - } -} - -module.exports = Users; \ No newline at end of file diff --git a/app/sdks/server-nodejs/package.json b/app/sdks/server-nodejs/package.json deleted file mode 100644 index 377ea48db2..0000000000 --- a/app/sdks/server-nodejs/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "node-appwrite", - "homepage": "https://appwrite.io/support", - "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", - "version": "1.1.0", - "license": "BSD-3-Clause", - "main": "index.js", - "repository": { - "type": "git", - "url": "https://github.com/appwrite/sdk-for-node" - }, - "devDependencies": {}, - "dependencies": { - "request": "^2.88.0", - "request-promise-native": "^1.0.7" - } -} \ No newline at end of file diff --git a/app/sdks/server-php/CHANGELOG.md b/app/sdks/server-php/CHANGELOG.md deleted file mode 100644 index fa4d35e687..0000000000 --- a/app/sdks/server-php/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -# Change Log \ No newline at end of file diff --git a/app/sdks/server-php/LICENSE b/app/sdks/server-php/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/server-php/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/server-php/README.md b/app/sdks/server-php/README.md deleted file mode 100644 index 0d64f84fca..0000000000 --- a/app/sdks/server-php/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# Appwrite PHP SDK - -![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.1-blue.svg?v=1) - -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 PHP 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) - - - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -To install via [Composer](http://getcomposer.org/): - -```bash -composer require appwrite/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. \ No newline at end of file diff --git a/app/sdks/server-php/composer.json b/app/sdks/server-php/composer.json deleted file mode 100644 index 64d2e1746f..0000000000 --- a/app/sdks/server-php/composer.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "appwrite/appwrite", - "description": "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 PHP 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)", - "type": "library", - "license": "BSD-3-Clause", - "support": { - "url": "https://appwrite.io/support", - "email": "team@localhost.test" - }, - "autoload": { - "psr-4": { - "Appwrite\\": "src/Appwrite" - } - }, - "require": { - "php": ">=7.1.0", - "ext-curl": "*", - "ext-json": "*" - }, - "require-dev": { - "phpunit/phpunit": "3.7.35" - }, - "minimum-stability": "dev" -} \ No newline at end of file diff --git a/app/sdks/server-php/docs/avatars.md b/app/sdks/server-php/docs/avatars.md deleted file mode 100644 index 9fa1ee61f1..0000000000 --- a/app/sdks/server-php/docs/avatars.md +++ /dev/null @@ -1,100 +0,0 @@ -# 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 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 | integer | Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0. | 0 | - diff --git a/app/sdks/server-php/docs/database.md b/app/sdks/server-php/docs/database.md deleted file mode 100644 index f192a92fc8..0000000000 --- a/app/sdks/server-php/docs/database.md +++ /dev/null @@ -1,183 +0,0 @@ -# Database Service - -## List Collections - -```http request -GET https://appwrite.io/v1/database/collections -``` - -** Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project collections. [Learn more about different API modes](/docs/admin). ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| search | string | Search term to filter your list results. | | -| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 | -| orderType | string | Order result by ASC or DESC order. | ASC | - -## Create Collection - -```http request -POST https://appwrite.io/v1/database/collections -``` - -** Create a new Collection. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| name | string | Collection name. | | -| read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| rules | array | Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation. | | - -## Get Collection - -```http request -GET https://appwrite.io/v1/database/collections/{collectionId} -``` - -** Get collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| collectionId | string | **Required** Collection unique ID. | | - -## Update Collection - -```http request -PUT https://appwrite.io/v1/database/collections/{collectionId} -``` - -** Update collection by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| collectionId | string | **Required** Collection unique ID. | | -| name | string | Collection name. | | -| read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions(/docs/permissions) and get a full list of available permissions. | | -| write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| rules | array | Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation. | [] | - -## Delete Collection - -```http request -DELETE https://appwrite.io/v1/database/collections/{collectionId} -``` - -** Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| collectionId | string | **Required** Collection unique ID. | | - -## 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/database?platform=server#createCollection). | | -| filters | array | Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: 'name=John Doe' or 'category.$id>=5bed2d152c362'. | [] | -| offset | integer | Offset value. Use this value to manage pagination. | 0 | -| limit | integer | Maximum number of documents to return in response. Use this value to manage pagination. | 50 | -| 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. | | -| first | integer | Return only the first document. Pass 1 for true or 0 for false. The default value is 0. | 0 | -| last | integer | Return only the last document. Pass 1 for true or 0 for false. The default value is 0. | 0 | - -## Create Document - -```http request -POST https://appwrite.io/v1/database/collections/{collectionId}/documents -``` - -** Create a new Document. ** - -### 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/database?platform=server#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. | | -| parentDocument | string | Parent document unique ID. Use when you want your new document to be a child of a parent document. | | -| parentProperty | string | Parent document property name. Use when you want your new document to be a child of a parent document. | | -| parentPropertyType | string | 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. | assign | - -## 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/database?platform=server#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/database?platform=server#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/database?platform=server#createCollection). | | -| documentId | string | **Required** Document unique ID. | | - -## Get Collection Logs - -```http request -GET https://appwrite.io/v1/database/collections/{collectionId}/logs -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| collectionId | string | **Required** Collection unique ID. | | - diff --git a/app/sdks/server-php/docs/health.md b/app/sdks/server-php/docs/health.md deleted file mode 100644 index 38b814b633..0000000000 --- a/app/sdks/server-php/docs/health.md +++ /dev/null @@ -1,96 +0,0 @@ -# Health Service - -## Get HTTP - -```http request -GET https://appwrite.io/v1/health -``` - -** Check the Appwrite HTTP server is up and responsive. ** - -## Get Anti virus - -```http request -GET https://appwrite.io/v1/health/anti-virus -``` - -** Check the Appwrite Anti Virus server is up and connection is successful. ** - -## Get Cache - -```http request -GET https://appwrite.io/v1/health/cache -``` - -** Check the Appwrite in-memory cache server is up and connection is successful. ** - -## Get DB - -```http request -GET https://appwrite.io/v1/health/db -``` - -** Check the Appwrite database server is up and connection is successful. ** - -## Get Certificate Queue - -```http request -GET https://appwrite.io/v1/health/queue/certificates -``` - -** Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. ** - -## Get Functions Queue - -```http request -GET https://appwrite.io/v1/health/queue/functions -``` - -## Get Logs Queue - -```http request -GET https://appwrite.io/v1/health/queue/logs -``` - -** Get the number of logs that are waiting to be processed in the Appwrite internal queue server. ** - -## Get Tasks Queue - -```http request -GET https://appwrite.io/v1/health/queue/tasks -``` - -** Get the number of tasks that are waiting to be processed in the Appwrite internal queue server. ** - -## Get Usage Queue - -```http request -GET https://appwrite.io/v1/health/queue/usage -``` - -** Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server. ** - -## Get Webhooks Queue - -```http request -GET https://appwrite.io/v1/health/queue/webhooks -``` - -** Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. ** - -## Get Local Storage - -```http request -GET https://appwrite.io/v1/health/storage/local -``` - -** Check the Appwrite local storage device is up and connection is successful. ** - -## Get Time - -```http request -GET https://appwrite.io/v1/health/time -``` - -** Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP. ** - diff --git a/app/sdks/server-php/docs/locale.md b/app/sdks/server-php/docs/locale.md deleted file mode 100644 index 7e99b08829..0000000000 --- a/app/sdks/server-php/docs/locale.md +++ /dev/null @@ -1,52 +0,0 @@ -# Locale Service - -## Get User Locale - -```http request -GET https://appwrite.io/v1/locale -``` - -** Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. - -([IP Geolocation by DB-IP](https://db-ip.com)) ** - -## List Continents - -```http request -GET https://appwrite.io/v1/locale/continents -``` - -** List of all continents. You can use the locale header to get the data in a supported language. ** - -## List Countries - -```http request -GET https://appwrite.io/v1/locale/countries -``` - -** List of all countries. You can use the locale header to get the data in a supported language. ** - -## List EU Countries - -```http request -GET https://appwrite.io/v1/locale/countries/eu -``` - -** List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. ** - -## List Countries Phone Codes - -```http request -GET https://appwrite.io/v1/locale/countries/phones -``` - -** List of all countries phone codes. You can use the locale header to get the data in a supported language. ** - -## List Currencies - -```http request -GET https://appwrite.io/v1/locale/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. ** - diff --git a/app/sdks/server-php/docs/storage.md b/app/sdks/server-php/docs/storage.md deleted file mode 100644 index 2138f901a8..0000000000 --- a/app/sdks/server-php/docs/storage.md +++ /dev/null @@ -1,127 +0,0 @@ -# Storage Service - -## List Files - -```http request -GET https://appwrite.io/v1/storage/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). ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| search | string | Search term to filter your list results. | | -| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 | -| orderType | string | Order result by ASC or DESC order. | ASC | - -## Create File - -```http request -POST https://appwrite.io/v1/storage/files -``` - -** 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. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| file | file | Binary File. | | -| read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | - -## Get File - -```http request -GET https://appwrite.io/v1/storage/files/{fileId} -``` - -** Get file by its unique ID. This endpoint response returns a JSON object with the file metadata. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| fileId | string | **Required** File unique ID. | | - -## Update File - -```http request -PUT https://appwrite.io/v1/storage/files/{fileId} -``` - -** Update file by its unique ID. Only users with write permissions have access to update this resource. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| fileId | string | **Required** File unique ID. | | -| 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 File - -```http request -DELETE https://appwrite.io/v1/storage/files/{fileId} -``` - -** Delete a file by its unique ID. Only users with write permissions have access to delete this resource. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| fileId | string | **Required** File unique ID. | | - -## Get File for Download - -```http request -GET https://appwrite.io/v1/storage/files/{fileId}/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. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| fileId | string | **Required** File unique ID. | | - -## Get File Preview - -```http request -GET https://appwrite.io/v1/storage/files/{fileId}/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. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| fileId | string | **Required** File unique ID | | -| width | integer | Resize preview image width, Pass an integer between 0 to 4000. | 0 | -| height | integer | Resize preview image height, Pass an integer between 0 to 4000. | 0 | -| quality | integer | Preview image quality. Pass an integer between 0 to 100. Defaults to 100. | 100 | -| background | string | Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. | | -| output | string | Output format type (jpeg, jpg, png, gif and webp). | | - -## Get File for View - -```http request -GET https://appwrite.io/v1/storage/files/{fileId}/view -``` - -** Get file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| fileId | string | **Required** File unique ID. | | -| as | string | 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. | | - diff --git a/app/sdks/server-php/docs/teams.md b/app/sdks/server-php/docs/teams.md deleted file mode 100644 index 7b2646c0ce..0000000000 --- a/app/sdks/server-php/docs/teams.md +++ /dev/null @@ -1,128 +0,0 @@ -# Teams Service - -## List Teams - -```http request -GET https://appwrite.io/v1/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). ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| search | string | Search term to filter your list results. | | -| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 | -| orderType | string | Order result by ASC or DESC order. | ASC | - -## Create Team - -```http request -POST https://appwrite.io/v1/teams -``` - -** 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. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| name | string | Team name. | | -| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). | ["owner"] | - -## Get Team - -```http request -GET https://appwrite.io/v1/teams/{teamId} -``` - -** Get team by its unique ID. All team members have read access for this resource. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| teamId | string | **Required** Team unique ID. | | - -## Update Team - -```http request -PUT https://appwrite.io/v1/teams/{teamId} -``` - -** Update team by its unique ID. Only team owners have write access for this resource. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| teamId | string | **Required** Team unique ID. | | -| name | string | Team name. | | - -## Delete Team - -```http request -DELETE https://appwrite.io/v1/teams/{teamId} -``` - -** Delete team by its unique ID. Only team owners have write access for this resource. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| teamId | string | **Required** Team unique ID. | | - -## Get Team Memberships - -```http request -GET https://appwrite.io/v1/teams/{teamId}/memberships -``` - -** Get team members by the team unique ID. All team members have read access for this list of resources. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| teamId | string | **Required** Team unique ID. | | - -## Create Team Membership - -```http request -POST https://appwrite.io/v1/teams/{teamId}/memberships -``` - -** Use this endpoint to invite a new member to join your team. An email with a link to join the team will be sent to the new member email address if the member doesn't exist in the project it will be created automatically. - -Use the 'URL' parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the [Update Team Membership Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. - -Please note that in order to avoid a [Redirect Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URL's are the once from domains you have set when added your platforms in the console interface. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| teamId | string | **Required** Team unique ID. | | -| email | string | New team member email. | | -| name | string | New team member name. | | -| roles | array | Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). | | -| url | string | URL to redirect the user back to your app from the invitation email. | | - -## Delete Team Membership - -```http request -DELETE https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId} -``` - -** This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if he didn't accept it. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| teamId | string | **Required** Team unique ID. | | -| inviteId | string | **Required** Invite unique ID. | | - diff --git a/app/sdks/server-php/docs/users.md b/app/sdks/server-php/docs/users.md deleted file mode 100644 index fd884b254f..0000000000 --- a/app/sdks/server-php/docs/users.md +++ /dev/null @@ -1,150 +0,0 @@ -# Users Service - -## List Users - -```http request -GET https://appwrite.io/v1/users -``` - -** Get a list of all the project users. You can use the query params to filter your results. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| search | string | Search term to filter your list results. | | -| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 | -| orderType | string | Order result by ASC or DESC order. | ASC | - -## Create User - -```http request -POST https://appwrite.io/v1/users -``` - -** Create a new user. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| email | string | User email. | | -| password | string | User password. | | -| name | string | User name. | | - -## Get User - -```http request -GET https://appwrite.io/v1/users/{userId} -``` - -** Get user by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User unique ID. | | - -## Get User Logs - -```http request -GET https://appwrite.io/v1/users/{userId}/logs -``` - -** Get user activity logs list by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User unique ID. | | - -## Get User Preferences - -```http request -GET https://appwrite.io/v1/users/{userId}/prefs -``` - -** Get user preferences by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User unique ID. | | - -## Update User Preferences - -```http request -PATCH https://appwrite.io/v1/users/{userId}/prefs -``` - -** Update user preferences by its unique ID. You can pass only the specific settings you wish to update. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User unique ID. | | -| prefs | object | Prefs key-value JSON object. | | - -## Get User Sessions - -```http request -GET https://appwrite.io/v1/users/{userId}/sessions -``` - -** Get user sessions list by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User unique ID. | | - -## Delete User Sessions - -```http request -DELETE https://appwrite.io/v1/users/{userId}/sessions -``` - -** Delete all user sessions by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User unique ID. | | - -## Delete User Session - -```http request -DELETE https://appwrite.io/v1/users/{userId}/sessions/{sessionId} -``` - -** Delete user sessions by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User unique ID. | | -| sessionId | string | **Required** User unique session ID. | | - -## Update User Status - -```http request -PATCH https://appwrite.io/v1/users/{userId}/status -``` - -** Update user status by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User unique ID. | | -| status | string | User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0 | | - diff --git a/app/sdks/server-php/src/Appwrite/Client.php b/app/sdks/server-php/src/Appwrite/Client.php deleted file mode 100644 index f44d0c9233..0000000000 --- a/app/sdks/server-php/src/Appwrite/Client.php +++ /dev/null @@ -1,240 +0,0 @@ - '', - 'x-sdk-version' => 'appwrite:php:1.1.0', - ]; - - /** - * SDK constructor. - */ - public function __construct() - { - } - - /** - * Set Project - * - * Your project ID - * - * @param string $value - * - * @return Client - */ - public function setProject($value) - { - $this->addHeader('X-Appwrite-Project', $value); - - return $this; - } - - /** - * Set Key - * - * Your secret API key - * - * @param string $value - * - * @return Client - */ - public function setKey($value) - { - $this->addHeader('X-Appwrite-Key', $value); - - return $this; - } - - /** - * Set Locale - * - * @param string $value - * - * @return Client - */ - public function setLocale($value) - { - $this->addHeader('X-Appwrite-Locale', $value); - - return $this; - } - - - /*** - * @param bool $status - * @return $this - */ - public function setSelfSigned($status = true) - { - $this->selfSigned = $status; - - return $this; - } - - /*** - * @param $endpoint - * @return $this - */ - public function setEndpoint($endpoint) - { - $this->endpoint = $endpoint; - - return $this; - } - - /** - * @param $key - * @param $value - */ - public function addHeader($key, $value) - { - $this->headers[strtolower($key)] = strtolower($value); - - return $this; - } - - /** - * Call - * - * Make an API call - * - * @param string $method - * @param string $path - * @param array $params - * @param array $headers - * @return array|string - * @throws Exception - */ - public function call($method, $path = '', $headers = array(), array $params = array()) - { - $headers = array_merge($this->headers, $headers); - $ch = curl_init($this->endpoint . $path . (($method == self::METHOD_GET && !empty($params)) ? '?' . http_build_query($params) : '')); - $responseHeaders = []; - $responseStatus = -1; - $responseType = ''; - $responseBody = ''; - - switch ($headers['content-type']) { - case 'application/json': - $query = json_encode($params); - break; - - case 'multipart/form-data': - $query = $this->flatten($params); - break; - - default: - $query = http_build_query($params); - break; - } - - foreach ($headers as $i => $header) { - $headers[] = $i . ':' . $header; - unset($headers[$i]); - } - - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_USERAGENT, php_uname('s') . '-' . php_uname('r') . ':php-' . phpversion()); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$responseHeaders) { - $len = strlen($header); - $header = explode(':', strtolower($header), 2); - - if (count($header) < 2) { // ignore invalid headers - return $len; - } - - $responseHeaders[strtolower(trim($header[0]))] = trim($header[1]); - - return $len; - }); - - if($method != self::METHOD_GET) { - curl_setopt($ch, CURLOPT_POSTFIELDS, $query); - } - - // Allow self signed certificates - if($this->selfSigned) { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - } - - $responseBody = curl_exec($ch); - $responseType = (isset($responseHeaders['content-type'])) ? $responseHeaders['content-type'] : ''; - $responseStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - switch(substr($responseType, 0, strpos($responseType, ';'))) { - case 'application/json': - $responseBody = json_decode($responseBody, true); - break; - } - - if ((curl_errno($ch)/* || 200 != $responseStatus*/)) { - throw new Exception(curl_error($ch) . ' with status code ' . $responseStatus, $responseStatus); - } - - curl_close($ch); - - return $responseBody; - } - - /** - * Flatten params array to PHP multiple format - * - * @param array $data - * @param string $prefix - * @return array - */ - protected function flatten(array $data, $prefix = '') { - $output = []; - - foreach($data as $key => $value) { - $finalKey = $prefix ? "{$prefix}[{$key}]" : $key; - - if (is_array($value)) { - $output += $this->flatten($value, $finalKey); // @todo: handle name collision here if needed - } - else { - $output[$finalKey] = $value; - } - } - - return $output; - } -} diff --git a/app/sdks/server-php/src/Appwrite/Service.php b/app/sdks/server-php/src/Appwrite/Service.php deleted file mode 100644 index ea3ad92e2d..0000000000 --- a/app/sdks/server-php/src/Appwrite/Service.php +++ /dev/null @@ -1,19 +0,0 @@ -client = $client; - } -} \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Avatars.php b/app/sdks/server-php/src/Appwrite/Services/Avatars.php deleted file mode 100644 index 90f39f8535..0000000000 --- a/app/sdks/server-php/src/Appwrite/Services/Avatars.php +++ /dev/null @@ -1,175 +0,0 @@ -client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getCreditCard(string $code, int $width = 100, int $height = 100, int $quality = 100):array - { - $path = str_replace(['{code}'], [$code], '/avatars/credit-cards/{code}'); - $params = []; - - $params['width'] = $width; - $params['height'] = $height; - $params['quality'] = $quality; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getFavicon(string $url):array - { - $path = str_replace([], [], '/avatars/favicon'); - $params = []; - - $params['url'] = $url; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getFlag(string $code, int $width = 100, int $height = 100, int $quality = 100):array - { - $path = str_replace(['{code}'], [$code], '/avatars/flags/{code}'); - $params = []; - - $params['width'] = $width; - $params['height'] = $height; - $params['quality'] = $quality; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getImage(string $url, int $width = 400, int $height = 400):array - { - $path = str_replace([], [], '/avatars/image'); - $params = []; - - $params['url'] = $url; - $params['width'] = $width; - $params['height'] = $height; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 int $download - * @throws Exception - * @return array - */ - public function getQR(string $text, int $size = 400, int $margin = 1, int $download = 0):array - { - $path = str_replace([], [], '/avatars/qr'); - $params = []; - - $params['text'] = $text; - $params['size'] = $size; - $params['margin'] = $margin; - $params['download'] = $download; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Database.php b/app/sdks/server-php/src/Appwrite/Services/Database.php deleted file mode 100644 index 7ce8ac359f..0000000000 --- a/app/sdks/server-php/src/Appwrite/Services/Database.php +++ /dev/null @@ -1,299 +0,0 @@ -client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Create Collection - * - * Create a new Collection. - * - * @param string $name - * @param array $read - * @param array $write - * @param array $rules - * @throws Exception - * @return array - */ - public function createCollection(string $name, array $read, array $write, array $rules):array - { - $path = str_replace([], [], '/database/collections'); - $params = []; - - $params['name'] = $name; - $params['read'] = $read; - $params['write'] = $write; - $params['rules'] = $rules; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Collection - * - * Get collection by its unique ID. This endpoint response returns a JSON - * object with the collection metadata. - * - * @param string $collectionId - * @throws Exception - * @return array - */ - public function getCollection(string $collectionId):array - { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Collection - * - * Update collection by its unique ID. - * - * @param string $collectionId - * @param string $name - * @param array $read - * @param array $write - * @param array $rules - * @throws Exception - * @return array - */ - public function updateCollection(string $collectionId, string $name, array $read, array $write, array $rules = []):array - { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}'); - $params = []; - - $params['name'] = $name; - $params['read'] = $read; - $params['write'] = $write; - $params['rules'] = $rules; - - return $this->client->call(Client::METHOD_PUT, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Delete Collection - * - * Delete a collection by its unique ID. Only users with write permissions - * have access to delete this resource. - * - * @param string $collectionId - * @throws Exception - * @return array - */ - public function deleteCollection(string $collectionId):array - { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * List Documents - * - * Get a list of all the user documents. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project documents. [Learn more about different API - * modes](/docs/admin). - * - * @param string $collectionId - * @param array $filters - * @param int $offset - * @param int $limit - * @param string $orderField - * @param string $orderType - * @param string $orderCast - * @param string $search - * @param int $first - * @param int $last - * @throws Exception - * @return array - */ - public function listDocuments(string $collectionId, array $filters = [], int $offset = 0, int $limit = 50, string $orderField = '$id', string $orderType = 'ASC', string $orderCast = 'string', string $search = '', int $first = 0, int $last = 0):array - { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/documents'); - $params = []; - - $params['filters'] = $filters; - $params['offset'] = $offset; - $params['limit'] = $limit; - $params['orderField'] = $orderField; - $params['orderType'] = $orderType; - $params['orderCast'] = $orderCast; - $params['search'] = $search; - $params['first'] = $first; - $params['last'] = $last; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Create Document - * - * Create a new Document. - * - * @param string $collectionId - * @param array $data - * @param array $read - * @param array $write - * @param string $parentDocument - * @param string $parentProperty - * @param string $parentPropertyType - * @throws Exception - * @return array - */ - public function createDocument(string $collectionId, array $data, array $read, array $write, string $parentDocument = '', string $parentProperty = '', string $parentPropertyType = 'assign'):array - { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/documents'); - $params = []; - - $params['data'] = $data; - $params['read'] = $read; - $params['write'] = $write; - $params['parentDocument'] = $parentDocument; - $params['parentProperty'] = $parentProperty; - $params['parentPropertyType'] = $parentPropertyType; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getDocument(string $collectionId, string $documentId):array - { - $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/collections/{collectionId}/documents/{documentId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update Document - * - * @param string $collectionId - * @param string $documentId - * @param array $data - * @param array $read - * @param array $write - * @throws Exception - * @return array - */ - public function updateDocument(string $collectionId, string $documentId, array $data, array $read, array $write):array - { - $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/collections/{collectionId}/documents/{documentId}'); - $params = []; - - $params['data'] = $data; - $params['read'] = $read; - $params['write'] = $write; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function deleteDocument(string $collectionId, string $documentId):array - { - $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/collections/{collectionId}/documents/{documentId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Collection Logs - * - * @param string $collectionId - * @throws Exception - * @return array - */ - public function getCollectionLogs(string $collectionId):array - { - $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/logs'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Health.php b/app/sdks/server-php/src/Appwrite/Services/Health.php deleted file mode 100644 index d39f1f406d..0000000000 --- a/app/sdks/server-php/src/Appwrite/Services/Health.php +++ /dev/null @@ -1,250 +0,0 @@ -client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Anti virus - * - * Check the Appwrite Anti Virus server is up and connection is successful. - * - * @throws Exception - * @return array - */ - public function getAntiVirus():array - { - $path = str_replace([], [], '/health/anti-virus'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Cache - * - * Check the Appwrite in-memory cache server is up and connection is - * successful. - * - * @throws Exception - * @return array - */ - public function getCache():array - { - $path = str_replace([], [], '/health/cache'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get DB - * - * Check the Appwrite database server is up and connection is successful. - * - * @throws Exception - * @return array - */ - public function getDB():array - { - $path = str_replace([], [], '/health/db'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Certificate Queue - * - * Get the number of certificates that are waiting to be issued against - * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - * server. - * - * @throws Exception - * @return array - */ - public function getQueueCertificates():array - { - $path = str_replace([], [], '/health/queue/certificates'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Functions Queue - * - * @throws Exception - * @return array - */ - public function getQueueFunctions():array - { - $path = str_replace([], [], '/health/queue/functions'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Logs Queue - * - * Get the number of logs that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws Exception - * @return array - */ - public function getQueueLogs():array - { - $path = str_replace([], [], '/health/queue/logs'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Tasks Queue - * - * Get the number of tasks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws Exception - * @return array - */ - public function getQueueTasks():array - { - $path = str_replace([], [], '/health/queue/tasks'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Usage Queue - * - * Get the number of usage stats that are waiting to be processed in the - * Appwrite internal queue server. - * - * @throws Exception - * @return array - */ - public function getQueueUsage():array - { - $path = str_replace([], [], '/health/queue/usage'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Webhooks Queue - * - * Get the number of webhooks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws Exception - * @return array - */ - public function getQueueWebhooks():array - { - $path = str_replace([], [], '/health/queue/webhooks'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Local Storage - * - * Check the Appwrite local storage device is up and connection is successful. - * - * @throws Exception - * @return array - */ - public function getStorageLocal():array - { - $path = str_replace([], [], '/health/storage/local'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get Time - * - * Check the Appwrite server time is synced with Google remote NTP server. We - * use this technology to smoothly handle leap seconds with no disruptive - * events. The [Network Time - * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - * used by hundreds of millions of computers and devices to synchronize their - * clocks over the Internet. If your computer sets its own clock, it likely - * uses NTP. - * - * @throws Exception - * @return array - */ - public function getTime():array - { - $path = str_replace([], [], '/health/time'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Locale.php b/app/sdks/server-php/src/Appwrite/Services/Locale.php deleted file mode 100644 index 25255c81a0..0000000000 --- a/app/sdks/server-php/src/Appwrite/Services/Locale.php +++ /dev/null @@ -1,136 +0,0 @@ -client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getContinents():array - { - $path = str_replace([], [], '/locale/continents'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getCountries():array - { - $path = str_replace([], [], '/locale/countries'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getCountriesEU():array - { - $path = str_replace([], [], '/locale/countries/eu'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getCountriesPhones():array - { - $path = str_replace([], [], '/locale/countries/phones'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * List Currencies - * - * List of all currencies, including currency symol, name, plural, and decimal - * digits for all major and minor currencies. You can use the locale header to - * get the data in a supported language. - * - * @throws Exception - * @return array - */ - public function getCurrencies():array - { - $path = str_replace([], [], '/locale/currencies'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Storage.php b/app/sdks/server-php/src/Appwrite/Services/Storage.php deleted file mode 100644 index 09b74fbf8f..0000000000 --- a/app/sdks/server-php/src/Appwrite/Services/Storage.php +++ /dev/null @@ -1,212 +0,0 @@ -client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 \CurlFile $file - * @param array $read - * @param array $write - * @throws Exception - * @return array - */ - public function createFile(\CurlFile $file, array $read, array $write):array - { - $path = str_replace([], [], '/storage/files'); - $params = []; - - $params['file'] = $file; - $params['read'] = $read; - $params['write'] = $write; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'multipart/form-data', - ], $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 - */ - public function getFile(string $fileId):array - { - $path = str_replace(['{fileId}'], [$fileId], '/storage/files/{fileId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 $read - * @param array $write - * @throws Exception - * @return array - */ - public function updateFile(string $fileId, array $read, array $write):array - { - $path = str_replace(['{fileId}'], [$fileId], '/storage/files/{fileId}'); - $params = []; - - $params['read'] = $read; - $params['write'] = $write; - - return $this->client->call(Client::METHOD_PUT, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function deleteFile(string $fileId):array - { - $path = str_replace(['{fileId}'], [$fileId], '/storage/files/{fileId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getFileDownload(string $fileId):array - { - $path = str_replace(['{fileId}'], [$fileId], '/storage/files/{fileId}/download'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getFilePreview(string $fileId, int $width = 0, int $height = 0, int $quality = 100, string $background = '', string $output = ''):array - { - $path = str_replace(['{fileId}'], [$fileId], '/storage/files/{fileId}/preview'); - $params = []; - - $params['width'] = $width; - $params['height'] = $height; - $params['quality'] = $quality; - $params['background'] = $background; - $params['output'] = $output; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function getFileView(string $fileId, string $as = ''):array - { - $path = str_replace(['{fileId}'], [$fileId], '/storage/files/{fileId}/view'); - $params = []; - - $params['as'] = $as; - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Teams.php b/app/sdks/server-php/src/Appwrite/Services/Teams.php deleted file mode 100644 index 7ef2240ab7..0000000000 --- a/app/sdks/server-php/src/Appwrite/Services/Teams.php +++ /dev/null @@ -1,215 +0,0 @@ -client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 $roles - * @throws Exception - * @return array - */ - public function create(string $name, array $roles = ["owner"]):array - { - $path = str_replace([], [], '/teams'); - $params = []; - - $params['name'] = $name; - $params['roles'] = $roles; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function get(string $teamId):array - { - $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function update(string $teamId, string $name):array - { - $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); - $params = []; - - $params['name'] = $name; - - return $this->client->call(Client::METHOD_PUT, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function delete(string $teamId):array - { - $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $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 - * @throws Exception - * @return array - */ - public function getMemberships(string $teamId):array - { - $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $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/teams#updateMembershipStatus) endpoint to allow the user to - * accept the invitation to the team. - * - * Please note that in order to avoid a [Redirect - * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URL's are the once from domains you have set when - * added your platforms in the console interface. - * - * @param string $teamId - * @param string $email - * @param array $roles - * @param string $url - * @param string $name - * @throws Exception - * @return array - */ - public function createMembership(string $teamId, string $email, array $roles, string $url, string $name = ''):array - { - $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); - $params = []; - - $params['email'] = $email; - $params['name'] = $name; - $params['roles'] = $roles; - $params['url'] = $url; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $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 - */ - public function deleteMembership(string $teamId, string $inviteId):array - { - $path = str_replace(['{teamId}', '{inviteId}'], [$teamId, $inviteId], '/teams/{teamId}/memberships/{inviteId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Users.php b/app/sdks/server-php/src/Appwrite/Services/Users.php deleted file mode 100644 index b2b4f576cc..0000000000 --- a/app/sdks/server-php/src/Appwrite/Services/Users.php +++ /dev/null @@ -1,230 +0,0 @@ -client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Create User - * - * Create a new user. - * - * @param string $email - * @param string $password - * @param string $name - * @throws Exception - * @return array - */ - public function create(string $email, string $password, string $name = ''):array - { - $path = str_replace([], [], '/users'); - $params = []; - - $params['email'] = $email; - $params['password'] = $password; - $params['name'] = $name; - - return $this->client->call(Client::METHOD_POST, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get User - * - * Get user by its unique ID. - * - * @param string $userId - * @throws Exception - * @return array - */ - public function get(string $userId):array - { - $path = str_replace(['{userId}'], [$userId], '/users/{userId}'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get User Logs - * - * Get user activity logs list by its unique ID. - * - * @param string $userId - * @throws Exception - * @return array - */ - public function getLogs(string $userId):array - { - $path = str_replace(['{userId}'], [$userId], '/users/{userId}/logs'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get User Preferences - * - * Get user preferences by its unique ID. - * - * @param string $userId - * @throws Exception - * @return array - */ - public function getPrefs(string $userId):array - { - $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update User Preferences - * - * Update user preferences by its unique ID. You can pass only the specific - * settings you wish to update. - * - * @param string $userId - * @param array $prefs - * @throws Exception - * @return array - */ - public function updatePrefs(string $userId, array $prefs):array - { - $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); - $params = []; - - $params['prefs'] = $prefs; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Get User Sessions - * - * Get user sessions list by its unique ID. - * - * @param string $userId - * @throws Exception - * @return array - */ - public function getSessions(string $userId):array - { - $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); - $params = []; - - - return $this->client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Delete User Sessions - * - * Delete all user sessions by its unique ID. - * - * @param string $userId - * @throws Exception - * @return array - */ - public function deleteSessions(string $userId):array - { - $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Delete User Session - * - * Delete user sessions by its unique ID. - * - * @param string $userId - * @param string $sessionId - * @throws Exception - * @return array - */ - public function deleteSession(string $userId, string $sessionId):array - { - $path = str_replace(['{userId}', '{sessionId}'], [$userId, $sessionId], '/users/{userId}/sessions/{sessionId}'); - $params = []; - - - return $this->client->call(Client::METHOD_DELETE, $path, [ - 'content-type' => 'application/json', - ], $params); - } - - /** - * Update User Status - * - * Update user status by its unique ID. - * - * @param string $userId - * @param string $status - * @throws Exception - * @return array - */ - public function updateStatus(string $userId, string $status):array - { - $path = str_replace(['{userId}'], [$userId], '/users/{userId}/status'); - $params = []; - - $params['status'] = $status; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - -} \ No newline at end of file diff --git a/app/sdks/server-python/CHANGELOG.md b/app/sdks/server-python/CHANGELOG.md deleted file mode 100644 index fa4d35e687..0000000000 --- a/app/sdks/server-python/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -# Change Log \ No newline at end of file diff --git a/app/sdks/server-python/LICENSE b/app/sdks/server-python/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/server-python/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/server-python/README.md b/app/sdks/server-python/README.md deleted file mode 100644 index 04421ff241..0000000000 --- a/app/sdks/server-python/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Appwrite Python SDK - -![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1) - -**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 Python 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) - - - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -To install via [PyPI](https://pypi.org/): - -```bash -pip install 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. diff --git a/app/sdks/server-python/appwrite/__init__.py b/app/sdks/server-python/appwrite/__init__.py deleted file mode 100644 index 0519ecba6e..0000000000 --- a/app/sdks/server-python/appwrite/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/app/sdks/server-python/appwrite/client.py b/app/sdks/server-python/appwrite/client.py deleted file mode 100644 index 8989fccb9c..0000000000 --- a/app/sdks/server-python/appwrite/client.py +++ /dev/null @@ -1,106 +0,0 @@ -import io -import requests - -class Client: - def __init__(self): - self._self_signed = False - self._endpoint = 'https://appwrite.io/v1' - self._global_headers = { - 'content-type': '', - 'x-sdk-version': 'appwrite:python:0.0.6', - } - - def set_self_signed(self, status=True): - self._self_signed = status - return self - - def set_endpoint(self, endpoint): - self._endpoint = endpoint - return self - - def add_header(self, key, value): - self._global_headers[key.lower()] = value.lower() - return self - - def set_project(self, value): - """Your project ID""" - - self._global_headers['x-appwrite-project'] = value.lower() - return self - - def set_key(self, value): - """Your secret API key""" - - self._global_headers['x-appwrite-key'] = value.lower() - return self - - def set_locale(self, value): - self._global_headers['x-appwrite-locale'] = value.lower() - return self - - def call(self, method, path='', headers=None, params=None): - if headers is None: - headers = {} - - if params is None: - params = {} - - data = {} - json = {} - files = {} - - headers = {**self._global_headers, **headers} - - if method != 'get': - data = params - params = {} - - if headers['content-type'].startswith('application/json'): - json = data - data = {} - - if headers['content-type'].startswith('multipart/form-data'): - del headers['content-type'] - - for key in data.copy(): - if isinstance(data[key], io.BufferedIOBase): - files[key] = data[key] - del data[key] - - response = requests.request( # call method dynamically https://stackoverflow.com/a/4246075/2299554 - method=method, - url=self._endpoint + path, - params=self.flatten(params), - data=self.flatten(data), - json=json, - files=files, - headers=headers, - verify=self._self_signed, - ) - - response.raise_for_status() - - content_type = response.headers['Content-Type'] - - if content_type.startswith('application/json'): - return response.json() - - return response._content - - def flatten(self, data, prefix=''): - output = {} - i = 0 - - for key in data: - value = data[key] if isinstance(data, dict) else key - finalKey = prefix + '[' + key +']' if prefix else key - finalKey = prefix + '[' + str(i) +']' if isinstance(data, list) else finalKey - i += 1 - - if isinstance(value, list) or isinstance(value, dict): - output = {**output, **self.flatten(value, finalKey)} - else: - output[finalKey] = value - - return output - diff --git a/app/sdks/server-python/appwrite/service.py b/app/sdks/server-python/appwrite/service.py deleted file mode 100644 index b5b60e6c22..0000000000 --- a/app/sdks/server-python/appwrite/service.py +++ /dev/null @@ -1,6 +0,0 @@ -from .client import Client - - -class Service: - def __init__(self, client: Client): - self.client = client diff --git a/app/sdks/server-python/appwrite/services/__init__.py b/app/sdks/server-python/appwrite/services/__init__.py deleted file mode 100644 index 0519ecba6e..0000000000 --- a/app/sdks/server-python/appwrite/services/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/app/sdks/server-python/appwrite/services/avatars.py b/app/sdks/server-python/appwrite/services/avatars.py deleted file mode 100644 index 4a2a4024a6..0000000000 --- a/app/sdks/server-python/appwrite/services/avatars.py +++ /dev/null @@ -1,87 +0,0 @@ -from ..service import Service - - -class Avatars(Service): - - def __init__(self, client): - super(Avatars, self).__init__(client) - - def get_browser(self, code, width=100, height=100, quality=100): - """Get Browser Icon""" - - params = {} - path = '/avatars/browsers/{code}' - path = path.replace('{code}', code) - params['width'] = width - params['height'] = height - params['quality'] = quality - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_credit_card(self, code, width=100, height=100, quality=100): - """Get Credit Card Icon""" - - params = {} - path = '/avatars/credit-cards/{code}' - path = path.replace('{code}', code) - params['width'] = width - params['height'] = height - params['quality'] = quality - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_favicon(self, url): - """Get Favicon""" - - params = {} - path = '/avatars/favicon' - params['url'] = url - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_flag(self, code, width=100, height=100, quality=100): - """Get Country Flag""" - - params = {} - path = '/avatars/flags/{code}' - path = path.replace('{code}', code) - params['width'] = width - params['height'] = height - params['quality'] = quality - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_image(self, url, width=400, height=400): - """Get Image from URL""" - - params = {} - path = '/avatars/image' - params['url'] = url - params['width'] = width - params['height'] = height - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_q_r(self, text, size=400, margin=1, download=0): - """Get QR Code""" - - params = {} - path = '/avatars/qr' - params['text'] = text - params['size'] = size - params['margin'] = margin - params['download'] = download - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/server-python/appwrite/services/database.py b/app/sdks/server-python/appwrite/services/database.py deleted file mode 100644 index 2549e689d5..0000000000 --- a/app/sdks/server-python/appwrite/services/database.py +++ /dev/null @@ -1,159 +0,0 @@ -from ..service import Service - - -class Database(Service): - - def __init__(self, client): - super(Database, self).__init__(client) - - def list_collections(self, search='', limit=25, offset=0, order_type='ASC'): - """List Collections""" - - params = {} - path = '/database/collections' - params['search'] = search - params['limit'] = limit - params['offset'] = offset - params['orderType'] = order_type - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_collection(self, name, read, write, rules): - """Create Collection""" - - params = {} - path = '/database/collections' - params['name'] = name - params['read'] = read - params['write'] = write - params['rules'] = rules - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_collection(self, collection_id): - """Get Collection""" - - params = {} - path = '/database/collections/{collectionId}' - path = path.replace('{collectionId}', collection_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_collection(self, collection_id, name, read, write, rules=[]): - """Update Collection""" - - params = {} - path = '/database/collections/{collectionId}' - path = path.replace('{collectionId}', collection_id) - params['name'] = name - params['read'] = read - params['write'] = write - params['rules'] = rules - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def delete_collection(self, collection_id): - """Delete Collection""" - - params = {} - path = '/database/collections/{collectionId}' - path = path.replace('{collectionId}', collection_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def list_documents(self, collection_id, filters=[], offset=0, limit=50, order_field='$id', order_type='ASC', order_cast='string', search='', first=0, last=0): - """List Documents""" - - params = {} - path = '/database/collections/{collectionId}/documents' - path = path.replace('{collectionId}', collection_id) - params['filters'] = filters - params['offset'] = offset - params['limit'] = limit - params['orderField'] = order_field - params['orderType'] = order_type - params['orderCast'] = order_cast - params['search'] = search - params['first'] = first - params['last'] = last - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_document(self, collection_id, data, read, write, parent_document='', parent_property='', parent_property_type='assign'): - """Create Document""" - - params = {} - path = '/database/collections/{collectionId}/documents' - path = path.replace('{collectionId}', collection_id) - params['data'] = data - params['read'] = read - params['write'] = write - params['parentDocument'] = parent_document - params['parentProperty'] = parent_property - params['parentPropertyType'] = parent_property_type - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_document(self, collection_id, document_id): - """Get Document""" - - params = {} - path = '/database/collections/{collectionId}/documents/{documentId}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{documentId}', document_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_document(self, collection_id, document_id, data, read, write): - """Update Document""" - - params = {} - path = '/database/collections/{collectionId}/documents/{documentId}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{documentId}', document_id) - params['data'] = data - params['read'] = read - params['write'] = write - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - - def delete_document(self, collection_id, document_id): - """Delete Document""" - - params = {} - path = '/database/collections/{collectionId}/documents/{documentId}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{documentId}', document_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def get_collection_logs(self, collection_id): - """Get Collection Logs""" - - params = {} - path = '/database/collections/{collectionId}/logs' - path = path.replace('{collectionId}', collection_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/server-python/appwrite/services/health.py b/app/sdks/server-python/appwrite/services/health.py deleted file mode 100644 index 5e08ebe6e8..0000000000 --- a/app/sdks/server-python/appwrite/services/health.py +++ /dev/null @@ -1,127 +0,0 @@ -from ..service import Service - - -class Health(Service): - - def __init__(self, client): - super(Health, self).__init__(client) - - def get(self): - """Get HTTP""" - - params = {} - path = '/health' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_anti_virus(self): - """Get Anti virus""" - - params = {} - path = '/health/anti-virus' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_cache(self): - """Get Cache""" - - params = {} - path = '/health/cache' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_d_b(self): - """Get DB""" - - params = {} - path = '/health/db' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_certificates(self): - """Get Certificate Queue""" - - params = {} - path = '/health/queue/certificates' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_functions(self): - """Get Functions Queue""" - - params = {} - path = '/health/queue/functions' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_logs(self): - """Get Logs Queue""" - - params = {} - path = '/health/queue/logs' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_tasks(self): - """Get Tasks Queue""" - - params = {} - path = '/health/queue/tasks' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_usage(self): - """Get Usage Queue""" - - params = {} - path = '/health/queue/usage' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_webhooks(self): - """Get Webhooks Queue""" - - params = {} - path = '/health/queue/webhooks' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_storage_local(self): - """Get Local Storage""" - - params = {} - path = '/health/storage/local' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_time(self): - """Get Time""" - - params = {} - path = '/health/time' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/server-python/appwrite/services/locale.py b/app/sdks/server-python/appwrite/services/locale.py deleted file mode 100644 index 70c955eb85..0000000000 --- a/app/sdks/server-python/appwrite/services/locale.py +++ /dev/null @@ -1,67 +0,0 @@ -from ..service import Service - - -class Locale(Service): - - def __init__(self, client): - super(Locale, self).__init__(client) - - def get(self): - """Get User Locale""" - - params = {} - path = '/locale' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_continents(self): - """List Continents""" - - params = {} - path = '/locale/continents' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_countries(self): - """List Countries""" - - params = {} - path = '/locale/countries' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_countries_e_u(self): - """List EU Countries""" - - params = {} - path = '/locale/countries/eu' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_countries_phones(self): - """List Countries Phone Codes""" - - params = {} - path = '/locale/countries/phones' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_currencies(self): - """List Currencies""" - - params = {} - path = '/locale/currencies' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/server-python/appwrite/services/storage.py b/app/sdks/server-python/appwrite/services/storage.py deleted file mode 100644 index 7e2a986f6e..0000000000 --- a/app/sdks/server-python/appwrite/services/storage.py +++ /dev/null @@ -1,108 +0,0 @@ -from ..service import Service - - -class Storage(Service): - - def __init__(self, client): - super(Storage, self).__init__(client) - - def list_files(self, search='', limit=25, offset=0, order_type='ASC'): - """List Files""" - - params = {} - path = '/storage/files' - params['search'] = search - params['limit'] = limit - params['offset'] = offset - params['orderType'] = order_type - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_file(self, file, read, write): - """Create File""" - - params = {} - path = '/storage/files' - params['file'] = file - params['read'] = read - params['write'] = write - - return self.client.call('post', path, { - 'content-type': 'multipart/form-data', - }, params) - - def get_file(self, file_id): - """Get File""" - - params = {} - path = '/storage/files/{fileId}' - path = path.replace('{fileId}', file_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_file(self, file_id, read, write): - """Update File""" - - params = {} - path = '/storage/files/{fileId}' - path = path.replace('{fileId}', file_id) - params['read'] = read - params['write'] = write - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def delete_file(self, file_id): - """Delete File""" - - params = {} - path = '/storage/files/{fileId}' - path = path.replace('{fileId}', file_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def get_file_download(self, file_id): - """Get File for Download""" - - params = {} - path = '/storage/files/{fileId}/download' - path = path.replace('{fileId}', file_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_file_preview(self, file_id, width=0, height=0, quality=100, background='', output=''): - """Get File Preview""" - - params = {} - path = '/storage/files/{fileId}/preview' - path = path.replace('{fileId}', file_id) - params['width'] = width - params['height'] = height - params['quality'] = quality - params['background'] = background - params['output'] = output - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_file_view(self, file_id, xas=''): - """Get File for View""" - - params = {} - path = '/storage/files/{fileId}/view' - path = path.replace('{fileId}', file_id) - params['as'] = xas - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/server-python/appwrite/services/teams.py b/app/sdks/server-python/appwrite/services/teams.py deleted file mode 100644 index cdc3780ad9..0000000000 --- a/app/sdks/server-python/appwrite/services/teams.py +++ /dev/null @@ -1,105 +0,0 @@ -from ..service import Service - - -class Teams(Service): - - def __init__(self, client): - super(Teams, self).__init__(client) - - def list(self, search='', limit=25, offset=0, order_type='ASC'): - """List Teams""" - - params = {} - path = '/teams' - params['search'] = search - params['limit'] = limit - params['offset'] = offset - params['orderType'] = order_type - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create(self, name, roles=[]): - """Create Team""" - - params = {} - path = '/teams' - params['name'] = name - params['roles'] = roles - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get(self, team_id): - """Get Team""" - - params = {} - path = '/teams/{teamId}' - path = path.replace('{teamId}', team_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update(self, team_id, name): - """Update Team""" - - params = {} - path = '/teams/{teamId}' - path = path.replace('{teamId}', team_id) - params['name'] = name - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def delete(self, team_id): - """Delete Team""" - - params = {} - path = '/teams/{teamId}' - path = path.replace('{teamId}', team_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def get_memberships(self, team_id): - """Get Team Memberships""" - - params = {} - path = '/teams/{teamId}/memberships' - path = path.replace('{teamId}', team_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_membership(self, team_id, email, roles, url, name=''): - """Create Team Membership""" - - params = {} - path = '/teams/{teamId}/memberships' - path = path.replace('{teamId}', team_id) - params['email'] = email - params['name'] = name - params['roles'] = roles - params['url'] = url - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def delete_membership(self, team_id, invite_id): - """Delete Team Membership""" - - params = {} - path = '/teams/{teamId}/memberships/{inviteId}' - path = path.replace('{teamId}', team_id) - path = path.replace('{inviteId}', invite_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/server-python/appwrite/services/users.py b/app/sdks/server-python/appwrite/services/users.py deleted file mode 100644 index 2608f07a50..0000000000 --- a/app/sdks/server-python/appwrite/services/users.py +++ /dev/null @@ -1,125 +0,0 @@ -from ..service import Service - - -class Users(Service): - - def __init__(self, client): - super(Users, self).__init__(client) - - def list(self, search='', limit=25, offset=0, order_type='ASC'): - """List Users""" - - params = {} - path = '/users' - params['search'] = search - params['limit'] = limit - params['offset'] = offset - params['orderType'] = order_type - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create(self, email, password, name=''): - """Create User""" - - params = {} - path = '/users' - params['email'] = email - params['password'] = password - params['name'] = name - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get(self, user_id): - """Get User""" - - params = {} - path = '/users/{userId}' - path = path.replace('{userId}', user_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_logs(self, user_id): - """Get User Logs""" - - params = {} - path = '/users/{userId}/logs' - path = path.replace('{userId}', user_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_prefs(self, user_id): - """Get User Preferences""" - - params = {} - path = '/users/{userId}/prefs' - path = path.replace('{userId}', user_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_prefs(self, user_id, prefs): - """Update User Preferences""" - - params = {} - path = '/users/{userId}/prefs' - path = path.replace('{userId}', user_id) - params['prefs'] = prefs - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - - def get_sessions(self, user_id): - """Get User Sessions""" - - params = {} - path = '/users/{userId}/sessions' - path = path.replace('{userId}', user_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def delete_sessions(self, user_id): - """Delete User Sessions""" - - params = {} - path = '/users/{userId}/sessions' - path = path.replace('{userId}', user_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def delete_session(self, user_id, session_id): - """Delete User Session""" - - params = {} - path = '/users/{userId}/sessions/{sessionId}' - path = path.replace('{userId}', user_id) - path = path.replace('{sessionId}', session_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def update_status(self, user_id, status): - """Update User Status""" - - params = {} - path = '/users/{userId}/status' - path = path.replace('{userId}', user_id) - params['status'] = status - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) diff --git a/app/sdks/server-python/requirements.txt b/app/sdks/server-python/requirements.txt deleted file mode 100644 index e20605c43d..0000000000 --- a/app/sdks/server-python/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -requests==2.22.0 \ No newline at end of file diff --git a/app/sdks/server-python/setup.cfg b/app/sdks/server-python/setup.cfg deleted file mode 100644 index 224a77957f..0000000000 --- a/app/sdks/server-python/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md \ No newline at end of file diff --git a/app/sdks/server-python/setup.py b/app/sdks/server-python/setup.py deleted file mode 100644 index 8e2fd0c3cb..0000000000 --- a/app/sdks/server-python/setup.py +++ /dev/null @@ -1,30 +0,0 @@ -import setuptools - -setuptools.setup( - name = 'appwrite', - packages = ['appwrite', 'appwrite/services'], - version = '0.0.6', - license='BSD-3-Clause', - description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', - author = 'Appwrite Team', - author_email = 'team@localhost.test', - maintainer = 'Appwrite Team', - maintainer_email = 'team@localhost.test', - url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/0.0.6.tar.gz', - # keywords = ['SOME', 'MEANINGFULL', 'KEYWORDS'], - install_requires=[ - 'requests', - ], - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Environment :: Web Environment', - 'Topic :: Software Development', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - ], -) diff --git a/app/sdks/server-ruby/CHANGELOG.md b/app/sdks/server-ruby/CHANGELOG.md deleted file mode 100644 index fa4d35e687..0000000000 --- a/app/sdks/server-ruby/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -# Change Log \ No newline at end of file diff --git a/app/sdks/server-ruby/Gemfile b/app/sdks/server-ruby/Gemfile deleted file mode 100644 index cd8aa9e04c..0000000000 --- a/app/sdks/server-ruby/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' - -gemspec \ No newline at end of file diff --git a/app/sdks/server-ruby/LICENSE b/app/sdks/server-ruby/LICENSE deleted file mode 100644 index fc7c051a91..0000000000 --- a/app/sdks/server-ruby/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/app/sdks/server-ruby/README.md b/app/sdks/server-ruby/README.md deleted file mode 100644 index cbc2cf781c..0000000000 --- a/app/sdks/server-ruby/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Appwrite Ruby SDK - -![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.6.1-blue.svg?v=1) - -**This SDK is compatible with Appwrite server version 0.6.1. 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 Ruby 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) - - - -![Appwrite](https://appwrite.io/images/github.png) - -## Installation - -To install via [Gem](https://rubygems.org/): - -```bash -gem install appwrite --save -``` - -## 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. \ No newline at end of file diff --git a/app/sdks/server-ruby/appwrite.gemspec b/app/sdks/server-ruby/appwrite.gemspec deleted file mode 100644 index f550cecf9f..0000000000 --- a/app/sdks/server-ruby/appwrite.gemspec +++ /dev/null @@ -1,13 +0,0 @@ -Gem::Specification.new do |s| - - s.name = 'appwrite' - s.version = '1.0.11' - s.summary = "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 Ruby 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)" - s.author = 'Appwrite Team' - s.homepage = 'https://appwrite.io/support' - s.email = 'team@localhost.test' - s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) - -end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite.rb b/app/sdks/server-ruby/lib/appwrite.rb deleted file mode 100644 index 8e88842789..0000000000 --- a/app/sdks/server-ruby/lib/appwrite.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'net/http' -require 'uri' -require 'json' -require_relative 'appwrite/client' -require_relative 'appwrite/service' -require_relative 'appwrite/services/avatars' -require_relative 'appwrite/services/database' -require_relative 'appwrite/services/health' -require_relative 'appwrite/services/locale' -require_relative 'appwrite/services/storage' -require_relative 'appwrite/services/teams' -require_relative 'appwrite/services/users' diff --git a/app/sdks/server-ruby/lib/appwrite/client.rb b/app/sdks/server-ruby/lib/appwrite/client.rb deleted file mode 100644 index 2cd09d52fe..0000000000 --- a/app/sdks/server-ruby/lib/appwrite/client.rb +++ /dev/null @@ -1,116 +0,0 @@ -require 'net/http' -require 'uri' -require 'json' -require 'cgi' - -module Appwrite - class Client - - METHOD_GET = 'get' - METHOD_POST = 'post' - METHOD_PUT = 'put' - METHOD_PATCH = 'patch' - METHOD_DELETE = 'delete' - METHOD_HEAD = 'head' - METHOD_OPTIONS = 'options' - METHOD_CONNECT = 'connect' - METHOD_TRACE = 'trace' - - def initialize() - @headers = { - 'content-type' => '', - 'user-agent' => RUBY_PLATFORM + ':ruby-' + RUBY_VERSION, - 'x-sdk-version' => 'appwrite:ruby:1.0.11' - } - @endpoint = 'https://appwrite.io/v1'; - end - - def set_project(value) - add_header('x-appwrite-project', value) - - return self - end - - def set_key(value) - add_header('x-appwrite-key', value) - - return self - end - - def set_locale(value) - add_header('x-appwrite-locale', value) - - return self - end - - def set_endpoint(endpoint) - @endpoint = endpoint - - return self - end - - def add_header(key, value) - @headers[key.downcase] = value.downcase - - return self - end - - def call(method, path = '', headers = {}, params = {}) - uri = URI.parse(@endpoint + path + ((method == METHOD_GET && params.length) ? '?' + encode(params) : '')) - return fetch(method, uri, headers, params) - end - - protected - - private - - def fetch(method, uri, headers, params, limit = 5) - raise ArgumentError, 'Too Many HTTP Redirects' if limit == 0 - - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = (uri.scheme == 'https') - payload = '' - - headers = @headers.merge(headers) - - if (method != METHOD_GET) - case headers['content-type'][0, headers['content-type'].index(';') || headers['content-type'].length] - when 'application/json' - payload = params.to_json - else - payload = encode(params) - end - end - - begin - response = http.send_request(method.upcase, uri.request_uri, payload, headers) - rescue => error - raise 'Request Failed: ' + error.message - end - - # Handle Redirects - if (response.class == Net::HTTPRedirection || response.class == Net::HTTPMovedPermanently) - location = response['location'] - uri = URI.parse(uri.scheme + "://" + uri.host + "" + location) - - return fetch(method, uri, headers, {}, limit - 1) - end - - return JSON.parse(response.body); - end - - def encode(value, key = nil) - case value - when Hash then value.map { |k,v| encode(v, append_key(key,k)) }.join('&') - when Array then value.map { |v| encode(v, "#{key}[]") }.join('&') - when nil then '' - else - "#{key}=#{CGI.escape(value.to_s)}" - end - end - - def append_key(root_key, key) - root_key.nil? ? key : "#{root_key}[#{key.to_s}]" - end - end -end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/service.rb b/app/sdks/server-ruby/lib/appwrite/service.rb deleted file mode 100644 index 0d954c6d17..0000000000 --- a/app/sdks/server-ruby/lib/appwrite/service.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Appwrite - class Service - - def initialize(client) - @client = client - end - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/services/avatars.rb b/app/sdks/server-ruby/lib/appwrite/services/avatars.rb deleted file mode 100644 index 2c8e8ee723..0000000000 --- a/app/sdks/server-ruby/lib/appwrite/services/avatars.rb +++ /dev/null @@ -1,95 +0,0 @@ -module Appwrite - class Avatars < Service - - def get_browser(code:, width: 100, height: 100, quality: 100) - path = '/avatars/browsers/{code}' - .gsub('{code}', code) - - params = { - 'width': width, - 'height': height, - 'quality': quality - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_credit_card(code:, width: 100, height: 100, quality: 100) - path = '/avatars/credit-cards/{code}' - .gsub('{code}', code) - - params = { - 'width': width, - 'height': height, - 'quality': quality - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_favicon(url:) - path = '/avatars/favicon' - - params = { - 'url': url - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_flag(code:, width: 100, height: 100, quality: 100) - path = '/avatars/flags/{code}' - .gsub('{code}', code) - - params = { - 'width': width, - 'height': height, - 'quality': quality - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_image(url:, width: 400, height: 400) - path = '/avatars/image' - - params = { - 'url': url, - 'width': width, - 'height': height - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_q_r(text:, size: 400, margin: 1, download: 0) - path = '/avatars/qr' - - params = { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/services/database.rb b/app/sdks/server-ruby/lib/appwrite/services/database.rb deleted file mode 100644 index d8efcc34e1..0000000000 --- a/app/sdks/server-ruby/lib/appwrite/services/database.rb +++ /dev/null @@ -1,172 +0,0 @@ -module Appwrite - class Database < Service - - def list_collections(search: '', limit: 25, offset: 0, order_type: 'ASC') - path = '/database/collections' - - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create_collection(name:, read:, write:, rules:) - path = '/database/collections' - - params = { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_collection(collection_id:) - path = '/database/collections/{collectionId}' - .gsub('{collectionId}', collection_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_collection(collection_id:, name:, read:, write:, rules: []) - path = '/database/collections/{collectionId}' - .gsub('{collectionId}', collection_id) - - params = { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules - } - - return @client.call('put', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_collection(collection_id:) - path = '/database/collections/{collectionId}' - .gsub('{collectionId}', collection_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def list_documents(collection_id:, filters: [], offset: 0, limit: 50, order_field: '$id', order_type: 'ASC', order_cast: 'string', search: '', first: 0, last: 0) - path = '/database/collections/{collectionId}/documents' - .gsub('{collectionId}', collection_id) - - params = { - 'filters': filters, - 'offset': offset, - 'limit': limit, - 'orderField': order_field, - 'orderType': order_type, - 'orderCast': order_cast, - 'search': search, - 'first': first, - 'last': last - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create_document(collection_id:, data:, read:, write:, parent_document: '', parent_property: '', parent_property_type: 'assign') - path = '/database/collections/{collectionId}/documents' - .gsub('{collectionId}', collection_id) - - params = { - 'data': data, - 'read': read, - 'write': write, - 'parentDocument': parent_document, - 'parentProperty': parent_property, - 'parentPropertyType': parent_property_type - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_document(collection_id:, document_id:) - path = '/database/collections/{collectionId}/documents/{documentId}' - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_document(collection_id:, document_id:, data:, read:, write:) - path = '/database/collections/{collectionId}/documents/{documentId}' - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - params = { - 'data': data, - 'read': read, - 'write': write - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_document(collection_id:, document_id:) - path = '/database/collections/{collectionId}/documents/{documentId}' - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_collection_logs(collection_id:) - path = '/database/collections/{collectionId}/logs' - .gsub('{collectionId}', collection_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/services/health.rb b/app/sdks/server-ruby/lib/appwrite/services/health.rb deleted file mode 100644 index d2c6bc7b60..0000000000 --- a/app/sdks/server-ruby/lib/appwrite/services/health.rb +++ /dev/null @@ -1,141 +0,0 @@ -module Appwrite - class Health < Service - - def get() - path = '/health' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_anti_virus() - path = '/health/anti-virus' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_cache() - path = '/health/cache' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_d_b() - path = '/health/db' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_queue_certificates() - path = '/health/queue/certificates' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_queue_functions() - path = '/health/queue/functions' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_queue_logs() - path = '/health/queue/logs' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_queue_tasks() - path = '/health/queue/tasks' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_queue_usage() - path = '/health/queue/usage' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_queue_webhooks() - path = '/health/queue/webhooks' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_storage_local() - path = '/health/storage/local' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_time() - path = '/health/time' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/services/locale.rb b/app/sdks/server-ruby/lib/appwrite/services/locale.rb deleted file mode 100644 index 707c8b2f4a..0000000000 --- a/app/sdks/server-ruby/lib/appwrite/services/locale.rb +++ /dev/null @@ -1,75 +0,0 @@ -module Appwrite - class Locale < Service - - def get() - path = '/locale' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_continents() - path = '/locale/continents' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_countries() - path = '/locale/countries' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_countries_e_u() - path = '/locale/countries/eu' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_countries_phones() - path = '/locale/countries/phones' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_currencies() - path = '/locale/currencies' - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/services/storage.rb b/app/sdks/server-ruby/lib/appwrite/services/storage.rb deleted file mode 100644 index 0e99a2b0d5..0000000000 --- a/app/sdks/server-ruby/lib/appwrite/services/storage.rb +++ /dev/null @@ -1,118 +0,0 @@ -module Appwrite - class Storage < Service - - def list_files(search: '', limit: 25, offset: 0, order_type: 'ASC') - path = '/storage/files' - - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create_file(file:, read:, write:) - path = '/storage/files' - - params = { - 'file': file, - 'read': read, - 'write': write - } - - return @client.call('post', path, { - 'content-type' => 'multipart/form-data', - }, params); - end - - def get_file(file_id:) - path = '/storage/files/{fileId}' - .gsub('{fileId}', file_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_file(file_id:, read:, write:) - path = '/storage/files/{fileId}' - .gsub('{fileId}', file_id) - - params = { - 'read': read, - 'write': write - } - - return @client.call('put', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_file(file_id:) - path = '/storage/files/{fileId}' - .gsub('{fileId}', file_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_file_download(file_id:) - path = '/storage/files/{fileId}/download' - .gsub('{fileId}', file_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_file_preview(file_id:, width: 0, height: 0, quality: 100, background: '', output: '') - path = '/storage/files/{fileId}/preview' - .gsub('{fileId}', file_id) - - params = { - 'width': width, - 'height': height, - 'quality': quality, - 'background': background, - 'output': output - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_file_view(file_id:, as: '') - path = '/storage/files/{fileId}/view' - .gsub('{fileId}', file_id) - - params = { - 'as': as - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/services/teams.rb b/app/sdks/server-ruby/lib/appwrite/services/teams.rb deleted file mode 100644 index 0e677476d2..0000000000 --- a/app/sdks/server-ruby/lib/appwrite/services/teams.rb +++ /dev/null @@ -1,115 +0,0 @@ -module Appwrite - class Teams < Service - - def list(search: '', limit: 25, offset: 0, order_type: 'ASC') - path = '/teams' - - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create(name:, roles: ["owner"]) - path = '/teams' - - params = { - 'name': name, - 'roles': roles - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def get(team_id:) - path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update(team_id:, name:) - path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - params = { - 'name': name - } - - return @client.call('put', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete(team_id:) - path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_memberships(team_id:) - path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create_membership(team_id:, email:, roles:, url:, name: '') - path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - params = { - 'email': email, - 'name': name, - 'roles': roles, - 'url': url - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_membership(team_id:, invite_id:) - path = '/teams/{teamId}/memberships/{inviteId}' - .gsub('{teamId}', team_id) - .gsub('{inviteId}', invite_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/services/users.rb b/app/sdks/server-ruby/lib/appwrite/services/users.rb deleted file mode 100644 index f75434bd1a..0000000000 --- a/app/sdks/server-ruby/lib/appwrite/services/users.rb +++ /dev/null @@ -1,137 +0,0 @@ -module Appwrite - class Users < Service - - def list(search: '', limit: 25, offset: 0, order_type: 'ASC') - path = '/users' - - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def create(email:, password:, name: '') - path = '/users' - - params = { - 'email': email, - 'password': password, - 'name': name - } - - return @client.call('post', path, { - 'content-type' => 'application/json', - }, params); - end - - def get(user_id:) - path = '/users/{userId}' - .gsub('{userId}', user_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_logs(user_id:) - path = '/users/{userId}/logs' - .gsub('{userId}', user_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_prefs(user_id:) - path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_prefs(user_id:, prefs:) - path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - params = { - 'prefs': prefs - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - - def get_sessions(user_id:) - path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - params = { - } - - return @client.call('get', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_sessions(user_id:) - path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def delete_session(user_id:, session_id:) - path = '/users/{userId}/sessions/{sessionId}' - .gsub('{userId}', user_id) - .gsub('{sessionId}', session_id) - - params = { - } - - return @client.call('delete', path, { - 'content-type' => 'application/json', - }, params); - end - - def update_status(user_id:, status:) - path = '/users/{userId}/status' - .gsub('{userId}', user_id) - - params = { - 'status': status - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - - - protected - - private - end -end \ No newline at end of file diff --git a/app/tasks/init.php b/app/tasks/doctor.php similarity index 61% rename from app/tasks/init.php rename to app/tasks/doctor.php index a6e6af101d..2918d4f1e4 100644 --- a/app/tasks/init.php +++ b/app/tasks/doctor.php @@ -1,90 +1,69 @@ -#!/bin/env php task('ssl') - ->desc('Validate server certificates') - ->action(function () use ($request) { - $domain = $request->getServer('_APP_DOMAIN', ''); - - Console::log('Issue a TLS certificate for master domain ('.$domain.')'); - - ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [ - 'document' => [], - 'domain' => $domain, - 'validateTarget' => false, - 'validateCNAME' => false, - ]); - }); - $cli ->task('doctor') ->desc('Validate server health') - ->action(function () use ($request, $register) { + ->action(function () use ($register) { Console::log(" __ ____ ____ _ _ ____ __ ____ ____ __ __ / _\ ( _ \( _ \/ )( \( _ \( )(_ _)( __) ( )/ \ / \ ) __/ ) __/\ /\ / ) / )( )( ) _) _ )(( O ) \_/\_/(__) (__) (_/\_)(__\_)(__) (__) (____)(_)(__)\__/ "); - Console::log("\n".'👩‍⚕️ Running '.APP_NAME.' Doctor for version '.$request->getServer('_APP_VERSION', 'UNKNOWN').' ...'."\n"); + Console::log("\n".'👩‍⚕️ Running '.APP_NAME.' Doctor for version '.App::getEnv('_APP_VERSION', 'UNKNOWN').' ...'."\n"); Console::log('Checking for production best practices...'); - - $domain = new Domain($request->getServer('_APP_DOMAIN')); + + $domain = new Domain(App::getEnv('_APP_DOMAIN')); if(!$domain->isKnown() || $domain->isTest()) { - Console::log('🔴 Hostname has a public suffix'); + Console::log('🔴 Hostname has no public suffix ('.$domain->get().')'); } else { - Console::log('🟢 Hostname has a public suffix'); + Console::log('🟢 Hostname has a public suffix ('.$domain->get().')'); } - - $domain = new Domain($request->getServer('_APP_DOMAIN_TARGET')); + + $domain = new Domain(App::getEnv('_APP_DOMAIN_TARGET')); if(!$domain->isKnown() || $domain->isTest()) { - Console::log('🔴 CNAME target has a public suffix'); + Console::log('🔴 CNAME target has no public suffix ('.$domain->get().')'); } else { - Console::log('🟢 CNAME target has a public suffix'); + Console::log('🟢 CNAME target has a public suffix ('.$domain->get().')'); } - - if($request->getServer('_APP_OPENSSL_KEY_V1', 'your-secret-key') === 'your-secret-key') { - Console::log('🔴 Using a unique secret key for encryption'); + + if(App::getEnv('_APP_OPENSSL_KEY_V1') === 'your-secret-key' || empty(App::getEnv('_APP_OPENSSL_KEY_V1'))) { + Console::log('🔴 Not using a unique secret key for encryption'); } else { Console::log('🟢 Using a unique secret key for encryption'); } - if($request->getServer('_APP_ENV', 'development') === 'development') { - Console::log('🔴 App enviornment is set for production'); + if(App::getEnv('_APP_ENV', 'development') !== 'production') { + Console::log('🔴 App environment is set for development'); } else { - Console::log('🟢 App enviornment is set for production'); + Console::log('🟢 App environment is set for production'); } - if($request->getServer('_APP_OPTIONS_ABUSE', 'disabled') === 'disabled') { - Console::log('🔴 Abuse protection is enabled'); + if('enabled' !== App::getEnv('_APP_OPTIONS_ABUSE', 'disabled')) { + Console::log('🔴 Abuse protection is disabled'); } else { Console::log('🟢 Abuse protection is enabled'); } - $authWhitelistEmails = $request->getServer('_APP_CONSOLE_WHITELIST_EMAILS', null); - $authWhitelistIPs = $request->getServer('_APP_CONSOLE_WHITELIST_IPS', null); - $authWhitelistDomains = $request->getServer('_APP_CONSOLE_WHITELIST_DOMAINS', null); + $authWhitelistEmails = App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null); + $authWhitelistIPs = App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null); + $authWhitelistDomains = App::getEnv('_APP_CONSOLE_WHITELIST_DOMAINS', null); if(empty($authWhitelistEmails) && empty($authWhitelistDomains) @@ -95,12 +74,12 @@ $cli else { Console::log('🟢 Console access limits are enabled'); } - - if(empty($request->getServer('_APP_OPTIONS_FORCE_HTTPS', null))) { - Console::log('🔴 HTTP force option is disabled'); + + if('enabled' !== App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled')) { + Console::log('🔴 HTTPS force option is disabled'); } else { - Console::log('🟢 HTTP force option is enabled'); + Console::log('🟢 HTTPS force option is enabled'); } \sleep(0.2); @@ -132,9 +111,10 @@ $cli Console::error('Cache............disconnected 👎'); } - if($request->getServer('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled + if(App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled try { - $antiVirus = new Network('clamav', 3310); + $antiVirus = new Network(App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), + (int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)); if((@$antiVirus->ping())) { Console::success('AntiVirus...........connected 👍'); @@ -154,27 +134,28 @@ $cli $mail->Subject = 'Test SMTP Connection'; $mail->Body = 'Hello World'; $mail->AltBody = 'Hello World'; - + $mail->send(); Console::success('SMTP................connected 👍'); } catch (\Throwable $th) { Console::error('SMTP.............disconnected 👎'); + var_dump($th); } - $host = $request->getServer('_APP_STATSD_HOST', 'telegraf'); - $port = $request->getServer('_APP_STATSD_PORT', 8125); + $host = App::getEnv('_APP_STATSD_HOST', 'telegraf'); + $port = App::getEnv('_APP_STATSD_PORT', 8125); - if($fp = @\fsockopen('udp://'.$host, $port, $errCode, $errStr, 2)){ + if($fp = @\fsockopen('udp://'.$host, $port, $errCode, $errStr, 2)){ Console::success('StatsD..............connected 👍'); \fclose($fp); } else { Console::error('StatsD...........disconnected 👎'); } - $host = $request->getServer('_APP_INFLUXDB_HOST', ''); - $port = $request->getServer('_APP_INFLUXDB_PORT', ''); + $host = App::getEnv('_APP_INFLUXDB_HOST', ''); + $port = App::getEnv('_APP_INFLUXDB_PORT', ''); - if($fp = @\fsockopen($host, $port, $errCode, $errStr, 2)){ + if($fp = @\fsockopen($host, $port, $errCode, $errStr, 2)){ Console::success('InfluxDB............connected 👍'); \fclose($fp); } else { @@ -200,7 +181,7 @@ $cli else { Console::error('🔴 '.$key.' Volume is unreadable'); } - + if (\is_writable($device->getRoot())) { Console::success('🟢 '.$key.' Volume is writeable'); } @@ -224,9 +205,9 @@ $cli $percentage = (($device->getPartitionTotalSpace() - $device->getPartitionFreeSpace()) / $device->getPartitionTotalSpace()) * 100; - + $message = $key.' Volume has '.Storage::human($device->getPartitionFreeSpace()) . ' free space ('.\round($percentage, 2).'% used)'; - + if ($percentage < 80) { Console::success('🟢 ' . $message); } @@ -235,25 +216,23 @@ $cli } } - try { - Console::log(''); - $version = \json_decode(@\file_get_contents($request->getServer('_APP_HOME', 'http://localhost').'/v1/health/version'), true); - - if($version && isset($version['version'])) { - if(\version_compare($version['version'], $request->getServer('_APP_VERSION', 'UNKNOWN')) === 0) { - Console::info('You are running the latest version of '.APP_NAME.'! 🥳'); + if(App::isProduction()) { + Console::log(''); + $version = \json_decode(@\file_get_contents(App::getEnv('_APP_HOME', 'http://localhost').'/v1/health/version'), true); + + if ($version && isset($version['version'])) { + if(\version_compare($version['version'], App::getEnv('_APP_VERSION', 'UNKNOWN')) === 0) { + Console::info('You are running the latest version of '.APP_NAME.'! 🥳'); + } + else { + Console::info('A new version ('.$version['version'].') is available! 🥳'."\n"); + } + } else { + Console::error('Failed to check for a newer version'."\n"); } - else { - Console::info('A new version ('.$version['version'].') is available! 🥳'."\n"); - } - } - else { - Console::error('Failed to check for a newer version'."\n"); } } catch (\Throwable $th) { Console::error('Failed to check for a newer version'."\n"); } }); - -$cli->run(); diff --git a/app/tasks/install.php b/app/tasks/install.php new file mode 100644 index 0000000000..39ed29a5bb --- /dev/null +++ b/app/tasks/install.php @@ -0,0 +1,184 @@ +task('install') + ->desc('Install Appwrite') + ->action(function () { + /** + * 1. Start - DONE + * 2. Check for older setup and get older version - DONE + * 2.1 If older version is equal or bigger(?) than current version, **stop setup** + * 2.2. Get ENV vars - DONE + * 2.2.1 Fetch from older docker-compose.yml file + * 2.2.2 Fetch from older .env file (manually parse) + * 2.3 Use old ENV vars as default values + * 2.4 Ask for all required vars not given as CLI args and if in interactive mode + * Otherwise, just use default vars. - DONE + * 3. Ask user to backup important volumes, env vars, and SQL tables + * In th future we can try and automate this for smaller/medium size setups + * 4. Drop new docker-compose.yml setup (located inside the container, no network dependencies with appwrite.io) - DONE + * 5. Run docker-compose up -d - DONE + * 6. Run data migration + */ + $config = Config::getParam('variables'); + $path = '/usr/src/code/appwrite'; + $defaultHTTPPort = '80'; + $defaultHTTPSPort = '443'; + $vars = []; + + /** + * We are using a random value every execution for identification. + * This allows us to collect information without invading the privacy of our users. + */ + $analytics = new GoogleAnalytics('UA-26264668-9', uniqid('server.', true)); + + foreach($config as $category) { + foreach($category['variables'] ?? [] as $var) { + $vars[] = $var; + } + } + + Console::success('Starting Appwrite installation...'); + + // Create directory with write permissions + if (null !== $path && !\file_exists(\dirname($path))) { + if (!@\mkdir(\dirname($path), 0755, true)) { + Console::error('Can\'t create directory '.\dirname($path)); + Console::exit(1); + } + } + + $data = @file_get_contents($path.'/docker-compose.yml'); + + if($data !== false) { + $compose = new Compose($data); + $appwrite = $compose->getService('appwrite'); + $oldVersion = ($appwrite) ? $appwrite->getImageVersion() : null; + $ports = $compose->getService('traefik')->getPorts(); + + if($oldVersion) { + foreach($compose->getServices() as $service) { // Fetch all env vars from previous compose file + if(!$service) { + continue; + } + + $env = $service->getEnvironment()->list(); + + foreach ($env as $key => $value) { + foreach($vars as &$var) { + if($var['name'] === $key) { + $var['default'] = $value; + } + } + } + } + + $data = @file_get_contents($path.'/.env'); + + if($data !== false) { // Fetch all env vars from previous .env file + $env = new Env($data); + + foreach ($env->list() as $key => $value) { + foreach($vars as &$var) { + if($var['name'] === $key) { + $var['default'] = $value; + } + } + } + } + + foreach ($ports as $key => $value) { + if($value === $defaultHTTPPort) { + $defaultHTTPPort = $key; + } + + if($value === $defaultHTTPSPort) { + $defaultHTTPSPort = $key; + } + } + } + } + + $httpPort = Console::confirm('Choose your server HTTP port: (default: '.$defaultHTTPPort.')'); + $httpPort = ($httpPort) ? $httpPort : $defaultHTTPPort; + + $httpsPort = Console::confirm('Choose your server HTTPS port: (default: '.$defaultHTTPSPort.')'); + $httpsPort = ($httpsPort) ? $httpsPort : $defaultHTTPSPort; + + $input = []; + + foreach($vars as $key => $var) { + if(!$var['required']) { + $input[$var['name']] = $var['default']; + continue; + } + + $input[$var['name']] = Console::confirm($var['question'].' (default: \''.$var['default'].'\')'); + + if(empty($input[$key])) { + $input[$var['name']] = $var['default']; + } + } + + $templateForCompose = new View(__DIR__.'/../views/install/compose.phtml'); + $templateForEnv = new View(__DIR__.'/../views/install/env.phtml'); + + $templateForCompose + ->setParam('httpPort', $httpPort) + ->setParam('httpsPort', $httpsPort) + ->setParam('version', APP_VERSION_STABLE) + ; + + $templateForEnv + ->setParam('vars', $input) + ; + + if(!file_put_contents($path.'/docker-compose.yml', $templateForCompose->render(false))) { + $message = 'Failed to save Docker Compose file'; + $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' - '.$message); + Console::error($message); + Console::exit(1); + } + + if(!file_put_contents($path.'/.env', $templateForEnv->render(false))) { + $message = 'Failed to save environment variables file'; + $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' - '.$message); + Console::error($message); + Console::exit(1); + } + + $env = ''; + $stdout = ''; + $stderr = ''; + + foreach ($input as $key => $value) { + if($value) { + $env .= $key.'='.$value.' '; + } + } + + Console::log("Running \"docker-compose -f {$path}/docker-compose.yml up -d --remove-orphans --renew-anon-volumes\""); + + $exit = Console::execute("${env} docker-compose -f {$path}/docker-compose.yml up -d --remove-orphans --renew-anon-volumes", '', $stdout, $stderr); + + if ($exit !== 0) { + $message = 'Failed to install Appwrite dockers'; + $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' - '.$message); + Console::error($message); + Console::error($stderr); + Console::exit($exit); + } else { + $message = 'Appwrite installed successfully'; + $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' - '.$message); + Console::success($message); + } + }); \ No newline at end of file diff --git a/app/tasks/maintenance.php b/app/tasks/maintenance.php new file mode 100644 index 0000000000..eccdf61b17 --- /dev/null +++ b/app/tasks/maintenance.php @@ -0,0 +1,55 @@ +task('maintenance') + ->desc('Schedules maintenance tasks and publishes them to resque') + ->action(function () { + Console::title('Maintenance V1'); + Console::success(APP_NAME.' maintenance process v1 has started'); + + function notifyDeleteExecutionLogs(int $interval) + { + Resque::enqueue(Event::DELETE_QUEUE_NAME, Event::DELETE_CLASS_NAME, [ + 'type' => DELETE_TYPE_EXECUTIONS, + 'timestamp' => time() - $interval + ]); + } + + function notifyDeleteAbuseLogs(int $interval) + { + Resque::enqueue(Event::DELETE_QUEUE_NAME, Event::DELETE_CLASS_NAME, [ + 'type' => DELETE_TYPE_ABUSE, + 'timestamp' => time() - $interval + ]); + } + + function notifyDeleteAuditLogs(int $interval) + { + Resque::enqueue(Event::DELETE_QUEUE_NAME, Event::DELETE_CLASS_NAME, [ + 'type' => DELETE_TYPE_AUDIT, + 'timestamp' => time() - $interval + ]); + } + + // # of days in seconds (1 day = 86400s) + $interval = (int) App::getEnv('_APP_MAINTENANCE_INTERVAL', '86400'); + $executionLogsRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', '1209600'); + $auditLogRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', '1209600'); + $abuseLogsRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', '86400'); + + Console::loop(function() use ($interval, $executionLogsRetention, $abuseLogsRetention, $auditLogRetention){ + $time = date('d-m-Y H:i:s', time()); + Console::info("[{$time}] Notifying deletes workers every {$interval} seconds"); + notifyDeleteExecutionLogs($executionLogsRetention); + notifyDeleteAbuseLogs($abuseLogsRetention); + notifyDeleteAuditLogs($auditLogRetention); + }, $interval); + }); \ No newline at end of file diff --git a/app/tasks/migrate.php b/app/tasks/migrate.php index fe833e27f6..f9e92b24b7 100644 --- a/app/tasks/migrate.php +++ b/app/tasks/migrate.php @@ -1,207 +1,58 @@ -#!/bin/env php get('db'); - -$callbacks = [ - '0.4.0' => function() { - Console::log('I got nothing to do.'); - }, - '0.5.0' => function($project) use ($db, $projectDB, $requset) { - - Console::log('Migrating project: '.$project->getId()); - - // Update all documents $uid -> $id - - $limit = 30; - $sum = 30; - $offset = 0; - - while ($sum >= 30) { - $all = $projectDB->getCollection([ - 'limit' => $limit, - 'offset' => $offset, - 'orderField' => '$uid', - 'orderType' => 'DESC', - 'orderCast' => 'string', - ]); - - $sum = \count($all); - - Console::log('Migrating: '.$offset.' / '.$projectDB->getSum()); - - foreach($all as $document) { - $document = fixDocument($document); - - if(empty($document->getId())) { - throw new Exception('Missing ID'); - } - - try { - $new = $projectDB->overwriteDocument($document->getArrayCopy()); - } catch (\Throwable $th) { - Console::error('Failed to update document: '.$th->getMessage()); - continue; - } - - if($new->getId() !== $document->getId()) { - throw new Exception('Duplication Error'); - } - } - - $offset = $offset + $limit; - } - - $schema = (isset($_SERVER['_APP_DB_SCHEMA'])) ? $_SERVER['_APP_DB_SCHEMA'] : ''; - - try { - $statement = $db->prepare(" - - CREATE TABLE IF NOT EXISTS `template.database.unique` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `key` varchar(128) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `index1` (`key`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - - CREATE TABLE IF NOT EXISTS `{$schema}`.`app_{$project->getId()}.database.unique` LIKE `template.database.unique`; - ALTER TABLE `{$schema}`.`app_{$project->getId()}.audit.audit` DROP COLUMN IF EXISTS `userType`; - ALTER TABLE `{$schema}`.`app_{$project->getId()}.audit.audit` DROP INDEX IF EXISTS `index_1`; - ALTER TABLE `{$schema}`.`app_{$project->getId()}.audit.audit` ADD INDEX IF NOT EXISTS `index_1` (`userId` ASC); - "); - - $statement->closeCursor(); - - $statement->execute(); - } - catch (\Exception $e) { - Console::error('Failed to alter table for project: '.$project->getId().' with message: '.$e->getMessage().'/'); - } - }, -]; - -function fixDocument(Document $document) { - $providers = Config::getParam('providers'); - - if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_PROJECTS){ - foreach($providers as $key => $provider) { - if(!empty($document->getAttribute('usersOauth'.\ucfirst($key).'Appid'))) { - $document - ->setAttribute('usersOauth2'.\ucfirst($key).'Appid', $document->getAttribute('usersOauth'.\ucfirst($key).'Appid', '')) - ->removeAttribute('usersOauth'.\ucfirst($key).'Appid') - ; - } - - if(!empty($document->getAttribute('usersOauth'.\ucfirst($key).'Secret'))) { - $document - ->setAttribute('usersOauth2'.\ucfirst($key).'Secret', $document->getAttribute('usersOauth'.\ucfirst($key).'Secret', '')) - ->removeAttribute('usersOauth'.\ucfirst($key).'Secret') - ; - } - } - } - - if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_USERS) { - foreach($providers as $key => $provider) { - if(!empty($document->getAttribute('oauth'.\ucfirst($key)))) { - $document - ->setAttribute('oauth2'.\ucfirst($key), $document->getAttribute('oauth'.\ucfirst($key), '')) - ->removeAttribute('oauth'.\ucfirst($key)) - ; - } - - if(!empty($document->getAttribute('oauth'.\ucfirst($key).'AccessToken'))) { - $document - ->setAttribute('oauth2'.\ucfirst($key).'AccessToken', $document->getAttribute('oauth'.\ucfirst($key).'AccessToken', '')) - ->removeAttribute('oauth'.\ucfirst($key).'AccessToken') - ; - } - } - - if($document->getAttribute('confirm', null) !== null) { - $document - ->setAttribute('emailVerification', $document->getAttribute('confirm', $document->getAttribute('emailVerification', false))) - ->removeAttribute('confirm') - ; - } - } - - if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_PLATFORMS) { - if($document->getAttribute('url', null) !== null) { - $document - ->setAttribute('hostname', \parse_url($document->getAttribute('url', $document->getAttribute('hostname', '')), PHP_URL_HOST)) - ->removeAttribute('url') - ; - } - } - - $document - ->setAttribute('$id', $document->getAttribute('$uid', $document->getAttribute('$id'))) - ->removeAttribute('$uid') - ; - - //Console::log('Switched from $uid to $id: '.$document->getCollection().'/'.$document->getId()); - - foreach($document as &$attr) { - if($attr instanceof Document) { - $attr = fixDocument($attr); - } - - if(\is_array($attr)) { - foreach($attr as &$child) { - if($child instanceof Document) { - $child = fixDocument($child); - } - } - } - } - - return $document; -} +use Appwrite\Database\Adapter\MySQL as MySQLAdapter; +use Appwrite\Database\Adapter\Redis as RedisAdapter; +use Appwrite\Migration\Version; $cli - ->task('run') - ->action(function () use ($console, $projectDB, $consoleDB, $callbacks) { + ->task('migrate') + ->action(function () use ($register) { Console::success('Starting Data Migration'); + $consoleDB = new Database(); + $consoleDB + ->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)) + ->setNamespace('app_console') // Main DB + ->setMocks(Config::getParam('collections', [])); + + $projectDB = new Database(); + $projectDB + ->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register)) + ->setMocks(Config::getParam('collections', [])); + + $console = $consoleDB->getDocument('console'); + Authorization::disable(); $limit = 30; $sum = 30; $offset = 0; $projects = [$console]; + $count = 0; - while ($sum >= 30) { - foreach($projects as $project) { - $projectDB->setNamespace('app_'.$project->getId()); + $migration = new Version\V06($register->get('db')); //TODO: remove hardcoded version and move to dynamic migration + while ($sum > 0) { + foreach ($projects as $project) { try { - $callbacks['0.5.0']($project); + $migration + ->setProject($project, $projectDB) + ->execute(); } catch (\Throwable $th) { + throw $th; Console::error('Failed to update project ("'.$project->getId().'") version with error: '.$th->getMessage()); - $projectDB->setNamespace('app_console'); - $projectDB->deleteDocument($project->getId()); } } $projects = $consoleDB->getCollection([ 'limit' => $limit, 'offset' => $offset, - 'orderField' => 'name', - 'orderType' => 'ASC', - 'orderCast' => 'string', 'filters' => [ '$collection='.Database::SYSTEM_COLLECTION_PROJECTS, ], @@ -209,11 +60,12 @@ $cli $sum = \count($projects); $offset = $offset + $limit; - - Console::log('Fetched '.$sum.' projects...'); + $count = $count + $sum; + + if ($sum > 0) { + Console::log('Fetched '.$count.'/'.$consoleDB->getSum().' projects...'); + } } Console::success('Data Migration Completed'); }); - -$cli->run(); diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index a8b9cdfdde..6b17104f6c 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -1,33 +1,26 @@ -#!/bin/env php task('generate') - ->action(function () use ($warning, $version) { + ->task('sdks') + ->action(function () { function getSSLPage($url) { $ch = \curl_init(); @@ -44,8 +37,14 @@ $cli $platforms = Config::getParam('platforms'); $selected = \strtolower(Console::confirm('Choose SDK ("*" for all):')); - $message = Console::confirm('Please enter your commit message:'); - $production = (Console::confirm('Type "Appwrite" to deploy for production') == 'Appwrite'); + $version = Console::confirm('Choose an Appwrite version'); + $git = (Console::confirm('Should we use git push? (yes/no)') == 'yes'); + $production = ($git) ? (Console::confirm('Type "Appwrite" to push code to production git repos') == 'Appwrite') : false; + $message = ($git) ? Console::confirm('Please enter your commit message:') : ''; + + if(!in_array($version, ['0.6.2', '0.7.0'])) { + throw new Exception('Unknown version given'); + } foreach($platforms as $key => $platform) { foreach($platform['languages'] as $language) { @@ -58,13 +57,13 @@ $cli continue; } - Console::info('Fetching API Spec for '.$language['name'].' for '.$platform['name']); + Console::info('Fetching API Spec for '.$language['name'].' for '.$platform['name'] . ' (version: '.$version.')'); - //$spec = getSSLPage('http://localhost/v1/open-api-2.json?extensions=1&platform='.$language['family']); - $spec = getSSLPage('https://appwrite.io/v1/open-api-2.json?extensions=1&platform='.$language['family']); - $spec = getSSLPage('https://localhost/v1/open-api-2.json?extensions=1&platform='.$language['family']); + $spec = file_get_contents(__DIR__.'/../config/specs/'.$version.'.'.$language['family'].'.json'); + $cover = 'https://appwrite.io/images/github.png'; $result = \realpath(__DIR__.'/..').'/sdks/'.$key.'-'.$language['key']; + $resultExamples = \realpath(__DIR__.'/../..').'/docs/examples/'.$version.'/'.$key.'-'.$language['key']; $target = \realpath(__DIR__.'/..').'/sdks/git/'.$language['key'].'/'; $readme = \realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/README.md'); $readme = ($readme) ? \file_get_contents($readme) : ''; @@ -72,9 +71,9 @@ $cli $examples = ($examples) ? \file_get_contents($examples) : ''; $changelog = \realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/CHANGELOG.md'); $changelog = ($changelog) ? \file_get_contents($changelog) : '# Change Log'; - $warning = ($language['beta']) ? '**This SDK is compatible with Appwrite server version ' . $version . '. For older versions, please check previous releases.**' : ''; + $warning = '**This SDK is compatible with Appwrite server version ' . $version . '. For older versions, please check [previous releases]('.$language['url'].'/releases).**'; $license = 'BSD-3-Clause'; - $licenseContent = 'Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors. + $licenseContent = 'Copyright (c) ' . date('Y') . ' 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: @@ -89,10 +88,15 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND switch ($language['key']) { case 'web': - $config = new JS(); + $config = new Web(); $config->setNPMPackage('appwrite'); $config->setBowerPackage('appwrite'); break; + case 'cli': + $config = new CLI(); + $config->setComposerVendor('appwrite'); + $config->setComposerPackage('cli'); + break; case 'php': $config = new PHP(); $config->setComposerVendor('appwrite'); @@ -102,6 +106,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND $config = new Node(); $config->setNPMPackage('node-appwrite'); $config->setBowerPackage('appwrite'); + $warning = $warning."\n\n > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. + If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web)"; break; case 'deno': $config = new Deno(); @@ -125,6 +131,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND break; case 'dart': $config = new Dart(); + $config->setPackageName('dart_appwrite'); + $warning = $warning."\n\n > This is the Dart SDK for integrating with Appwrite from your Dart server-side code. + If you're looking for the Flutter SDK you should check [appwrite/sdk-for-flutter](https://github.com/appwrite/sdk-for-flutter)"; break; case 'go': $config = new Go(); @@ -132,6 +141,13 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND case 'java': $config = new Java(); break; + case 'swift': + $config = new Swift(); + break; + case 'dotnet': + $cover = ''; + $config = new DotNet(); + break; default: throw new Exception('Language "'.$language['key'].'" not supported'); break; @@ -154,7 +170,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ->setGitRepo($language['gitUrl']) ->setGitRepoName($language['gitRepoName']) ->setGitUserName($language['gitUserName']) - ->setLogo('https://appwrite.io/images/github.png') + ->setLogo($cover) ->setURL('https://appwrite.io') ->setShareText('Appwrite is a backend as a service for building web or mobile apps') ->setShareURL('http://appwrite.io') @@ -175,37 +191,39 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND } $gitUrl = $language['gitUrl']; - - if(empty($gitUrl)) { - continue; - } - + if(!$production) { $gitUrl = 'git@github.com:aw-tests/'.$language['gitRepoName'].'.git'; } + + if($git && !empty($gitUrl)) { + \exec('rm -rf '.$target.' && \ + mkdir -p '.$target.' && \ + cd '.$target.' && \ + git init && \ + git remote add origin '.$gitUrl.' && \ + git fetch && \ + git pull '.$gitUrl.' && \ + rm -rf '.$target.'/* && \ + cp -r '.$result.'/ '.$target.'/ && \ + git add . && \ + git commit -m "'.$message.'" && \ + git push -u origin master + '); - \exec('rm -rf '.$target.' && \ - mkdir -p '.$target.' && \ - cd '.$target.' && \ - git init && \ - git remote add origin '.$gitUrl.' && \ - git fetch && \ - git pull '.$gitUrl.' && \ - rm -rf '.$target.'/* && \ - cp -r '.$result.'/ '.$target.'/ && \ - git add . && \ - git commit -m "'.$message.'" && \ - git push -u origin master'); + Console::success("Pushed {$language['name']} SDK to {$gitUrl}"); - Console::success("Pushed {$language['name']} SDK to {$gitUrl}"); - - \exec('rm -rf '.$target); + \exec('rm -rf '.$target); + Console::success("Remove temp directory '{$target}' for {$language['name']} SDK"); + } - Console::success("Remove temp directory '{$target}' for {$language['name']} SDK"); + \exec('mkdir -p '.$resultExamples.' && cp -r '.$result.'/docs/examples '.$resultExamples); + Console::success("Copied code examples for {$language['name']} SDK to: {$resultExamples}"); + + \exec('rm -rf '.$result); + Console::success("Removed source code directory '{$result}' for {$language['name']} SDK"); } } - exit(); + Console::exit(); }); - -$cli->run(); diff --git a/app/tasks/ssl.php b/app/tasks/ssl.php new file mode 100644 index 0000000000..2c32324fa3 --- /dev/null +++ b/app/tasks/ssl.php @@ -0,0 +1,23 @@ +task('ssl') + ->desc('Validate server certificates') + ->action(function () { + $domain = App::getEnv('_APP_DOMAIN', ''); + + Console::log('Issue a TLS certificate for master domain ('.$domain.') in 30 seconds. + Make sure your domain points to your server or restart to try again.'); + + ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [ + 'document' => [], + 'domain' => $domain, + 'validateTarget' => false, + 'validateCNAME' => false, + ]); + }); \ No newline at end of file diff --git a/app/tasks/vars.php b/app/tasks/vars.php new file mode 100644 index 0000000000..6c02348222 --- /dev/null +++ b/app/tasks/vars.php @@ -0,0 +1,25 @@ +task('vars') + ->desc('List all the server environment variables') + ->action(function () { + $config = Config::getParam('variables', []); + $vars = []; + + foreach($config as $category) { + foreach($category['variables'] ?? [] as $var) { + $vars[] = $var; + } + } + + foreach ($vars as $key => $value) { + Console::log('- '.$value['name'].'='.App::getEnv($value['name'], '')); + } + }); \ No newline at end of file diff --git a/app/views/console/account/index.phtml b/app/views/console/account/index.phtml index b90e2b4e11..3f1e7decc9 100644 --- a/app/views/console/account/index.phtml +++ b/app/views/console/account/index.phtml @@ -10,6 +10,8 @@
+ +
  • +

    Settings

    + +
    +
    + + +
    + +
    +
    + + + + Learn more) + +
    Add * for wildcard access
    + + + +
    Max value is escape(number_format($timeout)); ?> seconds (escape((int) ($timeout / 60)); ?> minutes)
    +
    + +
    + +
    + $event) : ?> +
    + +   + +
    + +
    +
    + + + +
    +
    + + + +
    Leave blank for no schedule
    + +

    Variables

    + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    + +
    + +
    + +
      +
    • +
    • Last Updated:
    • +
    • Created:
    • +
    + +
    + + +
    +
    +
    +
  • + + + + +
    diff --git a/app/views/console/functions/index.phtml b/app/views/console/functions/index.phtml new file mode 100644 index 0000000000..2aec5b6493 --- /dev/null +++ b/app/views/console/functions/index.phtml @@ -0,0 +1,128 @@ +getParam('environments', []); +?> +
    +

    + Home +
    + + Functions +

    +
    + +
    +
      +
    • +

      Functions

      + +
      + +
      +

      No Functions Found

      + +

      You haven't created any functions for your project yet.

      +
      + +
      +
      functions found
      + +
      + +
      +
      + +
      +
      + +
      + + + +
      + +
      +
      + +
      + +
      +
      +
    • +
    +
    \ No newline at end of file diff --git a/app/views/console/home/index.phtml b/app/views/console/home/index.phtml index 2141eb8ee8..e7164ebfde 100644 --- a/app/views/console/home/index.phtml +++ b/app/views/console/home/index.phtml @@ -1,5 +1,6 @@ getParam('graph', false); +$usageStatsEnabled = $this->getParam('usageStatsEnabled',true); ?>
    @@ -13,69 +14,119 @@ $graph = $this->getParam('graph', false);     -
    -
    -
    -
    +
    +
    + +
    - +
    + +
    + + + +
    + +
    + + + +
    + +
    + + +
    + +
    +
    + + +
    -
    +
    N/A
    Requests
    -
    Last 30 days
    0
    Bandwidth
    -
    Last 30 days
    - + +
    + +
    + Func. Executions +
    +
    + -
    - - -
    -
    -
    -
    0
    -
    Documents
    -
    -
    -
    0
    -
    Storage
    -
    -
    -
    0
    -
    Users
    -
    -
    -
    0
    -
    Tasks
    -
    +
    +
    +
    +
    0
    +
    Documents
    +
    +
    +
    0
    +
    Storage
    +
    +
    +
    0
    +
    Users
    +
    +
    +
    0
    +
    Tasks
    @@ -103,6 +154,8 @@ $graph = $this->getParam('graph', false);
    getParam('graph', false);
    - + Platform Logo
    - + iOS Logo
    - + Android Logo
    - +
    -

    +

    -
    +
    @@ -154,7 +207,11 @@ $graph = $this->getParam('graph', false);
    @@ -166,13 +223,13 @@ $graph = $this->getParam('graph', false);
  • - +
  • - +
  • - +
  • @@ -184,6 +241,8 @@ $graph = $this->getParam('graph', false);

    New Web App

    getParam('graph', false); - + @@ -209,7 +268,7 @@ $graph = $this->getParam('graph', false);
    Next Steps
    -

    After adding your new website, install our JS SDK to integrate with your code and read our getting started tutorial.

    +

    After adding your new website, install our Web SDK to integrate with your code and read our getting started tutorial.

    npm install appwrite
    @@ -222,6 +281,8 @@ $graph = $this->getParam('graph', false);