From e13e859607d28020f5b3a1ec42c9ae184fef6e01 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 4 Jan 2022 15:19:43 +0545 Subject: [PATCH] feat(version): support 0.12.0 --- LICENSE | 2 +- README.md | 4 +- app/account.php | 37 +- app/client.php | 2 +- app/database.php | 534 ++++++++++++++++-- app/functions.php | 103 ++-- app/health.php | 21 +- app/storage.php | 39 +- app/teams.php | 126 +++-- app/users.php | 70 ++- docs/examples/account/get-logs.md | 4 +- .../database/create-boolean-attribute.md | 6 + docs/examples/database/create-collection.md | 7 +- docs/examples/database/create-document.md | 8 +- .../database/create-email-attribute.md | 6 + .../database/create-enum-attribute.md | 7 + .../database/create-float-attribute.md | 8 + docs/examples/database/create-index.md | 6 + .../database/create-integer-attribute.md | 8 + docs/examples/database/create-ip-attribute.md | 6 + .../database/create-string-attribute.md | 7 + .../examples/database/create-url-attribute.md | 6 + docs/examples/database/delete-attribute.md | 3 + docs/examples/database/delete-index.md | 3 + docs/examples/database/get-attribute.md | 3 + docs/examples/database/get-index.md | 3 + docs/examples/database/list-attributes.md | 2 + docs/examples/database/list-collections.md | 2 + docs/examples/database/list-documents.md | 10 +- docs/examples/database/list-indexes.md | 2 + docs/examples/database/update-collection.md | 7 +- docs/examples/database/update-document.md | 4 +- docs/examples/functions/create.md | 3 +- docs/examples/functions/list-executions.md | 5 +- docs/examples/functions/list-runtimes.md | 1 + docs/examples/functions/list-tags.md | 2 + docs/examples/functions/list.md | 2 + docs/examples/health/get-anti-virus.md | 1 - docs/examples/health/get-antivirus.md | 1 + docs/examples/health/get-queue-tasks.md | 1 - docs/examples/storage/create-file.md | 1 + docs/examples/storage/get-file-preview.md | 2 +- docs/examples/storage/list-files.md | 2 + docs/examples/teams/create.md | 1 + docs/examples/teams/get-membership.md | 3 + docs/examples/teams/get-memberships.md | 2 + docs/examples/teams/list.md | 2 + docs/examples/users/create.md | 1 + docs/examples/users/get-logs.md | 4 +- docs/examples/users/list.md | 2 + docs/examples/users/update-status.md | 2 +- src/Client.php | 2 +- 52 files changed, 853 insertions(+), 243 deletions(-) create mode 100644 docs/examples/database/create-boolean-attribute.md create mode 100644 docs/examples/database/create-email-attribute.md create mode 100644 docs/examples/database/create-enum-attribute.md create mode 100644 docs/examples/database/create-float-attribute.md create mode 100644 docs/examples/database/create-index.md create mode 100644 docs/examples/database/create-integer-attribute.md create mode 100644 docs/examples/database/create-ip-attribute.md create mode 100644 docs/examples/database/create-string-attribute.md create mode 100644 docs/examples/database/create-url-attribute.md create mode 100644 docs/examples/database/delete-attribute.md create mode 100644 docs/examples/database/delete-index.md create mode 100644 docs/examples/database/get-attribute.md create mode 100644 docs/examples/database/get-index.md create mode 100644 docs/examples/database/list-attributes.md create mode 100644 docs/examples/database/list-indexes.md create mode 100644 docs/examples/functions/list-runtimes.md delete mode 100644 docs/examples/health/get-anti-virus.md create mode 100644 docs/examples/health/get-antivirus.md delete mode 100644 docs/examples/health/get-queue-tasks.md create mode 100644 docs/examples/teams/get-membership.md diff --git a/LICENSE b/LICENSE index d73a6e9..96201c4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index a486686..b73168f 100644 --- a/README.md +++ b/README.md @@ -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.11.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.12.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?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![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.11.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.12.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) diff --git a/app/account.php b/app/account.php index 991dbe8..860bea3 100644 --- a/app/account.php +++ b/app/account.php @@ -72,10 +72,11 @@ $cli ->task('updateEmail') - ->label('description', "Update currently logged in user account email address. After changing user address, user confirmation status is being reset and a new confirmation mail is sent. For security measures, user password is required to complete this request. -This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.\n\n") + ->label('description', "Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. +This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. +\n\n") ->param('email', '' , new Wildcard() , 'User email.', false) - ->param('password', '' , new Wildcard() , 'User password. Must be between 6 to 32 chars.', false) + ->param('password', '' , new Wildcard() , 'User password. Must be at least 8 chars.', false) ->action(function ( $email, $password ) use ($parser) { /** @var string $email */ /** @var string $password */ @@ -95,11 +96,18 @@ $cli ->task('getLogs') ->label('description', "Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.\n\n") - ->action(function ( ) use ($parser) { + ->param('limit', 25 , new Wildcard() , 'Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->action(function ( $limit, $offset ) use ($parser) { + /** @var integer $limit */ + /** @var integer $offset */ $client = new Client(); $path = str_replace([], [], '/account/logs'); $params = []; + /** Query Params */ + $params['limit'] = $limit; + $params['offset'] = $offset; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', ], $params); @@ -127,8 +135,8 @@ $cli ->task('updatePassword') ->label('description', "Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth and Team Invites, oldPassword is optional.\n\n") - ->param('password', '' , new Wildcard() , 'New user password. Must be between 6 to 32 chars.', false) - ->param('oldPassword', '' , new Wildcard() , 'Old user password. Must be between 6 to 32 chars.', true) + ->param('password', '' , new Wildcard() , 'New user password. Must be at least 8 chars.', false) + ->param('oldPassword', '' , new Wildcard() , 'Current user password. Must be at least 8 chars.', true) ->action(function ( $password, $oldPassword ) use ($parser) { /** @var string $password */ /** @var string $oldPassword */ @@ -203,10 +211,10 @@ ->label('description', "Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](/docs/client/account#accountCreateRecovery) endpoint. Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.\n\n") - ->param('userId', '' , new Wildcard() , 'User account UID address.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->param('secret', '' , new Wildcard() , 'Valid reset token.', false) - ->param('password', '' , new Wildcard() , 'New password. Must be between 6 to 32 chars.', false) - ->param('passwordAgain', '' , new Wildcard() , 'New password again. Must be between 6 to 32 chars.', false) + ->param('password', '' , new Wildcard() , 'New user password. Must be at least 8 chars.', false) + ->param('passwordAgain', '' , new Wildcard() , 'Repeat new user password. Must be at least 8 chars.', false) ->action(function ( $userId, $secret, $password, $passwordAgain ) use ($parser) { /** @var string $userId */ /** @var string $secret */ @@ -258,7 +266,7 @@ $cli ->task('getSession') ->label('description', "Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.\n\n") - ->param('sessionId', '' , new Wildcard() , 'Session unique ID. Use the string 'current' to get the current device session.', false) + ->param('sessionId', '' , new Wildcard() , 'Session ID. Use the string 'current' to get the current device session.', false) ->action(function ( $sessionId ) use ($parser) { /** @var string $sessionId */ @@ -274,7 +282,7 @@ $cli ->task('deleteSession') ->label('description', "Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted.\n\n") - ->param('sessionId', '' , new Wildcard() , 'Session unique ID. Use the string 'current' to delete the current device session.', false) + ->param('sessionId', '' , new Wildcard() , 'Session ID. Use the string 'current' to delete the current device session.', false) ->action(function ( $sessionId ) use ($parser) { /** @var string $sessionId */ @@ -311,7 +319,7 @@ $cli ->task('updateVerification') ->label('description', "Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->param('secret', '' , new Wildcard() , 'Valid verification token.', false) ->action(function ( $userId, $secret ) use ($parser) { /** @var string $userId */ @@ -346,8 +354,9 @@ $commands = [ "get" => "Get currently logged in user data as JSON object.", "delete" => "Delete a currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. This is done to avoid deleted accounts being overtaken by new users with the same email address. Any user-related resources like documents or storage files should be deleted separately.", - "updateEmail" => "Update currently logged in user account email address. After changing user address, user confirmation status is being reset and a new confirmation mail is sent. For security measures, user password is required to complete this request. -This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.", + "updateEmail" => "Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. +This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. +", "getLogs" => "Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.", "updateName" => "Update currently logged in user account name.", "updatePassword" => "Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth and Team Invites, oldPassword is optional.", diff --git a/app/client.php b/app/client.php index a0f390b..7e4375b 100644 --- a/app/client.php +++ b/app/client.php @@ -110,7 +110,7 @@ ->task('version') ->action(function() { Console::log('CLI Version : 0.12.1'); - Console::log('Server Version : 0.11.0'); + Console::log('Server Version : 0.12.0'); }); diff --git a/app/database.php b/app/database.php index 47ea8b6..0f15a71 100644 --- a/app/database.php +++ b/app/database.php @@ -46,13 +46,17 @@ ->task('listCollections') ->label('description', "Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's collections. [Learn more about different API modes](/docs/admin).\n\n") ->param('search', '' , new Wildcard() , 'Search term to filter your list results. Max length: 256 chars.', true) - ->param('limit', 25 , new Wildcard() , 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0 , new Wildcard() , 'Results offset. The default value is 0. Use this param to manage pagination.', true) + ->param('limit', 25 , new Wildcard() , 'Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursor', '' , new Wildcard() , 'ID of the collection used as the starting point for the query, excluding the collection itself. Should be used for efficient pagination when working with large sets of data.', true) + ->param('cursorDirection', 'after' , new Wildcard() , 'Direction of the cursor.', true) ->param('orderType', 'ASC' , new Wildcard() , 'Order result by ASC or DESC order.', true) - ->action(function ( $search, $limit, $offset, $orderType ) use ($parser) { + ->action(function ( $search, $limit, $offset, $cursor, $cursorDirection, $orderType ) use ($parser) { /** @var string $search */ /** @var integer $limit */ /** @var integer $offset */ + /** @var string $cursor */ + /** @var string $cursorDirection */ /** @var string $orderType */ $client = new Client(); @@ -62,6 +66,8 @@ $params['search'] = $search; $params['limit'] = $limit; $params['offset'] = $offset; + $params['cursor'] = $cursor; + $params['cursorDirection'] = $cursorDirection; $params['orderType'] = $orderType; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -72,24 +78,27 @@ $cli ->task('createCollection') ->label('description', "Create a new Collection.\n\n") + ->param('collectionId', '' , new Wildcard() , 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. 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.', false) ->param('name', '' , new Wildcard() , 'Collection name. Max length: 128 chars.', false) - ->param('read', '' , new Wildcard() , 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', false) - ->param('write', '' , new Wildcard() , 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', false) - ->param('rules', '' , new Wildcard() , 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', false) - ->action(function ( $name, $read, $write, $rules ) use ($parser) { + ->param('permission', '' , new Wildcard() , 'Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the `read` and `write` params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', false) + ->param('read', '' , new Wildcard() , 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', false) + ->param('write', '' , new Wildcard() , 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', false) + ->action(function ( $collectionId, $name, $permission, $read, $write ) use ($parser) { + /** @var string $collectionId */ /** @var string $name */ + /** @var string $permission */ /** @var array $read */ /** @var array $write */ - /** @var array $rules */ $client = new Client(); $path = str_replace([], [], '/database/collections'); $params = []; /** Body Params */ + $params['collectionId'] = $collectionId; $params['name'] = $name; + $params['permission'] = $permission; $params['read'] = !is_array($read) ? array($read) : $read; $params['write'] = !is_array($write) ? array($write) : $write; - $params['rules'] = !is_array($rules) ? array($rules) : $rules; $response = $client->call(Client::METHOD_POST, $path, [ 'content-type' => 'application/json', ], $params); @@ -99,7 +108,7 @@ $cli ->task('getCollection') ->label('description', "Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.\n\n") - ->param('collectionId', '' , new Wildcard() , 'Collection unique ID.', false) + ->param('collectionId', '' , new Wildcard() , 'Collection ID.', false) ->action(function ( $collectionId ) use ($parser) { /** @var string $collectionId */ @@ -115,26 +124,29 @@ $cli ->task('updateCollection') ->label('description', "Update a collection by its unique ID.\n\n") - ->param('collectionId', '' , new Wildcard() , 'Collection unique ID.', false) + ->param('collectionId', '' , new Wildcard() , 'Collection ID.', false) ->param('name', '' , new Wildcard() , 'Collection name. Max length: 128 chars.', false) - ->param('read', [] , new Wildcard() , 'An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) - ->param('write', [] , new Wildcard() , 'An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) - ->param('rules', [] , new Wildcard() , 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', true) - ->action(function ( $collectionId, $name, $read, $write, $rules ) use ($parser) { + ->param('permission', '' , new Wildcard() , 'Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the `read` and `write` params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', false) + ->param('read', [] , new Wildcard() , 'An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) + ->param('write', [] , new Wildcard() , 'An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) + ->param('enabled', true , new Wildcard() , 'Is collection enabled?', true) + ->action(function ( $collectionId, $name, $permission, $read, $write, $enabled ) use ($parser) { /** @var string $collectionId */ /** @var string $name */ + /** @var string $permission */ /** @var array $read */ /** @var array $write */ - /** @var array $rules */ + /** @var boolean $enabled */ $client = new Client(); $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}'); $params = []; /** Body Params */ $params['name'] = $name; + $params['permission'] = $permission; $params['read'] = !is_array($read) ? array($read) : $read; $params['write'] = !is_array($write) ? array($write) : $write; - $params['rules'] = !is_array($rules) ? array($rules) : $rules; + $params['enabled'] = $enabled; $response = $client->call(Client::METHOD_PUT, $path, [ 'content-type' => 'application/json', ], $params); @@ -144,7 +156,7 @@ $cli ->task('deleteCollection') ->label('description', "Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.\n\n") - ->param('collectionId', '' , new Wildcard() , 'Collection unique ID.', false) + ->param('collectionId', '' , new Wildcard() , 'Collection ID.', false) ->action(function ( $collectionId ) use ($parser) { /** @var string $collectionId */ @@ -157,38 +169,347 @@ $parser->parseResponse($response); }); +$cli + ->task('listAttributes') + ->label('description', "\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->action(function ( $collectionId ) use ($parser) { + /** @var string $collectionId */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/attributes'); + $params = []; + $response = $client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('createBooleanAttribute') + ->label('description', "Create a boolean attribute. +\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->param('required', '' , new Wildcard() , 'Is attribute required?', false) + ->param('xdefault', null , new Wildcard() , 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('xarray', false , new Wildcard() , 'Is attribute an array?', true) + ->action(function ( $collectionId, $key, $required, $xdefault, $xarray ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + /** @var boolean $required */ + /** @var boolean $xdefault */ + /** @var boolean $xarray */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/attributes/boolean'); + $params = []; + /** Body Params */ + $params['key'] = $key; + $params['required'] = $required; + $params['default'] = $xdefault; + $params['array'] = $xarray; + $response = $client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('createEmailAttribute') + ->label('description', "Create an email attribute. +\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->param('required', '' , new Wildcard() , 'Is attribute required?', false) + ->param('xdefault', '' , new Wildcard() , 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('xarray', false , new Wildcard() , 'Is attribute an array?', true) + ->action(function ( $collectionId, $key, $required, $xdefault, $xarray ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + /** @var boolean $required */ + /** @var string $xdefault */ + /** @var boolean $xarray */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/attributes/email'); + $params = []; + /** Body Params */ + $params['key'] = $key; + $params['required'] = $required; + $params['default'] = $xdefault; + $params['array'] = $xarray; + $response = $client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('createEnumAttribute') + ->label('description', "\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->param('elements', '' , new Wildcard() , 'Array of elements in enumerated type. Uses length of longest element to determine size.', false) + ->param('required', '' , new Wildcard() , 'Is attribute required?', false) + ->param('xdefault', '' , new Wildcard() , 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('xarray', false , new Wildcard() , 'Is attribute an array?', true) + ->action(function ( $collectionId, $key, $elements, $required, $xdefault, $xarray ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + /** @var array $elements */ + /** @var boolean $required */ + /** @var string $xdefault */ + /** @var boolean $xarray */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/attributes/enum'); + $params = []; + /** Body Params */ + $params['key'] = $key; + $params['elements'] = !is_array($elements) ? array($elements) : $elements; + $params['required'] = $required; + $params['default'] = $xdefault; + $params['array'] = $xarray; + $response = $client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('createFloatAttribute') + ->label('description', "Create a float attribute. Optionally, minimum and maximum values can be provided. +\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->param('required', '' , new Wildcard() , 'Is attribute required?', false) + ->param('min', '' , new Wildcard() , 'Minimum value to enforce on new documents', true) + ->param('max', '' , new Wildcard() , 'Maximum value to enforce on new documents', true) + ->param('xdefault', '' , new Wildcard() , 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('xarray', false , new Wildcard() , 'Is attribute an array?', true) + ->action(function ( $collectionId, $key, $required, $min, $max, $xdefault, $xarray ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + /** @var boolean $required */ + /** @var string $min */ + /** @var string $max */ + /** @var string $xdefault */ + /** @var boolean $xarray */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/attributes/float'); + $params = []; + /** Body Params */ + $params['key'] = $key; + $params['required'] = $required; + $params['min'] = $min; + $params['max'] = $max; + $params['default'] = $xdefault; + $params['array'] = $xarray; + $response = $client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('createIntegerAttribute') + ->label('description', "Create an integer attribute. Optionally, minimum and maximum values can be provided. +\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->param('required', '' , new Wildcard() , 'Is attribute required?', false) + ->param('min', null , new Wildcard() , 'Minimum value to enforce on new documents', true) + ->param('max', null , new Wildcard() , 'Maximum value to enforce on new documents', true) + ->param('xdefault', null , new Wildcard() , 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('xarray', false , new Wildcard() , 'Is attribute an array?', true) + ->action(function ( $collectionId, $key, $required, $min, $max, $xdefault, $xarray ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + /** @var boolean $required */ + /** @var integer $min */ + /** @var integer $max */ + /** @var integer $xdefault */ + /** @var boolean $xarray */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/attributes/integer'); + $params = []; + /** Body Params */ + $params['key'] = $key; + $params['required'] = $required; + $params['min'] = (int)$min; + $params['max'] = (int)$max; + $params['default'] = (int)$xdefault; + $params['array'] = $xarray; + $response = $client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('createIpAttribute') + ->label('description', "Create IP address attribute. +\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->param('required', '' , new Wildcard() , 'Is attribute required?', false) + ->param('xdefault', '' , new Wildcard() , 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('xarray', false , new Wildcard() , 'Is attribute an array?', true) + ->action(function ( $collectionId, $key, $required, $xdefault, $xarray ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + /** @var boolean $required */ + /** @var string $xdefault */ + /** @var boolean $xarray */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/attributes/ip'); + $params = []; + /** Body Params */ + $params['key'] = $key; + $params['required'] = $required; + $params['default'] = $xdefault; + $params['array'] = $xarray; + $response = $client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('createStringAttribute') + ->label('description', "Create a string attribute. +\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->param('size', '' , new Wildcard() , 'Attribute size for text attributes, in number of characters.', false) + ->param('required', '' , new Wildcard() , 'Is attribute required?', false) + ->param('xdefault', '' , new Wildcard() , 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('xarray', false , new Wildcard() , 'Is attribute an array?', true) + ->action(function ( $collectionId, $key, $size, $required, $xdefault, $xarray ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + /** @var integer $size */ + /** @var boolean $required */ + /** @var string $xdefault */ + /** @var boolean $xarray */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/attributes/string'); + $params = []; + /** Body Params */ + $params['key'] = $key; + $params['size'] = (int)$size; + $params['required'] = $required; + $params['default'] = $xdefault; + $params['array'] = $xarray; + $response = $client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('createUrlAttribute') + ->label('description', "Create a URL attribute. +\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->param('required', '' , new Wildcard() , 'Is attribute required?', false) + ->param('xdefault', '' , new Wildcard() , 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('xarray', false , new Wildcard() , 'Is attribute an array?', true) + ->action(function ( $collectionId, $key, $required, $xdefault, $xarray ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + /** @var boolean $required */ + /** @var string $xdefault */ + /** @var boolean $xarray */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/attributes/url'); + $params = []; + /** Body Params */ + $params['key'] = $key; + $params['required'] = $required; + $params['default'] = $xdefault; + $params['array'] = $xarray; + $response = $client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('getAttribute') + ->label('description', "\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->action(function ( $collectionId, $key ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + + $client = new Client(); + $path = str_replace(['{collectionId}', '{key}'], [$collectionId, $key], '/database/collections/{collectionId}/attributes/{key}'); + $params = []; + $response = $client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('deleteAttribute') + ->label('description', "\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Attribute Key.', false) + ->action(function ( $collectionId, $key ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + + $client = new Client(); + $path = str_replace(['{collectionId}', '{key}'], [$collectionId, $key], '/database/collections/{collectionId}/attributes/{key}'); + $params = []; + $response = $client->call(Client::METHOD_DELETE, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + $cli ->task('listDocuments') ->label('description', "Get a list of all the user documents. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's documents. [Learn more about different API modes](/docs/admin).\n\n") - ->param('collectionId', '' , new Wildcard() , 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).', false) - ->param('filters', [] , new Wildcard() , 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: 'name=John Doe' or 'category.$id>=5bed2d152c362'.', true) - ->param('limit', 25 , new Wildcard() , 'Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this param to manage pagination.', true) - ->param('orderField', '' , new Wildcard() , 'Document field that results will be sorted by.', true) - ->param('orderType', 'ASC' , new Wildcard() , 'Order direction. Possible values are DESC for descending order, or ASC for ascending order.', true) - ->param('orderCast', 'string' , new Wildcard() , 'Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string.', true) - ->param('search', '' , new Wildcard() , 'Search query. Enter any free text search. The database will try to find a match against all document attributes and children. Max length: 256 chars.', true) - ->action(function ( $collectionId, $filters, $limit, $offset, $orderField, $orderType, $orderCast, $search ) use ($parser) { + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('queries', [] , new Wildcard() , 'Array of query strings.', true) + ->param('limit', 25 , new Wildcard() , 'Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursor', '' , new Wildcard() , 'ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursorDirection', 'after' , new Wildcard() , 'Direction of the cursor.', true) + ->param('orderAttributes', [] , new Wildcard() , 'Array of attributes used to sort results.', true) + ->param('orderTypes', [] , new Wildcard() , 'Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order.', true) + ->action(function ( $collectionId, $queries, $limit, $offset, $cursor, $cursorDirection, $orderAttributes, $orderTypes ) use ($parser) { /** @var string $collectionId */ - /** @var array $filters */ + /** @var array $queries */ /** @var integer $limit */ /** @var integer $offset */ - /** @var string $orderField */ - /** @var string $orderType */ - /** @var string $orderCast */ - /** @var string $search */ + /** @var string $cursor */ + /** @var string $cursorDirection */ + /** @var array $orderAttributes */ + /** @var array $orderTypes */ $client = new Client(); $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/documents'); $params = []; /** Query Params */ - $params['filters'] = !is_array($filters) ? array($filters) : $filters; + $params['queries'] = !is_array($queries) ? array($queries) : $queries; $params['limit'] = $limit; $params['offset'] = $offset; - $params['orderField'] = $orderField; - $params['orderType'] = $orderType; - $params['orderCast'] = $orderCast; - $params['search'] = $search; + $params['cursor'] = $cursor; + $params['cursorDirection'] = $cursorDirection; + $params['orderAttributes'] = !is_array($orderAttributes) ? array($orderAttributes) : $orderAttributes; + $params['orderTypes'] = !is_array($orderTypes) ? array($orderTypes) : $orderTypes; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', ], $params); @@ -198,32 +519,26 @@ $cli ->task('createDocument') ->label('description', "Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](/docs/server/database#databaseCreateCollection) API or directly from your database console.\n\n") - ->param('collectionId', '' , new Wildcard() , 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).', false) + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection with validation rules using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('documentId', '' , new Wildcard() , 'Document ID. Choose your own unique ID or pass the string `unique()` to auto generate it. 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.', false) ->param('data', '' , new Wildcard() , 'Document data as JSON object.', false) - ->param('read', [] , new Wildcard() , 'An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) - ->param('write', [] , new Wildcard() , 'An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) - ->param('parentDocument', '' , new Wildcard() , 'Parent document unique ID. Use when you want your new document to be a child of a parent document.', true) - ->param('parentProperty', '' , new Wildcard() , 'Parent document property name. Use when you want your new document to be a child of a parent document.', true) - ->param('parentPropertyType', 'assign' , new Wildcard() , 'Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document.', true) - ->action(function ( $collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType ) use ($parser) { + ->param('read', [] , new Wildcard() , 'An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) + ->param('write', [] , new Wildcard() , 'An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) + ->action(function ( $collectionId, $documentId, $data, $read, $write ) use ($parser) { /** @var string $collectionId */ + /** @var string $documentId */ /** @var object $data */ /** @var array $read */ /** @var array $write */ - /** @var string $parentDocument */ - /** @var string $parentProperty */ - /** @var string $parentPropertyType */ $client = new Client(); $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/documents'); $params = []; /** Body Params */ + $params['documentId'] = $documentId; $params['data'] = \json_decode($data); $params['read'] = !is_array($read) ? array($read) : $read; $params['write'] = !is_array($write) ? array($write) : $write; - $params['parentDocument'] = $parentDocument; - $params['parentProperty'] = $parentProperty; - $params['parentPropertyType'] = $parentPropertyType; $response = $client->call(Client::METHOD_POST, $path, [ 'content-type' => 'application/json', ], $params); @@ -233,8 +548,8 @@ $cli ->task('getDocument') ->label('description', "Get a document by its unique ID. This endpoint response returns a JSON object with the document data.\n\n") - ->param('collectionId', '' , new Wildcard() , 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).', false) - ->param('documentId', '' , new Wildcard() , 'Document unique ID.', false) + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('documentId', '' , new Wildcard() , 'Document ID.', false) ->action(function ( $collectionId, $documentId ) use ($parser) { /** @var string $collectionId */ /** @var string $documentId */ @@ -251,11 +566,11 @@ $cli ->task('updateDocument') ->label('description', "Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.\n\n") - ->param('collectionId', '' , new Wildcard() , 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).', false) - ->param('documentId', '' , new Wildcard() , 'Document unique ID.', false) + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection with validation rules using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('documentId', '' , new Wildcard() , 'Document ID.', false) ->param('data', '' , new Wildcard() , 'Document data as JSON object.', false) - ->param('read', [] , new Wildcard() , 'An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) - ->param('write', [] , new Wildcard() , 'An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) + ->param('read', [] , new Wildcard() , 'An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) + ->param('write', [] , new Wildcard() , 'An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) ->action(function ( $collectionId, $documentId, $data, $read, $write ) use ($parser) { /** @var string $collectionId */ /** @var string $documentId */ @@ -279,8 +594,8 @@ $cli ->task('deleteDocument') ->label('description', "Delete a document by its unique ID. This endpoint deletes only the parent documents, its attributes and relations to other documents. Child documents **will not** be deleted.\n\n") - ->param('collectionId', '' , new Wildcard() , 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).', false) - ->param('documentId', '' , new Wildcard() , 'Document unique ID.', false) + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('documentId', '' , new Wildcard() , 'Document ID.', false) ->action(function ( $collectionId, $documentId ) use ($parser) { /** @var string $collectionId */ /** @var string $documentId */ @@ -294,6 +609,87 @@ $parser->parseResponse($response); }); +$cli + ->task('listIndexes') + ->label('description', "\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->action(function ( $collectionId ) use ($parser) { + /** @var string $collectionId */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/indexes'); + $params = []; + $response = $client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('createIndex') + ->label('description', "\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Index Key.', false) + ->param('type', '' , new Wildcard() , 'Index type.', false) + ->param('attributes', '' , new Wildcard() , 'Array of attributes to index.', false) + ->param('orders', [] , new Wildcard() , 'Array of index orders.', true) + ->action(function ( $collectionId, $key, $type, $attributes, $orders ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + /** @var string $type */ + /** @var array $attributes */ + /** @var array $orders */ + + $client = new Client(); + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/indexes'); + $params = []; + /** Body Params */ + $params['key'] = $key; + $params['type'] = $type; + $params['attributes'] = !is_array($attributes) ? array($attributes) : $attributes; + $params['orders'] = !is_array($orders) ? array($orders) : $orders; + $response = $client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('getIndex') + ->label('description', "\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Index Key.', false) + ->action(function ( $collectionId, $key ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + + $client = new Client(); + $path = str_replace(['{collectionId}', '{key}'], [$collectionId, $key], '/database/collections/{collectionId}/indexes/{key}'); + $params = []; + $response = $client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + +$cli + ->task('deleteIndex') + ->label('description', "\n\n") + ->param('collectionId', '' , new Wildcard() , 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).', false) + ->param('key', '' , new Wildcard() , 'Index Key.', false) + ->action(function ( $collectionId, $key ) use ($parser) { + /** @var string $collectionId */ + /** @var string $key */ + + $client = new Client(); + $path = str_replace(['{collectionId}', '{key}'], [$collectionId, $key], '/database/collections/{collectionId}/indexes/{key}'); + $params = []; + $response = $client->call(Client::METHOD_DELETE, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + $cli ->task('help') @@ -314,11 +710,33 @@ "getCollection" => "Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.", "updateCollection" => "Update a collection by its unique ID.", "deleteCollection" => "Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.", + "listAttributes" => "", + "createBooleanAttribute" => "Create a boolean attribute. +", + "createEmailAttribute" => "Create an email attribute. +", + "createEnumAttribute" => "", + "createFloatAttribute" => "Create a float attribute. Optionally, minimum and maximum values can be provided. +", + "createIntegerAttribute" => "Create an integer attribute. Optionally, minimum and maximum values can be provided. +", + "createIpAttribute" => "Create IP address attribute. +", + "createStringAttribute" => "Create a string attribute. +", + "createUrlAttribute" => "Create a URL attribute. +", + "getAttribute" => "", + "deleteAttribute" => "", "listDocuments" => "Get a list of all the user documents. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's documents. [Learn more about different API modes](/docs/admin).", "createDocument" => "Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](/docs/server/database#databaseCreateCollection) API or directly from your database console.", "getDocument" => "Get a document by its unique ID. This endpoint response returns a JSON object with the document data.", "updateDocument" => "Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.", "deleteDocument" => "Delete a document by its unique ID. This endpoint deletes only the parent documents, its attributes and relations to other documents. Child documents **will not** be deleted.", + "listIndexes" => "", + "createIndex" => "", + "getIndex" => "", + "deleteIndex" => "", ]; $parser->formatArray($commands); Console::log("\nRun 'appwrite database COMMAND --help' for more information on a command."); diff --git a/app/functions.php b/app/functions.php index a860906..b75e229 100644 --- a/app/functions.php +++ b/app/functions.php @@ -46,13 +46,17 @@ ->task('list') ->label('description', "Get a list of all the project's functions. You can use the query params to filter your results.\n\n") ->param('search', '' , new Wildcard() , 'Search term to filter your list results. Max length: 256 chars.', true) - ->param('limit', 25 , new Wildcard() , 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0 , new Wildcard() , 'Results offset. The default value is 0. Use this param to manage pagination.', true) + ->param('limit', 25 , new Wildcard() , 'Maximum number of functions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursor', '' , new Wildcard() , 'ID of the function used as the starting point for the query, excluding the function itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursorDirection', 'after' , new Wildcard() , 'Direction of the cursor.', true) ->param('orderType', 'ASC' , new Wildcard() , 'Order result by ASC or DESC order.', true) - ->action(function ( $search, $limit, $offset, $orderType ) use ($parser) { + ->action(function ( $search, $limit, $offset, $cursor, $cursorDirection, $orderType ) use ($parser) { /** @var string $search */ /** @var integer $limit */ /** @var integer $offset */ + /** @var string $cursor */ + /** @var string $cursorDirection */ /** @var string $orderType */ $client = new Client(); @@ -62,6 +66,8 @@ $params['search'] = $search; $params['limit'] = $limit; $params['offset'] = $offset; + $params['cursor'] = $cursor; + $params['cursorDirection'] = $cursorDirection; $params['orderType'] = $orderType; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -72,14 +78,16 @@ $cli ->task('create') ->label('description', "Create a new function. You can pass a list of [permissions](/docs/permissions) to allow different project users or team with access to execute the function using the client API.\n\n") + ->param('functionId', '' , new Wildcard() , 'Function ID. Choose your own unique ID or pass the string `unique()` to auto generate it. 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.', false) ->param('name', '' , new Wildcard() , 'Function name. Max length: 128 chars.', false) - ->param('execute', '' , new Wildcard() , 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', false) + ->param('execute', '' , new Wildcard() , 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', false) ->param('runtime', '' , new Wildcard() , 'Execution runtime.', false) - ->param('vars', [] , new Wildcard() , 'Key-value JSON object.', true) + ->param('vars', [] , new Wildcard() , 'Key-value JSON object that will be passed to the function as environment variables.', true) ->param('events', [] , new Wildcard() , 'Events list.', true) ->param('schedule', '' , new Wildcard() , 'Schedule CRON syntax.', true) ->param('timeout', 15 , new Wildcard() , 'Function maximum execution time in seconds.', true) - ->action(function ( $name, $execute, $runtime, $vars, $events, $schedule, $timeout ) use ($parser) { + ->action(function ( $functionId, $name, $execute, $runtime, $vars, $events, $schedule, $timeout ) use ($parser) { + /** @var string $functionId */ /** @var string $name */ /** @var array $execute */ /** @var string $runtime */ @@ -92,6 +100,7 @@ $path = str_replace([], [], '/functions'); $params = []; /** Body Params */ + $params['functionId'] = $functionId; $params['name'] = $name; $params['execute'] = !is_array($execute) ? array($execute) : $execute; $params['runtime'] = $runtime; @@ -105,10 +114,24 @@ $parser->parseResponse($response); }); +$cli + ->task('listRuntimes') + ->label('description', "Get a list of all runtimes that are currently active in your project.\n\n") + ->action(function ( ) use ($parser) { + + $client = new Client(); + $path = str_replace([], [], '/functions/runtimes'); + $params = []; + $response = $client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + $cli ->task('get') ->label('description', "Get a function by its unique ID.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) ->action(function ( $functionId ) use ($parser) { /** @var string $functionId */ @@ -124,13 +147,13 @@ $cli ->task('update') ->label('description', "Update function by its unique ID.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) ->param('name', '' , new Wildcard() , 'Function name. Max length: 128 chars.', false) - ->param('execute', '' , new Wildcard() , 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', false) - ->param('vars', [] , new Wildcard() , 'Key-value JSON object.', true) + ->param('execute', '' , new Wildcard() , 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', false) + ->param('vars', [] , new Wildcard() , 'Key-value JSON object that will be passed to the function as environment variables.', true) ->param('events', [] , new Wildcard() , 'Events list.', true) ->param('schedule', '' , new Wildcard() , 'Schedule CRON syntax.', true) - ->param('timeout', 15 , new Wildcard() , 'Function maximum execution time in seconds.', true) + ->param('timeout', 15 , new Wildcard() , 'Maximum execution time in seconds.', true) ->action(function ( $functionId, $name, $execute, $vars, $events, $schedule, $timeout ) use ($parser) { /** @var string $functionId */ /** @var string $name */ @@ -159,7 +182,7 @@ $cli ->task('delete') ->label('description', "Delete a function by its unique ID.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) ->action(function ( $functionId ) use ($parser) { /** @var string $functionId */ @@ -175,26 +198,29 @@ $cli ->task('listExecutions') ->label('description', "Get a list of all the current user function execution logs. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's executions. [Learn more about different API modes](/docs/admin).\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) + ->param('limit', 25 , new Wildcard() , 'Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) ->param('search', '' , new Wildcard() , 'Search term to filter your list results. Max length: 256 chars.', true) - ->param('limit', 25 , new Wildcard() , 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0 , new Wildcard() , 'Results offset. The default value is 0. Use this param to manage pagination.', true) - ->param('orderType', 'ASC' , new Wildcard() , 'Order result by ASC or DESC order.', true) - ->action(function ( $functionId, $search, $limit, $offset, $orderType ) use ($parser) { + ->param('cursor', '' , new Wildcard() , 'ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursorDirection', 'after' , new Wildcard() , 'Direction of the cursor.', true) + ->action(function ( $functionId, $limit, $offset, $search, $cursor, $cursorDirection ) use ($parser) { /** @var string $functionId */ - /** @var string $search */ /** @var integer $limit */ /** @var integer $offset */ - /** @var string $orderType */ + /** @var string $search */ + /** @var string $cursor */ + /** @var string $cursorDirection */ $client = new Client(); $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions'); $params = []; /** Query Params */ - $params['search'] = $search; $params['limit'] = $limit; $params['offset'] = $offset; - $params['orderType'] = $orderType; + $params['search'] = $search; + $params['cursor'] = $cursor; + $params['cursorDirection'] = $cursorDirection; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', ], $params); @@ -204,7 +230,7 @@ $cli ->task('createExecution') ->label('description', "Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) ->param('data', '' , new Wildcard() , 'String of custom data to send to function.', true) ->action(function ( $functionId, $data ) use ($parser) { /** @var string $functionId */ @@ -224,8 +250,8 @@ $cli ->task('getExecution') ->label('description', "Get a function execution log by its unique ID.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) - ->param('executionId', '' , new Wildcard() , 'Execution unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) + ->param('executionId', '' , new Wildcard() , 'Execution ID.', false) ->action(function ( $functionId, $executionId ) use ($parser) { /** @var string $functionId */ /** @var string $executionId */ @@ -242,8 +268,8 @@ $cli ->task('updateTag') ->label('description', "Update the function code tag ID using the unique function ID. Use this endpoint to switch the code tag that should be executed by the execution endpoint.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) - ->param('tag', '' , new Wildcard() , 'Tag unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) + ->param('tag', '' , new Wildcard() , 'Tag ID.', false) ->action(function ( $functionId, $tag ) use ($parser) { /** @var string $functionId */ /** @var string $tag */ @@ -262,16 +288,20 @@ $cli ->task('listTags') ->label('description', "Get a list of all the project's code tags. You can use the query params to filter your results.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) ->param('search', '' , new Wildcard() , 'Search term to filter your list results. Max length: 256 chars.', true) - ->param('limit', 25 , new Wildcard() , 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0 , new Wildcard() , 'Results offset. The default value is 0. Use this param to manage pagination.', true) + ->param('limit', 25 , new Wildcard() , 'Maximum number of tags to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursor', '' , new Wildcard() , 'ID of the tag used as the starting point for the query, excluding the tag itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursorDirection', 'after' , new Wildcard() , 'Direction of the cursor.', true) ->param('orderType', 'ASC' , new Wildcard() , 'Order result by ASC or DESC order.', true) - ->action(function ( $functionId, $search, $limit, $offset, $orderType ) use ($parser) { + ->action(function ( $functionId, $search, $limit, $offset, $cursor, $cursorDirection, $orderType ) use ($parser) { /** @var string $functionId */ /** @var string $search */ /** @var integer $limit */ /** @var integer $offset */ + /** @var string $cursor */ + /** @var string $cursorDirection */ /** @var string $orderType */ $client = new Client(); @@ -281,6 +311,8 @@ $params['search'] = $search; $params['limit'] = $limit; $params['offset'] = $offset; + $params['cursor'] = $cursor; + $params['cursorDirection'] = $cursorDirection; $params['orderType'] = $orderType; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -295,7 +327,7 @@ This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](/docs/functions). Use the 'command' param to set the entry point used to execute your code.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) ->param('command', '' , new Wildcard() , 'Code execution command.', false) ->param('code', '' , new Wildcard() , 'Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.', false) ->action(function ( $functionId, $command, $code ) use ($parser) { @@ -331,8 +363,8 @@ $cli ->task('getTag') ->label('description', "Get a code tag by its unique ID.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) - ->param('tagId', '' , new Wildcard() , 'Tag unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) + ->param('tagId', '' , new Wildcard() , 'Tag ID.', false) ->action(function ( $functionId, $tagId ) use ($parser) { /** @var string $functionId */ /** @var string $tagId */ @@ -349,8 +381,8 @@ $cli ->task('deleteTag') ->label('description', "Delete a code tag by its unique ID.\n\n") - ->param('functionId', '' , new Wildcard() , 'Function unique ID.', false) - ->param('tagId', '' , new Wildcard() , 'Tag unique ID.', false) + ->param('functionId', '' , new Wildcard() , 'Function ID.', false) + ->param('tagId', '' , new Wildcard() , 'Tag ID.', false) ->action(function ( $functionId, $tagId ) use ($parser) { /** @var string $functionId */ /** @var string $tagId */ @@ -381,6 +413,7 @@ $commands = [ "list" => "Get a list of all the project's functions. You can use the query params to filter your results.", "create" => "Create a new function. You can pass a list of [permissions](/docs/permissions) to allow different project users or team with access to execute the function using the client API.", + "listRuntimes" => "Get a list of all runtimes that are currently active in your project.", "get" => "Get a function by its unique ID.", "update" => "Update function by its unique ID.", "delete" => "Delete a function by its unique ID.", diff --git a/app/health.php b/app/health.php index 90a79e2..bbfef02 100644 --- a/app/health.php +++ b/app/health.php @@ -57,8 +57,8 @@ }); $cli - ->task('getAntiVirus') - ->label('description', "Check the Appwrite Anti Virus server is up and connection is successful.\n\n") + ->task('getAntivirus') + ->label('description', "Check the Appwrite Antivirus server is up and connection is successful.\n\n") ->action(function ( ) use ($parser) { $client = new Client(); @@ -140,20 +140,6 @@ $parser->parseResponse($response); }); -$cli - ->task('getQueueTasks') - ->label('description', "Get the number of tasks that are waiting to be processed in the Appwrite internal queue server.\n\n") - ->action(function ( ) use ($parser) { - - $client = new Client(); - $path = str_replace([], [], '/health/queue/tasks'); - $params = []; - $response = $client->call(Client::METHOD_GET, $path, [ - 'content-type' => 'application/json', - ], $params); - $parser->parseResponse($response); - }); - $cli ->task('getQueueUsage') ->label('description', "Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server.\n\n") @@ -226,13 +212,12 @@ Console::log("Commands :"); $commands = [ "get" => "Check the Appwrite HTTP server is up and responsive.", - "getAntiVirus" => "Check the Appwrite Anti Virus server is up and connection is successful.", + "getAntivirus" => "Check the Appwrite Antivirus server is up and connection is successful.", "getCache" => "Check the Appwrite in-memory cache server is up and connection is successful.", "getDB" => "Check the Appwrite database server is up and connection is successful.", "getQueueCertificates" => "Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server.", "getQueueFunctions" => "", "getQueueLogs" => "Get the number of logs that are waiting to be processed in the Appwrite internal queue server.", - "getQueueTasks" => "Get the number of tasks that are waiting to be processed in the Appwrite internal queue server.", "getQueueUsage" => "Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server.", "getQueueWebhooks" => "Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server.", "getStorageLocal" => "Check the Appwrite local storage device is up and connection is successful.", diff --git a/app/storage.php b/app/storage.php index 89de069..ed6bde8 100644 --- a/app/storage.php +++ b/app/storage.php @@ -46,13 +46,17 @@ ->task('listFiles') ->label('description', "Get a list of all the user files. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's files. [Learn more about different API modes](/docs/admin).\n\n") ->param('search', '' , new Wildcard() , 'Search term to filter your list results. Max length: 256 chars.', true) - ->param('limit', 25 , new Wildcard() , 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0 , new Wildcard() , 'Results offset. The default value is 0. Use this param to manage pagination.', true) + ->param('limit', 25 , new Wildcard() , 'Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursor', '' , new Wildcard() , 'ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursorDirection', 'after' , new Wildcard() , 'Direction of the cursor.', true) ->param('orderType', 'ASC' , new Wildcard() , 'Order result by ASC or DESC order.', true) - ->action(function ( $search, $limit, $offset, $orderType ) use ($parser) { + ->action(function ( $search, $limit, $offset, $cursor, $cursorDirection, $orderType ) use ($parser) { /** @var string $search */ /** @var integer $limit */ /** @var integer $offset */ + /** @var string $cursor */ + /** @var string $cursorDirection */ /** @var string $orderType */ $client = new Client(); @@ -62,6 +66,8 @@ $params['search'] = $search; $params['limit'] = $limit; $params['offset'] = $offset; + $params['cursor'] = $cursor; + $params['cursorDirection'] = $cursorDirection; $params['orderType'] = $orderType; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -72,10 +78,12 @@ $cli ->task('createFile') ->label('description', "Create a new file. The user who creates the file will automatically be assigned to read and write access unless he has passed custom values for read and write arguments.\n\n") + ->param('fileId', '' , new Wildcard() , 'File ID. Choose your own unique ID or pass the string `unique()` to auto generate it. 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.', false) ->param('file', '' , new Wildcard() , 'Binary file.', false) - ->param('read', [] , new Wildcard() , 'An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) - ->param('write', [] , new Wildcard() , 'An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) - ->action(function ( $file, $read, $write ) use ($parser) { + ->param('read', [] , new Wildcard() , 'An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) + ->param('write', [] , new Wildcard() , 'An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', true) + ->action(function ( $fileId, $file, $read, $write ) use ($parser) { + /** @var string $fileId */ /** @var file $file */ /** @var array $read */ /** @var array $write */ @@ -84,6 +92,7 @@ $path = str_replace([], [], '/storage/files'); $params = []; /** Body Params */ + $params['fileId'] = $fileId; $file = realpath(__DIR__.'/../files/'.\urldecode($file)); if (file_exists($file) === false ) { throw new Exception("Path doesn't exist. Please ensure that the path is within the current directory. "); @@ -101,7 +110,7 @@ $cli ->task('getFile') ->label('description', "Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.\n\n") - ->param('fileId', '' , new Wildcard() , 'File unique ID.', false) + ->param('fileId', '' , new Wildcard() , 'File ID.', false) ->action(function ( $fileId ) use ($parser) { /** @var string $fileId */ @@ -117,9 +126,9 @@ $cli ->task('updateFile') ->label('description', "Update a file by its unique ID. Only users with write permissions have access to update this resource.\n\n") - ->param('fileId', '' , new Wildcard() , 'File unique ID.', false) - ->param('read', '' , new Wildcard() , 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', false) - ->param('write', '' , new Wildcard() , 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', false) + ->param('fileId', '' , new Wildcard() , 'File ID.', false) + ->param('read', '' , new Wildcard() , 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', false) + ->param('write', '' , new Wildcard() , 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.', false) ->action(function ( $fileId, $read, $write ) use ($parser) { /** @var string $fileId */ /** @var array $read */ @@ -140,7 +149,7 @@ $cli ->task('deleteFile') ->label('description', "Delete a file by its unique ID. Only users with write permissions have access to delete this resource.\n\n") - ->param('fileId', '' , new Wildcard() , 'File unique ID.', false) + ->param('fileId', '' , new Wildcard() , 'File ID.', false) ->action(function ( $fileId ) use ($parser) { /** @var string $fileId */ @@ -156,7 +165,7 @@ $cli ->task('getFileDownload') ->label('description', "Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.\n\n") - ->param('fileId', '' , new Wildcard() , 'File unique ID.', false) + ->param('fileId', '' , new Wildcard() , 'File ID.', false) ->action(function ( $fileId ) use ($parser) { /** @var string $fileId */ @@ -172,7 +181,7 @@ $cli ->task('getFilePreview') ->label('description', "Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image.\n\n") - ->param('fileId', '' , new Wildcard() , 'File unique ID', false) + ->param('fileId', '' , new Wildcard() , 'File ID.', false) ->param('width', 0 , new Wildcard() , 'Resize preview image width, Pass an integer between 0 to 4000.', true) ->param('height', 0 , new Wildcard() , 'Resize preview image height, Pass an integer between 0 to 4000.', true) ->param('gravity', 'center' , new Wildcard() , 'Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right', true) @@ -181,7 +190,7 @@ ->param('borderColor', '' , new Wildcard() , 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true) ->param('borderRadius', 0 , new Wildcard() , 'Preview image border radius in pixels. Pass an integer between 0 to 4000.', true) ->param('opacity', 1 , new Wildcard() , 'Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.', true) - ->param('rotation', 0 , new Wildcard() , 'Preview image rotation in degrees. Pass an integer between 0 and 360.', true) + ->param('rotation', 0 , new Wildcard() , 'Preview image rotation in degrees. Pass an integer between -360 and 360.', true) ->param('background', '' , new Wildcard() , 'Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.', true) ->param('output', '' , new Wildcard() , 'Output format type (jpeg, jpg, png, gif and webp).', true) ->action(function ( $fileId, $width, $height, $gravity, $quality, $borderWidth, $borderColor, $borderRadius, $opacity, $rotation, $background, $output ) use ($parser) { @@ -222,7 +231,7 @@ $cli ->task('getFileView') ->label('description', "Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.\n\n") - ->param('fileId', '' , new Wildcard() , 'File unique ID.', false) + ->param('fileId', '' , new Wildcard() , 'File ID.', false) ->action(function ( $fileId ) use ($parser) { /** @var string $fileId */ diff --git a/app/teams.php b/app/teams.php index 70f68e9..41ac952 100644 --- a/app/teams.php +++ b/app/teams.php @@ -44,15 +44,21 @@ $cli ->task('list') - ->label('description', "Get a list of all the current user teams. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's teams. [Learn more about different API modes](/docs/admin).\n\n") + ->label('description', "Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. + +In admin mode, this endpoint returns a list of all the teams in the current project. [Learn more about different API modes](/docs/admin).\n\n") ->param('search', '' , new Wildcard() , 'Search term to filter your list results. Max length: 256 chars.', true) - ->param('limit', 25 , new Wildcard() , 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0 , new Wildcard() , 'Results offset. The default value is 0. Use this param to manage pagination.', true) + ->param('limit', 25 , new Wildcard() , 'Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursor', '' , new Wildcard() , 'ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursorDirection', 'after' , new Wildcard() , 'Direction of the cursor.', true) ->param('orderType', 'ASC' , new Wildcard() , 'Order result by ASC or DESC order.', true) - ->action(function ( $search, $limit, $offset, $orderType ) use ($parser) { + ->action(function ( $search, $limit, $offset, $cursor, $cursorDirection, $orderType ) use ($parser) { /** @var string $search */ /** @var integer $limit */ /** @var integer $offset */ + /** @var string $cursor */ + /** @var string $cursorDirection */ /** @var string $orderType */ $client = new Client(); @@ -62,6 +68,8 @@ $params['search'] = $search; $params['limit'] = $limit; $params['offset'] = $offset; + $params['cursor'] = $cursor; + $params['cursorDirection'] = $cursorDirection; $params['orderType'] = $orderType; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -71,10 +79,12 @@ $cli ->task('create') - ->label('description', "Create a new team. The user who creates the team will automatically be assigned as the owner of the team. The team owner can invite new members, who will be able add new owners and update or delete the team from your project.\n\n") + ->label('description', "Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team.\n\n") + ->param('teamId', '' , new Wildcard() , 'Team ID. Choose your own unique ID or pass the string `unique()` to auto generate it. 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.', false) ->param('name', '' , new Wildcard() , 'Team name. Max length: 128 chars.', false) ->param('roles', ["owner"] , new Wildcard() , 'Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.', true) - ->action(function ( $name, $roles ) use ($parser) { + ->action(function ( $teamId, $name, $roles ) use ($parser) { + /** @var string $teamId */ /** @var string $name */ /** @var array $roles */ @@ -82,6 +92,7 @@ $path = str_replace([], [], '/teams'); $params = []; /** Body Params */ + $params['teamId'] = $teamId; $params['name'] = $name; $params['roles'] = !is_array($roles) ? array($roles) : $roles; $response = $client->call(Client::METHOD_POST, $path, [ @@ -92,8 +103,8 @@ $cli ->task('get') - ->label('description', "Get a team by its unique ID. All team members have read access for this resource.\n\n") - ->param('teamId', '' , new Wildcard() , 'Team unique ID.', false) + ->label('description', "Get a team by its ID. All team members have read access for this resource.\n\n") + ->param('teamId', '' , new Wildcard() , 'Team ID.', false) ->action(function ( $teamId ) use ($parser) { /** @var string $teamId */ @@ -108,9 +119,9 @@ $cli ->task('update') - ->label('description', "Update a team by its unique ID. Only team owners have write access for this resource.\n\n") - ->param('teamId', '' , new Wildcard() , 'Team unique ID.', false) - ->param('name', '' , new Wildcard() , 'Team name. Max length: 128 chars.', false) + ->label('description', "Update a team using its ID. Only members with the owner role can update the team.\n\n") + ->param('teamId', '' , new Wildcard() , 'Team ID.', false) + ->param('name', '' , new Wildcard() , 'New team name. Max length: 128 chars.', false) ->action(function ( $teamId, $name ) use ($parser) { /** @var string $teamId */ /** @var string $name */ @@ -128,8 +139,8 @@ $cli ->task('delete') - ->label('description', "Delete a team by its unique ID. Only team owners have write access for this resource.\n\n") - ->param('teamId', '' , new Wildcard() , 'Team unique ID.', false) + ->label('description', "Delete a team using its ID. Only team members with the owner role can delete the team.\n\n") + ->param('teamId', '' , new Wildcard() , 'Team ID.', false) ->action(function ( $teamId ) use ($parser) { /** @var string $teamId */ @@ -144,17 +155,21 @@ $cli ->task('getMemberships') - ->label('description', "Get a team members by the team unique ID. All team members have read access for this list of resources.\n\n") - ->param('teamId', '' , new Wildcard() , 'Team unique ID.', false) + ->label('description', "Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint.\n\n") + ->param('teamId', '' , new Wildcard() , 'Team ID.', false) ->param('search', '' , new Wildcard() , 'Search term to filter your list results. Max length: 256 chars.', true) - ->param('limit', 25 , new Wildcard() , 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0 , new Wildcard() , 'Results offset. The default value is 0. Use this param to manage pagination.', true) + ->param('limit', 25 , new Wildcard() , 'Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursor', '' , new Wildcard() , 'ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursorDirection', 'after' , new Wildcard() , 'Direction of the cursor.', true) ->param('orderType', 'ASC' , new Wildcard() , 'Order result by ASC or DESC order.', true) - ->action(function ( $teamId, $search, $limit, $offset, $orderType ) use ($parser) { + ->action(function ( $teamId, $search, $limit, $offset, $cursor, $cursorDirection, $orderType ) use ($parser) { /** @var string $teamId */ /** @var string $search */ /** @var integer $limit */ /** @var integer $offset */ + /** @var string $cursor */ + /** @var string $cursorDirection */ /** @var string $orderType */ $client = new Client(); @@ -164,6 +179,8 @@ $params['search'] = $search; $params['limit'] = $limit; $params['offset'] = $offset; + $params['cursor'] = $cursor; + $params['cursorDirection'] = $cursorDirection; $params['orderType'] = $orderType; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -173,16 +190,16 @@ $cli ->task('createMembership') - ->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. + ->label('description', "Invite a new member to join your team. If initiated from the client SDK, an email with a link to join the team will be sent to the member's email address and an account will be created for them should they not be signed up already. If initiated from server-side SDKs, the 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. While calling from side SDKs the redirect url can be empty string. +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. -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) - ->param('email', '' , new Wildcard() , 'New team member email.', false) +Please note that to avoid a [Redirect Attack](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 adding your platforms in the console interface.\n\n") + ->param('teamId', '' , new Wildcard() , 'Team ID.', false) + ->param('email', '' , new Wildcard() , 'Email of the new team member.', false) ->param('roles', '' , new Wildcard() , 'Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.', false) ->param('url', '' , new Wildcard() , 'URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false) - ->param('name', '' , new Wildcard() , 'New team member name. Max length: 128 chars.', true) + ->param('name', '' , new Wildcard() , 'Name of the new team member. Max length: 128 chars.', true) ->action(function ( $teamId, $email, $roles, $url, $name ) use ($parser) { /** @var string $teamId */ /** @var string $email */ @@ -204,12 +221,30 @@ $parser->parseResponse($response); }); +$cli + ->task('getMembership') + ->label('description', "Get a team member by the membership unique id. All team members have read access for this resource.\n\n") + ->param('teamId', '' , new Wildcard() , 'Team ID.', false) + ->param('membershipId', '' , new Wildcard() , 'Membership ID.', false) + ->action(function ( $teamId, $membershipId ) use ($parser) { + /** @var string $teamId */ + /** @var string $membershipId */ + + $client = new Client(); + $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); + $params = []; + $response = $client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + $parser->parseResponse($response); + }); + $cli ->task('updateMembershipRoles') - ->label('description', "\n\n") - ->param('teamId', '' , new Wildcard() , 'Team unique ID.', false) + ->label('description', "Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](/docs/permissions).\n\n") + ->param('teamId', '' , new Wildcard() , 'Team ID.', false) ->param('membershipId', '' , new Wildcard() , 'Membership ID.', false) - ->param('roles', '' , new Wildcard() , 'Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.', false) + ->param('roles', '' , new Wildcard() , 'An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Max length for each role is 32 chars.', false) ->action(function ( $teamId, $membershipId, $roles ) use ($parser) { /** @var string $teamId */ /** @var string $membershipId */ @@ -229,7 +264,7 @@ $cli ->task('deleteMembership') ->label('description', "This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted.\n\n") - ->param('teamId', '' , new Wildcard() , 'Team unique ID.', false) + ->param('teamId', '' , new Wildcard() , 'Team ID.', false) ->param('membershipId', '' , new Wildcard() , 'Membership ID.', false) ->action(function ( $teamId, $membershipId ) use ($parser) { /** @var string $teamId */ @@ -246,10 +281,10 @@ $cli ->task('updateMembershipStatus') - ->label('description', "Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email recieved by the user.\n\n") - ->param('teamId', '' , new Wildcard() , 'Team unique ID.', false) + ->label('description', "Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user.\n\n") + ->param('teamId', '' , new Wildcard() , 'Team ID.', false) ->param('membershipId', '' , new Wildcard() , 'Membership ID.', false) - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->param('secret', '' , new Wildcard() , 'Secret key.', false) ->action(function ( $teamId, $membershipId, $userId, $secret ) use ($parser) { /** @var string $teamId */ @@ -284,20 +319,23 @@ Console::log("\nUsage : appwrite teams [COMMAND]\n"); Console::log("Commands :"); $commands = [ - "list" => "Get a list of all the current user teams. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's teams. [Learn more about different API modes](/docs/admin).", - "create" => "Create a new team. The user who creates the team will automatically be assigned as the owner of the team. The team owner can invite new members, who will be able add new owners and update or delete the team from your project.", - "get" => "Get a team by its unique ID. All team members have read access for this resource.", - "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. 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. 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" => "", + "list" => "Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. + +In admin mode, this endpoint returns a list of all the teams in the current project. [Learn more about different API modes](/docs/admin).", + "create" => "Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team.", + "get" => "Get a team by its ID. All team members have read access for this resource.", + "update" => "Update a team using its ID. Only members with the owner role can update the team.", + "delete" => "Delete a team using its ID. Only team members with the owner role can delete the team.", + "getMemberships" => "Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint.", + "createMembership" => "Invite a new member to join your team. If initiated from the client SDK, an email with a link to join the team will be sent to the member's email address and an account will be created for them should they not be signed up already. If initiated from server-side SDKs, the 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. + +Please note that to avoid a [Redirect Attack](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 adding your platforms in the console interface.", + "getMembership" => "Get a team member by the membership unique id. All team members have read access for this resource.", + "updateMembershipRoles" => "Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](/docs/permissions).", "deleteMembership" => "This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted.", - "updateMembershipStatus" => "Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email recieved by the user.", + "updateMembershipStatus" => "Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user.", ]; $parser->formatArray($commands); Console::log("\nRun 'appwrite teams COMMAND --help' for more information on a command."); diff --git a/app/users.php b/app/users.php index ddb16f9..7caa667 100644 --- a/app/users.php +++ b/app/users.php @@ -46,13 +46,17 @@ ->task('list') ->label('description', "Get a list of all the project's users. You can use the query params to filter your results.\n\n") ->param('search', '' , new Wildcard() , 'Search term to filter your list results. Max length: 256 chars.', true) - ->param('limit', 25 , new Wildcard() , 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) - ->param('offset', 0 , new Wildcard() , 'Results offset. The default value is 0. Use this param to manage pagination.', true) + ->param('limit', 25 , new Wildcard() , 'Maximum number of users to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursor', '' , new Wildcard() , 'ID of the user used as the starting point for the query, excluding the user itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursorDirection', 'after' , new Wildcard() , 'Direction of the cursor.', true) ->param('orderType', 'ASC' , new Wildcard() , 'Order result by ASC or DESC order.', true) - ->action(function ( $search, $limit, $offset, $orderType ) use ($parser) { + ->action(function ( $search, $limit, $offset, $cursor, $cursorDirection, $orderType ) use ($parser) { /** @var string $search */ /** @var integer $limit */ /** @var integer $offset */ + /** @var string $cursor */ + /** @var string $cursorDirection */ /** @var string $orderType */ $client = new Client(); @@ -62,6 +66,8 @@ $params['search'] = $search; $params['limit'] = $limit; $params['offset'] = $offset; + $params['cursor'] = $cursor; + $params['cursorDirection'] = $cursorDirection; $params['orderType'] = $orderType; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -72,10 +78,12 @@ $cli ->task('create') ->label('description', "Create a new user.\n\n") + ->param('userId', '' , new Wildcard() , 'User ID. Choose your own unique ID or pass the string `unique()` to auto generate it. 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.', false) ->param('email', '' , new Wildcard() , 'User email.', false) - ->param('password', '' , new Wildcard() , 'User password. Must be between 6 to 32 chars.', false) + ->param('password', '' , new Wildcard() , 'User password. Must be at least 8 chars.', false) ->param('name', '' , new Wildcard() , 'User name. Max length: 128 chars.', true) - ->action(function ( $email, $password, $name ) use ($parser) { + ->action(function ( $userId, $email, $password, $name ) use ($parser) { + /** @var string $userId */ /** @var string $email */ /** @var string $password */ /** @var string $name */ @@ -84,6 +92,7 @@ $path = str_replace([], [], '/users'); $params = []; /** Body Params */ + $params['userId'] = $userId; $params['email'] = $email; $params['password'] = $password; $params['name'] = $name; @@ -96,7 +105,7 @@ $cli ->task('get') ->label('description', "Get a user by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->action(function ( $userId ) use ($parser) { /** @var string $userId */ @@ -112,7 +121,7 @@ $cli ->task('delete') ->label('description', "Delete a user by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->action(function ( $userId ) use ($parser) { /** @var string $userId */ @@ -128,7 +137,7 @@ $cli ->task('updateEmail') ->label('description', "Update the user email by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->param('email', '' , new Wildcard() , 'User email.', false) ->action(function ( $userId, $email ) use ($parser) { /** @var string $userId */ @@ -147,14 +156,21 @@ $cli ->task('getLogs') - ->label('description', "Get a user activity logs list by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) - ->action(function ( $userId ) use ($parser) { + ->label('description', "Get the user activity logs list by its unique ID.\n\n") + ->param('userId', '' , new Wildcard() , 'User ID.', false) + ->param('limit', 25 , new Wildcard() , 'Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('offset', 0 , new Wildcard() , 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->action(function ( $userId, $limit, $offset ) use ($parser) { /** @var string $userId */ + /** @var integer $limit */ + /** @var integer $offset */ $client = new Client(); $path = str_replace(['{userId}'], [$userId], '/users/{userId}/logs'); $params = []; + /** Query Params */ + $params['limit'] = $limit; + $params['offset'] = $offset; $response = $client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', ], $params); @@ -164,7 +180,7 @@ $cli ->task('updateName') ->label('description', "Update the user name by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->param('name', '' , new Wildcard() , 'User name. Max length: 128 chars.', false) ->action(function ( $userId, $name ) use ($parser) { /** @var string $userId */ @@ -184,8 +200,8 @@ $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) + ->param('userId', '' , new Wildcard() , 'User ID.', false) + ->param('password', '' , new Wildcard() , 'New user password. Must be at least 8 chars.', false) ->action(function ( $userId, $password ) use ($parser) { /** @var string $userId */ /** @var string $password */ @@ -204,7 +220,7 @@ $cli ->task('getPrefs') ->label('description', "Get the user preferences by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->action(function ( $userId ) use ($parser) { /** @var string $userId */ @@ -220,7 +236,7 @@ $cli ->task('updatePrefs') ->label('description', "Update the user preferences by its unique ID. You can pass only the specific settings you wish to update.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->param('prefs', '' , new Wildcard() , 'Prefs key-value JSON object.', false) ->action(function ( $userId, $prefs ) use ($parser) { /** @var string $userId */ @@ -240,7 +256,7 @@ $cli ->task('getSessions') ->label('description', "Get the user sessions list by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->action(function ( $userId ) use ($parser) { /** @var string $userId */ @@ -256,7 +272,7 @@ $cli ->task('deleteSessions') ->label('description', "Delete all user's sessions by using the user's unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) ->action(function ( $userId ) use ($parser) { /** @var string $userId */ @@ -272,8 +288,8 @@ $cli ->task('deleteSession') ->label('description', "Delete a user sessions by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) - ->param('sessionId', '' , new Wildcard() , 'User unique session ID.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) + ->param('sessionId', '' , new Wildcard() , 'Session ID.', false) ->action(function ( $userId, $sessionId ) use ($parser) { /** @var string $userId */ /** @var string $sessionId */ @@ -290,17 +306,17 @@ $cli ->task('updateStatus') ->label('description', "Update the user status by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) - ->param('status', '' , new Wildcard() , 'User Status code. To activate the user pass 1, to block the user pass 2 and for disabling the user pass 0', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) + ->param('status', '' , new Wildcard() , 'User Status. To activate the user pass `true` and to block the user pass `false`.', false) ->action(function ( $userId, $status ) use ($parser) { /** @var string $userId */ - /** @var integer $status */ + /** @var boolean $status */ $client = new Client(); $path = str_replace(['{userId}'], [$userId], '/users/{userId}/status'); $params = []; /** Body Params */ - $params['status'] = (int)$status; + $params['status'] = $status; $response = $client->call(Client::METHOD_PATCH, $path, [ 'content-type' => 'application/json', ], $params); @@ -310,8 +326,8 @@ $cli ->task('updateVerification') ->label('description', "Update the user email verification status by its unique ID.\n\n") - ->param('userId', '' , new Wildcard() , 'User unique ID.', false) - ->param('emailVerification', '' , new Wildcard() , 'User Email Verification Status.', false) + ->param('userId', '' , new Wildcard() , 'User ID.', false) + ->param('emailVerification', '' , new Wildcard() , 'User email verification status.', false) ->action(function ( $userId, $emailVerification ) use ($parser) { /** @var string $userId */ /** @var boolean $emailVerification */ @@ -347,7 +363,7 @@ "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.", + "getLogs" => "Get the 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.", diff --git a/docs/examples/account/get-logs.md b/docs/examples/account/get-logs.md index e50c3ca..2bb6de8 100644 --- a/docs/examples/account/get-logs.md +++ b/docs/examples/account/get-logs.md @@ -1 +1,3 @@ -appwrite account getLogs +appwrite account getLogs \ + --limit="0" \ + --offset="0" diff --git a/docs/examples/database/create-boolean-attribute.md b/docs/examples/database/create-boolean-attribute.md new file mode 100644 index 0000000..d892a31 --- /dev/null +++ b/docs/examples/database/create-boolean-attribute.md @@ -0,0 +1,6 @@ +appwrite database createBooleanAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" \ + --required="" \ + --default="" \ + --array="" diff --git a/docs/examples/database/create-collection.md b/docs/examples/database/create-collection.md index fd4504b..362ad04 100644 --- a/docs/examples/database/create-collection.md +++ b/docs/examples/database/create-collection.md @@ -1,5 +1,6 @@ appwrite database createCollection \ + --collectionId="" \ --name="[NAME]" \ - --read="" \ - --write="" \ - --rules="" + --permission="document" \ + --read="["role:all"]" \ + --write="["role:all"]" diff --git a/docs/examples/database/create-document.md b/docs/examples/database/create-document.md index 5f22d4a..23a9d2f 100644 --- a/docs/examples/database/create-document.md +++ b/docs/examples/database/create-document.md @@ -1,8 +1,6 @@ appwrite database createDocument \ --collectionId="[COLLECTION_ID]" \ + --documentId="" \ --data="{}" \ - --read="" \ - --write="" \ - --parentDocument="[PARENT_DOCUMENT]" \ - --parentProperty="" \ - --parentPropertyType="assign" + --read="["role:all"]" \ + --write="["role:all"]" diff --git a/docs/examples/database/create-email-attribute.md b/docs/examples/database/create-email-attribute.md new file mode 100644 index 0000000..1047774 --- /dev/null +++ b/docs/examples/database/create-email-attribute.md @@ -0,0 +1,6 @@ +appwrite database createEmailAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" \ + --required="" \ + --default="email@example.com" \ + --array="" diff --git a/docs/examples/database/create-enum-attribute.md b/docs/examples/database/create-enum-attribute.md new file mode 100644 index 0000000..72f1b9c --- /dev/null +++ b/docs/examples/database/create-enum-attribute.md @@ -0,0 +1,7 @@ +appwrite database createEnumAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" \ + --elements="" \ + --required="" \ + --default="[DEFAULT]" \ + --array="" diff --git a/docs/examples/database/create-float-attribute.md b/docs/examples/database/create-float-attribute.md new file mode 100644 index 0000000..abc4a55 --- /dev/null +++ b/docs/examples/database/create-float-attribute.md @@ -0,0 +1,8 @@ +appwrite database createFloatAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" \ + --required="" \ + --min="" \ + --max="" \ + --default="" \ + --array="" diff --git a/docs/examples/database/create-index.md b/docs/examples/database/create-index.md new file mode 100644 index 0000000..8d66bb2 --- /dev/null +++ b/docs/examples/database/create-index.md @@ -0,0 +1,6 @@ +appwrite database createIndex \ + --collectionId="[COLLECTION_ID]" \ + --key="" \ + --type="key" \ + --attributes="" \ + --orders="" diff --git a/docs/examples/database/create-integer-attribute.md b/docs/examples/database/create-integer-attribute.md new file mode 100644 index 0000000..73abc3f --- /dev/null +++ b/docs/examples/database/create-integer-attribute.md @@ -0,0 +1,8 @@ +appwrite database createIntegerAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" \ + --required="" \ + --min="" \ + --max="" \ + --default="" \ + --array="" diff --git a/docs/examples/database/create-ip-attribute.md b/docs/examples/database/create-ip-attribute.md new file mode 100644 index 0000000..d3dd96e --- /dev/null +++ b/docs/examples/database/create-ip-attribute.md @@ -0,0 +1,6 @@ +appwrite database createIpAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" \ + --required="" \ + --default="" \ + --array="" diff --git a/docs/examples/database/create-string-attribute.md b/docs/examples/database/create-string-attribute.md new file mode 100644 index 0000000..6c0eaa3 --- /dev/null +++ b/docs/examples/database/create-string-attribute.md @@ -0,0 +1,7 @@ +appwrite database createStringAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" \ + --size="1" \ + --required="" \ + --default="[DEFAULT]" \ + --array="" diff --git a/docs/examples/database/create-url-attribute.md b/docs/examples/database/create-url-attribute.md new file mode 100644 index 0000000..bc965d4 --- /dev/null +++ b/docs/examples/database/create-url-attribute.md @@ -0,0 +1,6 @@ +appwrite database createUrlAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" \ + --required="" \ + --default="https://example.com" \ + --array="" diff --git a/docs/examples/database/delete-attribute.md b/docs/examples/database/delete-attribute.md new file mode 100644 index 0000000..1a46094 --- /dev/null +++ b/docs/examples/database/delete-attribute.md @@ -0,0 +1,3 @@ +appwrite database deleteAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" diff --git a/docs/examples/database/delete-index.md b/docs/examples/database/delete-index.md new file mode 100644 index 0000000..cd9db99 --- /dev/null +++ b/docs/examples/database/delete-index.md @@ -0,0 +1,3 @@ +appwrite database deleteIndex \ + --collectionId="[COLLECTION_ID]" \ + --key="" diff --git a/docs/examples/database/get-attribute.md b/docs/examples/database/get-attribute.md new file mode 100644 index 0000000..d69f1e6 --- /dev/null +++ b/docs/examples/database/get-attribute.md @@ -0,0 +1,3 @@ +appwrite database getAttribute \ + --collectionId="[COLLECTION_ID]" \ + --key="" diff --git a/docs/examples/database/get-index.md b/docs/examples/database/get-index.md new file mode 100644 index 0000000..e144097 --- /dev/null +++ b/docs/examples/database/get-index.md @@ -0,0 +1,3 @@ +appwrite database getIndex \ + --collectionId="[COLLECTION_ID]" \ + --key="" diff --git a/docs/examples/database/list-attributes.md b/docs/examples/database/list-attributes.md new file mode 100644 index 0000000..24a89a0 --- /dev/null +++ b/docs/examples/database/list-attributes.md @@ -0,0 +1,2 @@ +appwrite database listAttributes \ + --collectionId="[COLLECTION_ID]" diff --git a/docs/examples/database/list-collections.md b/docs/examples/database/list-collections.md index b5cbb99..9d655db 100644 --- a/docs/examples/database/list-collections.md +++ b/docs/examples/database/list-collections.md @@ -2,4 +2,6 @@ appwrite database listCollections \ --search="[SEARCH]" \ --limit="0" \ --offset="0" \ + --cursor="[CURSOR]" \ + --cursorDirection="after" \ --orderType="ASC" diff --git a/docs/examples/database/list-documents.md b/docs/examples/database/list-documents.md index 6114821..7c37175 100644 --- a/docs/examples/database/list-documents.md +++ b/docs/examples/database/list-documents.md @@ -1,9 +1,9 @@ appwrite database listDocuments \ --collectionId="[COLLECTION_ID]" \ - --filters="" \ + --queries="" \ --limit="0" \ --offset="0" \ - --orderField="[ORDER_FIELD]" \ - --orderType="DESC" \ - --orderCast="int" \ - --search="[SEARCH]" + --cursor="[CURSOR]" \ + --cursorDirection="after" \ + --orderAttributes="" \ + --orderTypes="" diff --git a/docs/examples/database/list-indexes.md b/docs/examples/database/list-indexes.md new file mode 100644 index 0000000..3dd8916 --- /dev/null +++ b/docs/examples/database/list-indexes.md @@ -0,0 +1,2 @@ +appwrite database listIndexes \ + --collectionId="[COLLECTION_ID]" diff --git a/docs/examples/database/update-collection.md b/docs/examples/database/update-collection.md index 510c4a5..1c0670d 100644 --- a/docs/examples/database/update-collection.md +++ b/docs/examples/database/update-collection.md @@ -1,6 +1,7 @@ appwrite database updateCollection \ --collectionId="[COLLECTION_ID]" \ --name="[NAME]" \ - --read="" \ - --write="" \ - --rules="" + --permission="document" \ + --read="["role:all"]" \ + --write="["role:all"]" \ + --enabled="" diff --git a/docs/examples/database/update-document.md b/docs/examples/database/update-document.md index f449d09..90a0c83 100644 --- a/docs/examples/database/update-document.md +++ b/docs/examples/database/update-document.md @@ -2,5 +2,5 @@ appwrite database updateDocument \ --collectionId="[COLLECTION_ID]" \ --documentId="[DOCUMENT_ID]" \ --data="{}" \ - --read="" \ - --write="" + --read="["role:all"]" \ + --write="["role:all"]" diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index e8cd43e..1042725 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -1,7 +1,8 @@ appwrite functions create \ + --functionId="" \ --name="[NAME]" \ --execute="" \ - --runtime="dotnet-5.0" \ + --runtime="node-14.5" \ --vars="{}" \ --events="" \ --schedule="" \ diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index addc289..088ce67 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -1,6 +1,7 @@ appwrite functions listExecutions \ --functionId="[FUNCTION_ID]" \ - --search="[SEARCH]" \ --limit="0" \ --offset="0" \ - --orderType="ASC" + --search="[SEARCH]" \ + --cursor="[CURSOR]" \ + --cursorDirection="after" diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md new file mode 100644 index 0000000..15dc019 --- /dev/null +++ b/docs/examples/functions/list-runtimes.md @@ -0,0 +1 @@ +appwrite functions listRuntimes diff --git a/docs/examples/functions/list-tags.md b/docs/examples/functions/list-tags.md index 773b83a..d675cf4 100644 --- a/docs/examples/functions/list-tags.md +++ b/docs/examples/functions/list-tags.md @@ -3,4 +3,6 @@ appwrite functions listTags \ --search="[SEARCH]" \ --limit="0" \ --offset="0" \ + --cursor="[CURSOR]" \ + --cursorDirection="after" \ --orderType="ASC" diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index 23db398..9bcae19 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -2,4 +2,6 @@ appwrite functions list \ --search="[SEARCH]" \ --limit="0" \ --offset="0" \ + --cursor="[CURSOR]" \ + --cursorDirection="after" \ --orderType="ASC" diff --git a/docs/examples/health/get-anti-virus.md b/docs/examples/health/get-anti-virus.md deleted file mode 100644 index 744e8b3..0000000 --- a/docs/examples/health/get-anti-virus.md +++ /dev/null @@ -1 +0,0 @@ -appwrite health getAntiVirus diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md new file mode 100644 index 0000000..96dd7e7 --- /dev/null +++ b/docs/examples/health/get-antivirus.md @@ -0,0 +1 @@ +appwrite health getAntivirus diff --git a/docs/examples/health/get-queue-tasks.md b/docs/examples/health/get-queue-tasks.md deleted file mode 100644 index 47bf2a3..0000000 --- a/docs/examples/health/get-queue-tasks.md +++ /dev/null @@ -1 +0,0 @@ -appwrite health getQueueTasks diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index e68e802..b11de00 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,4 +1,5 @@ appwrite storage createFile \ + --fileId="" \ --file="" \ --read="" \ --write="" diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index d87763b..ed25491 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -8,6 +8,6 @@ appwrite storage getFilePreview \ --borderColor="" \ --borderRadius="0" \ --opacity="0" \ - --rotation="0" \ + --rotation="-360" \ --background="" \ --output="jpg" diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 67df528..a233551 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -2,4 +2,6 @@ appwrite storage listFiles \ --search="[SEARCH]" \ --limit="0" \ --offset="0" \ + --cursor="[CURSOR]" \ + --cursorDirection="after" \ --orderType="ASC" diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index 59dd9a1..5a389b2 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -1,3 +1,4 @@ appwrite teams create \ + --teamId="" \ --name="[NAME]" \ --roles="" diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md new file mode 100644 index 0000000..47ece4e --- /dev/null +++ b/docs/examples/teams/get-membership.md @@ -0,0 +1,3 @@ +appwrite teams getMembership \ + --teamId="[TEAM_ID]" \ + --membershipId="[MEMBERSHIP_ID]" diff --git a/docs/examples/teams/get-memberships.md b/docs/examples/teams/get-memberships.md index dafe834..a4b0e54 100644 --- a/docs/examples/teams/get-memberships.md +++ b/docs/examples/teams/get-memberships.md @@ -3,4 +3,6 @@ appwrite teams getMemberships \ --search="[SEARCH]" \ --limit="0" \ --offset="0" \ + --cursor="[CURSOR]" \ + --cursorDirection="after" \ --orderType="ASC" diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index c6c5090..1cc806c 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -2,4 +2,6 @@ appwrite teams list \ --search="[SEARCH]" \ --limit="0" \ --offset="0" \ + --cursor="[CURSOR]" \ + --cursorDirection="after" \ --orderType="ASC" diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 428f5d8..b16ed3d 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -1,4 +1,5 @@ appwrite users create \ + --userId="" \ --email="email@example.com" \ --password="password" \ --name="[NAME]" diff --git a/docs/examples/users/get-logs.md b/docs/examples/users/get-logs.md index c2e1f30..f013d5b 100644 --- a/docs/examples/users/get-logs.md +++ b/docs/examples/users/get-logs.md @@ -1,2 +1,4 @@ appwrite users getLogs \ - --userId="[USER_ID]" + --userId="[USER_ID]" \ + --limit="0" \ + --offset="0" diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index a8d95ce..1f92a51 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -2,4 +2,6 @@ appwrite users list \ --search="[SEARCH]" \ --limit="0" \ --offset="0" \ + --cursor="[CURSOR]" \ + --cursorDirection="after" \ --orderType="ASC" diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index d2cd0c5..00fbb4b 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -1,3 +1,3 @@ appwrite users updateStatus \ --userId="[USER_ID]" \ - --status="1" + --status="" diff --git a/src/Client.php b/src/Client.php index 94b4703..4909676 100644 --- a/src/Client.php +++ b/src/Client.php @@ -30,7 +30,7 @@ class Client protected $headers = [ 'content-type' => '', 'x-sdk-version' => 'appwrite:cli:0.12.1', - 'X-Appwrite-Response-Format' => '0.11.0' ]; + 'X-Appwrite-Response-Format' => '0.12.0' ]; /** * Default User Preferences