diff --git a/CHANGES.md b/CHANGES.md index 5699134be98..fb46b2b7d12 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,33 @@ +# Version 1.3.8 + +## Bugs +- Fix audit user internal [#5809](https://github.com/appwrite/appwrite/pull/5809) + +# Version 1.3.7 + +## Bugs +- Fix the routing for the default OAuth2 pages [#5640](https://github.com/appwrite/appwrite/pull/5640) [#5648](https://github.com/appwrite/appwrite/pull/5648) +- Add support for trailing slashes in Routes and URLs [#5647](https://github.com/appwrite/appwrite/pull/5647) [#5648](https://github.com/appwrite/appwrite/pull/5648) + +# Version 1.3.6 + +## Bugs + +- Fix Console deep linking to result in a 404 [#5632](https://github.com/appwrite/appwrite/pull/5632) +- Fix ACME HTTP Challenge [#5632](https://github.com/appwrite/appwrite/pull/5632) + +# Version 1.3.5 + +## Bugs + +- Fix minimum length for string attribute default values [#5606](https://github.com/appwrite/appwrite/pull/5606), [#5602](https://github.com/appwrite/appwrite/pull/5602) +- Update framework to fix route mismatches [#5603](https://github.com/appwrite/appwrite/pull/5603) + # Version 1.3.4 ## Bugs -- Update migration to properly migrate bucket permissiosn [#5497](https://github.com/appwrite/appwrite/pull/5497) +- Update migration to properly migrate bucket permissions [#5497](https://github.com/appwrite/appwrite/pull/5497) # Version 1.3.3 @@ -76,6 +101,7 @@ ## Changes - Released `appwrite/console` [2.0.2](https://github.com/appwrite/console/releases/tag/2.0.2) - Make `region` parameter optional with default for project create [#4763](https://github.com/appwrite/appwrite/pull/4763) +- Add security headers to the console endpoint [#4758](https://github.com/appwrite/appwrite/pull/4758) ## Bugs - Fix default oauth paths [#4725](https://github.com/appwrite/appwrite/pull/4725) diff --git a/README-CN.md b/README-CN.md index 14637220847..b6344585473 100644 --- a/README-CN.md +++ b/README-CN.md @@ -66,7 +66,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:1.3.4 + appwrite/appwrite:1.3.8 ``` ### Windows @@ -78,7 +78,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:1.3.4 + appwrite/appwrite:1.3.8 ``` #### PowerShell @@ -88,7 +88,7 @@ docker run -it --rm ` --volume /var/run/docker.sock:/var/run/docker.sock ` --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw ` --entrypoint="install" ` - appwrite/appwrite:1.3.4 + appwrite/appwrite:1.3.8 ``` 运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。 diff --git a/README.md b/README.md index 414c4bd0c36..2b82d49eb05 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:1.3.4 + appwrite/appwrite:1.3.8 ``` ### Windows @@ -87,7 +87,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:1.3.4 + appwrite/appwrite:1.3.8 ``` #### PowerShell @@ -97,7 +97,7 @@ docker run -it --rm ` --volume /var/run/docker.sock:/var/run/docker.sock ` --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw ` --entrypoint="install" ` - appwrite/appwrite:1.3.4 + appwrite/appwrite:1.3.8 ``` Once the Docker installation is complete, 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 completing the installation. @@ -128,6 +128,12 @@ Choose from one of the providers below:
Gitpod + + + Akamai Logo +
Akamai
+ + diff --git a/app/config/collections.php b/app/config/collections.php index 0b4dda68518..85a279faa55 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -32,6 +32,17 @@ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('enabled'), + 'type' => Database::VAR_BOOLEAN, + 'signed' => true, + 'size' => 0, + 'format' => '', + 'filters' => [], + 'required' => false, + 'default' => true, + 'array' => false, + ], [ '$id' => ID::custom('search'), 'type' => Database::VAR_STRING, diff --git a/app/config/errors.php b/app/config/errors.php index 078a6201688..a3b6cab24dd 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -112,7 +112,7 @@ ], Exception::USER_BLOCKED => [ 'name' => Exception::USER_BLOCKED, - 'description' => 'The current user has been blocked. You can unblock the user from the Appwrite console.', + 'description' => 'The current user has been blocked.', 'code' => 401, ], Exception::USER_INVALID_TOKEN => [ @@ -227,6 +227,11 @@ 'description' => 'The invite does not belong to the current user.', 'code' => 401, ], + Exception::TEAM_ALREADY_EXISTS => [ + 'name' => Exception::TEAM_ALREADY_EXISTS, + 'description' => 'Team with requested ID already exists.', + 'code' => 409, + ], /** Membership */ Exception::MEMBERSHIP_NOT_FOUND => [ @@ -408,9 +413,14 @@ 'description' => 'The document structure is invalid. Please ensure the attributes match the collection definition.', 'code' => 400, ], + Exception::DOCUMENT_MISSING_DATA => [ + 'name' => Exception::DOCUMENT_MISSING_DATA, + 'description' => 'The document data is missing. You must provide the document data.', + 'code' => 400, + ], Exception::DOCUMENT_MISSING_PAYLOAD => [ 'name' => Exception::DOCUMENT_MISSING_PAYLOAD, - 'description' => 'The document payload is missing.', + 'description' => 'The document data and permissions are missing. You must provide either the document data or permissions to be updated.', 'code' => 400, ], Exception::DOCUMENT_ALREADY_EXISTS => [ @@ -499,6 +509,11 @@ 'description' => 'Project with the requested ID could not be found. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.', 'code' => 404, ], + Exception::PROJECT_ALREADY_EXISTS => [ + 'name' => Exception::PROJECT_ALREADY_EXISTS, + 'description' => 'Project with the requested ID already exists.', + 'code' => 409, + ], Exception::PROJECT_UNKNOWN => [ 'name' => Exception::PROJECT_UNKNOWN, 'description' => 'The project ID is either missing or not valid. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.', diff --git a/app/config/locale/translations/pt-pt.json b/app/config/locale/translations/pt-pt.json index e257b472819..cf9ef377a86 100644 --- a/app/config/locale/translations/pt-pt.json +++ b/app/config/locale/translations/pt-pt.json @@ -17,7 +17,7 @@ "emails.magicSession.signature": "Equipa {{project}}", "emails.recovery.subject": "Redefinição de senha", "emails.recovery.hello": "Olá {{name}}", - "emails.recovery.body": "tilize este link para redefinir a palavra-passe do seu projecto {{project}}", + "emails.recovery.body": "Utilize este link para redefinir a palavra-passe do seu projecto {{project}}", "emails.recovery.footer": "Se não pediu para redefinir a sua palavra-passe, pode ignorar esta mensagem.", "emails.recovery.thanks": "Obrigado", "emails.recovery.signature": "Equipa {{project}}", diff --git a/app/config/platforms.php b/app/config/platforms.php index caff21b28b4..56103fad4a0 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -285,7 +285,7 @@ [ 'key' => 'python', 'name' => 'Python', - 'version' => '2.0.0', + 'version' => '2.0.2', 'url' => 'https://github.com/appwrite/sdk-for-python', 'package' => 'https://pypi.org/project/appwrite/', 'enabled' => true, @@ -357,12 +357,12 @@ [ 'key' => 'dotnet', 'name' => '.NET', - 'version' => '2.0.0', + 'version' => '0.4.2', 'url' => 'https://github.com/appwrite/sdk-for-dotnet', 'package' => 'https://www.nuget.org/packages/Appwrite', - 'enabled' => false, + 'enabled' => true, 'beta' => true, - 'dev' => true, + 'dev' => false, 'hidden' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'csharp', diff --git a/app/config/providers.php b/app/config/providers.php index 62430faae1b..dedb4ec665d 100644 --- a/app/config/providers.php +++ b/app/config/providers.php @@ -201,6 +201,16 @@ 'beta' => false, 'mock' => false, ], + 'oidc' => [ + 'name' => 'OpenID Connect', + 'developers' => 'https://openid.net/connect/faq/', + 'icon' => 'icon-oidc', + 'enabled' => true, + 'sandbox' => false, + 'form' => 'oidc.phtml', + 'beta' => false, + 'mock' => false, + ], 'okta' => [ 'name' => 'Okta', 'developers' => 'https://developer.okta.com/', @@ -222,7 +232,7 @@ 'mock' => false ], 'paypalSandbox' => [ - 'name' => 'PayPal', + 'name' => 'PayPal Sandbox', 'developers' => 'https://developer.paypal.com/docs/api/overview/', 'icon' => 'icon-paypal', 'enabled' => true, @@ -292,7 +302,7 @@ 'mock' => false, ], 'tradeshiftBox' => [ - 'name' => 'Tradeshift', + 'name' => 'Tradeshift Sandbox', 'developers' => 'https://developers.tradeshift.com/docs/api', 'icon' => 'icon-tradeshiftbox', 'enabled' => true, diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index dd5ac4a2da0..37485b92d8f 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -549,7 +549,7 @@ $detector = new Detector($request->getUserAgent('UNKNOWN')); $record = $geodb->get($request->getIP()); $secret = Auth::tokenGenerator(); - $expire = DateTime::addSeconds(new \DateTime(), $duration); + $expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), $duration)); $session = new Document(array_merge([ '$id' => ID::unique(), @@ -701,7 +701,7 @@ } $loginSecret = Auth::tokenGenerator(); - $expire = DateTime::addSeconds(new \DateTime(), Auth::TOKEN_EXPIRATION_CONFIRM); + $expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), Auth::TOKEN_EXPIRATION_CONFIRM)); $token = new Document([ '$id' => ID::unique(), @@ -827,7 +827,7 @@ $detector = new Detector($request->getUserAgent('UNKNOWN')); $record = $geodb->get($request->getIP()); $secret = Auth::tokenGenerator(); - $expire = DateTime::addSeconds(new \DateTime(), $duration); + $expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), $duration)); $session = new Document(array_merge( [ @@ -976,7 +976,7 @@ } $secret = Auth::codeGenerator(); - $expire = DateTime::addSeconds(new \DateTime(), Auth::TOKEN_EXPIRATION_PHONE); + $expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), Auth::TOKEN_EXPIRATION_PHONE)); $token = new Document([ '$id' => ID::unique(), @@ -1064,7 +1064,7 @@ $detector = new Detector($request->getUserAgent('UNKNOWN')); $record = $geodb->get($request->getIP()); $secret = Auth::tokenGenerator(); - $expire = DateTime::addSeconds(new \DateTime(), $duration); + $expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), $duration)); $session = new Document(array_merge( [ @@ -1216,7 +1216,7 @@ $detector = new Detector($request->getUserAgent('UNKNOWN')); $record = $geodb->get($request->getIP()); $secret = Auth::tokenGenerator(); - $expire = DateTime::addSeconds(new \DateTime(), $duration); + $expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), $duration)); $session = new Document(array_merge( [ @@ -1389,6 +1389,7 @@ $session->setAttribute('countryName', $countryName); $session->setAttribute('current', ($current == $session->getId()) ? true : false); + $session->setAttribute('expire', DateTime::formatTz(DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration))); $sessions[$key] = $session; } @@ -1426,7 +1427,7 @@ $audit = new EventAudit($dbForProject); - $logs = $audit->getLogsByUser($user->getId(), $limit, $offset); + $logs = $audit->getLogsByUser($user->getInternalId(), $limit, $offset); $output = []; @@ -1495,7 +1496,7 @@ $session ->setAttribute('current', ($session->getAttribute('secret') == Auth::hash(Auth::$secret))) ->setAttribute('countryName', $countryName) - ->setAttribute('expire', DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration)) + ->setAttribute('expire', DateTime::formatTz(DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration))) ; return $response->dynamic($session, Response::MODEL_SESSION); @@ -1763,11 +1764,12 @@ ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_USER) ->inject('requestTimestamp') + ->inject('request') ->inject('response') ->inject('user') ->inject('dbForProject') ->inject('events') - ->action(function (?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $events) { + ->action(function (?\DateTime $requestTimestamp, Request $request, Response $response, Document $user, Database $dbForProject, Event $events) { $user->setAttribute('status', false); @@ -1781,6 +1783,12 @@ $response->addHeader('X-Fallback-Cookies', \json_encode([])); } + $protocol = $request->getProtocol(); + $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')) + ; + $response->dynamic($user, Response::MODEL_ACCOUNT); }); @@ -1932,7 +1940,7 @@ $authDuration = $project->getAttribute('auths', [])['duration'] ?? Auth::TOKEN_EXPIRATION_LOGIN_LONG; - $session->setAttribute('expire', DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration)); + $session->setAttribute('expire', DateTime::formatTz(DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration))); $events ->setParam('userId', $user->getId()) @@ -2299,7 +2307,7 @@ ->setBody($body) ->setFrom($from) ->setRecipient($user->getAttribute('email')) - ->setName($user->getAttribute('name')) + ->setName($user->getAttribute('name') ?? '') ->trigger() ; @@ -2373,7 +2381,7 @@ $dbForProject->deleteCachedDocument('users', $profile->getId()); $events - ->setParam('userId', $user->getId()) + ->setParam('userId', $userId) ->setParam('tokenId', $verificationDocument->getId()) ; diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 8a18e28dba5..c8159547475 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -327,22 +327,22 @@ function updateAttribute( } if ($type === Database::VAR_RELATIONSHIP) { - $options = \array_merge($attribute->getAttribute('options', []), $options); - $attribute->setAttribute('options', $options); + $primaryDocumentOptions = \array_merge($attribute->getAttribute('options', []), $options); + $attribute->setAttribute('options', $primaryDocumentOptions); $dbForProject->updateRelationship( collection: $collectionId, id: $key, - onDelete: $options['onDelete'], + onDelete: $primaryDocumentOptions['onDelete'], ); - if ($options['twoWay']) { - $relatedCollection = $dbForProject->getDocument('database_' . $db->getInternalId(), $options['relatedCollection']); - $relatedAttribute = $dbForProject->getDocument('attributes', $db->getInternalId() . '_' . $relatedCollection->getInternalId() . '_' . $options['twoWayKey']); + if ($primaryDocumentOptions['twoWay']) { + $relatedCollection = $dbForProject->getDocument('database_' . $db->getInternalId(), $primaryDocumentOptions['relatedCollection']); + + $relatedAttribute = $dbForProject->getDocument('attributes', $db->getInternalId() . '_' . $relatedCollection->getInternalId() . '_' . $primaryDocumentOptions['twoWayKey']); $relatedOptions = \array_merge($relatedAttribute->getAttribute('options'), $options); $relatedAttribute->setAttribute('options', $relatedOptions); - - $dbForProject->updateDocument('attributes', $db->getInternalId() . '_' . $relatedCollection->getInternalId() . '_' . $options['twoWayKey'], $relatedAttribute); + $dbForProject->updateDocument('attributes', $db->getInternalId() . '_' . $relatedCollection->getInternalId() . '_' . $primaryDocumentOptions['twoWayKey'], $relatedAttribute); $dbForProject->deleteCachedDocument('database_' . $db->getInternalId(), $relatedCollection->getId()); } } else { @@ -384,11 +384,12 @@ function updateAttribute( ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_DATABASE) // Model for database needs to be created ->param('databaseId', '', new CustomId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') - ->param('name', '', new Text(128), 'Collection name. Max length: 128 chars.') + ->param('name', '', new Text(128), 'Database name. Max length: 128 chars.') + ->param('enabled', true, new Boolean(), 'Is database enabled?', true) ->inject('response') ->inject('dbForProject') ->inject('events') - ->action(function (string $databaseId, string $name, Response $response, Database $dbForProject, Event $events) { + ->action(function (string $databaseId, string $name, bool $enabled, Response $response, Database $dbForProject, Event $events) { $databaseId = $databaseId == 'unique()' ? ID::unique() : $databaseId; @@ -396,6 +397,7 @@ function updateAttribute( $dbForProject->createDocument('databases', new Document([ '$id' => $databaseId, 'name' => $name, + 'enabled' => $enabled, 'search' => implode(' ', [$databaseId, $name]), ])); $database = $dbForProject->getDocument('databases', $databaseId); @@ -507,7 +509,7 @@ function updateAttribute( ->inject('dbForProject') ->action(function (string $databaseId, Response $response, Database $dbForProject) { - $database = $dbForProject->getDocument('databases', $databaseId); + $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -564,7 +566,7 @@ function updateAttribute( $output[$i] = new Document([ 'event' => $log['event'], - 'userId' => ID::custom($log['userId']), + 'userId' => ID::custom($log['data']['userId']), 'userEmail' => $log['data']['userEmail'] ?? null, 'userName' => $log['data']['userName'] ?? null, 'mode' => $log['data']['mode'] ?? null, @@ -619,12 +621,13 @@ function updateAttribute( ->label('sdk.response.model', Response::MODEL_DATABASE) ->param('databaseId', '', new UID(), 'Database ID.') ->param('name', null, new Text(128), 'Database name. Max length: 128 chars.') + ->param('enabled', true, new Boolean(), 'Is database enabled?', true) ->inject('response') ->inject('dbForProject') ->inject('events') - ->action(function (string $databaseId, string $name, Response $response, Database $dbForProject, Event $events) { + ->action(function (string $databaseId, string $name, bool $enabled, Response $response, Database $dbForProject, Event $events) { - $database = $dbForProject->getDocument('databases', $databaseId); + $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -633,6 +636,7 @@ function updateAttribute( try { $database = $dbForProject->updateDocument('databases', $databaseId, $database ->setAttribute('name', $name) + ->setAttribute('enabled', $enabled) ->setAttribute('search', implode(' ', [$databaseId, $name]))); } catch (AuthorizationException $exception) { throw new Exception(Exception::USER_UNAUTHORIZED); @@ -714,14 +718,16 @@ function updateAttribute( ->param('name', '', new Text(128), 'Collection name. Max length: 128 chars.') ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).', true) ->param('documentSecurity', false, new Boolean(true), 'Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions).', true) + ->param('enabled', true, new Boolean(), 'Is collection enabled?', true) ->inject('response') ->inject('dbForProject') + ->inject('mode') ->inject('events') - ->action(function (string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, Response $response, Database $dbForProject, Event $events) { + ->action(function (string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, Response $response, Database $dbForProject, string $mode, Event $events) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -737,7 +743,7 @@ function updateAttribute( 'databaseId' => $databaseId, '$permissions' => $permissions ?? [], 'documentSecurity' => $documentSecurity, - 'enabled' => true, + 'enabled' => $enabled, 'name' => $name, 'search' => implode(' ', [$collectionId, $name]), ])); @@ -779,11 +785,12 @@ function updateAttribute( ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->inject('response') ->inject('dbForProject') - ->action(function (string $databaseId, array $queries, string $search, Response $response, Database $dbForProject) { + ->inject('mode') + ->action(function (string $databaseId, array $queries, string $search, Response $response, Database $dbForProject, string $mode) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -834,11 +841,12 @@ function updateAttribute( ->param('collectionId', '', new UID(), 'Collection ID.') ->inject('response') ->inject('dbForProject') - ->action(function (string $databaseId, string $collectionId, Response $response, Database $dbForProject) { + ->inject('mode') + ->action(function (string $databaseId, string $collectionId, Response $response, Database $dbForProject, string $mode) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -874,7 +882,7 @@ function updateAttribute( ->inject('geodb') ->action(function (string $databaseId, string $collectionId, array $queries, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -909,7 +917,7 @@ function updateAttribute( $output[$i] = new Document([ 'event' => $log['event'], - 'userId' => $log['userId'], + 'userId' => $log['data']['userId'], 'userEmail' => $log['data']['userEmail'] ?? null, 'userName' => $log['data']['userName'] ?? null, 'mode' => $log['data']['mode'] ?? null, @@ -972,12 +980,13 @@ function updateAttribute( ->param('enabled', true, new Boolean(), 'Is collection enabled?', true) ->inject('response') ->inject('dbForProject') + ->inject('mode') ->inject('events') - ->action(function (string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, Response $response, Database $dbForProject, Event $events) { + ->action(function (string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, Response $response, Database $dbForProject, string $mode, Event $events) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -1036,13 +1045,14 @@ function updateAttribute( ->param('collectionId', '', new UID(), 'Collection ID.') ->inject('response') ->inject('dbForProject') + ->inject('mode') ->inject('events') ->inject('deletes') - ->action(function (string $databaseId, string $collectionId, Response $response, Database $dbForProject, Event $events, Delete $deletes) { + ->action(function (string $databaseId, string $collectionId, Response $response, Database $dbForProject, string $mode, Event $events, Delete $deletes) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -1060,15 +1070,13 @@ function updateAttribute( $deletes ->setType(DELETE_TYPE_DOCUMENT) - ->setDocument($collection) - ; + ->setDocument($collection); $events ->setContext('database', $database) ->setParam('databaseId', $databaseId) ->setParam('collectionId', $collection->getId()) - ->setPayload($response->output($collection, Response::MODEL_COLLECTION)) - ; + ->setPayload($response->output($collection, Response::MODEL_COLLECTION)); $response->noContent(); }); @@ -1095,7 +1103,7 @@ function updateAttribute( ->param('key', '', new Key(), 'Attribute Key.') ->param('size', null, new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Range::TYPE_INTEGER), 'Attribute size for text attributes, in number of characters.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('default', null, new Text(0), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('default', null, new Text(0, 0), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') ->inject('dbForProject') @@ -1104,7 +1112,7 @@ function updateAttribute( ->action(function (string $databaseId, string $collectionId, string $key, ?int $size, ?bool $required, ?string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, Event $events) { // Ensure attribute default is within required size - $validator = new Text($size); + $validator = new Text($size, 0); if (!is_null($default) && !$validator->isValid($default)) { throw new Exception(Exception::ATTRIBUTE_VALUE_INVALID, $validator->getDescription()); } @@ -1593,7 +1601,7 @@ function updateAttribute( Database $dbForProject, EventDatabase $database, Event $events -) { + ) { $key ??= $relatedCollectionId; $twoWayKey ??= $collectionId; @@ -1653,7 +1661,7 @@ function updateAttribute( ->inject('dbForProject') ->action(function (string $databaseId, string $collectionId, Response $response, Database $dbForProject) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -1704,7 +1712,7 @@ function updateAttribute( ->inject('dbForProject') ->action(function (string $databaseId, string $collectionId, string $key, Response $response, Database $dbForProject) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -1769,7 +1777,7 @@ function updateAttribute( ->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('default', null, new Nullable(new Text(0)), 'Default value for attribute when not provided. Cannot be set when attribute is required.') + ->param('default', null, new Nullable(new Text(0, 0)), 'Default value for attribute when not provided. Cannot be set when attribute is required.') ->inject('response') ->inject('dbForProject') ->inject('events') @@ -2177,7 +2185,7 @@ function updateAttribute( $events, type: Database::VAR_RELATIONSHIP, required: false, - options : [ + options: [ 'onDelete' => $onDelete ] ); @@ -2218,7 +2226,7 @@ function updateAttribute( ->inject('events') ->action(function (string $databaseId, string $collectionId, string $key, Response $response, Database $dbForProject, EventDatabase $database, Event $events) { - $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $db = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -2271,8 +2279,7 @@ function updateAttribute( ->setType(DATABASE_TYPE_DELETE_ATTRIBUTE) ->setCollection($collection) ->setDatabase($db) - ->setDocument($attribute) - ; + ->setDocument($attribute); // Select response model based on type and format $type = $attribute->getAttribute('type'); @@ -2300,8 +2307,7 @@ function updateAttribute( ->setParam('attributeId', $attribute->getId()) ->setContext('collection', $collection) ->setContext('database', $db) - ->setPayload($response->output($attribute, $model)) - ; + ->setPayload($response->output($attribute, $model)); $response->noContent(); }); @@ -2335,7 +2341,7 @@ function updateAttribute( ->inject('events') ->action(function (string $databaseId, string $collectionId, string $key, string $type, array $attributes, array $orders, Response $response, Database $dbForProject, EventDatabase $database, Event $events) { - $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $db = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -2358,7 +2364,7 @@ function updateAttribute( } // Convert Document[] to array of attribute metadata - $oldAttributes = \array_map(fn ($a) => $a->getArrayCopy(), $collection->getAttribute('attributes')); + $oldAttributes = \array_map(fn($a) => $a->getArrayCopy(), $collection->getAttribute('attributes')); $oldAttributes[] = [ 'key' => '$id', @@ -2444,16 +2450,14 @@ function updateAttribute( ->setType(DATABASE_TYPE_CREATE_INDEX) ->setDatabase($db) ->setCollection($collection) - ->setDocument($index) - ; + ->setDocument($index); $events ->setParam('databaseId', $databaseId) ->setParam('collectionId', $collection->getId()) ->setParam('indexId', $index->getId()) ->setContext('collection', $collection) - ->setContext('database', $db) - ; + ->setContext('database', $db); $response ->setStatusCode(Response::STATUS_CODE_ACCEPTED) @@ -2480,7 +2484,7 @@ function updateAttribute( ->inject('dbForProject') ->action(function (string $databaseId, string $collectionId, Response $response, Database $dbForProject) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -2520,7 +2524,7 @@ function updateAttribute( ->inject('dbForProject') ->action(function (string $databaseId, string $collectionId, string $key, Response $response, Database $dbForProject) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -2531,21 +2535,15 @@ function updateAttribute( throw new Exception(Exception::COLLECTION_NOT_FOUND); } - $indexes = $collection->getAttribute('indexes'); - - // Search for index - $indexIndex = array_search($key, array_map(fn($idx) => $idx['key'], $indexes)); - - if ($indexIndex === false) { + $index = $collection->find('key', $key, 'indexes'); + if (empty($index)) { throw new Exception(Exception::INDEX_NOT_FOUND); } - $index = $indexes[$indexIndex]; - $index->setAttribute('collectionId', $database->getInternalId() . '_' . $collectionId); - $response->dynamic($index, Response::MODEL_INDEX); }); + App::delete('/v1/databases/:databaseId/collections/:collectionId/indexes/:key') ->alias('/v1/database/collections/:collectionId/indexes/:key', ['databaseId' => 'default']) ->desc('Delete Index') @@ -2571,7 +2569,7 @@ function updateAttribute( ->inject('events') ->action(function (string $databaseId, string $collectionId, string $key, Response $response, Database $dbForProject, EventDatabase $database, Event $events) { - $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $db = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -2599,8 +2597,7 @@ function updateAttribute( ->setType(DATABASE_TYPE_DELETE_INDEX) ->setDatabase($db) ->setCollection($collection) - ->setDocument($index) - ; + ->setDocument($index); $events ->setParam('databaseId', $databaseId) @@ -2608,8 +2605,7 @@ function updateAttribute( ->setParam('indexId', $index->getId()) ->setContext('collection', $collection) ->setContext('database', $db) - ->setPayload($response->output($index, Response::MODEL_INDEX)) - ; + ->setPayload($response->output($index, Response::MODEL_INDEX)); $response->noContent(); }); @@ -2621,7 +2617,7 @@ function updateAttribute( ->label('event', 'databases.[databaseId].collections.[collectionId].documents.[documentId].create') ->label('scope', 'documents.write') ->label('audits.event', 'document.create') - ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') + ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{response.$id}') ->label('usage.metric', 'documents.{scope}.requests.create') ->label('usage.params', ['databaseId:{request.databaseId}', 'collectionId:{request.collectionId}']) ->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}') @@ -2651,7 +2647,7 @@ function updateAttribute( $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array if (empty($data)) { - throw new Exception(Exception::DOCUMENT_MISSING_PAYLOAD); + throw new Exception(Exception::DOCUMENT_MISSING_DATA); } if (isset($data['$id'])) { @@ -2660,7 +2656,7 @@ function updateAttribute( $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -2735,7 +2731,7 @@ function updateAttribute( $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP + fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -2814,7 +2810,7 @@ function updateAttribute( $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP + fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -2847,8 +2843,7 @@ function updateAttribute( ->setParam('collectionId', $collection->getId()) ->setParam('documentId', $document->getId()) ->setContext('collection', $collection) - ->setContext('database', $database) - ; + ->setContext('database', $database); $response ->setStatusCode(Response::STATUS_CODE_CREATED) @@ -2878,9 +2873,9 @@ function updateAttribute( ->inject('mode') ->action(function (string $databaseId, string $collectionId, array $queries, Response $response, Database $dbForProject, string $mode) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -2940,7 +2935,7 @@ function updateAttribute( $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP + fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -2956,8 +2951,7 @@ function updateAttribute( } $relatedCollectionId = $relationship->getAttribute('relatedCollection'); - $relatedCollection = Authorization::skip(fn() => - $dbForProject->getDocument('database_' . $database->getInternalId(), $relatedCollectionId)); + $relatedCollection = Authorization::skip(fn() => $dbForProject->getDocument('database_' . $database->getInternalId(), $relatedCollectionId)); foreach ($relations as $index => $doc) { if ($doc instanceof Document) { @@ -2977,7 +2971,7 @@ function updateAttribute( return true; }; - // The linter is forcing this indentation + // The linter is forcing this indentation foreach ($documents as $document) { $processDocument($collection, $document); } @@ -3013,9 +3007,9 @@ function updateAttribute( ->inject('mode') ->action(function (string $databaseId, string $collectionId, string $documentId, array $queries, Response $response, Database $dbForProject, string $mode) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -3053,7 +3047,7 @@ function updateAttribute( $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP + fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -3108,7 +3102,7 @@ function updateAttribute( ->inject('geodb') ->action(function (string $databaseId, string $collectionId, string $documentId, array $queries, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -3149,7 +3143,7 @@ function updateAttribute( $output[$i] = new Document([ 'event' => $log['event'], - 'userId' => $log['userId'], + 'userId' => $log['data']['userId'], 'userEmail' => $log['data']['userEmail'] ?? null, 'userName' => $log['data']['userName'] ?? null, 'mode' => $log['data']['mode'] ?? null, @@ -3225,9 +3219,9 @@ function updateAttribute( throw new Exception(Exception::DOCUMENT_MISSING_PAYLOAD); } - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -3304,7 +3298,7 @@ function updateAttribute( $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP + fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -3372,7 +3366,7 @@ function updateAttribute( try { $document = $dbForProject->withRequestTimestamp( $requestTimestamp, - fn () => $dbForProject->updateDocument( + fn() => $dbForProject->updateDocument( 'database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $document->getId(), $newDocument @@ -3393,7 +3387,7 @@ function updateAttribute( $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP + fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -3426,8 +3420,7 @@ function updateAttribute( ->setParam('collectionId', $collection->getId()) ->setParam('documentId', $document->getId()) ->setContext('collection', $collection) - ->setContext('database', $database) - ; + ->setContext('database', $database); $response->dynamic($document, Response::MODEL_DOCUMENT); }); @@ -3464,9 +3457,9 @@ function updateAttribute( ->inject('mode') ->action(function (string $databaseId, string $collectionId, string $documentId, ?\DateTime $requestTimestamp, Response $response, Database $dbForProject, Event $events, Delete $deletes, string $mode) { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); - if ($database->isEmpty()) { + if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -3501,7 +3494,7 @@ function updateAttribute( $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP + fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -3532,7 +3525,7 @@ function updateAttribute( $checkPermissions($collection, $document); - Authorization::skip(fn () => $dbForProject->withRequestTimestamp($requestTimestamp, function () use ($dbForProject, $database, $collection, $documentId) { + Authorization::skip(fn() => $dbForProject->withRequestTimestamp($requestTimestamp, function () use ($dbForProject, $database, $collection, $documentId) { try { $dbForProject->deleteDocument( 'database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), @@ -3555,7 +3548,7 @@ function updateAttribute( $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP + fn($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -3585,8 +3578,7 @@ function updateAttribute( $deletes ->setType(DELETE_TYPE_AUDIT) - ->setDocument($document) - ; + ->setDocument($document); $events ->setParam('databaseId', $databaseId) @@ -3594,8 +3586,7 @@ function updateAttribute( ->setParam('documentId', $document->getId()) ->setContext('collection', $collection) ->setContext('database', $database) - ->setPayload($response->output($document, Response::MODEL_DOCUMENT)) - ; + ->setPayload($response->output($document, Response::MODEL_DOCUMENT)); $response->noContent(); }); @@ -3700,16 +3691,16 @@ function updateAttribute( 'databasesCount' => $stats['databases.$all.count.total'] ?? [], 'documentsCount' => $stats['documents.$all.count.total'] ?? [], 'collectionsCount' => $stats['collections.$all.count.total'] ?? [], - 'documentsCreate' => $stats['documents.$all.requests.create'] ?? [], - 'documentsRead' => $stats['documents.$all.requests.read'] ?? [], + 'documentsCreate' => $stats['documents.$all.requests.create'] ?? [], + 'documentsRead' => $stats['documents.$all.requests.read'] ?? [], 'documentsUpdate' => $stats['documents.$all.requests.update'] ?? [], 'documentsDelete' => $stats['documents.$all.requests.delete'] ?? [], 'collectionsCreate' => $stats['collections.$all.requests.create'] ?? [], - 'collectionsRead' => $stats['collections.$all.requests.read'] ?? [], + 'collectionsRead' => $stats['collections.$all.requests.read'] ?? [], 'collectionsUpdate' => $stats['collections.$all.requests.update'] ?? [], 'collectionsDelete' => $stats['collections.$all.requests.delete'] ?? [], 'databasesCreate' => $stats['databases.$all.requests.create'] ?? [], - 'databasesRead' => $stats['databases.$all.requests.read'] ?? [], + 'databasesRead' => $stats['databases.$all.requests.read'] ?? [], 'databasesUpdate' => $stats['databases.$all.requests.update'] ?? [], 'databasesDelete' => $stats['databases.$all.requests.delete'] ?? [], ]); @@ -3813,12 +3804,12 @@ function updateAttribute( 'range' => $range, 'collectionsCount' => $stats["collections.{$databaseId}.count.total"] ?? [], 'collectionsCreate' => $stats["collections.{$databaseId}.requests.create"] ?? [], - 'collectionsRead' => $stats["collections.{$databaseId}.requests.read"] ?? [], + 'collectionsRead' => $stats["collections.{$databaseId}.requests.read"] ?? [], 'collectionsUpdate' => $stats["collections.{$databaseId}.requests.update"] ?? [], 'collectionsDelete' => $stats["collections.{$databaseId}.requests.delete"] ?? [], 'documentsCount' => $stats["documents.{$databaseId}.count.total"] ?? [], - 'documentsCreate' => $stats["documents.{$databaseId}.requests.create"] ?? [], - 'documentsRead' => $stats["documents.{$databaseId}.requests.read"] ?? [], + 'documentsCreate' => $stats["documents.{$databaseId}.requests.create"] ?? [], + 'documentsRead' => $stats["documents.{$databaseId}.requests.read"] ?? [], 'documentsUpdate' => $stats["documents.{$databaseId}.requests.update"] ?? [], 'documentsDelete' => $stats["documents.{$databaseId}.requests.delete"] ?? [], ]); @@ -3928,8 +3919,8 @@ function updateAttribute( 'documentsCount' => $stats["documents.{$databaseId}/{$collectionId}.count.total"] ?? [], 'documentsCreate' => $stats["documents.{$databaseId}/{$collectionId}.requests.create"] ?? [], 'documentsRead' => $stats["documents.{$databaseId}/{$collectionId}.requests.read"] ?? [], - 'documentsUpdate' => $stats["documents.{$databaseId}/{$collectionId}.requests.update"] ?? [], - 'documentsDelete' => $stats["documents.{$databaseId}/{$collectionId}.requests.delete" ?? []] + 'documentsUpdate' => $stats["documents.{$databaseId}/{$collectionId}.requests.update"] ?? [], + 'documentsDelete' => $stats["documents.{$databaseId}/{$collectionId}.requests.delete" ?? []] ]); } diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index bc9f28d0cc7..4e16f8ad5f6 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -650,11 +650,13 @@ $end = $request->getContentRangeEnd(); $fileSize = $request->getContentRangeSize(); $deploymentId = $request->getHeader('x-appwrite-id', $deploymentId); - if (is_null($start) || is_null($end) || is_null($fileSize)) { + // TODO make `end >= $fileSize` in next breaking version + if (is_null($start) || is_null($end) || is_null($fileSize) || $end > $fileSize) { throw new Exception(Exception::STORAGE_INVALID_CONTENT_RANGE); } - if ($end === $fileSize) { + // TODO remove the condition that checks `$end === $fileSize` in next breaking version + if ($end === $fileSize - 1 || $end === $fileSize) { //if it's a last chunks the chunk size might differ, so we set the $chunks and $chunk to notify it's last chunk $chunks = $chunk = -1; } else { diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index d99743f88ab..90aefbf8097 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -29,6 +29,7 @@ use Utopia\Registry\Registry; use Appwrite\Extend\Exception; use Appwrite\Utopia\Database\Validator\Queries\Projects; +use Utopia\Database\Exception\Duplicate; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; use Utopia\Validator\Hostname; @@ -91,38 +92,43 @@ throw new Exception(Exception::PROJECT_RESERVED_PROJECT, "'console' is a reserved project."); } - $project = $dbForConsole->createDocument('projects', new Document([ - '$id' => $projectId, - '$permissions' => [ - Permission::read(Role::team(ID::custom($teamId))), - Permission::update(Role::team(ID::custom($teamId), 'owner')), - Permission::update(Role::team(ID::custom($teamId), 'developer')), - Permission::delete(Role::team(ID::custom($teamId), 'owner')), - Permission::delete(Role::team(ID::custom($teamId), 'developer')), - ], - 'name' => $name, - 'teamInternalId' => $team->getInternalId(), - 'teamId' => $team->getId(), - 'region' => $region, - 'description' => $description, - 'logo' => $logo, - 'url' => $url, - 'version' => APP_VERSION_STABLE, - 'legalName' => $legalName, - 'legalCountry' => $legalCountry, - 'legalState' => $legalState, - 'legalCity' => $legalCity, - 'legalAddress' => $legalAddress, - 'legalTaxId' => ID::custom($legalTaxId), - 'services' => new stdClass(), - 'platforms' => null, - 'authProviders' => [], - 'webhooks' => null, - 'keys' => null, - 'domains' => null, - 'auths' => $auths, - 'search' => implode(' ', [$projectId, $name]), - ])); + try { + $project = $dbForConsole->createDocument('projects', new Document([ + '$id' => $projectId, + '$permissions' => [ + Permission::read(Role::team(ID::custom($teamId))), + Permission::update(Role::team(ID::custom($teamId), 'owner')), + Permission::update(Role::team(ID::custom($teamId), 'developer')), + Permission::delete(Role::team(ID::custom($teamId), 'owner')), + Permission::delete(Role::team(ID::custom($teamId), 'developer')), + ], + 'name' => $name, + 'teamInternalId' => $team->getInternalId(), + 'teamId' => $team->getId(), + 'region' => $region, + 'description' => $description, + 'logo' => $logo, + 'url' => $url, + 'version' => APP_VERSION_STABLE, + 'legalName' => $legalName, + 'legalCountry' => $legalCountry, + 'legalState' => $legalState, + 'legalCity' => $legalCity, + 'legalAddress' => $legalAddress, + 'legalTaxId' => ID::custom($legalTaxId), + 'services' => new stdClass(), + 'platforms' => null, + 'authProviders' => [], + 'webhooks' => null, + 'keys' => null, + 'domains' => null, + 'auths' => $auths, + 'search' => implode(' ', [$projectId, $name]), + ])); + } catch (Duplicate $th) { + throw new Exception(Exception::PROJECT_ALREADY_EXISTS); + } + /** @var array $collections */ $collections = Config::getParam('collections', []); @@ -678,17 +684,11 @@ ->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 Password(), 'Your user password for confirmation. Must be at least 8 chars.') ->inject('response') ->inject('user') ->inject('dbForConsole') ->inject('deletes') - ->action(function (string $projectId, string $password, Response $response, Document $user, Database $dbForConsole, Delete $deletes) { - - if (!Auth::passwordVerify($password, $user->getAttribute('password'), $user->getAttribute('hash'), $user->getAttribute('hashOptions'))) { // Double check user password - throw new Exception(Exception::USER_INVALID_CREDENTIALS); - } - + ->action(function (string $projectId, Response $response, Document $user, Database $dbForConsole, Delete $deletes) { $project = $dbForConsole->getDocument('projects', $projectId); if ($project->isEmpty()) { diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index b8a249f6541..d24cd8577f2 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -445,7 +445,8 @@ $end = $request->getContentRangeEnd(); $fileSize = $request->getContentRangeSize(); $fileId = $request->getHeader('x-appwrite-id', $fileId); - if (is_null($start) || is_null($end) || is_null($fileSize)) { + // TODO make `end >= $fileSize` in next breaking version + if (is_null($start) || is_null($end) || is_null($fileSize) || $end > $fileSize) { throw new Exception(Exception::STORAGE_INVALID_CONTENT_RANGE); } @@ -454,7 +455,8 @@ throw new Exception(Exception::STORAGE_INVALID_APPWRITE_ID); } - if ($end === $fileSize) { + // TODO remove the condition that checks `$end === $fileSize` in next breaking version + if ($end === $fileSize - 1 || $end === $fileSize) { //if it's a last chunks the chunk size might differ, so we set the $chunks and $chunk to -1 notify it's last chunk $chunks = $chunk = -1; } else { diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 338af704060..5c5c128f573 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -67,18 +67,23 @@ $isAppUser = Auth::isAppUser(Authorization::getRoles()); $teamId = $teamId == 'unique()' ? ID::unique() : $teamId; - $team = Authorization::skip(fn() => $dbForProject->createDocument('teams', new Document([ - '$id' => $teamId, - '$permissions' => [ - Permission::read(Role::team($teamId)), - Permission::update(Role::team($teamId, 'owner')), - Permission::delete(Role::team($teamId, 'owner')), - ], - 'name' => $name, - 'total' => ($isPrivilegedUser || $isAppUser) ? 0 : 1, - 'prefs' => new \stdClass(), - 'search' => implode(' ', [$teamId, $name]), - ]))); + + try { + $team = Authorization::skip(fn() => $dbForProject->createDocument('teams', new Document([ + '$id' => $teamId, + '$permissions' => [ + Permission::read(Role::team($teamId)), + Permission::update(Role::team($teamId, 'owner')), + Permission::delete(Role::team($teamId, 'owner')), + ], + 'name' => $name, + 'total' => ($isPrivilegedUser || $isAppUser) ? 0 : 1, + 'prefs' => new \stdClass(), + 'search' => implode(' ', [$teamId, $name]), + ]))); + } catch (Duplicate $th) { + throw new Exception(Exception::TEAM_ALREADY_EXISTS); + } if (!$isPrivilegedUser && !$isAppUser) { // Don't add user on server mode if (!\in_array('owner', $roles)) { @@ -338,11 +343,12 @@ Query::limit(2000), // TODO fix members limit ]); - // TODO delete all members individually from the user object + // Memberships are deleted here instead of in the worker to make sure user permisions are updated instantly foreach ($memberships as $membership) { if (!$dbForProject->deleteDocument('memberships', $membership->getId())) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove membership for team from DB'); } + $dbForProject->deleteCachedDocument('users', $membership->getAttribute('userId')); } if (!$dbForProject->deleteDocument('teams', $teamId)) { @@ -1038,7 +1044,7 @@ $output[$i] = new Document([ 'event' => $log['event'], - 'userId' => $log['userId'], + 'userId' => $log['data']['userId'], 'userEmail' => $log['data']['userEmail'] ?? null, 'userName' => $log['data']['userName'] ?? null, 'mode' => $log['data']['mode'] ?? null, diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index cd217afe315..d84d83ff776 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -577,7 +577,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e $audit = new Audit($dbForProject); - $logs = $audit->getLogsByUser($user->getId(), $limit, $offset); + $logs = $audit->getLogsByUser($user->getInternalId(), $limit, $offset); $output = []; diff --git a/app/controllers/general.php b/app/controllers/general.php index fe25f5c2738..741b9f4111d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -41,6 +41,7 @@ Config::setParam('cookieSamesite', Response::COOKIE_SAMESITE_NONE); App::init() + ->groups(['api']) ->inject('utopia') ->inject('request') ->inject('response') @@ -437,7 +438,7 @@ $log->addExtra('line', $error->getLine()); $log->addExtra('trace', $error->getTraceAsString()); $log->addExtra('detailedTrace', $error->getTrace()); - $log->addExtra('roles', Authorization::$roles); + $log->addExtra('roles', Authorization::getRoles()); $action = $route->getLabel("sdk.namespace", "UNKNOWN_NAMESPACE") . '.' . $route->getLabel("sdk.method", "UNKNOWN_METHOD"); $log->setAction($action); @@ -584,7 +585,7 @@ $response->text($template->render(false)); }); -App::get('/.well-known/acme-challenge') +App::get('/.well-known/acme-challenge/*') ->desc('SSL Verification') ->label('scope', 'public') ->label('docs', false) diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 33e92f289a8..1f251a6d357 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -286,7 +286,7 @@ $id = $request->getHeader('x-appwrite-id', ''); $file['size'] = (\is_array($file['size'])) ? $file['size'][0] : $file['size']; - if (is_null($start) || is_null($end) || is_null($size)) { + if (is_null($start) || is_null($end) || is_null($size) || $end >= $size) { throw new Exception(Exception::GENERAL_MOCK, 'Invalid content-range header'); } @@ -302,11 +302,11 @@ throw new Exception(Exception::GENERAL_MOCK, 'All chunked request must have id header (except first)'); } - if ($end !== $size && $end - $start + 1 !== $chunkSize) { + if ($end !== $size - 1 && $end - $start + 1 !== $chunkSize) { throw new Exception(Exception::GENERAL_MOCK, 'Chunk size must be 5MB (except last chunk)'); } - if ($end !== $size && $file['size'] !== $chunkSize) { + if ($end !== $size - 1 && $file['size'] !== $chunkSize) { throw new Exception(Exception::GENERAL_MOCK, 'Wrong chunk size'); } @@ -314,11 +314,11 @@ throw new Exception(Exception::GENERAL_MOCK, 'Chunk size must be 5MB or less'); } - if ($end !== $size) { + if ($end !== $size - 1) { $response->json([ '$id' => ID::custom('newfileid'), - 'chunksTotal' => $file['size'] / $chunkSize, - 'chunksUploaded' => $start / $chunkSize + 'chunksTotal' => (int) ceil($size / ($end + 1 - $start)), + 'chunksUploaded' => ceil($start / $chunkSize) + 1 ]); } } else { diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 289fbca8f4d..daa7f9d5dae 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -27,7 +27,7 @@ $parts = explode('.', $match); if (count($parts) !== 2) { - throw new Exception('Too less or too many parts', 400, Exception::GENERAL_ARGUMENT_INVALID); + throw new Exception(Exception::GENERAL_SERVER_ERROR, "The server encountered an error while parsing the label: $label. Please create an issue on GitHub to allow us to investigate further https://github.com/appwrite/appwrite/issues/new/choose"); } $namespace = $parts[0] ?? ''; diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index 8115f092859..9fbdfe9b003 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -1,14 +1,28 @@ groups(['web']) + ->inject('request') + ->inject('response') + ->action(function (Request $request, Response $response) { + $response + ->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 + ; + }); + +App::get('/console/*') ->alias('/') + ->alias('auth/*') ->alias('/invite') ->alias('/login') ->alias('/recover') - ->alias('/register') + ->alias('/register/*') ->groups(['web']) ->label('permission', 'public') ->label('scope', 'home') diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index da1307e5eab..e90f3ec25bd 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -6,7 +6,7 @@ App::get('/versions') ->desc('Get Version') - ->groups(['web', 'home']) + ->groups(['home']) ->label('scope', 'public') ->inject('response') ->action(function (Response $response) { diff --git a/app/init.php b/app/init.php index 2dd01d2134c..132acb62cee 100644 --- a/app/init.php +++ b/app/init.php @@ -100,8 +100,8 @@ const APP_LIMIT_LIST_DEFAULT = 25; // Default maximum number of items to return in list API calls const APP_KEY_ACCCESS = 24 * 60 * 60; // 24 hours const APP_CACHE_UPDATE = 24 * 60 * 60; // 24 hours -const APP_CACHE_BUSTER = 503; -const APP_VERSION_STABLE = '1.3.4'; +const APP_CACHE_BUSTER = 506; +const APP_VERSION_STABLE = '1.3.8'; const APP_DATABASE_ATTRIBUTE_EMAIL = 'email'; const APP_DATABASE_ATTRIBUTE_ENUM = 'enum'; const APP_DATABASE_ATTRIBUTE_IP = 'ip'; @@ -903,7 +903,7 @@ function (mixed $value) { /** @var Utopia\Database\Database $dbForConsole */ /** @var Utopia\Database\Document $console */ - $projectId = $request->getParam('project', $request->getHeader('x-appwrite-project', 'console')); + $projectId = $request->getParam('project', $request->getHeader('x-appwrite-project', '')); if ($projectId === 'console') { return $console; diff --git a/app/workers/audits.php b/app/workers/audits.php index b25430ec41c..57614e60f62 100644 --- a/app/workers/audits.php +++ b/app/workers/audits.php @@ -40,8 +40,7 @@ public function run(): void $dbForProject = $this->getProjectDB($project->getId()); $audit = new Audit($dbForProject); $audit->log( - userInternalId: $user->getInternalId(), - userId: $user->getId(), + userId: $user->getInternalId(), // Pass first, most verbose event pattern event: $event, resource: $resource, @@ -49,6 +48,7 @@ public function run(): void ip: $ip, location: '', data: [ + 'userId' => $user->getId(), 'userName' => $userName, 'userEmail' => $userEmail, 'mode' => $mode, diff --git a/composer.json b/composer.json index 78f960d3d12..b02a6111bcd 100644 --- a/composer.json +++ b/composer.json @@ -45,12 +45,12 @@ "appwrite/php-runtimes": "0.11.*", "utopia-php/abuse": "0.25.*", "utopia-php/analytics": "0.2.*", - "utopia-php/audit": "0.26.*", + "utopia-php/audit": "0.27.*", "utopia-php/cache": "0.8.*", "utopia-php/cli": "0.13.*", "utopia-php/config": "0.2.*", "utopia-php/database": "0.36.*", - "utopia-php/domains": "1.1.*", + "utopia-php/domains": "0.3.*", "utopia-php/framework": "0.28.*", "utopia-php/image": "0.5.*", "utopia-php/locale": "0.4.*", @@ -79,7 +79,7 @@ } ], "require-dev": { - "appwrite/sdk-generator": "0.32.*", + "appwrite/sdk-generator": "0.33.*", "ext-fileinfo": "*", "phpunit/phpunit": "9.5.20", "squizlabs/php_codesniffer": "^3.6", diff --git a/composer.lock b/composer.lock index 978d14f4905..5e6640b9fb3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "169ab6e7dd540e45309d3c5093506fad", + "content-hash": "a15f62920dedaf99e321ffd94e89d9f4", "packages": [ { "name": "adhocore/jwt", @@ -481,21 +481,21 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.5.1", + "version": "7.7.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "b964ca597e86b752cd994f27293e9fa6b6a95ed9" + "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b964ca597e86b752cd994f27293e9fa6b6a95ed9", - "reference": "b964ca597e86b752cd994f27293e9fa6b6a95ed9", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/fb7566caccf22d74d1ab270de3551f72a58399f5", + "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5", + "guzzlehttp/promises": "^1.5.3 || ^2.0", "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", @@ -507,7 +507,8 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8.1", "ext-curl": "*", - "php-http/client-integration-tests": "^3.0", + "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", + "php-http/message-factory": "^1.1", "phpunit/phpunit": "^8.5.29 || ^9.5.23", "psr/log": "^1.1 || ^2.0 || ^3.0" }, @@ -521,9 +522,6 @@ "bamarni-bin": { "bin-links": true, "forward-command": false - }, - "branch-alias": { - "dev-master": "7.5-dev" } }, "autoload": { @@ -589,7 +587,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.5.1" + "source": "https://github.com/guzzle/guzzle/tree/7.7.0" }, "funding": [ { @@ -605,38 +603,37 @@ "type": "tidelift" } ], - "time": "2023-04-17T16:30:08+00:00" + "time": "2023-05-21T14:04:53+00:00" }, { "name": "guzzlehttp/promises", - "version": "1.5.2", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "b94b2807d85443f9719887892882d0329d1e2598" + "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598", - "reference": "b94b2807d85443f9719887892882d0329d1e2598", + "url": "https://api.github.com/repos/guzzle/promises/zipball/3a494dc7dc1d7d12e511890177ae2d0e6c107da6", + "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6", "shasum": "" }, "require": { - "php": ">=5.5" + "php": "^7.2.5 || ^8.0" }, "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" + "bamarni/composer-bin-plugin": "^1.8.1", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "1.5-dev" + "bamarni-bin": { + "bin-links": true, + "forward-command": false } }, "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\Promise\\": "src/" } @@ -673,7 +670,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.2" + "source": "https://github.com/guzzle/promises/tree/2.0.0" }, "funding": [ { @@ -689,7 +686,7 @@ "type": "tidelift" } ], - "time": "2022-08-28T14:55:35+00:00" + "time": "2023-05-21T13:50:22+00:00" }, { "name": "guzzlehttp/psr7", @@ -1655,16 +1652,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.2.1", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", - "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", "shasum": "" }, "require": { @@ -1673,7 +1670,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.3-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -1702,7 +1699,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" }, "funding": [ { @@ -1718,7 +1715,7 @@ "type": "tidelift" } ], - "time": "2023-03-01T10:25:55+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/polyfill-php80", @@ -1909,16 +1906,16 @@ }, { "name": "utopia-php/audit", - "version": "0.26.0", + "version": "0.27.0", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "e7228080f14df28737fbb050c180c26d86ac0403" + "reference": "bdf89d7fe381bd4c891ad217612580a35e8c7642" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/e7228080f14df28737fbb050c180c26d86ac0403", - "reference": "e7228080f14df28737fbb050c180c26d86ac0403", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/bdf89d7fe381bd4c891ad217612580a35e8c7642", + "reference": "bdf89d7fe381bd4c891ad217612580a35e8c7642", "shasum": "" }, "require": { @@ -1950,9 +1947,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.26.0" + "source": "https://github.com/utopia-php/audit/tree/0.27.0" }, - "time": "2023-04-27T15:43:50+00:00" + "time": "2023-05-15T07:04:48+00:00" }, { "name": "utopia-php/cache", @@ -2167,23 +2164,25 @@ }, { "name": "utopia-php/domains", - "version": "v1.1.0", + "version": "0.3.2", "source": { "type": "git", "url": "https://github.com/utopia-php/domains.git", - "reference": "1665e1d9932afa3be63b5c1e0dcfe01fe77d8e73" + "reference": "aaa8c9a96c69ccb397997b1f4f2299c66f77eefb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/domains/zipball/1665e1d9932afa3be63b5c1e0dcfe01fe77d8e73", - "reference": "1665e1d9932afa3be63b5c1e0dcfe01fe77d8e73", + "url": "https://api.github.com/repos/utopia-php/domains/zipball/aaa8c9a96c69ccb397997b1f4f2299c66f77eefb", + "reference": "aaa8c9a96c69ccb397997b1f4f2299c66f77eefb", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.0", + "utopia-php/framework": "0.*.*" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "laravel/pint": "1.2.*", + "phpunit/phpunit": "^9.3" }, "type": "library", "autoload": { @@ -2199,6 +2198,10 @@ { "name": "Eldad Fux", "email": "eldad@appwrite.io" + }, + { + "name": "Wess Cope", + "email": "wess@appwrite.io" } ], "description": "Utopia Domains library is simple and lite library for parsing web domains. This library is aiming to be as simple and easy to learn and use.", @@ -2215,29 +2218,30 @@ ], "support": { "issues": "https://github.com/utopia-php/domains/issues", - "source": "https://github.com/utopia-php/domains/tree/master" + "source": "https://github.com/utopia-php/domains/tree/0.3.2" }, - "time": "2020-02-23T07:40:02+00:00" + "time": "2023-07-19T16:39:24+00:00" }, { "name": "utopia-php/framework", - "version": "0.28.1", + "version": "0.28.4", "source": { "type": "git", "url": "https://github.com/utopia-php/framework.git", - "reference": "7f22c556fc5991e54e5811a68fb39809b21bda55" + "reference": "98c5469efe195aeecc63745dbf8e2f357f8cedac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/7f22c556fc5991e54e5811a68fb39809b21bda55", - "reference": "7f22c556fc5991e54e5811a68fb39809b21bda55", + "url": "https://api.github.com/repos/utopia-php/framework/zipball/98c5469efe195aeecc63745dbf8e2f357f8cedac", + "reference": "98c5469efe195aeecc63745dbf8e2f357f8cedac", "shasum": "" }, "require": { - "php": ">=8.0.0" + "php": ">=8.0" }, "require-dev": { "laravel/pint": "^1.2", + "phpstan/phpstan": "1.9.x-dev", "phpunit/phpunit": "^9.5.25", "vimeo/psalm": "4.27.0" }, @@ -2259,9 +2263,9 @@ ], "support": { "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.28.1" + "source": "https://github.com/utopia-php/framework/tree/0.28.4" }, - "time": "2023-03-02T08:16:01+00:00" + "time": "2023-06-03T14:09:22+00:00" }, { "name": "utopia-php/image", @@ -2966,16 +2970,16 @@ }, { "name": "webonyx/graphql-php", - "version": "v14.11.9", + "version": "v14.11.10", "source": { "type": "git", "url": "https://github.com/webonyx/graphql-php.git", - "reference": "ff91c9f3cf241db702e30b2c42bcc0920e70ac70" + "reference": "d9c2fdebc6aa01d831bc2969da00e8588cffef19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/ff91c9f3cf241db702e30b2c42bcc0920e70ac70", - "reference": "ff91c9f3cf241db702e30b2c42bcc0920e70ac70", + "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/d9c2fdebc6aa01d831bc2969da00e8588cffef19", + "reference": "d9c2fdebc6aa01d831bc2969da00e8588cffef19", "shasum": "" }, "require": { @@ -2995,8 +2999,7 @@ "phpunit/phpunit": "^7.2 || ^8.5", "psr/http-message": "^1.0", "react/promise": "2.*", - "simpod/php-coveralls-mirror": "^3.0", - "squizlabs/php_codesniffer": "3.5.4" + "simpod/php-coveralls-mirror": "^3.0" }, "suggest": { "psr/http-message": "To use standard GraphQL server", @@ -3020,7 +3023,7 @@ ], "support": { "issues": "https://github.com/webonyx/graphql-php/issues", - "source": "https://github.com/webonyx/graphql-php/tree/v14.11.9" + "source": "https://github.com/webonyx/graphql-php/tree/v14.11.10" }, "funding": [ { @@ -3028,22 +3031,22 @@ "type": "open_collective" } ], - "time": "2023-01-06T12:12:50+00:00" + "time": "2023-07-05T14:23:37+00:00" } ], "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.32.3", + "version": "0.33.7", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "4057e14a61335070034b1cbdce9e39bef94d997d" + "reference": "9f5db4a637b23879ceacea9ed2d33b0486771ffc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/4057e14a61335070034b1cbdce9e39bef94d997d", - "reference": "4057e14a61335070034b1cbdce9e39bef94d997d", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/9f5db4a637b23879ceacea9ed2d33b0486771ffc", + "reference": "9f5db4a637b23879ceacea9ed2d33b0486771ffc", "shasum": "" }, "require": { @@ -3079,31 +3082,35 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.32.3" + "source": "https://github.com/appwrite/sdk-generator/tree/0.33.7" }, - "time": "2023-04-27T19:22:05+00:00" + "time": "2023-07-12T12:15:43+00:00" }, { "name": "doctrine/deprecations", - "version": "v1.0.0", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", "shasum": "" }, "require": { - "php": "^7.1|^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^9", - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "psr/log": "^1|^2|^3" + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" @@ -3122,9 +3129,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" + "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" }, - "time": "2022-05-02T15:47:09+00:00" + "time": "2023-06-03T09:27:29+00:00" }, { "name": "doctrine/instantiator", @@ -3198,16 +3205,16 @@ }, { "name": "matthiasmullie/minify", - "version": "1.3.70", + "version": "1.3.71", "source": { "type": "git", "url": "https://github.com/matthiasmullie/minify.git", - "reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b" + "reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/2807d9f9bece6877577ad44acb5c801bb3ae536b", - "reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b", + "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1", + "reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1", "shasum": "" }, "require": { @@ -3257,7 +3264,7 @@ ], "support": { "issues": "https://github.com/matthiasmullie/minify/issues", - "source": "https://github.com/matthiasmullie/minify/tree/1.3.70" + "source": "https://github.com/matthiasmullie/minify/tree/1.3.71" }, "funding": [ { @@ -3265,7 +3272,7 @@ "type": "github" } ], - "time": "2022-12-09T12:56:44+00:00" + "time": "2023-04-25T20:33:03+00:00" }, { "name": "matthiasmullie/path-converter", @@ -3381,16 +3388,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.15.4", + "version": "v4.16.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290" + "reference": "19526a33fb561ef417e822e85f08a00db4059c17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6bb5176bc4af8bcb7d926f88718db9b96a2d4290", - "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17", + "reference": "19526a33fb561ef417e822e85f08a00db4059c17", "shasum": "" }, "require": { @@ -3431,9 +3438,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.4" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0" }, - "time": "2023-03-05T19:49:14+00:00" + "time": "2023-06-25T14:52:30+00:00" }, { "name": "phar-io/manifest", @@ -3658,16 +3665,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.7.1", + "version": "1.7.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "dfc078e8af9c99210337325ff5aa152872c98714" + "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/dfc078e8af9c99210337325ff5aa152872c98714", - "reference": "dfc078e8af9c99210337325ff5aa152872c98714", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b2fe4d22a5426f38e014855322200b97b5362c0d", + "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d", "shasum": "" }, "require": { @@ -3710,9 +3717,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.1" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.2" }, - "time": "2023-03-27T19:02:04+00:00" + "time": "2023-05-30T18:13:47+00:00" }, { "name": "phpspec/prophecy", @@ -3784,22 +3791,24 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.20.3", + "version": "1.22.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6c04009f6cae6eda2f040745b6b846080ef069c2" + "reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6c04009f6cae6eda2f040745b6b846080ef069c2", - "reference": "6c04009f6cae6eda2f040745b6b846080ef069c2", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/65c39594fbd8c67abfc68bb323f86447bab79cc0", + "reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^4.15", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.5", @@ -3823,9 +3832,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.20.3" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.1" }, - "time": "2023-04-25T09:01:03+00:00" + "time": "2023-06-29T20:46:06+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4548,16 +4557,16 @@ }, { "name": "sebastian/diff", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", "shasum": "" }, "require": { @@ -4602,7 +4611,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" }, "funding": [ { @@ -4610,7 +4619,7 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2023-05-07T05:35:17+00:00" }, { "name": "sebastian/environment", @@ -5577,16 +5586,16 @@ }, { "name": "twig/twig", - "version": "v3.5.1", + "version": "v3.6.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "a6e0510cc793912b451fd40ab983a1d28f611c15" + "reference": "7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/a6e0510cc793912b451fd40ab983a1d28f611c15", - "reference": "a6e0510cc793912b451fd40ab983a1d28f611c15", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd", + "reference": "7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd", "shasum": "" }, "require": { @@ -5595,15 +5604,10 @@ "symfony/polyfill-mbstring": "^1.3" }, "require-dev": { - "psr/container": "^1.0", + "psr/container": "^1.0|^2.0", "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } - }, "autoload": { "psr-4": { "Twig\\": "src/" @@ -5637,7 +5641,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.5.1" + "source": "https://github.com/twigphp/Twig/tree/v3.6.1" }, "funding": [ { @@ -5649,7 +5653,7 @@ "type": "tidelift" } ], - "time": "2023-02-08T07:49:20+00:00" + "time": "2023-06-08T12:52:13+00:00" } ], "aliases": [], diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/create-phone-verification.md b/docs/examples/1.3.x/server-dotnet/examples/account/create-phone-verification.md new file mode 100644 index 00000000000..570bb20f5e4 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/create-phone-verification.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Token result = await account.CreatePhoneVerification(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/create-recovery.md b/docs/examples/1.3.x/server-dotnet/examples/account/create-recovery.md new file mode 100644 index 00000000000..1edc79bc502 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/create-recovery.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Token result = await account.CreateRecovery( + email: "email@example.com", + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/create-verification.md b/docs/examples/1.3.x/server-dotnet/examples/account/create-verification.md new file mode 100644 index 00000000000..928fcb85616 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/create-verification.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Token result = await account.CreateVerification( + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/delete-session.md b/docs/examples/1.3.x/server-dotnet/examples/account/delete-session.md new file mode 100644 index 00000000000..c880a4f88db --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/delete-session.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +await account.DeleteSession( + sessionId: "[SESSION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/delete-sessions.md b/docs/examples/1.3.x/server-dotnet/examples/account/delete-sessions.md new file mode 100644 index 00000000000..8dcefaf71ce --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/delete-sessions.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +await account.DeleteSessions(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/get-prefs.md b/docs/examples/1.3.x/server-dotnet/examples/account/get-prefs.md new file mode 100644 index 00000000000..ce3ecc1179d --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/get-prefs.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Preferences result = await account.GetPrefs(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/get-session.md b/docs/examples/1.3.x/server-dotnet/examples/account/get-session.md new file mode 100644 index 00000000000..9560b6a78aa --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/get-session.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Session result = await account.GetSession( + sessionId: "[SESSION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/get.md b/docs/examples/1.3.x/server-dotnet/examples/account/get.md new file mode 100644 index 00000000000..5a50299c733 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/get.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +User result = await account.Get(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/list-logs.md b/docs/examples/1.3.x/server-dotnet/examples/account/list-logs.md new file mode 100644 index 00000000000..03b50407f50 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/list-logs.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +LogList result = await account.ListLogs(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/list-sessions.md b/docs/examples/1.3.x/server-dotnet/examples/account/list-sessions.md new file mode 100644 index 00000000000..aa813bc1dd5 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/list-sessions.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +SessionList result = await account.ListSessions(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-email.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-email.md new file mode 100644 index 00000000000..0b457e0abb0 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-email.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +User result = await account.UpdateEmail( + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-name.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-name.md new file mode 100644 index 00000000000..b41ba372894 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-name.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +User result = await account.UpdateName( + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-password.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-password.md new file mode 100644 index 00000000000..d8bab0b4d23 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-password.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +User result = await account.UpdatePassword( + password: ""); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-phone-verification.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-phone-verification.md new file mode 100644 index 00000000000..6914e7805f7 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-phone-verification.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Token result = await account.UpdatePhoneVerification( + userId: "[USER_ID]", + secret: "[SECRET]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-phone.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-phone.md new file mode 100644 index 00000000000..f3e2f14df75 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-phone.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +User result = await account.UpdatePhone( + phone: "+12065550100", + password: "password"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-prefs.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-prefs.md new file mode 100644 index 00000000000..7a4f2378e49 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-prefs.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +User result = await account.UpdatePrefs( + prefs: [object]); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-recovery.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-recovery.md new file mode 100644 index 00000000000..d26f4ab8dae --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-recovery.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Token result = await account.UpdateRecovery( + userId: "[USER_ID]", + secret: "[SECRET]", + password: "password", + passwordAgain: "password"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-session.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-session.md new file mode 100644 index 00000000000..f3365bb96b7 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-session.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Session result = await account.UpdateSession( + sessionId: "[SESSION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-status.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-status.md new file mode 100644 index 00000000000..c5e3e2c5764 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-status.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +User result = await account.UpdateStatus(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/account/update-verification.md b/docs/examples/1.3.x/server-dotnet/examples/account/update-verification.md new file mode 100644 index 00000000000..697d2dffa4e --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/account/update-verification.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Token result = await account.UpdateVerification( + userId: "[USER_ID]", + secret: "[SECRET]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/avatars/get-browser.md b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-browser.md new file mode 100644 index 00000000000..3ac58f8b475 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-browser.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var avatars = new Avatars(client); + +byte[] result = await avatars.GetBrowser( + code: "aa"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/avatars/get-credit-card.md b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-credit-card.md new file mode 100644 index 00000000000..89f36fe35d1 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-credit-card.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var avatars = new Avatars(client); + +byte[] result = await avatars.GetCreditCard( + code: "amex"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/avatars/get-favicon.md b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-favicon.md new file mode 100644 index 00000000000..dbabf05d574 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-favicon.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var avatars = new Avatars(client); + +byte[] result = await avatars.GetFavicon( + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/avatars/get-flag.md b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-flag.md new file mode 100644 index 00000000000..fc20581c1ce --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-flag.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var avatars = new Avatars(client); + +byte[] result = await avatars.GetFlag( + code: "af"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/avatars/get-image.md b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-image.md new file mode 100644 index 00000000000..35bf382f12f --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-image.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var avatars = new Avatars(client); + +byte[] result = await avatars.GetImage( + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/avatars/get-initials.md b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-initials.md new file mode 100644 index 00000000000..20ea37a3a42 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-initials.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var avatars = new Avatars(client); + +byte[] result = await avatars.GetInitials(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/avatars/get-q-r.md b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-q-r.md new file mode 100644 index 00000000000..33dcac6f918 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/avatars/get-q-r.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var avatars = new Avatars(client); + +byte[] result = await avatars.GetQR( + text: "[TEXT]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-boolean-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-boolean-attribute.md new file mode 100644 index 00000000000..439537a9cb3 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-boolean-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeBoolean result = await databases.CreateBooleanAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-collection.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-collection.md new file mode 100644 index 00000000000..1b7aa198a60 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-collection.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Collection result = await databases.CreateCollection( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-datetime-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-datetime-attribute.md new file mode 100644 index 00000000000..1fff2965ffd --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-datetime-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeDatetime result = await databases.CreateDatetimeAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-document.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-document.md new file mode 100644 index 00000000000..c0081f1f200 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-document.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Document result = await databases.CreateDocument( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + documentId: "[DOCUMENT_ID]", + data: [object]); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-email-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-email-attribute.md new file mode 100644 index 00000000000..e22ed7ddca6 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-email-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeEmail result = await databases.CreateEmailAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-enum-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-enum-attribute.md new file mode 100644 index 00000000000..773d41e9fa8 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-enum-attribute.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeEnum result = await databases.CreateEnumAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + elements: new List {}, + required: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-float-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-float-attribute.md new file mode 100644 index 00000000000..d0915184e8a --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-float-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeFloat result = await databases.CreateFloatAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-index.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-index.md new file mode 100644 index 00000000000..b13de722aa6 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-index.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Index result = await databases.CreateIndex( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + type: "key", + attributes: new List {}); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-integer-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-integer-attribute.md new file mode 100644 index 00000000000..0d84ea7868d --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-integer-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeInteger result = await databases.CreateIntegerAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-ip-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-ip-attribute.md new file mode 100644 index 00000000000..ca571d00bda --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-ip-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeIp result = await databases.CreateIpAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-relationship-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-relationship-attribute.md new file mode 100644 index 00000000000..9c4a8c36043 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-relationship-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeRelationship result = await databases.CreateRelationshipAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + relatedCollectionId: "[RELATED_COLLECTION_ID]", + type: "oneToOne"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-string-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-string-attribute.md new file mode 100644 index 00000000000..645492eeabf --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-string-attribute.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeString result = await databases.CreateStringAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + size: 1, + required: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create-url-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create-url-attribute.md new file mode 100644 index 00000000000..9425882decb --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create-url-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeUrl result = await databases.CreateUrlAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/create.md b/docs/examples/1.3.x/server-dotnet/examples/databases/create.md new file mode 100644 index 00000000000..61ba46c03a5 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/create.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Database result = await databases.Create( + databaseId: "[DATABASE_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/delete-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/delete-attribute.md new file mode 100644 index 00000000000..8ebde257c52 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/delete-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.DeleteAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/delete-collection.md b/docs/examples/1.3.x/server-dotnet/examples/databases/delete-collection.md new file mode 100644 index 00000000000..398185c509e --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/delete-collection.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.DeleteCollection( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/delete-document.md b/docs/examples/1.3.x/server-dotnet/examples/databases/delete-document.md new file mode 100644 index 00000000000..6892b25438b --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/delete-document.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.DeleteDocument( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + documentId: "[DOCUMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/delete-index.md b/docs/examples/1.3.x/server-dotnet/examples/databases/delete-index.md new file mode 100644 index 00000000000..c5dab69e0fc --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/delete-index.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.DeleteIndex( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/delete.md b/docs/examples/1.3.x/server-dotnet/examples/databases/delete.md new file mode 100644 index 00000000000..cc8b4317e19 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/delete.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.Delete( + databaseId: "[DATABASE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/get-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/get-attribute.md new file mode 100644 index 00000000000..13eae946e96 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/get-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + + result = await databases.GetAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/get-collection.md b/docs/examples/1.3.x/server-dotnet/examples/databases/get-collection.md new file mode 100644 index 00000000000..b617da7810f --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/get-collection.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Collection result = await databases.GetCollection( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/get-document.md b/docs/examples/1.3.x/server-dotnet/examples/databases/get-document.md new file mode 100644 index 00000000000..079f93a4031 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/get-document.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Document result = await databases.GetDocument( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + documentId: "[DOCUMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/get-index.md b/docs/examples/1.3.x/server-dotnet/examples/databases/get-index.md new file mode 100644 index 00000000000..d989ed46519 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/get-index.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Index result = await databases.GetIndex( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/get.md b/docs/examples/1.3.x/server-dotnet/examples/databases/get.md new file mode 100644 index 00000000000..5dfa70eec14 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/get.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Database result = await databases.Get( + databaseId: "[DATABASE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/list-attributes.md b/docs/examples/1.3.x/server-dotnet/examples/databases/list-attributes.md new file mode 100644 index 00000000000..8af529df418 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/list-attributes.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeList result = await databases.ListAttributes( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/list-collections.md b/docs/examples/1.3.x/server-dotnet/examples/databases/list-collections.md new file mode 100644 index 00000000000..ed0d7bb56fc --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/list-collections.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +CollectionList result = await databases.ListCollections( + databaseId: "[DATABASE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/list-documents.md b/docs/examples/1.3.x/server-dotnet/examples/databases/list-documents.md new file mode 100644 index 00000000000..92895692f0a --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/list-documents.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +DocumentList result = await databases.ListDocuments( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/list-indexes.md b/docs/examples/1.3.x/server-dotnet/examples/databases/list-indexes.md new file mode 100644 index 00000000000..dbbed3ca537 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/list-indexes.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +IndexList result = await databases.ListIndexes( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/list.md b/docs/examples/1.3.x/server-dotnet/examples/databases/list.md new file mode 100644 index 00000000000..ec234ddbab3 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/list.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +DatabaseList result = await databases.List(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-boolean-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-boolean-attribute.md new file mode 100644 index 00000000000..2d6fa80849a --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-boolean-attribute.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeBoolean result = await databases.UpdateBooleanAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-collection.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-collection.md new file mode 100644 index 00000000000..aa477e4ce01 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-collection.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Collection result = await databases.UpdateCollection( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-datetime-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-datetime-attribute.md new file mode 100644 index 00000000000..81966f05f14 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-datetime-attribute.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeDatetime result = await databases.UpdateDatetimeAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: ""); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-document.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-document.md new file mode 100644 index 00000000000..b19d9226c69 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-document.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Document result = await databases.UpdateDocument( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + documentId: "[DOCUMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-email-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-email-attribute.md new file mode 100644 index 00000000000..5baf67fd729 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-email-attribute.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeEmail result = await databases.UpdateEmailAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: "email@example.com"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-enum-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-enum-attribute.md new file mode 100644 index 00000000000..184ac1820f1 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-enum-attribute.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeEnum result = await databases.UpdateEnumAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + elements: new List {}, + required: false, + default: "[DEFAULT]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-float-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-float-attribute.md new file mode 100644 index 00000000000..d68815ab07f --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-float-attribute.md @@ -0,0 +1,19 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeFloat result = await databases.UpdateFloatAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + min: 0, + max: 0, + default: 0); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-integer-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-integer-attribute.md new file mode 100644 index 00000000000..2ad0e057549 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-integer-attribute.md @@ -0,0 +1,19 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeInteger result = await databases.UpdateIntegerAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + min: 0, + max: 0, + default: 0); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-ip-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-ip-attribute.md new file mode 100644 index 00000000000..10fd34b3066 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-ip-attribute.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeIp result = await databases.UpdateIpAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: ""); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-relationship-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-relationship-attribute.md new file mode 100644 index 00000000000..8a65da0a421 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-relationship-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeRelationship result = await databases.UpdateRelationshipAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-string-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-string-attribute.md new file mode 100644 index 00000000000..84fc2b8da95 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-string-attribute.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeString result = await databases.UpdateStringAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: "[DEFAULT]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update-url-attribute.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update-url-attribute.md new file mode 100644 index 00000000000..e79812a77b1 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update-url-attribute.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeUrl result = await databases.UpdateUrlAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/databases/update.md b/docs/examples/1.3.x/server-dotnet/examples/databases/update.md new file mode 100644 index 00000000000..743108fc66b --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/databases/update.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Database result = await databases.Update( + databaseId: "[DATABASE_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/create-build.md b/docs/examples/1.3.x/server-dotnet/examples/functions/create-build.md new file mode 100644 index 00000000000..71eb842c6c7 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/create-build.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + + result = await functions.CreateBuild( + functionId: "[FUNCTION_ID]", + deploymentId: "[DEPLOYMENT_ID]", + buildId: "[BUILD_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/create-deployment.md b/docs/examples/1.3.x/server-dotnet/examples/functions/create-deployment.md new file mode 100644 index 00000000000..c58d1ef68de --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/create-deployment.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Deployment result = await functions.CreateDeployment( + functionId: "[FUNCTION_ID]", + entrypoint: "[ENTRYPOINT]", + code: InputFile.FromPath("./path-to-files/image.jpg"), + activate: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/create-execution.md b/docs/examples/1.3.x/server-dotnet/examples/functions/create-execution.md new file mode 100644 index 00000000000..93cd65be5d2 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/create-execution.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Execution result = await functions.CreateExecution( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/create-variable.md b/docs/examples/1.3.x/server-dotnet/examples/functions/create-variable.md new file mode 100644 index 00000000000..0724bc6eef4 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/create-variable.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Variable result = await functions.CreateVariable( + functionId: "[FUNCTION_ID]", + key: "[KEY]", + value: "[VALUE]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/create.md b/docs/examples/1.3.x/server-dotnet/examples/functions/create.md new file mode 100644 index 00000000000..75c9b242f69 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/create.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Function result = await functions.Create( + functionId: "[FUNCTION_ID]", + name: "[NAME]", + runtime: "node-14.5"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/delete-deployment.md b/docs/examples/1.3.x/server-dotnet/examples/functions/delete-deployment.md new file mode 100644 index 00000000000..2c17dfae9f2 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/delete-deployment.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +await functions.DeleteDeployment( + functionId: "[FUNCTION_ID]", + deploymentId: "[DEPLOYMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/delete-variable.md b/docs/examples/1.3.x/server-dotnet/examples/functions/delete-variable.md new file mode 100644 index 00000000000..cf201480fa1 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/delete-variable.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +await functions.DeleteVariable( + functionId: "[FUNCTION_ID]", + variableId: "[VARIABLE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/delete.md b/docs/examples/1.3.x/server-dotnet/examples/functions/delete.md new file mode 100644 index 00000000000..123e307c799 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/delete.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +await functions.Delete( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/get-deployment.md b/docs/examples/1.3.x/server-dotnet/examples/functions/get-deployment.md new file mode 100644 index 00000000000..7d895c6d82c --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/get-deployment.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Deployment result = await functions.GetDeployment( + functionId: "[FUNCTION_ID]", + deploymentId: "[DEPLOYMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/get-execution.md b/docs/examples/1.3.x/server-dotnet/examples/functions/get-execution.md new file mode 100644 index 00000000000..ed65d26bef4 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/get-execution.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Execution result = await functions.GetExecution( + functionId: "[FUNCTION_ID]", + executionId: "[EXECUTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/get-variable.md b/docs/examples/1.3.x/server-dotnet/examples/functions/get-variable.md new file mode 100644 index 00000000000..12083e5acb8 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/get-variable.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Variable result = await functions.GetVariable( + functionId: "[FUNCTION_ID]", + variableId: "[VARIABLE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/get.md b/docs/examples/1.3.x/server-dotnet/examples/functions/get.md new file mode 100644 index 00000000000..1914ccf7acc --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/get.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Function result = await functions.Get( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/list-deployments.md b/docs/examples/1.3.x/server-dotnet/examples/functions/list-deployments.md new file mode 100644 index 00000000000..cd6a7b94468 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/list-deployments.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +DeploymentList result = await functions.ListDeployments( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/list-executions.md b/docs/examples/1.3.x/server-dotnet/examples/functions/list-executions.md new file mode 100644 index 00000000000..d4c73a0d362 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/list-executions.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +ExecutionList result = await functions.ListExecutions( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/list-runtimes.md b/docs/examples/1.3.x/server-dotnet/examples/functions/list-runtimes.md new file mode 100644 index 00000000000..ca1d125eb23 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/list-runtimes.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +RuntimeList result = await functions.ListRuntimes(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/list-variables.md b/docs/examples/1.3.x/server-dotnet/examples/functions/list-variables.md new file mode 100644 index 00000000000..31177df9ff3 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/list-variables.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +VariableList result = await functions.ListVariables( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/list.md b/docs/examples/1.3.x/server-dotnet/examples/functions/list.md new file mode 100644 index 00000000000..1b8897b76fb --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/list.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +FunctionList result = await functions.List(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/update-deployment.md b/docs/examples/1.3.x/server-dotnet/examples/functions/update-deployment.md new file mode 100644 index 00000000000..8cd7fc54257 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/update-deployment.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Function result = await functions.UpdateDeployment( + functionId: "[FUNCTION_ID]", + deploymentId: "[DEPLOYMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/update-variable.md b/docs/examples/1.3.x/server-dotnet/examples/functions/update-variable.md new file mode 100644 index 00000000000..63eac46609c --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/update-variable.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Variable result = await functions.UpdateVariable( + functionId: "[FUNCTION_ID]", + variableId: "[VARIABLE_ID]", + key: "[KEY]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/functions/update.md b/docs/examples/1.3.x/server-dotnet/examples/functions/update.md new file mode 100644 index 00000000000..d9b29e6e77e --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/functions/update.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Function result = await functions.Update( + functionId: "[FUNCTION_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/graphql/mutation.md b/docs/examples/1.3.x/server-dotnet/examples/graphql/mutation.md new file mode 100644 index 00000000000..8ab5f0e458e --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/graphql/mutation.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var graphql = new Graphql(client); + +Any result = await graphql.Mutation( + query: [object]); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/graphql/query.md b/docs/examples/1.3.x/server-dotnet/examples/graphql/query.md new file mode 100644 index 00000000000..e019f43e5bd --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/graphql/query.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var graphql = new Graphql(client); + +Any result = await graphql.Query( + query: [object]); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get-antivirus.md b/docs/examples/1.3.x/server-dotnet/examples/health/get-antivirus.md new file mode 100644 index 00000000000..b8b0d5d95e4 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get-antivirus.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthAntivirus result = await health.GetAntivirus(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get-cache.md b/docs/examples/1.3.x/server-dotnet/examples/health/get-cache.md new file mode 100644 index 00000000000..2f36c10f3b1 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get-cache.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthStatus result = await health.GetCache(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get-d-b.md b/docs/examples/1.3.x/server-dotnet/examples/health/get-d-b.md new file mode 100644 index 00000000000..a263709073d --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get-d-b.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthStatus result = await health.GetDB(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-certificates.md b/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-certificates.md new file mode 100644 index 00000000000..b2f945cbc72 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-certificates.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthQueue result = await health.GetQueueCertificates(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-functions.md b/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-functions.md new file mode 100644 index 00000000000..cf2ed7fc082 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-functions.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthQueue result = await health.GetQueueFunctions(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-logs.md b/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-logs.md new file mode 100644 index 00000000000..8821509dbc2 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-logs.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthQueue result = await health.GetQueueLogs(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-webhooks.md b/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-webhooks.md new file mode 100644 index 00000000000..d2ffb01c4df --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get-queue-webhooks.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthQueue result = await health.GetQueueWebhooks(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get-storage-local.md b/docs/examples/1.3.x/server-dotnet/examples/health/get-storage-local.md new file mode 100644 index 00000000000..bc60cc6ccd6 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get-storage-local.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthStatus result = await health.GetStorageLocal(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get-time.md b/docs/examples/1.3.x/server-dotnet/examples/health/get-time.md new file mode 100644 index 00000000000..15f17454537 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get-time.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthTime result = await health.GetTime(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/health/get.md b/docs/examples/1.3.x/server-dotnet/examples/health/get.md new file mode 100644 index 00000000000..d1ddd8fdf08 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/health/get.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthStatus result = await health.Get(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/locale/get.md b/docs/examples/1.3.x/server-dotnet/examples/locale/get.md new file mode 100644 index 00000000000..f049a920726 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/locale/get.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +Locale result = await locale.Get(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/locale/list-continents.md b/docs/examples/1.3.x/server-dotnet/examples/locale/list-continents.md new file mode 100644 index 00000000000..dd91caba9de --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/locale/list-continents.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +ContinentList result = await locale.ListContinents(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/locale/list-countries-e-u.md b/docs/examples/1.3.x/server-dotnet/examples/locale/list-countries-e-u.md new file mode 100644 index 00000000000..8692c7b78e8 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/locale/list-countries-e-u.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +CountryList result = await locale.ListCountriesEU(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/locale/list-countries-phones.md b/docs/examples/1.3.x/server-dotnet/examples/locale/list-countries-phones.md new file mode 100644 index 00000000000..8607ae90f58 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/locale/list-countries-phones.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +PhoneList result = await locale.ListCountriesPhones(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/locale/list-countries.md b/docs/examples/1.3.x/server-dotnet/examples/locale/list-countries.md new file mode 100644 index 00000000000..c67d863856a --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/locale/list-countries.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +CountryList result = await locale.ListCountries(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/locale/list-currencies.md b/docs/examples/1.3.x/server-dotnet/examples/locale/list-currencies.md new file mode 100644 index 00000000000..1bb3c427e04 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/locale/list-currencies.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +CurrencyList result = await locale.ListCurrencies(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/locale/list-languages.md b/docs/examples/1.3.x/server-dotnet/examples/locale/list-languages.md new file mode 100644 index 00000000000..1c2897d4fb8 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/locale/list-languages.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +LanguageList result = await locale.ListLanguages(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/create-bucket.md b/docs/examples/1.3.x/server-dotnet/examples/storage/create-bucket.md new file mode 100644 index 00000000000..b1da6cb0bd0 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/create-bucket.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +Bucket result = await storage.CreateBucket( + bucketId: "[BUCKET_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/create-file.md b/docs/examples/1.3.x/server-dotnet/examples/storage/create-file.md new file mode 100644 index 00000000000..f7d73152098 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/create-file.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +File result = await storage.CreateFile( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]", + file: InputFile.FromPath("./path-to-files/image.jpg")); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/delete-bucket.md b/docs/examples/1.3.x/server-dotnet/examples/storage/delete-bucket.md new file mode 100644 index 00000000000..c8825f30639 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/delete-bucket.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +await storage.DeleteBucket( + bucketId: "[BUCKET_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/delete-file.md b/docs/examples/1.3.x/server-dotnet/examples/storage/delete-file.md new file mode 100644 index 00000000000..8b70175d97a --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/delete-file.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +await storage.DeleteFile( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/get-bucket.md b/docs/examples/1.3.x/server-dotnet/examples/storage/get-bucket.md new file mode 100644 index 00000000000..aca9020f285 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/get-bucket.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +Bucket result = await storage.GetBucket( + bucketId: "[BUCKET_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/get-file-download.md b/docs/examples/1.3.x/server-dotnet/examples/storage/get-file-download.md new file mode 100644 index 00000000000..e6aa24bea3e --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/get-file-download.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +byte[] result = await storage.GetFileDownload( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/get-file-preview.md b/docs/examples/1.3.x/server-dotnet/examples/storage/get-file-preview.md new file mode 100644 index 00000000000..92565ae5efe --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/get-file-preview.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +byte[] result = await storage.GetFilePreview( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/get-file-view.md b/docs/examples/1.3.x/server-dotnet/examples/storage/get-file-view.md new file mode 100644 index 00000000000..081f2dce7ba --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/get-file-view.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +byte[] result = await storage.GetFileView( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/get-file.md b/docs/examples/1.3.x/server-dotnet/examples/storage/get-file.md new file mode 100644 index 00000000000..0299a91bbe9 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/get-file.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +File result = await storage.GetFile( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/list-buckets.md b/docs/examples/1.3.x/server-dotnet/examples/storage/list-buckets.md new file mode 100644 index 00000000000..2caae5e0af8 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/list-buckets.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +BucketList result = await storage.ListBuckets(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/list-files.md b/docs/examples/1.3.x/server-dotnet/examples/storage/list-files.md new file mode 100644 index 00000000000..9d861171acd --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/list-files.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +FileList result = await storage.ListFiles( + bucketId: "[BUCKET_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/update-bucket.md b/docs/examples/1.3.x/server-dotnet/examples/storage/update-bucket.md new file mode 100644 index 00000000000..eac74562092 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/update-bucket.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +Bucket result = await storage.UpdateBucket( + bucketId: "[BUCKET_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/storage/update-file.md b/docs/examples/1.3.x/server-dotnet/examples/storage/update-file.md new file mode 100644 index 00000000000..c51d335eef2 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/storage/update-file.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +File result = await storage.UpdateFile( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/create-membership.md b/docs/examples/1.3.x/server-dotnet/examples/teams/create-membership.md new file mode 100644 index 00000000000..bcc331724e4 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/create-membership.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +Membership result = await teams.CreateMembership( + teamId: "[TEAM_ID]", + roles: new List {}, + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/create.md b/docs/examples/1.3.x/server-dotnet/examples/teams/create.md new file mode 100644 index 00000000000..fa34098cb25 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/create.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +Team result = await teams.Create( + teamId: "[TEAM_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/delete-membership.md b/docs/examples/1.3.x/server-dotnet/examples/teams/delete-membership.md new file mode 100644 index 00000000000..e3c7562f998 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/delete-membership.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +await teams.DeleteMembership( + teamId: "[TEAM_ID]", + membershipId: "[MEMBERSHIP_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/delete.md b/docs/examples/1.3.x/server-dotnet/examples/teams/delete.md new file mode 100644 index 00000000000..8229839b1cf --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/delete.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +await teams.Delete( + teamId: "[TEAM_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/get-membership.md b/docs/examples/1.3.x/server-dotnet/examples/teams/get-membership.md new file mode 100644 index 00000000000..108dbadbe04 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/get-membership.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +Membership result = await teams.GetMembership( + teamId: "[TEAM_ID]", + membershipId: "[MEMBERSHIP_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/get-prefs.md b/docs/examples/1.3.x/server-dotnet/examples/teams/get-prefs.md new file mode 100644 index 00000000000..08be12ba836 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/get-prefs.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var teams = new Teams(client); + +Preferences result = await teams.GetPrefs( + teamId: "[TEAM_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/get.md b/docs/examples/1.3.x/server-dotnet/examples/teams/get.md new file mode 100644 index 00000000000..f6c92a007b1 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/get.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +Team result = await teams.Get( + teamId: "[TEAM_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/list-memberships.md b/docs/examples/1.3.x/server-dotnet/examples/teams/list-memberships.md new file mode 100644 index 00000000000..145376cfb9d --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/list-memberships.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +MembershipList result = await teams.ListMemberships( + teamId: "[TEAM_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/list.md b/docs/examples/1.3.x/server-dotnet/examples/teams/list.md new file mode 100644 index 00000000000..1acf615039f --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/list.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +TeamList result = await teams.List(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/update-membership-roles.md b/docs/examples/1.3.x/server-dotnet/examples/teams/update-membership-roles.md new file mode 100644 index 00000000000..5f9db4401f3 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/update-membership-roles.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +Membership result = await teams.UpdateMembershipRoles( + teamId: "[TEAM_ID]", + membershipId: "[MEMBERSHIP_ID]", + roles: new List {}); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/update-membership-status.md b/docs/examples/1.3.x/server-dotnet/examples/teams/update-membership-status.md new file mode 100644 index 00000000000..bb377203ccb --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/update-membership-status.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var teams = new Teams(client); + +Membership result = await teams.UpdateMembershipStatus( + teamId: "[TEAM_ID]", + membershipId: "[MEMBERSHIP_ID]", + userId: "[USER_ID]", + secret: "[SECRET]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/update-name.md b/docs/examples/1.3.x/server-dotnet/examples/teams/update-name.md new file mode 100644 index 00000000000..12867304375 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/update-name.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +Team result = await teams.UpdateName( + teamId: "[TEAM_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/teams/update-prefs.md b/docs/examples/1.3.x/server-dotnet/examples/teams/update-prefs.md new file mode 100644 index 00000000000..3dfc0a3fc1a --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/teams/update-prefs.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var teams = new Teams(client); + +Preferences result = await teams.UpdatePrefs( + teamId: "[TEAM_ID]", + prefs: [object]); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/create-argon2user.md b/docs/examples/1.3.x/server-dotnet/examples/users/create-argon2user.md new file mode 100644 index 00000000000..6038594547b --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/create-argon2user.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateArgon2User( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/create-bcrypt-user.md b/docs/examples/1.3.x/server-dotnet/examples/users/create-bcrypt-user.md new file mode 100644 index 00000000000..954e1ad1cca --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/create-bcrypt-user.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateBcryptUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/create-m-d5user.md b/docs/examples/1.3.x/server-dotnet/examples/users/create-m-d5user.md new file mode 100644 index 00000000000..de54ee98fec --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/create-m-d5user.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateMD5User( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/create-p-h-pass-user.md b/docs/examples/1.3.x/server-dotnet/examples/users/create-p-h-pass-user.md new file mode 100644 index 00000000000..e8ede042daf --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/create-p-h-pass-user.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreatePHPassUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/create-s-h-a-user.md b/docs/examples/1.3.x/server-dotnet/examples/users/create-s-h-a-user.md new file mode 100644 index 00000000000..f3816196514 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/create-s-h-a-user.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateSHAUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/create-scrypt-modified-user.md b/docs/examples/1.3.x/server-dotnet/examples/users/create-scrypt-modified-user.md new file mode 100644 index 00000000000..c16cfe97f95 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/create-scrypt-modified-user.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateScryptModifiedUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password", + passwordSalt: "[PASSWORD_SALT]", + passwordSaltSeparator: "[PASSWORD_SALT_SEPARATOR]", + passwordSignerKey: "[PASSWORD_SIGNER_KEY]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/create-scrypt-user.md b/docs/examples/1.3.x/server-dotnet/examples/users/create-scrypt-user.md new file mode 100644 index 00000000000..1d6e60dd2d2 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/create-scrypt-user.md @@ -0,0 +1,20 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateScryptUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password", + passwordSalt: "[PASSWORD_SALT]", + passwordCpu: 0, + passwordMemory: 0, + passwordParallel: 0, + passwordLength: 0); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/create.md b/docs/examples/1.3.x/server-dotnet/examples/users/create.md new file mode 100644 index 00000000000..0a8421a5448 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/create.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.Create( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/delete-session.md b/docs/examples/1.3.x/server-dotnet/examples/users/delete-session.md new file mode 100644 index 00000000000..841bd456c85 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/delete-session.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +await users.DeleteSession( + userId: "[USER_ID]", + sessionId: "[SESSION_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/delete-sessions.md b/docs/examples/1.3.x/server-dotnet/examples/users/delete-sessions.md new file mode 100644 index 00000000000..8ff8f765228 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/delete-sessions.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +await users.DeleteSessions( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/delete.md b/docs/examples/1.3.x/server-dotnet/examples/users/delete.md new file mode 100644 index 00000000000..7833a7950fd --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/delete.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +await users.Delete( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/get-prefs.md b/docs/examples/1.3.x/server-dotnet/examples/users/get-prefs.md new file mode 100644 index 00000000000..c19f5e07786 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/get-prefs.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +Preferences result = await users.GetPrefs( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/get.md b/docs/examples/1.3.x/server-dotnet/examples/users/get.md new file mode 100644 index 00000000000..9c315e60210 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/get.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.Get( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/list-logs.md b/docs/examples/1.3.x/server-dotnet/examples/users/list-logs.md new file mode 100644 index 00000000000..277addcd25e --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/list-logs.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +LogList result = await users.ListLogs( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/list-memberships.md b/docs/examples/1.3.x/server-dotnet/examples/users/list-memberships.md new file mode 100644 index 00000000000..c25d98b41d2 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/list-memberships.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +MembershipList result = await users.ListMemberships( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/list-sessions.md b/docs/examples/1.3.x/server-dotnet/examples/users/list-sessions.md new file mode 100644 index 00000000000..fcd87f01ad5 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/list-sessions.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +SessionList result = await users.ListSessions( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/list.md b/docs/examples/1.3.x/server-dotnet/examples/users/list.md new file mode 100644 index 00000000000..9cb177b6923 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/list.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +UserList result = await users.List(); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/update-email-verification.md b/docs/examples/1.3.x/server-dotnet/examples/users/update-email-verification.md new file mode 100644 index 00000000000..2b7a5b86748 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/update-email-verification.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdateEmailVerification( + userId: "[USER_ID]", + emailVerification: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/update-email.md b/docs/examples/1.3.x/server-dotnet/examples/users/update-email.md new file mode 100644 index 00000000000..0d371b13fc0 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/update-email.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdateEmail( + userId: "[USER_ID]", + email: "email@example.com"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/update-name.md b/docs/examples/1.3.x/server-dotnet/examples/users/update-name.md new file mode 100644 index 00000000000..f846543117c --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/update-name.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdateName( + userId: "[USER_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/update-password.md b/docs/examples/1.3.x/server-dotnet/examples/users/update-password.md new file mode 100644 index 00000000000..ce3241dfd5d --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/update-password.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdatePassword( + userId: "[USER_ID]", + password: ""); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/update-phone-verification.md b/docs/examples/1.3.x/server-dotnet/examples/users/update-phone-verification.md new file mode 100644 index 00000000000..c2fd1673de4 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/update-phone-verification.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdatePhoneVerification( + userId: "[USER_ID]", + phoneVerification: false); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/update-phone.md b/docs/examples/1.3.x/server-dotnet/examples/users/update-phone.md new file mode 100644 index 00000000000..90728d76c70 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/update-phone.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdatePhone( + userId: "[USER_ID]", + number: "+12065550100"); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/update-prefs.md b/docs/examples/1.3.x/server-dotnet/examples/users/update-prefs.md new file mode 100644 index 00000000000..a39d54565a1 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/update-prefs.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +Preferences result = await users.UpdatePrefs( + userId: "[USER_ID]", + prefs: [object]); \ No newline at end of file diff --git a/docs/examples/1.3.x/server-dotnet/examples/users/update-status.md b/docs/examples/1.3.x/server-dotnet/examples/users/update-status.md new file mode 100644 index 00000000000..713ece02ba5 --- /dev/null +++ b/docs/examples/1.3.x/server-dotnet/examples/users/update-status.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Services; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdateStatus( + userId: "[USER_ID]", + status: false); \ No newline at end of file diff --git a/docs/references/account/create-magic-url-session.md b/docs/references/account/create-magic-url-session.md index 03383713ed1..b1e63e144c3 100644 --- a/docs/references/account/create-magic-url-session.md +++ b/docs/references/account/create-magic-url-session.md @@ -1,3 +1,3 @@ -Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default. +Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default. -A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication-security#limits). \ No newline at end of file +A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication-security#limits). diff --git a/docs/references/account/delete-session.md b/docs/references/account/delete-session.md index cd1f22f6272..c7439638af7 100644 --- a/docs/references/account/delete-session.md +++ b/docs/references/account/delete-session.md @@ -1 +1 @@ -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 Session ID argument, only the unique session ID provided is deleted. +Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](/docs/client/account#accountDeleteSessions) instead. \ No newline at end of file diff --git a/docs/sdks/dotnet/GETTING_STARTED.md b/docs/sdks/dotnet/GETTING_STARTED.md index 23bab6f70a7..08d7742dd09 100644 --- a/docs/sdks/dotnet/GETTING_STARTED.md +++ b/docs/sdks/dotnet/GETTING_STARTED.md @@ -1,44 +1,46 @@ ## Getting Started ### Initialize & Make API Request -Once you add the dependencies, its extremely easy to get started with the SDK; All you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example: +Once you have installed the package, it is extremely easy to get started with the SDK; all you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example: ```csharp using Appwrite; +using Appwrite.Services; +using Appwrite.Models; -static async Task Main(string[] args) -{ - var client = Client(); +var client = new Client() + .SetEndpoint("http://cloud.appwrite.io/v1") + .SetProject("5ff3379a01d25") // Your project ID + .SetKey("cd868db89"); // Your secret API key - client - .setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible - .setProject('5ff3379a01d25') // Your project ID - .setKey('cd868c7af8bdc893b4...93b7535db89') - .setSelfSigned() // Use only on dev mode with a self-signed SSL cert - ; +var users = new Users(client); - var users = Users(client); +var user = await users.Create( + userId: ID.Unique(), + email: "email@example.com", + password: "password", + name: "name"); - try { - var user = await users.Create(ID.Unique(), 'email@example.com', 'password', 'name'); - Console.WriteLine(user.ToMap()); - } catch (AppwriteException e) { - Console.WriteLine(e.Message); - } -} +Console.WriteLine(user.ToMap()); ``` ### Error Handling -The Appwrite .NET SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example. +The Appwrite .NET SDK raises an `AppwriteException` object with `message`, `code`, and `response` properties. You can handle any errors by catching `AppwriteException` and presenting the `message` to the user or handling it yourself based on the provided error information. Below is an example. ```csharp -var users = Users(client); +var users = new Users(client); -try { - var user = await users.Create(ID.Unique(), 'email@example.com', 'password', 'name'); - Console.WriteLine(user.ToMap()); -} catch (AppwriteException e) { - Console.WriteLine(e.Message); +try +{ + var user = await users.Create( + userId: ID.Unique(), + email: "email@example.com", + password: "password", + name: "name"); +} +catch (AppwriteException e) +{ + Console.WriteLine(e.Message); } ``` @@ -47,4 +49,4 @@ You can use the following resources to learn more and get help - 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) - 📜 [Appwrite Docs](https://appwrite.io/docs) - 💬 [Discord Community](https://appwrite.io/discord) -- 🚂 [Appwrite Dart Playground](https://github.com/appwrite/playground-for-dotnet) +- 🚂 [Appwrite .NET Playground](https://github.com/appwrite/playground-for-dotnet) diff --git a/docs/sdks/flutter/GETTING_STARTED.md b/docs/sdks/flutter/GETTING_STARTED.md index b9b8dc3a47b..110ee3eb4ad 100644 --- a/docs/sdks/flutter/GETTING_STARTED.md +++ b/docs/sdks/flutter/GETTING_STARTED.md @@ -46,6 +46,8 @@ For **Linux** add your app name and package name, Your package nam ### Mac OS For **Mac OS** add your app name and Bundle ID, You can find your Bundle Identifier in the General tab for your app's primary target in Xcode. +The Appwrite SDK uses ASWebAuthenticationSession on macOS 10.15+ to allow OAuth authentication. You have to change your macOS Deployment Target in Xcode to be macOS >= 10.15 to be able to build your app for macOS. + ### Web Appwrite 0.7, and the Appwrite Flutter SDK 0.3.0 have added support for Flutter Web. To build web apps that integrate with Appwrite successfully, all you have to do is add a web platform on your Appwrite project's dashboard and list the domain your website will use to allow communication to the Appwrite API. diff --git a/public/images/integrations/akamai-logo.svg b/public/images/integrations/akamai-logo.svg new file mode 100644 index 00000000000..cdcf31b4c2d --- /dev/null +++ b/public/images/integrations/akamai-logo.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/Appwrite/Auth/OAuth2/Oidc.php b/src/Appwrite/Auth/OAuth2/Oidc.php new file mode 100644 index 00000000000..de2eab65c8d --- /dev/null +++ b/src/Appwrite/Auth/OAuth2/Oidc.php @@ -0,0 +1,296 @@ +getAuthorizationEndpoint() . '?' . \http_build_query([ + 'client_id' => $this->appID, + 'redirect_uri' => $this->callback, + 'state' => \json_encode($this->state), + 'scope' => \implode(' ', $this->getScopes()), + 'response_type' => 'code', + ]); + } + + /** + * @param string $code + * + * @return array + */ + protected function getTokens(string $code): array + { + if (empty($this->tokens)) { + $headers = ['Content-Type: application/x-www-form-urlencoded']; + $this->tokens = \json_decode($this->request( + 'POST', + $this->getTokenEndpoint(), + $headers, + \http_build_query([ + 'code' => $code, + 'client_id' => $this->appID, + 'client_secret' => $this->getClientSecret(), + 'redirect_uri' => $this->callback, + 'scope' => \implode(' ', $this->getScopes()), + 'grant_type' => 'authorization_code' + ]) + ), true); + } + return $this->tokens; + } + + + /** + * @param string $refreshToken + * + * @return array + */ + public function refreshTokens(string $refreshToken): array + { + $headers = ['Content-Type: application/x-www-form-urlencoded']; + $this->tokens = \json_decode($this->request( + 'POST', + $this->getTokenEndpoint(), + $headers, + \http_build_query([ + 'refresh_token' => $refreshToken, + 'client_id' => $this->appID, + 'client_secret' => $this->getClientSecret(), + 'grant_type' => 'refresh_token' + ]) + ), true); + + if (empty($this->tokens['refresh_token'])) { + $this->tokens['refresh_token'] = $refreshToken; + } + + return $this->tokens; + } + + /** + * @param string $accessToken + * + * @return string + */ + public function getUserID(string $accessToken): string + { + $user = $this->getUser($accessToken); + + if (isset($user['sub'])) { + return $user['sub']; + } + + return ''; + } + + /** + * @param string $accessToken + * + * @return string + */ + public function getUserEmail(string $accessToken): string + { + $user = $this->getUser($accessToken); + + if (isset($user['email'])) { + return $user['email']; + } + + return ''; + } + + /** + * Check if the User email is verified + * + * @param string $accessToken + * + * @return bool + */ + public function isEmailVerified(string $accessToken): bool + { + $user = $this->getUser($accessToken); + + return $user['email_verified'] ?? false; + } + + /** + * @param string $accessToken + * + * @return string + */ + public function getUserName(string $accessToken): string + { + $user = $this->getUser($accessToken); + + if (isset($user['name'])) { + return $user['name']; + } + + return ''; + } + + /** + * @param string $accessToken + * + * @return array + */ + protected function getUser(string $accessToken): array + { + if (empty($this->user)) { + $headers = ['Authorization: Bearer ' . \urlencode($accessToken)]; + $user = $this->request('GET', $this->getUserinfoEndpoint(), $headers); + $this->user = \json_decode($user, true); + } + + return $this->user; + } + + /** + * Extracts the Client Secret from the JSON stored in appSecret + * + * @return string + */ + protected function getClientSecret(): string + { + $secret = $this->getAppSecret(); + + return $secret['clientSecret'] ?? ''; + } + + /** + * Extracts the well known endpoint from the JSON stored in appSecret. + * + * @return string + */ + protected function getWellKnownEndpoint(): string + { + $secret = $this->getAppSecret(); + return $secret['wellKnownEndpoint'] ?? ''; + } + + /** + * Extracts the authorization endpoint from the JSON stored in appSecret. + * + * If one is not provided, it will be retrieved from the well-known configuration. + * + * @return string + */ + protected function getAuthorizationEndpoint(): string + { + $secret = $this->getAppSecret(); + + $endpoint = $secret['authorizationEndpoint'] ?? ''; + if (!empty($endpoint)) { + return $endpoint; + } + + $wellKnownConfiguration = $this->getWellKnownConfiguration(); + return $wellKnownConfiguration['authorization_endpoint'] ?? ''; + } + + /** + * Extracts the token endpoint from the JSON stored in appSecret. + * + * If one is not provided, it will be retrieved from the well-known configuration. + * + * @return string + */ + protected function getTokenEndpoint(): string + { + $secret = $this->getAppSecret(); + + $endpoint = $secret['tokenEndpoint'] ?? ''; + if (!empty($endpoint)) { + return $endpoint; + } + + $wellKnownConfiguration = $this->getWellKnownConfiguration(); + return $wellKnownConfiguration['token_endpoint'] ?? ''; + } + + /** + * Extracts the userinfo endpoint from the JSON stored in appSecret. + * + * If one is not provided, it will be retrieved from the well-known configuration. + * + * @return string + */ + protected function getUserinfoEndpoint(): string + { + $secret = $this->getAppSecret(); + $endpoint = $secret['userinfoEndpoint'] ?? ''; + if (!empty($endpoint)) { + return $endpoint; + } + + $wellKnownConfiguration = $this->getWellKnownConfiguration(); + return $wellKnownConfiguration['userinfo_endpoint'] ?? ''; + } + + /** + * Get the well-known configuration using the well known endpoint + */ + protected function getWellKnownConfiguration(): array + { + if (empty($this->wellKnownConfiguration)) { + $response = $this->request('GET', $this->getWellKnownEndpoint()); + $this->wellKnownConfiguration = \json_decode($response, true); + } + + return $this->wellKnownConfiguration; + } + + /** + * Decode the JSON stored in appSecret + * + * @return array + */ + protected function getAppSecret(): array + { + try { + $secret = \json_decode($this->appSecret, true, 512, JSON_THROW_ON_ERROR); + } catch (\Throwable $th) { + throw new \Exception('Invalid secret'); + } + return $secret; + } +} diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 05caa75c633..ca896a60b5a 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -83,6 +83,7 @@ class Exception extends \Exception public const TEAM_INVALID_SECRET = 'team_invalid_secret'; public const TEAM_MEMBERSHIP_MISMATCH = 'team_membership_mismatch'; public const TEAM_INVITE_MISMATCH = 'team_invite_mismatch'; + public const TEAM_ALREADY_EXISTS = 'team_already_exists'; /** Membership */ public const MEMBERSHIP_NOT_FOUND = 'membership_not_found'; @@ -135,6 +136,7 @@ class Exception extends \Exception /** Documents */ public const DOCUMENT_NOT_FOUND = 'document_not_found'; public const DOCUMENT_INVALID_STRUCTURE = 'document_invalid_structure'; + public const DOCUMENT_MISSING_DATA = 'document_missing_data'; public const DOCUMENT_MISSING_PAYLOAD = 'document_missing_payload'; public const DOCUMENT_ALREADY_EXISTS = 'document_already_exists'; public const DOCUMENT_UPDATE_CONFLICT = 'document_update_conflict'; @@ -161,6 +163,7 @@ class Exception extends \Exception public const PROJECT_UNKNOWN = 'project_unknown'; public const PROJECT_PROVIDER_DISABLED = 'project_provider_disabled'; public const PROJECT_PROVIDER_UNSUPPORTED = 'project_provider_unsupported'; + public const PROJECT_ALREADY_EXISTS = 'project_already_exists'; public const PROJECT_INVALID_SUCCESS_URL = 'project_invalid_success_url'; public const PROJECT_INVALID_FAILURE_URL = 'project_invalid_failure_url'; public const PROJECT_RESERVED_PROJECT = 'project_reserved_project'; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 397d41efdd3..ffb5ce6ac4c 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -60,6 +60,10 @@ abstract class Migration '1.3.2' => 'V18', '1.3.3' => 'V18', '1.3.4' => 'V18', + '1.3.5' => 'V18', + '1.3.6' => 'V18', + '1.3.7' => 'V18', + '1.3.8' => 'V18', ]; /** diff --git a/src/Appwrite/Migration/Version/V18.php b/src/Appwrite/Migration/Version/V18.php index be628e0fbb6..839269f9407 100644 --- a/src/Appwrite/Migration/Version/V18.php +++ b/src/Appwrite/Migration/Version/V18.php @@ -133,6 +133,16 @@ private function migrateCollections(): void Console::warning("'options' from {$id}: {$th->getMessage()}"); } break; + case 'audit': + try { + /** + * Delete 'userInternalId' attribute + */ + $this->projectDB->deleteAttribute($id, 'userInternalId'); + } catch (\Throwable $th) { + Console::warning("'userInternalId' from {$id}: {$th->getMessage()}"); + } + break; default: break; } @@ -195,6 +205,34 @@ protected function fixDocument(Document $document): Document Console::warning($th->getMessage()); } break; + case 'audit': + /** + * Set the userId to the userInternalId and add userId to data + */ + try { + $userId = $document->getAttribute('userId'); + $data = $document->getAttribute('data', []); + $mode = $data['mode'] ?? 'default'; + $user = match ($mode) { + 'admin' => $this->consoleDB->getDocument('users', $userId), + default => $this->projectDB->getDocument('users', $userId), + }; + + if ($user->isEmpty()) { + // The audit userId could already be an internal Id. + // Otherwise, the user could have been deleted. + // Nonetheless, there's nothing else we can do here. + break; + } + $internalId = $user->getInternalId(); + $document->setAttribute('userId', $internalId); + $data = $document->getAttribute('data', []); + $data['userId'] = $user->getId(); + $document->setAttribute('data', $data); + } catch (\Throwable $th) { + Console::warning($th->getMessage()); + } + break; } return $document; diff --git a/src/Appwrite/Utopia/Response/Model/Database.php b/src/Appwrite/Utopia/Response/Model/Database.php index 9d9a4b2762d..bd9ae4625ce 100644 --- a/src/Appwrite/Utopia/Response/Model/Database.php +++ b/src/Appwrite/Utopia/Response/Model/Database.php @@ -34,6 +34,12 @@ public function __construct() 'default' => '', 'example' => self::TYPE_DATETIME_EXAMPLE, ]) + ->addRule('enabled', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Database enabled.', + 'default' => true, + 'example' => false, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index 6fbc794698d..ed41c250fcc 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -136,7 +136,7 @@ public function __construct() 'type' => Response::MODEL_PROVIDER, 'description' => 'List of Providers.', 'default' => [], - 'example' => new \stdClass(), + 'example' => [new \stdClass()], 'array' => true, ]) ->addRule('platforms', [ @@ -273,7 +273,8 @@ public function filter(Document $document): Document } $projectProviders[] = new Document([ - 'name' => ucfirst($key), + 'key' => $key, + 'name' => $provider['name'] ?? '', 'appId' => $providerValues[$key . 'Appid'] ?? '', 'secret' => $providerValues[$key . 'Secret'] ?? '', 'enabled' => $providerValues[$key . 'Enabled'] ?? false, diff --git a/src/Appwrite/Utopia/Response/Model/Provider.php b/src/Appwrite/Utopia/Response/Model/Provider.php index 0f149935083..c589011a46e 100644 --- a/src/Appwrite/Utopia/Response/Model/Provider.php +++ b/src/Appwrite/Utopia/Response/Model/Provider.php @@ -15,6 +15,12 @@ class Provider extends Model public function __construct() { $this + ->addRule('key', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider.', + 'default' => '', + 'example' => 'github', + ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Provider name.', diff --git a/tests/e2e/Client.php b/tests/e2e/Client.php index e98472b2b83..21e4ccc958b 100644 --- a/tests/e2e/Client.php +++ b/tests/e2e/Client.php @@ -160,35 +160,21 @@ public function addHeader(string $key, string $value): self * @param array $params * @param array $headers * @param bool $decode - * @return array|string + * @return array * @throws Exception */ - public function call(string $method, string $path = '', array $headers = [], array $params = [], bool $decode = true) + public function call(string $method, string $path = '', array $headers = [], array $params = [], bool $decode = true): 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; - - case 'application/graphql': - $query = $params[0]; - break; - - default: - $query = http_build_query($params); - break; - } + + $query = match ($headers['content-type']) { + 'application/json' => json_encode($params), + 'multipart/form-data' => $this->flatten($params), + 'application/graphql' => $params[0], + default => http_build_query($params), + }; foreach ($headers as $i => $header) { $headers[] = $i . ':' . $header; @@ -220,7 +206,7 @@ public function call(string $method, string $path = '', array $headers = [], arr curl_setopt($ch, CURLOPT_POSTFIELDS, $query); } - // Allow self signed certificates + // Allow self-signed certificates if ($this->selfSigned) { curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); @@ -230,22 +216,18 @@ public function call(string $method, string $path = '', array $headers = [], arr $responseType = $responseHeaders['content-type'] ?? ''; $responseStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); - if ($decode) { - switch (substr($responseType, 0, strpos($responseType, ';'))) { - case 'application/json': - $json = json_decode($responseBody, true); + if ($decode && substr($responseType, 0, strpos($responseType, ';')) == 'application/json') { + $json = json_decode($responseBody, true); - if ($json === null) { - throw new Exception('Failed to parse response: ' . $responseBody); - } - - $responseBody = $json; - $json = null; - break; + if ($json === null) { + throw new Exception('Failed to parse response: ' . $responseBody); } + + $responseBody = $json; + $json = null; } - if ((curl_errno($ch)/* || 200 != $responseStatus*/)) { + if ((curl_errno($ch))) { throw new Exception(curl_error($ch) . ' with status code ' . $responseStatus, $responseStatus); } @@ -273,7 +255,7 @@ public function parseCookie(string $cookie): array { $cookies = []; - parse_str(strtr($cookie, array('&' => '%26', '+' => '%2B', ';' => '&')), $cookies); + parse_str(strtr($cookie, ['&' => '%26', '+' => '%2B', ';' => '&']), $cookies); return $cookies; } diff --git a/tests/e2e/General/HTTPTest.php b/tests/e2e/General/HTTPTest.php index f033cd6d42f..087b984f9d2 100644 --- a/tests/e2e/General/HTTPTest.php +++ b/tests/e2e/General/HTTPTest.php @@ -12,6 +12,12 @@ class HTTPTest extends Scope use ProjectNone; use SideNone; + public function setUp(): void + { + parent::setUp(); + $this->client->setEndpoint('http://localhost'); + } + public function testOptions() { /** @@ -32,24 +38,6 @@ public function testOptions() $this->assertEmpty($response['body']); } - public function testError() - { - /** - * Test for SUCCESS - */ - $this->markTestIncomplete('This test needs to be updated for the new console.'); - // $response = $this->client->call(Client::METHOD_GET, '/error', \array_merge([ - // 'origin' => 'http://localhost', - // 'content-type' => 'application/json', - // ]), []); - - // $this->assertEquals(404, $response['headers']['status-code']); - // $this->assertEquals('Not Found', $response['body']['message']); - // $this->assertEquals(Exception::GENERAL_ROUTE_NOT_FOUND, $response['body']['type']); - // $this->assertEquals(404, $response['body']['code']); - // $this->assertEquals('dev', $response['body']['version']); - } - public function testHumans() { /** @@ -57,7 +45,7 @@ public function testHumans() */ $response = $this->client->call(Client::METHOD_GET, '/humans.txt', \array_merge([ 'origin' => 'http://localhost', - ]), []); + ])); $this->assertEquals(200, $response['headers']['status-code']); $this->assertStringContainsString('# humanstxt.org/', $response['body']); @@ -70,7 +58,7 @@ public function testRobots() */ $response = $this->client->call(Client::METHOD_GET, '/robots.txt', \array_merge([ 'origin' => 'http://localhost', - ]), []); + ])); $this->assertEquals(200, $response['headers']['status-code']); $this->assertStringContainsString('# robotstxt.org/', $response['body']); @@ -87,18 +75,19 @@ public function testAcmeChallenge() */ $response = $this->client->call(Client::METHOD_GET, '/.well-known/acme-challenge/8DdIKX257k6Dih5s_saeVMpTnjPJdKO5Ase0OCiJrIg', \array_merge([ 'origin' => 'http://localhost', - ]), []); + ])); - $this->assertEquals(404, $response['headers']['status-code']); // 'Unknown path', but validation passed + $this->assertEquals(404, $response['headers']['status-code']); /** * Test for FAILURE */ $response = $this->client->call(Client::METHOD_GET, '/.well-known/acme-challenge/../../../../../../../etc/passwd', \array_merge([ 'origin' => 'http://localhost', - ]), []); + ])); + // Check for too many path segments $this->assertEquals(400, $response['headers']['status-code']); // Cleanup @@ -171,4 +160,15 @@ public function testVersions() $this->assertIsString($body['server-ruby']); $this->assertIsString($body['console-cli']); } + + public function testDefaultOAuth2() + { + $response = $this->client->call(Client::METHOD_GET, '/auth/oauth2/success', $this->getHeaders()); + + $this->assertEquals(200, $response['headers']['status-code']); + + $response = $this->client->call(Client::METHOD_GET, '/auth/oauth2/failure', $this->getHeaders()); + + $this->assertEquals(200, $response['headers']['status-code']); + } } diff --git a/tests/e2e/Scopes/Scope.php b/tests/e2e/Scopes/Scope.php index 42057e8e945..14eb83897bd 100644 --- a/tests/e2e/Scopes/Scope.php +++ b/tests/e2e/Scopes/Scope.php @@ -17,10 +17,7 @@ abstract class Scope extends TestCase protected function setUp(): void { $this->client = new Client(); - - $this->client - ->setEndpoint($this->endpoint) - ; + $this->client->setEndpoint($this->endpoint); } protected function tearDown(): void @@ -45,10 +42,10 @@ protected function getLastRequest(): array { sleep(2); - $resquest = json_decode(file_get_contents('http://request-catcher:5000/__last_request__'), true); - $resquest['data'] = json_decode($resquest['data'], true); + $request = json_decode(file_get_contents('http://request-catcher:5000/__last_request__'), true); + $request['data'] = json_decode($request['data'], true); - return $resquest; + return $request; } /** diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index ba751516d36..f6d10653d83 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -308,6 +308,7 @@ public function testGetAccountSessions($data): array $this->assertEquals(true, $response['body']['sessions'][0]['current']); + $this->assertNotFalse(\DateTime::createFromFormat('Y-m-d\TH:i:s.uP', $response['body']['sessions'][0]['expire'])); /** * Test for FAILURE */ @@ -1295,7 +1296,7 @@ public function testCreateMagicUrl(): array $token = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256); - $expireTime = strpos($lastEmail['text'], 'expire=' . urlencode(DateTime::format(new \DateTime($response['body']['expire']))), 0); + $expireTime = strpos($lastEmail['text'], 'expire=' . urlencode($response['body']['expire']), 0); $this->assertNotFalse($expireTime); diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index 6f75a998c17..6e9d2b6dbb4 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -225,6 +225,8 @@ public function testSelfBlockedAccount(): array ]); $this->assertEquals($response['headers']['status-code'], 200); + $this->assertStringContainsString('a_session_' . $this->getProject()['$id'] . '=deleted', $response['headers']['set-cookie']); + $this->assertEquals('[]', $response['headers']['x-fallback-cookies']); $response = $this->client->call(Client::METHOD_GET, '/account', array_merge([ 'origin' => 'http://localhost', @@ -492,6 +494,18 @@ public function testConvertAnonymousAccount() 'password' => $password, ]); + $this->assertEquals($response['headers']['status-code'], 201); + + $response = $this->client->call(Client::METHOD_POST, '/account/verification', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, + ]), [ + 'url' => 'http://localhost' + ]); + + $this->assertEquals($response['headers']['status-code'], 201); return []; diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 0648db849e6..144adfb9891 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -157,6 +157,7 @@ public function testDisableCollection(array $data): void public function testCreateAttributes(array $data): array { $databaseId = $data['databaseId']; + $title = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/attributes/string', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -167,6 +168,17 @@ public function testCreateAttributes(array $data): array 'required' => true, ]); + $description = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/attributes/string', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'key' => 'description', + 'size' => 256, + 'required' => false, + 'default' => '', + ]); + $releaseYear = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/attributes/integer', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -226,6 +238,13 @@ public function testCreateAttributes(array $data): array $this->assertEquals($title['body']['size'], 256); $this->assertEquals($title['body']['required'], true); + $this->assertEquals(202, $description['headers']['status-code']); + $this->assertEquals($description['body']['key'], 'description'); + $this->assertEquals($description['body']['type'], 'string'); + $this->assertEquals($description['body']['size'], 256); + $this->assertEquals($description['body']['required'], false); + $this->assertEquals($description['body']['default'], ''); + $this->assertEquals(202, $releaseYear['headers']['status-code']); $this->assertEquals($releaseYear['body']['key'], 'releaseYear'); $this->assertEquals($releaseYear['body']['type'], 'integer'); @@ -266,13 +285,14 @@ public function testCreateAttributes(array $data): array ]), []); $this->assertIsArray($movies['body']['attributes']); - $this->assertCount(6, $movies['body']['attributes']); + $this->assertCount(7, $movies['body']['attributes']); $this->assertEquals($movies['body']['attributes'][0]['key'], $title['body']['key']); - $this->assertEquals($movies['body']['attributes'][1]['key'], $releaseYear['body']['key']); - $this->assertEquals($movies['body']['attributes'][2]['key'], $duration['body']['key']); - $this->assertEquals($movies['body']['attributes'][3]['key'], $actors['body']['key']); - $this->assertEquals($movies['body']['attributes'][4]['key'], $datetime['body']['key']); - $this->assertEquals($movies['body']['attributes'][5]['key'], $relationship['body']['key']); + $this->assertEquals($movies['body']['attributes'][1]['key'], $description['body']['key']); + $this->assertEquals($movies['body']['attributes'][2]['key'], $releaseYear['body']['key']); + $this->assertEquals($movies['body']['attributes'][3]['key'], $duration['body']['key']); + $this->assertEquals($movies['body']['attributes'][4]['key'], $actors['body']['key']); + $this->assertEquals($movies['body']['attributes'][5]['key'], $datetime['body']['key']); + $this->assertEquals($movies['body']['attributes'][6]['key'], $relationship['body']['key']); return $data; } @@ -1086,6 +1106,12 @@ public function testCreateDocument(array $data): array $this->assertEquals(400, $document4['headers']['status-code']); + // Delete document 4 with incomplete path + $this->assertEquals(404, $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()))['headers']['status-code']); + return $data; } @@ -3047,7 +3073,7 @@ public function testUpdatePermissionsWithEmptyPayload(): array $databaseId = $database['body']['$id']; // Create collection - $movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/', array_merge([ + $movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'] diff --git a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php index ad97a2bb3e7..13d28df5f35 100644 --- a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php @@ -20,13 +20,13 @@ public function testCreateCollection(): array $database = $this->client->call(Client::METHOD_POST, '/databases', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ]), [ + ], $this->getHeaders()), [ 'databaseId' => ID::unique(), 'name' => 'invalidDocumentDatabase', ]); $this->assertEquals(201, $database['headers']['status-code']); $this->assertEquals('invalidDocumentDatabase', $database['body']['name']); + $this->assertTrue($database['body']['enabled']); $databaseId = $database['body']['$id']; /** @@ -50,7 +50,129 @@ public function testCreateCollection(): array $this->assertEquals(201, $movies['headers']['status-code']); $this->assertEquals($movies['body']['name'], 'Movies'); - return ['moviesId' => $movies['body']['$id'], 'databaseId' => $databaseId]; + /** + * Test When database is disabled but can still create collections + */ + $database = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'name' => 'invalidDocumentDatabase Updated', + 'enabled' => false, + ]); + + $this->assertFalse($database['body']['enabled']); + + $tvShows = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'collectionId' => ID::unique(), + 'name' => 'TvShows', + 'permissions' => [ + Permission::read(Role::any()), + Permission::create(Role::any()), + Permission::update(Role::any()), + Permission::delete(Role::any()), + ], + 'documentSecurity' => true, + ]); + + $this->assertEquals(201, $tvShows['headers']['status-code']); + $this->assertEquals($tvShows['body']['name'], 'TvShows'); + + return ['moviesId' => $movies['body']['$id'], 'databaseId' => $databaseId, 'tvShowsId' => $tvShows['body']['$id']]; + } + + /** + * @depends testCreateCollection + * @param array $data + */ + public function testListCollection(array $data) + { + /** + * Test When database is disabled but can still call list collections + */ + $databaseId = $data['databaseId']; + + $collections = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ], $this->getHeaders())); + + $this->assertEquals(200, $collections['headers']['status-code']); + $this->assertEquals(2, $collections['body']['total']); + } + + /** + * @depends testCreateCollection + * @param array $data + */ + public function testGetCollection(array $data) + { + $databaseId = $data['databaseId']; + $moviesCollectionId = $data['moviesId']; + + /** + * Test When database is disabled but can still call get collection + */ + $collection = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $moviesCollectionId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $collection['headers']['status-code']); + $this->assertEquals('Movies', $collection['body']['name']); + $this->assertEquals($moviesCollectionId, $collection['body']['$id']); + $this->assertTrue($collection['body']['enabled']); + } + + /** + * @depends testCreateCollection + * @param array $data + */ + public function testUpdateCollection(array $data) + { + $databaseId = $data['databaseId']; + $moviesCollectionId = $data['moviesId']; + + /** + * Test When database is disabled but can still call update collection + */ + $collection = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $moviesCollectionId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'name' => 'Movies Updated', + 'enabled' => false + ]); + + $this->assertEquals(200, $collection['headers']['status-code']); + $this->assertEquals('Movies Updated', $collection['body']['name']); + $this->assertEquals($moviesCollectionId, $collection['body']['$id']); + $this->assertFalse($collection['body']['enabled']); + } + + /** + * @depends testCreateCollection + * @param array $data + */ + public function testDeleteCollection(array $data) + { + $databaseId = $data['databaseId']; + $tvShowsId = $data['tvShowsId']; + + /** + * Test When database is disabled but can still call Delete collection + */ + $response = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $tvShowsId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(204, $response['headers']['status-code']); + $this->assertEquals($response['body'], ""); } /** diff --git a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php index de59723e53b..b0ab884a075 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php @@ -225,4 +225,95 @@ public function testUpdateWithoutPermission(): array return []; } + + public function testUpdateTwoWayRelationship(): void + { + + $database = $this->client->call(Client::METHOD_POST, '/databases', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ], [ + 'databaseId' => ID::unique(), + 'name' => 'Test Database' + ]); + + $databaseId = $database['body']['$id']; + + + // Creating collection 1 + $collection1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'collectionId' => ID::unique(), + 'name' => 'level1', + 'documentSecurity' => false, + 'permissions' => [ + Permission::create(Role::user($this->getUser()['$id'])), + Permission::read(Role::user($this->getUser()['$id'])), + Permission::update(Role::user($this->getUser()['$id'])), + Permission::delete(Role::user($this->getUser()['$id'])), + ] + ]); + + // Creating collection 2 + $collection2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'collectionId' => ID::unique(), + 'name' => 'level2', + 'documentSecurity' => false, + 'permissions' => [ + Permission::create(Role::user($this->getUser()['$id'])), + Permission::read(Role::user($this->getUser()['$id'])), + Permission::update(Role::user($this->getUser()['$id'])), + Permission::delete(Role::user($this->getUser()['$id'])), + ] + ]); + + \sleep(2); + + // Creating two way relationship between collection 1 and collection 2 from collection 1 + $relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collection1['body']['$id'] . '/attributes/relationship', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'relatedCollectionId' => $collection2['body']['$id'], + 'type' => 'oneToMany', + 'twoWay' => true, + 'onDelete' => 'cascade', + 'key' => $collection2['body']['$id'], + 'twoWayKey' => $collection1['body']['$id'] + ]); + + \sleep(3); + + // Update relation from collection 2 to on delete restrict + $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collection2['body']['$id'] . '/attributes/' . $collection1['body']['$id'] . '/relationship', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'onDelete' => 'restrict', + ]); + + // Fetching attributes after updating relation to compare + $collection1Attributes = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collection1['body']['$id'], [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]); + + $collection1RelationAttribute = $collection1Attributes['body']['attributes'][0]; + + $this->assertEquals($relation['body']['side'], $collection1RelationAttribute['side']); + $this->assertEquals($relation['body']['twoWayKey'], $collection1RelationAttribute['twoWayKey']); + $this->assertEquals($relation['body']['relatedCollection'], $collection1RelationAttribute['relatedCollection']); + $this->assertEquals('restrict', $collection1RelationAttribute['onDelete']); + } } diff --git a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php index ce6602c1763..5e734fbcb2e 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php @@ -27,6 +27,7 @@ public function testListDatabases() 'databaseId' => ID::custom('first'), 'name' => 'Test 1', ]); + $this->assertEquals(201, $test1['headers']['status-code']); $this->assertEquals('Test 1', $test1['body']['name']); @@ -56,7 +57,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'limit(1)' ], + 'queries' => ['limit(1)'], ]); $this->assertEquals(200, $databases['headers']['status-code']); $this->assertCount(1, $databases['body']['databases']); @@ -65,7 +66,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'offset(1)' ], + 'queries' => ['offset(1)'], ]); $this->assertEquals(200, $databases['headers']['status-code']); $this->assertCount(1, $databases['body']['databases']); @@ -74,7 +75,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'equal("name", ["Test 1", "Test 2"])' ], + 'queries' => ['equal("name", ["Test 1", "Test 2"])'], ]); $this->assertEquals(200, $databases['headers']['status-code']); $this->assertCount(2, $databases['body']['databases']); @@ -83,7 +84,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'equal("name", "Test 2")' ], + 'queries' => ['equal("name", "Test 2")'], ]); $this->assertEquals(200, $databases['headers']['status-code']); $this->assertCount(1, $databases['body']['databases']); @@ -92,7 +93,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'equal("$id", "first")' ], + 'queries' => ['equal("$id", "first")'], ]); $this->assertEquals(200, $databases['headers']['status-code']); $this->assertCount(1, $databases['body']['databases']); @@ -104,7 +105,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'orderDesc("")' ], + 'queries' => ['orderDesc("")'], ]); $this->assertEquals(2, $databases['body']['total']); @@ -123,7 +124,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorAfter("' . $base['body']['databases'][0]['$id'] . '")' ], + 'queries' => ['cursorAfter("' . $base['body']['databases'][0]['$id'] . '")'], ]); $this->assertCount(1, $databases['body']['databases']); @@ -133,7 +134,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorAfter("' . $base['body']['databases'][1]['$id'] . '")' ], + 'queries' => ['cursorAfter("' . $base['body']['databases'][1]['$id'] . '")'], ]); $this->assertCount(0, $databases['body']['databases']); @@ -151,7 +152,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorBefore("' . $base['body']['databases'][1]['$id'] . '")' ], + 'queries' => ['cursorBefore("' . $base['body']['databases'][1]['$id'] . '")'], ]); $this->assertCount(1, $databases['body']['databases']); @@ -161,7 +162,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorBefore("' . $base['body']['databases'][0]['$id'] . '")' ], + 'queries' => ['cursorBefore("' . $base['body']['databases'][0]['$id'] . '")'], ]); $this->assertCount(0, $databases['body']['databases']); @@ -207,7 +208,7 @@ public function testListDatabases() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorAfter("unknown")' ], + 'queries' => ['cursorAfter("unknown")'], ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -244,10 +245,44 @@ public function testGetDatabase(array $data): array $this->assertEquals(200, $database['headers']['status-code']); $this->assertEquals($databaseId, $database['body']['$id']); $this->assertEquals('Test 1', $database['body']['name']); - + $this->assertEquals(true, $database['body']['enabled']); return ['databaseId' => $database['body']['$id']]; } + /** + * @depends testListDatabases + */ + public function testUpdateDatabase(array $data) + { + $databaseId = $data['databaseId']; + + $database = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ], [ + 'name' => 'Test 1 Updated', + 'enabled' => false, + ]); + + $this->assertEquals(200, $database['headers']['status-code']); + $this->assertEquals('Test 1 Updated', $database['body']['name']); + $this->assertFalse($database['body']['enabled']); + + // Now update the database without the passing the enabled parameter + $database = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ], [ + 'name' => 'Test 1' + ]); + + $this->assertEquals(200, $database['headers']['status-code']); + $this->assertEquals('Test 1', $database['body']['name']); + $this->assertTrue($database['body']['enabled']); + } + /** * @depends testListDatabases */ @@ -273,7 +308,7 @@ public function testDeleteDatabase($data) $this->assertEquals(404, $response['headers']['status-code']); } - public function testListCollections() + public function testListCollections(): array { $database = $this->client->call(Client::METHOD_POST, '/databases', array_merge([ 'content-type' => 'application/json', @@ -285,6 +320,7 @@ public function testListCollections() ]); $this->assertEquals(201, $database['headers']['status-code']); $this->assertEquals('invalidDocumentDatabase', $database['body']['name']); + $this->assertTrue($database['body']['enabled']); $databaseId = $database['body']['$id']; /** @@ -329,7 +365,9 @@ public function testListCollections() $this->assertEquals(2, $collections['body']['total']); $this->assertEquals($test1['body']['$id'], $collections['body']['collections'][0]['$id']); + $this->assertEquals($test1['body']['enabled'], $collections['body']['collections'][0]['enabled']); $this->assertEquals($test2['body']['$id'], $collections['body']['collections'][1]['$id']); + $this->assertEquals($test1['body']['enabled'], $collections['body']['collections'][0]['enabled']); $base = array_reverse($collections['body']['collections']); @@ -337,7 +375,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'limit(1)' ] + 'queries' => ['limit(1)'] ]); $this->assertEquals(200, $collections['headers']['status-code']); @@ -347,7 +385,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'offset(1)' ] + 'queries' => ['offset(1)'] ]); $this->assertEquals(200, $collections['headers']['status-code']); @@ -357,7 +395,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'equal("enabled", true)' ] + 'queries' => ['equal("enabled", true)'] ]); $this->assertEquals(200, $collections['headers']['status-code']); @@ -367,7 +405,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'equal("enabled", false)' ] + 'queries' => ['equal("enabled", false)'] ]); $this->assertEquals(200, $collections['headers']['status-code']); @@ -380,7 +418,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'orderDesc("")' ], + 'queries' => ['orderDesc("")'], ]); $this->assertEquals(2, $collections['body']['total']); @@ -399,7 +437,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorAfter("' . $base['body']['collections'][0]['$id'] . '")' ], + 'queries' => ['cursorAfter("' . $base['body']['collections'][0]['$id'] . '")'], ]); $this->assertCount(1, $collections['body']['collections']); @@ -409,7 +447,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorAfter("' . $base['body']['collections'][1]['$id'] . '")' ], + 'queries' => ['cursorAfter("' . $base['body']['collections'][1]['$id'] . '")'], ]); $this->assertCount(0, $collections['body']['collections']); @@ -427,7 +465,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorBefore("' . $base['body']['collections'][1]['$id'] . '")' ], + 'queries' => ['cursorBefore("' . $base['body']['collections'][1]['$id'] . '")'], ]); $this->assertCount(1, $collections['body']['collections']); @@ -437,7 +475,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorBefore("' . $base['body']['collections'][0]['$id'] . '")' ], + 'queries' => ['cursorBefore("' . $base['body']['collections'][0]['$id'] . '")'], ]); $this->assertCount(0, $collections['body']['collections']); @@ -483,7 +521,7 @@ public function testListCollections() 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [ 'cursorAfter("unknown")' ], + 'queries' => ['cursorAfter("unknown")'], ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -506,6 +544,53 @@ public function testListCollections() ]); $this->assertEquals(409, $response['headers']['status-code']); + return [ + 'databaseId' => $databaseId, + 'collectionId' => $test1['body']['$id'], + ]; + } + + /** + * @depends testListCollections + */ + public function testGetCollection(array $data): void + { + $databaseId = $data['databaseId']; + $collectionId = $data['collectionId']; + + $collection = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ], $this->getHeaders())); + + $this->assertEquals(200, $collection['headers']['status-code']); + $this->assertEquals('Test 1', $collection['body']['name']); + $this->assertEquals('first', $collection['body']['$id']); + $this->assertTrue($collection['body']['enabled']); + } + + /** + * @depends testListCollections + */ + public function testUpdateCollection(array $data) + { + $databaseId = $data['databaseId']; + $collectionId = $data['collectionId']; + + $collection = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'name' => 'Test 1 Updated', + 'enabled' => false + ]); + + $this->assertEquals(200, $collection['headers']['status-code']); + $this->assertEquals('Test 1 Updated', $collection['body']['name']); + $this->assertEquals('first', $collection['body']['$id']); + $this->assertFalse($collection['body']['enabled']); } public function testDeleteAttribute(): array @@ -589,7 +674,7 @@ public function testDeleteAttribute(): array 'data' => [ 'firstName' => 'lorem', 'lastName' => 'ipsum', - 'unneeded' => 'dolor' + 'unneeded' => 'dolor' ], 'permissions' => [ Permission::read(Role::any()), @@ -1432,7 +1517,7 @@ public function testAttributeUpdateString(array $data) 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null; + $attribute = array_values(array_filter($new['body']['attributes'], fn(array $a) => $a['key'] === $key))[0] ?? null; $this->assertNotNull($attribute); $this->assertFalse($attribute['required']); $this->assertEquals('lorem', $attribute['default']); @@ -1574,7 +1659,7 @@ public function testAttributeUpdateEmail(array $data) 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null; + $attribute = array_values(array_filter($new['body']['attributes'], fn(array $a) => $a['key'] === $key))[0] ?? null; $this->assertNotNull($attribute); $this->assertFalse($attribute['required']); $this->assertEquals('torsten@appwrite.io', $attribute['default']); @@ -1717,7 +1802,7 @@ public function testAttributeUpdateIp(array $data) 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null; + $attribute = array_values(array_filter($new['body']['attributes'], fn(array $a) => $a['key'] === $key))[0] ?? null; $this->assertNotNull($attribute); $this->assertFalse($attribute['required']); $this->assertEquals('127.0.0.1', $attribute['default']); @@ -1859,7 +1944,7 @@ public function testAttributeUpdateUrl(array $data) 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null; + $attribute = array_values(array_filter($new['body']['attributes'], fn(array $a) => $a['key'] === $key))[0] ?? null; $this->assertNotNull($attribute); $this->assertFalse($attribute['required']); $this->assertEquals('http://appwrite.io', $attribute['default']); @@ -2005,7 +2090,7 @@ public function testAttributeUpdateInteger(array $data) 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null; + $attribute = array_values(array_filter($new['body']['attributes'], fn(array $a) => $a['key'] === $key))[0] ?? null; $this->assertNotNull($attribute); $this->assertFalse($attribute['required']); $this->assertEquals(123, $attribute['default']); @@ -2268,7 +2353,7 @@ public function testAttributeUpdateFloat(array $data) 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null; + $attribute = array_values(array_filter($new['body']['attributes'], fn(array $a) => $a['key'] === $key))[0] ?? null; $this->assertNotNull($attribute); $this->assertFalse($attribute['required']); $this->assertEquals(123.456, $attribute['default']); @@ -2527,7 +2612,7 @@ public function testAttributeUpdateBoolean(array $data) 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null; + $attribute = array_values(array_filter($new['body']['attributes'], fn(array $a) => $a['key'] === $key))[0] ?? null; $this->assertNotNull($attribute); $this->assertFalse($attribute['required']); $this->assertEquals(true, $attribute['default']); @@ -2669,7 +2754,7 @@ public function testAttributeUpdateDatetime(array $data) 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null; + $attribute = array_values(array_filter($new['body']['attributes'], fn(array $a) => $a['key'] === $key))[0] ?? null; $this->assertNotNull($attribute); $this->assertFalse($attribute['required']); $this->assertEquals('1975-06-12 14:12:55+02:00', $attribute['default']); @@ -2816,7 +2901,7 @@ public function testAttributeUpdateEnum(array $data) 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null; + $attribute = array_values(array_filter($new['body']['attributes'], fn(array $a) => $a['key'] === $key))[0] ?? null; $this->assertNotNull($attribute); $this->assertFalse($attribute['required']); $this->assertEquals('lorem', $attribute['default']); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 2b662779520..37ba2ede7bd 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -405,7 +405,7 @@ public function testCreateDeploymentLarge($data): array $id = ''; while (!feof($handle)) { $curlFile = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode(@fread($handle, $chunkSize)), $mimeType, 'php-large-fx.tar.gz'); - $headers['content-range'] = 'bytes ' . ($counter * $chunkSize) . '-' . min(((($counter * $chunkSize) + $chunkSize) - 1), $size) . '/' . $size; + $headers['content-range'] = 'bytes ' . ($counter * $chunkSize) . '-' . min(((($counter * $chunkSize) + $chunkSize) - 1), $size - 1) . '/' . $size; if (!empty($id)) { $headers['x-appwrite-id'] = $id; } diff --git a/tests/e2e/Services/GraphQL/StorageServerTest.php b/tests/e2e/Services/GraphQL/StorageServerTest.php index afaef083217..7fea895b1c1 100644 --- a/tests/e2e/Services/GraphQL/StorageServerTest.php +++ b/tests/e2e/Services/GraphQL/StorageServerTest.php @@ -77,7 +77,7 @@ public function testCreateFile($bucket): array 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), ]; - $file = $this->client->call(Client::METHOD_POST, '/graphql/upload', \array_merge([ + $file = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ 'content-type' => 'multipart/form-data', 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 91699f2dba0..52991b46215 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -3,6 +3,7 @@ namespace Tests\E2E\Services\Projects; use Appwrite\Auth\Auth; +use Appwrite\Extend\Exception; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectConsole; use Tests\E2E\Scopes\SideClient; @@ -98,7 +99,37 @@ public function testCreateProject(): array $this->assertEquals(400, $response['headers']['status-code']); - return ['projectId' => $projectId]; + return [ + 'projectId' => $projectId, + 'teamId' => $team['body']['$id'] + ]; + } + + /** + * @depends testCreateProject + */ + public function testCreateDuplicateProject($data) + { + $teamId = $data['teamId'] ?? ''; + $projectId = $data['projectId'] ?? ''; + + /** + * Test for FAILURE + */ + $response = $this->client->call(Client::METHOD_POST, '/projects', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'projectId' => $projectId, + 'name' => 'Project Duplicate', + 'teamId' => $teamId, + 'region' => 'default' + ]); + + $this->assertEquals(409, $response['headers']['status-code']); + $this->assertEquals(409, $response['body']['code']); + $this->assertEquals(Exception::PROJECT_ALREADY_EXISTS, $response['body']['type']); + $this->assertEquals('Project with the requested ID already exists.', $response['body']['message']); } /** @@ -587,7 +618,7 @@ public function testUpdateProjectOAuth($data): array foreach ($providers as $key => $provider) { $asserted = false; foreach ($response['body']['providers'] as $responseProvider) { - if ($responseProvider['name'] === ucfirst($key)) { + if ($responseProvider['key'] === $key) { $this->assertEquals('AppId-' . ucfirst($key), $responseProvider['appId']); $this->assertEquals('Secret-' . ucfirst($key), $responseProvider['secret']); $this->assertFalse($responseProvider['enabled']); @@ -629,7 +660,7 @@ public function testUpdateProjectOAuth($data): array foreach ($providers as $key => $provider) { $asserted = false; foreach ($response['body']['providers'] as $responseProvider) { - if ($responseProvider['name'] === ucfirst($key)) { + if ($responseProvider['key'] === $key) { // On first provider, test enabled=false $this->assertEquals($i !== 0, $responseProvider['enabled']); $asserted = true; @@ -783,11 +814,11 @@ public function testUpdateProjectAuthStatus($data): array $this->assertEquals($response['headers']['status-code'], 501); - $response = $this->client->call(Client::METHOD_POST, '/account/anonymous', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/account/sessions/anonymous', array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $id, - ]), []); + ])); $this->assertEquals($response['headers']['status-code'], 501); @@ -843,6 +874,19 @@ public function testUpdateProjectAuthLimit($data): array 'name' => $name, ]); + $email = uniqid() . 'user@localhost.test'; + + $response = $this->client->call(Client::METHOD_POST, '/account', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + ]), [ + 'userId' => ID::unique(), + 'email' => $email, + 'password' => $password, + 'name' => $name, + ]); + $this->assertEquals($response['headers']['status-code'], 501); /** @@ -858,6 +902,8 @@ public function testUpdateProjectAuthLimit($data): array $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); + $email = uniqid() . 'user@localhost.test'; + $response = $this->client->call(Client::METHOD_POST, '/account', array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', @@ -2966,15 +3012,13 @@ public function testDeleteProject(): array $this->assertEquals(200, $project['headers']['status-code']); - // Delete team - $team = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([ + // Delete Project + $project = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'password' => 'password' - ]); + ], $this->getHeaders())); - $this->assertEquals(204, $team['headers']['status-code']); + $this->assertEquals(204, $project['headers']['status-code']); // Ensure I can get team but not a project $team = $this->client->call(Client::METHOD_GET, '/teams/' . $teamId, array_merge([ diff --git a/tests/e2e/Services/Storage/StorageBase.php b/tests/e2e/Services/Storage/StorageBase.php index 62b49e62f37..e8890b89d07 100644 --- a/tests/e2e/Services/Storage/StorageBase.php +++ b/tests/e2e/Services/Storage/StorageBase.php @@ -100,7 +100,7 @@ public function testCreateBucketFile(): array $id = ''; while (!feof($handle)) { $curlFile = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode(@fread($handle, $chunkSize)), $mimeType, 'large-file.mp4'); - $headers['content-range'] = 'bytes ' . ($counter * $chunkSize) . '-' . min(((($counter * $chunkSize) + $chunkSize) - 1), $size) . '/' . $size; + $headers['content-range'] = 'bytes ' . ($counter * $chunkSize) . '-' . min(((($counter * $chunkSize) + $chunkSize) - 1), $size - 1) . '/' . $size; if (!empty($id)) { $headers['x-appwrite-id'] = $id; } @@ -144,7 +144,7 @@ public function testCreateBucketFile(): array ]; $id = ''; $curlFile = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode(@fread($handle, $chunkSize)), $mimeType, 'large-file.mp4'); - $headers['content-range'] = 'bytes ' . ($counter * $chunkSize) . '-' . min(((($counter * $chunkSize) + $chunkSize) - 1), $size) . '/' . $size; + $headers['content-range'] = 'bytes ' . ($counter * $chunkSize) . '-' . min(((($counter * $chunkSize) + $chunkSize) - 1), $size - 1) . '/' . $size; $res = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucket2['body']['$id'] . '/files', $this->getHeaders(), [ 'fileId' => $fileId, 'file' => $curlFile, diff --git a/tests/e2e/Services/Teams/TeamsBase.php b/tests/e2e/Services/Teams/TeamsBase.php index 04b5f93691b..8e19bede173 100644 --- a/tests/e2e/Services/Teams/TeamsBase.php +++ b/tests/e2e/Services/Teams/TeamsBase.php @@ -79,6 +79,17 @@ public function testCreateTeam(): array $this->assertEquals(400, $response['headers']['status-code']); + $response = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'teamId' => $teamId, + 'name' => 'John' + ]); + + $this->assertEquals(409, $response['headers']['status-code']); + $this->assertEquals('team_already_exists', $response['body']['type']); + return ['teamUid' => $teamUid, 'teamName' => $teamName]; } diff --git a/tests/e2e/Services/Teams/TeamsBaseServer.php b/tests/e2e/Services/Teams/TeamsBaseServer.php index aa1be49f413..5950824da31 100644 --- a/tests/e2e/Services/Teams/TeamsBaseServer.php +++ b/tests/e2e/Services/Teams/TeamsBaseServer.php @@ -4,6 +4,7 @@ use Tests\E2E\Client; use Utopia\Database\Validator\Datetime as DatetimeValidator; +use Utopia\Database\Helpers\ID; trait TeamsBaseServer { @@ -281,4 +282,81 @@ public function testDeleteUserUpdatesTeamMembershipCount($data) $this->assertIsInt($response['body']['total']); $this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt'])); } + + public function testTeamDeleteUpdatesUserMembership() + { + // Array to store the IDs of newly created users + $new_users = []; + + /** + * Create a new team + */ + $new_team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'teamId' => ID::unique(), + 'name' => 'New Team Test', + 'roles' => ['admin', 'editor'], + ]); + + $this->assertEquals(201, $new_team['headers']['status-code']); + $this->assertNotEmpty($new_team['body']['$id']); + $this->assertEquals('New Team Test', $new_team['body']['name']); + $this->assertGreaterThan(-1, $new_team['body']['total']); + $this->assertIsInt($new_team['body']['total']); + $this->assertArrayHasKey('prefs', $new_team['body']); + + /** + * Use the Create Team Membership endpoint + * to create 5 new users and add them to the team immediately + */ + for ($i = 0; $i < 5; $i++) { + $new_membership = $this->client->call(Client::METHOD_POST, '/teams/' . $new_team['body']['$id'] . '/memberships', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'email' => 'newuser' . $i . '@localhost.test', + 'name' => 'New User ' . $i, + 'roles' => ['admin', 'editor'], + 'url' => 'http://localhost:5000/join-us#title' + ]); + + $this->assertEquals(201, $new_membership['headers']['status-code']); + $this->assertNotEmpty($new_membership['body']['$id']); + $this->assertNotEmpty($new_membership['body']['userId']); + $this->assertEquals('New User ' . $i, $new_membership['body']['userName']); + $this->assertEquals('newuser' . $i . '@localhost.test', $new_membership['body']['userEmail']); + $this->assertNotEmpty($new_membership['body']['teamId']); + $this->assertCount(2, $new_membership['body']['roles']); + $dateValidator = new DatetimeValidator(); + $this->assertEquals(true, $dateValidator->isValid($new_membership['body']['joined'])); + $this->assertEquals(true, $new_membership['body']['confirm']); + + $new_users[] = $new_membership['body']['userId']; + } + + /** + * Delete the team + */ + $team_del_response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $new_team['body']['$id'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(204, $team_del_response['headers']['status-code']); + + /** + * Check that the team memberships for each of the new users has been deleted + */ + for ($i = 0; $i < 5; $i++) { + $membership = $this->client->call(Client::METHOD_GET, '/users/' . $new_users[$i] . '/memberships', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $membership['headers']['status-code']); + $this->assertEquals(0, $membership['body']['total']); + } + } }