Skip to content

Commit

Permalink
implement realtime feature
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Sep 2, 2021
1 parent f9eb3ae commit 7aee91f
Show file tree
Hide file tree
Showing 105 changed files with 380 additions and 108 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Appwrite Command Line SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.10.0-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
**This SDK is compatible with Appwrite server version 0.10.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**

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

Expand Down
4 changes: 2 additions & 2 deletions app/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@
$cli
->task('version')
->action(function() {
Console::log('CLI Version : 0.11.0');
Console::log('Server Version : 0.9.0');
Console::log('CLI Version : 0.12.0');
Console::log('Server Version : 0.10.0');
});


Expand Down
8 changes: 4 additions & 4 deletions app/teams.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@

$cli
->task('createMembership')
->label('description', "Use this endpoint to invite a new member to join your team. An email with a link to join the team will be sent to the new member email address if the member doesn't exist in the project it will be created automatically.
->label('description', "Use this endpoint to invite a new member to join your team. If initiated from Client SDK, an email with a link to join the team will be sent to the new member's email address if the member doesn't exist in the project it will be created automatically. If initiated from server side SDKs, new member will automatically be added to the team.
Use the 'URL' parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the [Update Team Membership Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team.
Use the 'URL' parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the [Update Team Membership Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team. While calling from side SDKs the redirect url can be empty string.
Please note that in order to avoid a [Redirect Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URL's are the once from domains you have set when added your platforms in the console interface.\n\n")
->param('teamId', '' , new Wildcard() , 'Team unique ID.', false)
Expand Down Expand Up @@ -290,9 +290,9 @@
"update" => "Update a team by its unique ID. Only team owners have write access for this resource.",
"delete" => "Delete a team by its unique ID. Only team owners have write access for this resource.",
"getMemberships" => "Get a team members by the team unique ID. All team members have read access for this list of resources.",
"createMembership" => "Use this endpoint to invite a new member to join your team. An email with a link to join the team will be sent to the new member email address if the member doesn't exist in the project it will be created automatically.
"createMembership" => "Use this endpoint to invite a new member to join your team. If initiated from Client SDK, an email with a link to join the team will be sent to the new member's email address if the member doesn't exist in the project it will be created automatically. If initiated from server side SDKs, new member will automatically be added to the team.
Use the 'URL' parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the [Update Team Membership Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team.
Use the 'URL' parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the [Update Team Membership Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team. While calling from side SDKs the redirect url can be empty string.
Please note that in order to avoid a [Redirect Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URL's are the once from domains you have set when added your platforms in the console interface.",
"updateMembershipRoles" => "",
Expand Down
63 changes: 63 additions & 0 deletions app/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@
$parser->parseResponse($response);
});

$cli
->task('updateEmail')
->label('description', "Update the user email by its unique ID.\n\n")
->param('userId', '' , new Wildcard() , 'User unique ID.', false)
->param('email', '' , new Wildcard() , 'User email.', false)
->action(function ( $userId, $email ) use ($parser) {
/** @var string $userId */
/** @var string $email */

$client = new Client();
$path = str_replace(['{userId}'], [$userId], '/users/{userId}/email');
$params = [];
/** Body Params */
$params['email'] = $email;
$response = $client->call(Client::METHOD_PATCH, $path, [
'content-type' => 'application/json',
], $params);
$parser->parseResponse($response);
});

$cli
->task('getLogs')
->label('description', "Get a user activity logs list by its unique ID.\n\n")
Expand All @@ -141,6 +161,46 @@
$parser->parseResponse($response);
});

$cli
->task('updateName')
->label('description', "Update the user name by its unique ID.\n\n")
->param('userId', '' , new Wildcard() , 'User unique ID.', false)
->param('name', '' , new Wildcard() , 'User name. Max length: 128 chars.', false)
->action(function ( $userId, $name ) use ($parser) {
/** @var string $userId */
/** @var string $name */

$client = new Client();
$path = str_replace(['{userId}'], [$userId], '/users/{userId}/name');
$params = [];
/** Body Params */
$params['name'] = $name;
$response = $client->call(Client::METHOD_PATCH, $path, [
'content-type' => 'application/json',
], $params);
$parser->parseResponse($response);
});

$cli
->task('updatePassword')
->label('description', "Update the user password by its unique ID.\n\n")
->param('userId', '' , new Wildcard() , 'User unique ID.', false)
->param('password', '' , new Wildcard() , 'New user password. Must be between 6 to 32 chars.', false)
->action(function ( $userId, $password ) use ($parser) {
/** @var string $userId */
/** @var string $password */

$client = new Client();
$path = str_replace(['{userId}'], [$userId], '/users/{userId}/password');
$params = [];
/** Body Params */
$params['password'] = $password;
$response = $client->call(Client::METHOD_PATCH, $path, [
'content-type' => 'application/json',
], $params);
$parser->parseResponse($response);
});

$cli
->task('getPrefs')
->label('description', "Get the user preferences by its unique ID.\n\n")
Expand Down Expand Up @@ -286,7 +346,10 @@
"create" => "Create a new user.",
"get" => "Get a user by its unique ID.",
"delete" => "Delete a user by its unique ID.",
"updateEmail" => "Update the user email by its unique ID.",
"getLogs" => "Get a user activity logs list by its unique ID.",
"updateName" => "Update the user name by its unique ID.",
"updatePassword" => "Update the user password by its unique ID.",
"getPrefs" => "Get the user preferences by its unique ID.",
"updatePrefs" => "Update the user preferences by its unique ID. You can pass only the specific settings you wish to update.",
"getSessions" => "Get the user sessions list by its unique ID.",
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/account/create-recovery.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite account createRecovery --email="[email protected]" --url="https://example.com"
appwrite account createRecovery \
--email="[email protected]" \
--url="https://example.com"
3 changes: 2 additions & 1 deletion docs/examples/account/create-verification.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite account createVerification --url="https://example.com"
appwrite account createVerification \
--url="https://example.com"
3 changes: 2 additions & 1 deletion docs/examples/account/delete-session.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite account deleteSession --sessionId="[SESSION_ID]"
appwrite account deleteSession \
--sessionId="[SESSION_ID]"
2 changes: 1 addition & 1 deletion docs/examples/account/delete-sessions.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite account deleteSessions
appwrite account deleteSessions
2 changes: 1 addition & 1 deletion docs/examples/account/delete.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite account delete
appwrite account delete
2 changes: 1 addition & 1 deletion docs/examples/account/get-logs.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite account getLogs
appwrite account getLogs
2 changes: 1 addition & 1 deletion docs/examples/account/get-prefs.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite account getPrefs
appwrite account getPrefs
3 changes: 2 additions & 1 deletion docs/examples/account/get-session.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite account getSession --sessionId="[SESSION_ID]"
appwrite account getSession \
--sessionId="[SESSION_ID]"
2 changes: 1 addition & 1 deletion docs/examples/account/get-sessions.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite account getSessions
appwrite account getSessions
2 changes: 1 addition & 1 deletion docs/examples/account/get.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite account get
appwrite account get
4 changes: 3 additions & 1 deletion docs/examples/account/update-email.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite account updateEmail --email="[email protected]" --password="password"
appwrite account updateEmail \
--email="[email protected]" \
--password="password"
3 changes: 2 additions & 1 deletion docs/examples/account/update-name.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite account updateName --name="[NAME]"
appwrite account updateName \
--name="[NAME]"
4 changes: 3 additions & 1 deletion docs/examples/account/update-password.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite account updatePassword --password="password" --oldPassword="password"
appwrite account updatePassword \
--password="password" \
--oldPassword="password"
3 changes: 2 additions & 1 deletion docs/examples/account/update-prefs.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite account updatePrefs --prefs="{}"
appwrite account updatePrefs \
--prefs="{}"
6 changes: 5 additions & 1 deletion docs/examples/account/update-recovery.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
appwrite account updateRecovery --userId="[USER_ID]" --secret="[SECRET]" --password="password" --passwordAgain="password"
appwrite account updateRecovery \
--userId="[USER_ID]" \
--secret="[SECRET]" \
--password="password" \
--passwordAgain="password"
4 changes: 3 additions & 1 deletion docs/examples/account/update-verification.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite account updateVerification --userId="[USER_ID]" --secret="[SECRET]"
appwrite account updateVerification \
--userId="[USER_ID]" \
--secret="[SECRET]"
6 changes: 5 additions & 1 deletion docs/examples/avatars/get-browser.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
appwrite avatars getBrowser --code="aa" --width="0" --height="0" --quality="0"
appwrite avatars getBrowser \
--code="aa" \
--width="0" \
--height="0" \
--quality="0"
6 changes: 5 additions & 1 deletion docs/examples/avatars/get-credit-card.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
appwrite avatars getCreditCard --code="amex" --width="0" --height="0" --quality="0"
appwrite avatars getCreditCard \
--code="amex" \
--width="0" \
--height="0" \
--quality="0"
3 changes: 2 additions & 1 deletion docs/examples/avatars/get-favicon.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite avatars getFavicon --url="https://example.com"
appwrite avatars getFavicon \
--url="https://example.com"
6 changes: 5 additions & 1 deletion docs/examples/avatars/get-flag.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
appwrite avatars getFlag --code="af" --width="0" --height="0" --quality="0"
appwrite avatars getFlag \
--code="af" \
--width="0" \
--height="0" \
--quality="0"
5 changes: 4 additions & 1 deletion docs/examples/avatars/get-image.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
appwrite avatars getImage --url="https://example.com" --width="0" --height="0"
appwrite avatars getImage \
--url="https://example.com" \
--width="0" \
--height="0"
7 changes: 6 additions & 1 deletion docs/examples/avatars/get-initials.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
appwrite avatars getInitials --name="[NAME]" --width="0" --height="0" --color="" --background=""
appwrite avatars getInitials \
--name="[NAME]" \
--width="0" \
--height="0" \
--color="" \
--background=""
6 changes: 5 additions & 1 deletion docs/examples/avatars/get-q-r.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
appwrite avatars getQR --text="[TEXT]" --size="0" --margin="0" --download=""
appwrite avatars getQR \
--text="[TEXT]" \
--size="0" \
--margin="0" \
--download=""
6 changes: 5 additions & 1 deletion docs/examples/database/create-collection.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
appwrite database createCollection --name="[NAME]" --read="" --write="" --rules=""
appwrite database createCollection \
--name="[NAME]" \
--read="" \
--write="" \
--rules=""
9 changes: 8 additions & 1 deletion docs/examples/database/create-document.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
appwrite database createDocument --collectionId="[COLLECTION_ID]" --data="{}" --read="" --write="" --parentDocument="[PARENT_DOCUMENT]" --parentProperty="" --parentPropertyType="assign"
appwrite database createDocument \
--collectionId="[COLLECTION_ID]" \
--data="{}" \
--read="" \
--write="" \
--parentDocument="[PARENT_DOCUMENT]" \
--parentProperty="" \
--parentPropertyType="assign"
3 changes: 2 additions & 1 deletion docs/examples/database/delete-collection.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite database deleteCollection --collectionId="[COLLECTION_ID]"
appwrite database deleteCollection \
--collectionId="[COLLECTION_ID]"
4 changes: 3 additions & 1 deletion docs/examples/database/delete-document.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite database deleteDocument --collectionId="[COLLECTION_ID]" --documentId="[DOCUMENT_ID]"
appwrite database deleteDocument \
--collectionId="[COLLECTION_ID]" \
--documentId="[DOCUMENT_ID]"
3 changes: 2 additions & 1 deletion docs/examples/database/get-collection.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite database getCollection --collectionId="[COLLECTION_ID]"
appwrite database getCollection \
--collectionId="[COLLECTION_ID]"
4 changes: 3 additions & 1 deletion docs/examples/database/get-document.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite database getDocument --collectionId="[COLLECTION_ID]" --documentId="[DOCUMENT_ID]"
appwrite database getDocument \
--collectionId="[COLLECTION_ID]" \
--documentId="[DOCUMENT_ID]"
6 changes: 5 additions & 1 deletion docs/examples/database/list-collections.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
appwrite database listCollections --search="[SEARCH]" --limit="0" --offset="0" --orderType="ASC"
appwrite database listCollections \
--search="[SEARCH]" \
--limit="0" \
--offset="0" \
--orderType="ASC"
10 changes: 9 additions & 1 deletion docs/examples/database/list-documents.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
appwrite database listDocuments --collectionId="[COLLECTION_ID]" --filters="" --limit="0" --offset="0" --orderField="[ORDER_FIELD]" --orderType="DESC" --orderCast="int" --search="[SEARCH]"
appwrite database listDocuments \
--collectionId="[COLLECTION_ID]" \
--filters="" \
--limit="0" \
--offset="0" \
--orderField="[ORDER_FIELD]" \
--orderType="DESC" \
--orderCast="int" \
--search="[SEARCH]"
7 changes: 6 additions & 1 deletion docs/examples/database/update-collection.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
appwrite database updateCollection --collectionId="[COLLECTION_ID]" --name="[NAME]" --read="" --write="" --rules=""
appwrite database updateCollection \
--collectionId="[COLLECTION_ID]" \
--name="[NAME]" \
--read="" \
--write="" \
--rules=""
7 changes: 6 additions & 1 deletion docs/examples/database/update-document.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
appwrite database updateDocument --collectionId="[COLLECTION_ID]" --documentId="[DOCUMENT_ID]" --data="{}" --read="" --write=""
appwrite database updateDocument \
--collectionId="[COLLECTION_ID]" \
--documentId="[DOCUMENT_ID]" \
--data="{}" \
--read="" \
--write=""
4 changes: 3 additions & 1 deletion docs/examples/functions/create-execution.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite functions createExecution --functionId="[FUNCTION_ID]" --data="[DATA]"
appwrite functions createExecution \
--functionId="[FUNCTION_ID]" \
--data="[DATA]"
5 changes: 4 additions & 1 deletion docs/examples/functions/create-tag.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
appwrite functions createTag --functionId="[FUNCTION_ID]" --command="[COMMAND]" --code=""
appwrite functions createTag \
--functionId="[FUNCTION_ID]" \
--command="[COMMAND]" \
--code=""
9 changes: 8 additions & 1 deletion docs/examples/functions/create.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
appwrite functions create --name="[NAME]" --execute="" --runtime="java-11.0" --vars="{}" --events="" --schedule="" --timeout="1"
appwrite functions create \
--name="[NAME]" \
--execute="" \
--runtime="dotnet-5.0" \
--vars="{}" \
--events="" \
--schedule="" \
--timeout="1"
4 changes: 3 additions & 1 deletion docs/examples/functions/delete-tag.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite functions deleteTag --functionId="[FUNCTION_ID]" --tagId="[TAG_ID]"
appwrite functions deleteTag \
--functionId="[FUNCTION_ID]" \
--tagId="[TAG_ID]"
3 changes: 2 additions & 1 deletion docs/examples/functions/delete.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite functions delete --functionId="[FUNCTION_ID]"
appwrite functions delete \
--functionId="[FUNCTION_ID]"
4 changes: 3 additions & 1 deletion docs/examples/functions/get-execution.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite functions getExecution --functionId="[FUNCTION_ID]" --executionId="[EXECUTION_ID]"
appwrite functions getExecution \
--functionId="[FUNCTION_ID]" \
--executionId="[EXECUTION_ID]"
4 changes: 3 additions & 1 deletion docs/examples/functions/get-tag.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
appwrite functions getTag --functionId="[FUNCTION_ID]" --tagId="[TAG_ID]"
appwrite functions getTag \
--functionId="[FUNCTION_ID]" \
--tagId="[TAG_ID]"
3 changes: 2 additions & 1 deletion docs/examples/functions/get.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
appwrite functions get --functionId="[FUNCTION_ID]"
appwrite functions get \
--functionId="[FUNCTION_ID]"
Loading

0 comments on commit 7aee91f

Please sign in to comment.