From 87132fd03722066c3ff630e84d1054c19e84acfc Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 2 Sep 2022 09:39:37 +0000 Subject: [PATCH 1/4] update to support 1.0.0-RC1 --- LICENSE | 2 +- README.md | 4 +- docs/account.md | 9 +- docs/avatars.md | 2 +- docs/databases.md | 182 +++-- .../databases/create-boolean-attribute.md | 4 +- docs/examples/databases/create-collection.md | 4 +- .../databases/create-datetime-attribute.md | 16 + docs/examples/databases/create-document.md | 4 +- .../databases/create-email-attribute.md | 4 +- .../databases/create-enum-attribute.md | 4 +- .../databases/create-float-attribute.md | 4 +- docs/examples/databases/create-index.md | 4 +- .../databases/create-integer-attribute.md | 4 +- .../examples/databases/create-ip-attribute.md | 4 +- .../databases/create-string-attribute.md | 4 +- .../databases/create-url-attribute.md | 4 +- docs/examples/databases/create.md | 4 +- docs/examples/databases/delete-attribute.md | 4 +- docs/examples/databases/delete-collection.md | 4 +- docs/examples/databases/delete-document.md | 4 +- docs/examples/databases/delete-index.md | 4 +- docs/examples/databases/delete.md | 4 +- docs/examples/databases/get-attribute.md | 4 +- docs/examples/databases/get-collection.md | 4 +- docs/examples/databases/get-document.md | 4 +- docs/examples/databases/get-index.md | 4 +- docs/examples/databases/get.md | 4 +- docs/examples/databases/list-attributes.md | 4 +- docs/examples/databases/list-collections.md | 4 +- docs/examples/databases/list-documents.md | 4 +- docs/examples/databases/list-indexes.md | 4 +- docs/examples/databases/list.md | 2 +- docs/examples/databases/update-collection.md | 4 +- docs/examples/databases/update-document.md | 4 +- docs/examples/databases/update.md | 4 +- docs/examples/functions/create-deployment.md | 3 +- docs/examples/functions/create-variable.md | 16 + docs/examples/functions/create.md | 2 +- docs/examples/functions/delete-variable.md | 16 + docs/examples/functions/get-variable.md | 16 + docs/examples/functions/list-variables.md | 16 + docs/examples/functions/update-variable.md | 16 + docs/examples/functions/update.md | 2 +- docs/examples/storage/create-bucket.md | 2 +- docs/examples/storage/create-file.md | 3 +- docs/examples/storage/update-bucket.md | 2 +- docs/examples/users/create-argon2user.md | 16 + docs/examples/users/create-bcrypt-user.md | 16 + docs/examples/users/create-m-d5user.md | 16 + docs/examples/users/create-p-h-pass-user.md | 16 + docs/examples/users/create-s-h-a-user.md | 16 + .../users/create-scrypt-modified-user.md | 16 + docs/examples/users/create-scrypt-user.md | 16 + docs/examples/users/create.md | 2 +- docs/functions.md | 102 ++- docs/storage.md | 32 +- docs/teams.md | 12 +- docs/users.md | 140 +++- src/Appwrite/Client.php | 7 +- src/Appwrite/ID.php | 15 + src/Appwrite/Permission.php | 27 + src/Appwrite/Query.php | 90 ++- src/Appwrite/Role.php | 34 + src/Appwrite/Services/Account.php | 112 +-- src/Appwrite/Services/Avatars.php | 40 +- src/Appwrite/Services/Databases.php | 639 +++++++++++------- src/Appwrite/Services/Functions.php | 354 ++++++---- src/Appwrite/Services/Health.php | 5 + src/Appwrite/Services/Locale.php | 5 + src/Appwrite/Services/Storage.php | 223 +++--- src/Appwrite/Services/Teams.php | 133 ++-- src/Appwrite/Services/Users.php | 554 +++++++++++++-- 73 files changed, 2134 insertions(+), 931 deletions(-) create mode 100644 docs/examples/databases/create-datetime-attribute.md create mode 100644 docs/examples/functions/create-variable.md create mode 100644 docs/examples/functions/delete-variable.md create mode 100644 docs/examples/functions/get-variable.md create mode 100644 docs/examples/functions/list-variables.md create mode 100644 docs/examples/functions/update-variable.md create mode 100644 docs/examples/users/create-argon2user.md create mode 100644 docs/examples/users/create-bcrypt-user.md create mode 100644 docs/examples/users/create-m-d5user.md create mode 100644 docs/examples/users/create-p-h-pass-user.md create mode 100644 docs/examples/users/create-s-h-a-user.md create mode 100644 docs/examples/users/create-scrypt-modified-user.md create mode 100644 docs/examples/users/create-scrypt-user.md create mode 100644 src/Appwrite/ID.php create mode 100644 src/Appwrite/Permission.php create mode 100644 src/Appwrite/Role.php diff --git a/LICENSE b/LICENSE index 96201c4..b0761cc 100644 --- a/LICENSE +++ b/LICENSE @@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification, 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index f05b8cd..0f9a5f7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-0.15.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-blue.svg?style=flat-square&v=1) [![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.15.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** +**This SDK is compatible with Appwrite server version 1.0.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/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 PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/docs/account.md b/docs/account.md index 89eea7b..a1ca2e5 100644 --- a/docs/account.md +++ b/docs/account.md @@ -37,8 +37,7 @@ GET https://HOSTNAME/v1/account/logs | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| limit | integer | Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only supported methods are limit and offset | [] | ## Update Account Name @@ -75,13 +74,13 @@ PATCH https://HOSTNAME/v1/account/password PATCH https://HOSTNAME/v1/account/phone ``` -** Update currently logged in user account phone number. After changing phone number, the user confirmation status will get reset. A new confirmation SMS is not sent automatically however you can use the phone confirmation endpoint again to send the confirmation SMS. ** +** Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) endpoint to send a confirmation SMS. ** ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| number | string | Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| phone | string | Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | | password | string | User password. Must be at least 8 chars. | | ## Get Account Preferences @@ -245,7 +244,7 @@ PUT https://HOSTNAME/v1/account/verification POST https://HOSTNAME/v1/account/verification/phone ``` -** Use this endpoint to send a verification message to your user's phone number to confirm they are the valid owners of that address. The provided secret should allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](/docs/client/account#accountUpdatePhoneVerification). The verification link sent to the user's phone number is valid for 15 minutes. ** +** Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone) endpoint. Learn more about how to [complete the verification process](/docs/client/account#accountUpdatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. ** ## Create Phone Verification (confirmation) diff --git a/docs/avatars.md b/docs/avatars.md index 015b45e..96baee4 100644 --- a/docs/avatars.md +++ b/docs/avatars.md @@ -60,7 +60,7 @@ GET https://HOSTNAME/v1/avatars/favicon GET https://HOSTNAME/v1/avatars/flags/{code} ``` -** You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. +** You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. ** diff --git a/docs/databases.md b/docs/databases.md index a3cedd9..6d02b7b 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -6,16 +6,14 @@ GET https://HOSTNAME/v1/databases ``` +** Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| limit | integer | Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | -| cursor | string | 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. | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderType | string | Order result by ASC or DESC order. | ASC | ## Create Database @@ -23,10 +21,14 @@ GET https://HOSTNAME/v1/databases POST https://HOSTNAME/v1/databases ``` +** Create a new Database. + ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| databaseId | string | 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. | | | name | string | Collection name. Max length: 128 chars. | | ## Get Database @@ -35,16 +37,27 @@ POST https://HOSTNAME/v1/databases GET https://HOSTNAME/v1/databases/{databaseId} ``` +** Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | + ## Update Database ```http request PUT https://HOSTNAME/v1/databases/{databaseId} ``` +** Update a database by its unique ID. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | | name | string | Collection name. Max length: 128 chars. | | ## Delete Database @@ -53,22 +66,29 @@ PUT https://HOSTNAME/v1/databases/{databaseId} DELETE https://HOSTNAME/v1/databases/{databaseId} ``` +** Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | + ## List Collections ```http request GET https://HOSTNAME/v1/databases/{databaseId}/collections ``` +** Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| limit | integer | Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | -| cursor | string | 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. | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderType | string | Order result by ASC or DESC order. | ASC | ## Create Collection @@ -76,15 +96,17 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections POST https://HOSTNAME/v1/databases/{databaseId}/collections ``` +** Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | | collectionId | string | 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. | | | name | string | Collection name. Max length: 128 chars. | | -| permission | string | Specifies the permissions model used in this collection, which accepts either 'collection' or 'document'. For 'collection' level permission, the permissions specified in read and write params are applied to all documents in the collection. For 'document' level permissions, read and write permissions are specified in each document. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. | | -| read | array | 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. | | -| write | array | 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. | | +| permissions | array | An array of permissions strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions). | | +| documentSecurity | boolean | Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions). | | ## Get Collection @@ -92,10 +114,13 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} ``` +** Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | ## Update Collection @@ -104,15 +129,17 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} PUT https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} ``` +** Update a collection by its unique ID. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | | name | string | Collection name. Max length: 128 chars. | | -| permission | string | 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. | | -| read | array | 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. | | -| write | array | 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. | | +| permissions | array | An array of permission strings. By default the current permission are inherited. [Learn more about permissions](/docs/permissions). | | +| documentSecurity | boolean | Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions). | | | enabled | boolean | Is collection enabled? | 1 | ## Delete Collection @@ -121,10 +148,13 @@ PUT https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId} ``` +** Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | ## List Attributes @@ -137,7 +167,8 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attrib | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | ## Create Boolean Attribute @@ -145,27 +176,52 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attrib POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/boolean ``` +** Create a boolean attribute. + ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | boolean | Default value for attribute when not provided. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | +## Create DateTime Attribute + +```http request +POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/datetime +``` + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| key | string | Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| array | boolean | Is attribute an array? | | + ## Create Email Attribute ```http request POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/email ``` +** Create an email attribute. + ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -181,7 +237,8 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | elements | array | Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 4096 characters long. | | | required | boolean | Is attribute required? | | @@ -194,11 +251,15 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/float ``` +** Create a float attribute. Optionally, minimum and maximum values can be provided. + ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | min | number | Minimum value to enforce on new documents | | @@ -212,11 +273,15 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/integer ``` +** Create an integer attribute. Optionally, minimum and maximum values can be provided. + ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | min | integer | Minimum value to enforce on new documents | | @@ -230,11 +295,15 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/ip ``` +** Create IP address attribute. + ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -246,11 +315,15 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/string ``` +** Create a string attribute. + ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | size | integer | Attribute size for text attributes, in number of characters. | | | required | boolean | Is attribute required? | | @@ -263,11 +336,15 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attributes/url ``` +** Create a URL attribute. + ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -283,7 +360,8 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attrib | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | ## Delete Attribute @@ -296,7 +374,8 @@ DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/att | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | ## List Documents @@ -305,18 +384,15 @@ DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/att GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents ``` +** Get a list of all the user's documents in a given collection. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of documents belonging to the provided collectionId. [Learn more about different API modes](/docs/admin). ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. | [] | -| limit | integer | Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | -| cursor | string | 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) | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderAttributes | array | Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 4096 characters long. | [] | -| orderTypes | array | Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed. | [] | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. | [] | ## Create Document @@ -324,15 +400,17 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/docume POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents ``` +** Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). Make sure to define attributes before creating documents. | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. | | | documentId | string | 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. | | | data | object | Document data as JSON object. | {} | -| read | array | 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. | | -| write | array | 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. | | +| permissions | array | An array of permissions strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). | | ## Get Document @@ -340,11 +418,14 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/docum GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ``` +** Get a document by its unique ID. This endpoint response returns a JSON object with the document data. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | documentId | string | **Required** Document ID. | | ## Update Document @@ -353,15 +434,17 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/docume PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ``` +** Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | | documentId | string | **Required** Document ID. | | | data | object | Document data as JSON object. Include only attribute and value pairs to be updated. | {} | -| read | array | 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. | | -| write | array | 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. | | +| permissions | array | An array of permissions strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). | | ## Delete Document @@ -369,11 +452,14 @@ PATCH https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/docu DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ``` +** Delete a document by its unique ID. ** + ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | documentId | string | **Required** Document ID. | | ## List Indexes @@ -386,7 +472,8 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/indexe | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | ## Create Index @@ -398,7 +485,8 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/index | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Index Key. | | | type | string | Index type. | | | attributes | array | Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. | | @@ -414,7 +502,8 @@ GET https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/indexe | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Index Key. | | ## Delete Index @@ -427,6 +516,7 @@ DELETE https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/ind | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). | | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Index Key. | | diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index d125f63..274f66f 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createBooleanAttribute('[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createBooleanAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index 8aba64a..bde7c9e 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createCollection('[COLLECTION_ID]', '[NAME]', 'document', ["role:all"], ["role:all"]); \ No newline at end of file +$result = $databases->createCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]', ["read("any")"], false); \ No newline at end of file diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md new file mode 100644 index 0000000..420675e --- /dev/null +++ b/docs/examples/databases/create-datetime-attribute.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$databases = new Databases($client); + +$result = $databases->createDatetimeAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 34f16d6..8fbf102 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', []); \ No newline at end of file +$result = $databases->createDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]', []); \ No newline at end of file diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index 196ef91..ff7f1ac 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createEmailAttribute('[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createEmailAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index e5ba725..44a0fae 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createEnumAttribute('[COLLECTION_ID]', '', [], false); \ No newline at end of file +$result = $databases->createEnumAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', [], false); \ No newline at end of file diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index 902ec79..5ee3647 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createFloatAttribute('[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createFloatAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index e81662c..9a2c1b7 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createIndex('[COLLECTION_ID]', '', 'key', []); \ No newline at end of file +$result = $databases->createIndex('[DATABASE_ID]', '[COLLECTION_ID]', '', 'key', []); \ No newline at end of file diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index 73b10fd..9746922 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createIntegerAttribute('[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createIntegerAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index a750ef6..f2318a4 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createIpAttribute('[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createIpAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index 33440a9..975e633 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createStringAttribute('[COLLECTION_ID]', '', 1, false); \ No newline at end of file +$result = $databases->createStringAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', 1, false); \ No newline at end of file diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index 1a40bee..79bce0c 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->createUrlAttribute('[COLLECTION_ID]', '', false); \ No newline at end of file +$result = $databases->createUrlAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); \ No newline at end of file diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index 4618e1a..a4a5fb6 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->create('[NAME]'); \ No newline at end of file +$result = $databases->create('[DATABASE_ID]', '[NAME]'); \ No newline at end of file diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index d25b318..8643a94 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->deleteAttribute('[COLLECTION_ID]', ''); \ No newline at end of file +$result = $databases->deleteAttribute('[DATABASE_ID]', '[COLLECTION_ID]', ''); \ No newline at end of file diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index e8fa73a..6ebd2ca 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->deleteCollection('[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->deleteCollection('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 936f704..3d9633e 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->deleteDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); \ No newline at end of file +$result = $databases->deleteDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index 8e6a976..7fb417d 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->deleteIndex('[COLLECTION_ID]', ''); \ No newline at end of file +$result = $databases->deleteIndex('[DATABASE_ID]', '[COLLECTION_ID]', ''); \ No newline at end of file diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 8192ad3..dfb1fa1 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->delete(); \ No newline at end of file +$result = $databases->delete('[DATABASE_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index 5237335..e0f03cd 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->getAttribute('[COLLECTION_ID]', ''); \ No newline at end of file +$result = $databases->getAttribute('[DATABASE_ID]', '[COLLECTION_ID]', ''); \ No newline at end of file diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index 25ad73a..9168c7a 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->getCollection('[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->getCollection('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 6f58bff..06a41fe 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->getDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); \ No newline at end of file +$result = $databases->getDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index 91e7761..d110544 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->getIndex('[COLLECTION_ID]', ''); \ No newline at end of file +$result = $databases->getIndex('[DATABASE_ID]', '[COLLECTION_ID]', ''); \ No newline at end of file diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index 5255cc7..629718a 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->get(); \ No newline at end of file +$result = $databases->get('[DATABASE_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index 3a32fde..0586032 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->listAttributes('[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->listAttributes('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index 9ea900d..b26540e 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->listCollections(); \ No newline at end of file +$result = $databases->listCollections('[DATABASE_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 55e7b0f..3dacec0 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->listDocuments('[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->listDocuments('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index a8e9833..5b06141 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->listIndexes('[COLLECTION_ID]'); \ No newline at end of file +$result = $databases->listIndexes('[DATABASE_ID]', '[COLLECTION_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index 3b27872..74daf1a 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); $result = $databases->list(); \ No newline at end of file diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 753e21a..1ce3ff3 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->updateCollection('[COLLECTION_ID]', '[NAME]', 'document'); \ No newline at end of file +$result = $databases->updateCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]', false); \ No newline at end of file diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 43388ee..e8f6dd9 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); \ No newline at end of file +$result = $databases->updateDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]'); \ No newline at end of file diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index a2bfb7d..32daa16 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -11,6 +11,6 @@ $client ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -$databases = new Databases($client, '[DATABASE_ID]'); +$databases = new Databases($client); -$result = $databases->update('[NAME]'); \ No newline at end of file +$result = $databases->update('[DATABASE_ID]', '[NAME]'); \ No newline at end of file diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 4df1ad8..1286055 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -1,6 +1,7 @@ createDeployment('[FUNCTION_ID]', '[ENTRYPOINT]', 'file.png', false); \ No newline at end of file +$result = $functions->createDeployment('[FUNCTION_ID]', '[ENTRYPOINT]', InputFile::withPath('file.png'), false); \ No newline at end of file diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md new file mode 100644 index 0000000..9a443b2 --- /dev/null +++ b/docs/examples/functions/create-variable.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->createVariable('[FUNCTION_ID]', '[KEY]', '[VALUE]'); \ No newline at end of file diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 69f8d7f..276a5ee 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -13,4 +13,4 @@ $client $functions = new Functions($client); -$result = $functions->create('[FUNCTION_ID]', '[NAME]', [], 'node-14.5'); \ No newline at end of file +$result = $functions->create('[FUNCTION_ID]', '[NAME]', ["any"], 'node-14.5'); \ No newline at end of file diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md new file mode 100644 index 0000000..98a1ea1 --- /dev/null +++ b/docs/examples/functions/delete-variable.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->deleteVariable('[FUNCTION_ID]', '[VARIABLE_ID]'); \ No newline at end of file diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md new file mode 100644 index 0000000..c30d9d2 --- /dev/null +++ b/docs/examples/functions/get-variable.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->getVariable('[FUNCTION_ID]', '[VARIABLE_ID]'); \ No newline at end of file diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md new file mode 100644 index 0000000..58d5570 --- /dev/null +++ b/docs/examples/functions/list-variables.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->listVariables('[FUNCTION_ID]'); \ No newline at end of file diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md new file mode 100644 index 0000000..efbe12d --- /dev/null +++ b/docs/examples/functions/update-variable.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->updateVariable('[FUNCTION_ID]', '[VARIABLE_ID]', '[KEY]'); \ No newline at end of file diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index b33ac8a..5829430 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -13,4 +13,4 @@ $client $functions = new Functions($client); -$result = $functions->update('[FUNCTION_ID]', '[NAME]', []); \ No newline at end of file +$result = $functions->update('[FUNCTION_ID]', '[NAME]', ["any"]); \ No newline at end of file diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index 8dc1498..27d7a3d 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -13,4 +13,4 @@ $client $storage = new Storage($client); -$result = $storage->createBucket('[BUCKET_ID]', '[NAME]', 'file'); \ No newline at end of file +$result = $storage->createBucket('[BUCKET_ID]', '[NAME]', false); \ No newline at end of file diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 883f565..0fc57b9 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,6 +1,7 @@ createFile('[BUCKET_ID]', '[FILE_ID]', 'file.png'); \ No newline at end of file +$result = $storage->createFile('[BUCKET_ID]', '[FILE_ID]', InputFile::withPath('file.png')); \ No newline at end of file diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 57dca9c..07c6f83 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -13,4 +13,4 @@ $client $storage = new Storage($client); -$result = $storage->updateBucket('[BUCKET_ID]', '[NAME]', 'file'); \ No newline at end of file +$result = $storage->updateBucket('[BUCKET_ID]', '[NAME]', false); \ No newline at end of file diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon2user.md new file mode 100644 index 0000000..acd40e2 --- /dev/null +++ b/docs/examples/users/create-argon2user.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->createArgon2User('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md new file mode 100644 index 0000000..a9d218e --- /dev/null +++ b/docs/examples/users/create-bcrypt-user.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->createBcryptUser('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-m-d5user.md new file mode 100644 index 0000000..11f47ec --- /dev/null +++ b/docs/examples/users/create-m-d5user.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->createMD5User('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-p-h-pass-user.md new file mode 100644 index 0000000..57f8074 --- /dev/null +++ b/docs/examples/users/create-p-h-pass-user.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->createPHPassUser('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md new file mode 100644 index 0000000..018bb2c --- /dev/null +++ b/docs/examples/users/create-s-h-a-user.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->createSHAUser('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md new file mode 100644 index 0000000..494def2 --- /dev/null +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->createScryptModifiedUser('[USER_ID]', 'email@example.com', 'password', '[PASSWORD_SALT]', '[PASSWORD_SALT_SEPARATOR]', '[PASSWORD_SIGNER_KEY]'); \ No newline at end of file diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md new file mode 100644 index 0000000..9774c9c --- /dev/null +++ b/docs/examples/users/create-scrypt-user.md @@ -0,0 +1,16 @@ +setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->createScryptUser('[USER_ID]', 'email@example.com', 'password', '[PASSWORD_SALT]', null, null, null, null); \ No newline at end of file diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 5292b21..545952e 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -13,4 +13,4 @@ $client $users = new Users($client); -$result = $users->create('[USER_ID]', 'email@example.com', 'password'); \ No newline at end of file +$result = $users->create('[USER_ID]'); \ No newline at end of file diff --git a/docs/functions.md b/docs/functions.md index 168e36d..6a6110b 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -12,12 +12,8 @@ GET https://HOSTNAME/v1/functions | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, status, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| limit | integer | Maximum number of functions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | -| cursor | string | 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) | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderType | string | Order result by ASC or DESC order. | ASC | ## Create Function @@ -33,9 +29,8 @@ POST https://HOSTNAME/v1/functions | --- | --- | --- | --- | | functionId | string | 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. | | | name | string | Function name. Max length: 128 chars. | | -| execute | array | 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. Maximum of 100 scopes are allowed, each 64 characters long. | | +| execute | array | An array of strings with execution roles. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 64 characters long. | | | runtime | string | Execution runtime. | | -| vars | object | Key-value JSON object that will be passed to the function as environment variables. | {} | | events | array | Events list. Maximum of 100 events are allowed. | [] | | schedule | string | Schedule CRON syntax. | | | timeout | integer | Function maximum execution time in seconds. | 15 | @@ -76,8 +71,7 @@ PUT https://HOSTNAME/v1/functions/{functionId} | --- | --- | --- | --- | | functionId | string | **Required** Function ID. | | | name | string | Function name. Max length: 128 chars. | | -| execute | array | 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. Maximum of 100 scopes are allowed, each 64 characters long. | | -| vars | object | Key-value JSON object that will be passed to the function as environment variables. | {} | +| execute | array | An array of strings with execution roles. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 64 characters long. | | | events | array | Events list. Maximum of 100 events are allowed. | [] | | schedule | string | Schedule CRON syntax. | | | timeout | integer | Maximum execution time in seconds. | 15 | @@ -109,12 +103,8 @@ GET https://HOSTNAME/v1/functions/{functionId}/deployments | Field Name | Type | Description | Default | | --- | --- | --- | --- | | functionId | string | **Required** Function ID. | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: entrypoint, size, buildId, activate | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| limit | integer | Maximum number of deployments to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | -| cursor | string | ID of the deployment used as the starting point for the query, excluding the deployment itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderType | string | Order result by ASC or DESC order. | ASC | ## Create Deployment @@ -209,11 +199,8 @@ GET https://HOSTNAME/v1/functions/{functionId}/executions | Field Name | Type | Description | Default | | --- | --- | --- | --- | | functionId | string | **Required** Function ID. | | -| limit | integer | Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, statusCode, time | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| cursor | string | 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) | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | ## Create Execution @@ -246,3 +233,82 @@ GET https://HOSTNAME/v1/functions/{functionId}/executions/{executionId} | functionId | string | **Required** Function ID. | | | executionId | string | **Required** Execution ID. | | +## List Variables + +```http request +GET https://HOSTNAME/v1/functions/{functionId}/variables +``` + +** Get a list of all variables of a specific function. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| functionId | string | **Required** Function unique ID. | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key | [] | +| search | string | Search term to filter your list results. Max length: 256 chars. | | + +## Create Variable + +```http request +POST https://HOSTNAME/v1/functions/{functionId}/variables +``` + +** Create a new function variable. These variables can be accessed within function in the `env` object under the request variable. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| functionId | string | **Required** Function unique ID. | | +| key | string | Variable key. Max length: 255 chars. | | +| value | string | Variable value. Max length: 8192 chars. | | + +## Get Variable + +```http request +GET https://HOSTNAME/v1/functions/{functionId}/variables/{variableId} +``` + +** Get a variable by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| functionId | string | **Required** Function unique ID. | | +| variableId | string | **Required** Variable unique ID. | | + +## Update Variable + +```http request +PUT https://HOSTNAME/v1/functions/{functionId}/variables/{variableId} +``` + +** Update variable by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| functionId | string | **Required** Function unique ID. | | +| variableId | string | **Required** Variable unique ID. | | +| key | string | Variable key. Max length: 255 chars. | | +| value | string | Variable value. Max length: 8192 chars. | | + +## Delete Variable + +```http request +DELETE https://HOSTNAME/v1/functions/{functionId}/variables/{variableId} +``` + +** Delete a variable by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| functionId | string | **Required** Function unique ID. | | +| variableId | string | **Required** Variable unique ID. | | + diff --git a/docs/storage.md b/docs/storage.md index fb1fce6..82c734a 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -12,12 +12,8 @@ GET https://HOSTNAME/v1/storage/buckets | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 | -| cursor | string | ID of the bucket used as the starting point for the query, excluding the bucket itself. Should be used for efficient pagination when working with large sets of data. | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderType | string | Order result by ASC or DESC order. | ASC | ## Create bucket @@ -33,12 +29,12 @@ POST https://HOSTNAME/v1/storage/buckets | --- | --- | --- | --- | | bucketId | string | 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. | | | name | string | Bucket name | | -| permission | string | Permissions type model to use for reading files in this bucket. You can use bucket-level permission set once on the bucket using the `read` and `write` params, or you can set file-level permission where each file read and write params will decide who has access to read and write to each file individually. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | +| permissions | array | An array of permission strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions). | | +| fileSecurity | boolean | Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions). | | | enabled | boolean | Is bucket enabled? | 1 | | maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self-hosted setups you can change the max limit by changing the `_APP_STORAGE_LIMIT` environment variable. [Learn more about storage environment variables](docs/environment-variables#storage) | 30000000 | | allowedFileExtensions | array | Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. | [] | +| compression | string | Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | | encryption | boolean | Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled | 1 | | antivirus | boolean | Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled | 1 | @@ -70,12 +66,12 @@ PUT https://HOSTNAME/v1/storage/buckets/{bucketId} | --- | --- | --- | --- | | bucketId | string | **Required** Bucket unique ID. | | | name | string | Bucket name | | -| permission | string | Permissions type model to use for reading files in this bucket. You can use bucket-level permission set once on the bucket using the `read` and `write` params, or you can set file-level permission where each file read and write params will decide who has access to read and write to each file individually. [learn more about permissions](/docs/permissions) and get a full list of available permissions. | | -| read | array | 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. | | -| write | array | 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. | | +| permissions | array | An array of permission strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). | | +| fileSecurity | boolean | Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions). | | | enabled | boolean | Is bucket enabled? | 1 | | maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](docs/environment-variables#storage) | | | allowedFileExtensions | array | Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. | [] | +| compression | string | Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | | encryption | boolean | Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled | 1 | | antivirus | boolean | Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled | 1 | @@ -106,12 +102,8 @@ GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files | Field Name | Type | Description | Default | | --- | --- | --- | --- | | bucketId | string | **Required** Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| limit | integer | Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | -| cursor | string | 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) | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderType | string | Order result by ASC or DESC order. | ASC | ## Create File @@ -119,7 +111,7 @@ GET https://HOSTNAME/v1/storage/buckets/{bucketId}/files POST https://HOSTNAME/v1/storage/buckets/{bucketId}/files ``` -** Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](/docs/server/database#storageCreateBucket) API or directly from your Appwrite console. +** Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes. @@ -135,8 +127,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk | bucketId | string | **Required** Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). | | | fileId | string | 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. | | | file | file | Binary file. | | -| read | array | 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. | | -| write | array | 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. | | +| permissions | array | An array of permission strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). | | ## Get File @@ -167,8 +158,7 @@ PUT https://HOSTNAME/v1/storage/buckets/{bucketId}/files/{fileId} | --- | --- | --- | --- | | bucketId | string | **Required** Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). | | | fileId | string | **Required** File unique ID. | | -| read | array | An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. | | -| write | array | An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. | | +| permissions | array | An array of permission string. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). | | ## Delete File diff --git a/docs/teams.md b/docs/teams.md index 0e14ece..fc6a447 100644 --- a/docs/teams.md +++ b/docs/teams.md @@ -14,12 +14,8 @@ In admin mode, this endpoint returns a list of all the teams in the current proj | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| limit | integer | Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | -| cursor | string | 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) | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderType | string | Order result by ASC or DESC order. | ASC | ## Create Team @@ -93,12 +89,8 @@ GET https://HOSTNAME/v1/teams/{teamId}/memberships | Field Name | Type | Description | Default | | --- | --- | --- | --- | | teamId | string | **Required** Team ID. | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| limit | integer | Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | -| cursor | string | 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) | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderType | string | Order result by ASC or DESC order. | ASC | ## Create Team Membership diff --git a/docs/users.md b/docs/users.md index d0bcc34..d67fa37 100644 --- a/docs/users.md +++ b/docs/users.md @@ -12,12 +12,8 @@ GET https://HOSTNAME/v1/users | Field Name | Type | Description | Default | | --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | -| limit | integer | Maximum number of users to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | -| cursor | string | 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) | | -| cursorDirection | string | Direction of the cursor, can be either 'before' or 'after'. | after | -| orderType | string | Order result by ASC or DESC order. | ASC | ## Create User @@ -33,7 +29,136 @@ POST https://HOSTNAME/v1/users | --- | --- | --- | --- | | userId | string | 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. | | | email | string | User email. | | -| password | string | User password. Must be at least 8 chars. | | +| phone | string | Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| password | string | Plain text user password. Must be at least 8 chars. | | +| name | string | User name. Max length: 128 chars. | | + +## Create User with Argon2 Password + +```http request +POST https://HOSTNAME/v1/users/argon2 +``` + +** Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | 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. | | +| email | string | User email. | | +| password | string | User password hashed using Argon2. | | +| name | string | User name. Max length: 128 chars. | | + +## Create User with Bcrypt Password + +```http request +POST https://HOSTNAME/v1/users/bcrypt +``` + +** Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | 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. | | +| email | string | User email. | | +| password | string | User password hashed using Bcrypt. | | +| name | string | User name. Max length: 128 chars. | | + +## Create User with MD5 Password + +```http request +POST https://HOSTNAME/v1/users/md5 +``` + +** Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | 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. | | +| email | string | User email. | | +| password | string | User password hashed using MD5. | | +| name | string | User name. Max length: 128 chars. | | + +## Create User with PHPass Password + +```http request +POST https://HOSTNAME/v1/users/phpass +``` + +** Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | 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. | | +| email | string | User email. | | +| password | string | User password hashed using PHPass. | | +| name | string | User name. Max length: 128 chars. | | + +## Create User with Scrypt Password + +```http request +POST https://HOSTNAME/v1/users/scrypt +``` + +** Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | 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. | | +| email | string | User email. | | +| password | string | User password hashed using Scrypt. | | +| passwordSalt | string | Optional salt used to hash password. | | +| passwordCpu | integer | Optional CPU cost used to hash password. | | +| passwordMemory | integer | Optional memory cost used to hash password. | | +| passwordParallel | integer | Optional parallelization cost used to hash password. | | +| passwordLength | integer | Optional hash length used to hash password. | | +| name | string | User name. Max length: 128 chars. | | + +## Create User with Scrypt Modified Password + +```http request +POST https://HOSTNAME/v1/users/scrypt-modified +``` + +** Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | 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. | | +| email | string | User email. | | +| password | string | User password hashed using Scrypt Modified. | | +| passwordSalt | string | Salt used to hash password. | | +| passwordSaltSeparator | string | Salt separator used to hash password. | | +| passwordSignerKey | string | Signer key used to hash password. | | +| name | string | User name. Max length: 128 chars. | | + +## Create User with SHA Password + +```http request +POST https://HOSTNAME/v1/users/sha +``` + +** Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| userId | string | 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. | | +| email | string | User email. | | +| password | string | User password hashed using SHA. | | +| passwordVersion | string | Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512' | | | name | string | User name. Max length: 128 chars. | | ## Get User @@ -92,8 +217,7 @@ GET https://HOSTNAME/v1/users/{userId}/logs | Field Name | Type | Description | Default | | --- | --- | --- | --- | | userId | string | **Required** User ID. | | -| limit | integer | Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 | -| offset | integer | Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) | 0 | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only supported methods are limit and offset | [] | ## Get User Memberships diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 8e96112..5658317 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,7 +37,10 @@ class Client */ protected $headers = [ 'content-type' => '', - 'x-sdk-version' => 'appwrite:php:6.0.0', + 'x-sdk-name'=> 'PHP', + 'x-sdk-platform'=> 'server', + 'x-sdk-language'=> 'php', + 'x-sdk-version'=> '6.1.0-RC1', ]; /** @@ -45,7 +48,7 @@ class Client */ public function __construct() { - $this->headers['X-Appwrite-Response-Format'] = '0.15.0'; + $this->headers['X-Appwrite-Response-Format'] = '1.0.0-RC1'; } diff --git a/src/Appwrite/ID.php b/src/Appwrite/ID.php new file mode 100644 index 0000000..8725c5a --- /dev/null +++ b/src/Appwrite/ID.php @@ -0,0 +1,15 @@ +client = $client; + } + /** * Get Account * @@ -41,13 +46,13 @@ public function get(): array * one, by passing an email address and a new password. * * - * @param string $email - * @param string $password + * @param string$email + * @param string$password * @throws AppwriteException * @return array */ - public function updateEmail(string $email, string $password): array + public function updateEmail(string$email, string$password): array { $path = str_replace([], [], '/account/email'); @@ -78,23 +83,18 @@ public function updateEmail(string $email, string $password): array * Get currently logged in user list of latest security activity logs. Each * log returns user IP address, location and date and time of log. * - * @param int $limit - * @param int $offset + * @param array $queries * @throws AppwriteException * @return array */ - public function getLogs(int $limit = null, int $offset = null): array + public function getLogs(array $queries = null): array { $path = str_replace([], [], '/account/logs'); $params = []; - if (!is_null($limit)) { - $params['limit'] = $limit; - } - - if (!is_null($offset)) { - $params['offset'] = $offset; + if (!is_null($queries)) { + $params['queries'] = $queries; } @@ -108,12 +108,12 @@ public function getLogs(int $limit = null, int $offset = null): array * * Update currently logged in user account name. * - * @param string $name + * @param string$name * @throws AppwriteException * @return array */ - public function updateName(string $name): array + public function updateName(string$name): array { $path = str_replace([], [], '/account/name'); @@ -138,13 +138,13 @@ public function updateName(string $name): array * to pass in the new password, and the old password. For users created with * OAuth, Team Invites and Magic URL, oldPassword is optional. * - * @param string $password - * @param string $oldPassword + * @param string$password + * @param string$oldPassword * @throws AppwriteException * @return array */ - public function updatePassword(string $password, string $oldPassword = null): array + public function updatePassword(string$password, string$oldPassword = null): array { $path = str_replace([], [], '/account/password'); @@ -169,30 +169,31 @@ public function updatePassword(string $password, string $oldPassword = null): ar /** * Update Account Phone * - * Update currently logged in user account phone number. After changing phone - * number, the user confirmation status will get reset. A new confirmation SMS - * is not sent automatically however you can use the phone confirmation - * endpoint again to send the confirmation SMS. + * Update the currently logged in user's phone number. After updating the + * phone number, the phone verification status will be reset. A confirmation + * SMS is not sent automatically, however you can use the [POST + * /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) + * endpoint to send a confirmation SMS. * - * @param string $number - * @param string $password + * @param string$phone + * @param string$password * @throws AppwriteException * @return array */ - public function updatePhone(string $number, string $password): array + public function updatePhone(string$phone, string$password): array { $path = str_replace([], [], '/account/phone'); $params = []; - if (!isset($number)) { - throw new AppwriteException('Missing required parameter: "number"'); + if (!isset($phone)) { + throw new AppwriteException('Missing required parameter: "phone"'); } if (!isset($password)) { throw new AppwriteException('Missing required parameter: "password"'); } - if (!is_null($number)) { - $params['number'] = $number; + if (!is_null($phone)) { + $params['phone'] = $phone; } if (!is_null($password)) { @@ -267,13 +268,13 @@ public function updatePrefs(array $prefs): array * complete the process. The verification link sent to the user's email * address is valid for 1 hour. * - * @param string $email - * @param string $url + * @param string$email + * @param string$url * @throws AppwriteException * @return array */ - public function createRecovery(string $email, string $url): array + public function createRecovery(string$email, string$url): array { $path = str_replace([], [], '/account/recovery'); @@ -311,15 +312,15 @@ public function createRecovery(string $email, string $url): array * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param string $userId - * @param string $secret - * @param string $password - * @param string $passwordAgain + * @param string$userId + * @param string$secret + * @param string$password + * @param string$passwordAgain * @throws AppwriteException * @return array */ - public function updateRecovery(string $userId, string $secret, string $password, string $passwordAgain): array + public function updateRecovery(string$userId, string$secret, string$password, string$passwordAgain): array { $path = str_replace([], [], '/account/recovery'); @@ -406,12 +407,12 @@ public function deleteSessions(): string * Use this endpoint to get a logged in user's session using a Session ID. * Inputting 'current' will return the current session being used. * - * @param string $sessionId + * @param string$sessionId * @throws AppwriteException * @return array */ - public function getSession(string $sessionId): array + public function getSession(string$sessionId): array { $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); @@ -432,12 +433,12 @@ public function getSession(string $sessionId): array * If session was created using an OAuth provider, this route can be used to * "refresh" the access token. * - * @param string $sessionId + * @param string$sessionId * @throws AppwriteException * @return array */ - public function updateSession(string $sessionId): array + public function updateSession(string$sessionId): array { $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); @@ -459,12 +460,12 @@ public function updateSession(string $sessionId): array * Session ID argument, only the unique session ID provided is deleted. * * - * @param string $sessionId + * @param string$sessionId * @throws AppwriteException * @return string */ - public function deleteSession(string $sessionId): string + public function deleteSession(string$sessionId): string { $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); @@ -519,12 +520,12 @@ public function updateStatus(): array * adding your platforms in the console interface. * * - * @param string $url + * @param string$url * @throws AppwriteException * @return array */ - public function createVerification(string $url): array + public function createVerification(string$url): array { $path = str_replace([], [], '/account/verification'); @@ -550,13 +551,13 @@ public function createVerification(string $url): array * to verify the user email ownership. If confirmed this route will return a * 200 status code. * - * @param string $userId - * @param string $secret + * @param string$userId + * @param string$secret * @throws AppwriteException * @return array */ - public function updateVerification(string $userId, string $secret): array + public function updateVerification(string$userId, string$secret): array { $path = str_replace([], [], '/account/verification'); @@ -584,13 +585,12 @@ public function updateVerification(string $userId, string $secret): array /** * Create Phone Verification * - * Use this endpoint to send a verification message to your user's phone - * number to confirm they are the valid owners of that address. The provided - * secret should allow you to complete the verification process by verifying - * both the **userId** and **secret** parameters. Learn more about how to - * [complete the verification + * Use this endpoint to send a verification SMS to the currently logged in + * user. This endpoint is meant for use after updating a user's phone number + * using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone) + * endpoint. Learn more about how to [complete the verification * process](/docs/client/account#accountUpdatePhoneVerification). The - * verification link sent to the user's phone number is valid for 15 minutes. + * verification code sent to the user's phone number is valid for 15 minutes. * * @throws AppwriteException * @return array @@ -615,13 +615,13 @@ public function createPhoneVerification(): array * verify the user email ownership. If confirmed this route will return a 200 * status code. * - * @param string $userId - * @param string $secret + * @param string$userId + * @param string$secret * @throws AppwriteException * @return array */ - public function updatePhoneVerification(string $userId, string $secret): array + public function updatePhoneVerification(string$userId, string$secret): array { $path = str_replace([], [], '/account/verification/phone'); diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index 01e5167..82af493 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -9,6 +9,11 @@ class Avatars extends Service { + public function __construct(Client $client) + { + $this->client = $client; + } + /** * Get Browser Icon * @@ -22,7 +27,7 @@ class Avatars extends Service * image at source quality. If dimensions are not specified, the default size * of image returned is 100x100px. * - * @param string $code + * @param string$code * @param int $width * @param int $height * @param int $quality @@ -30,7 +35,7 @@ class Avatars extends Service * @return string */ - public function getBrowser(string $code, int $width = null, int $height = null, int $quality = null): string + public function getBrowser(string$code, int $width = null, int $height = null, int $quality = null): string { $path = str_replace(['{code}'], [$code], '/avatars/browsers/{code}'); @@ -69,7 +74,7 @@ public function getBrowser(string $code, int $width = null, int $height = null, * of image returned is 100x100px. * * - * @param string $code + * @param string$code * @param int $width * @param int $height * @param int $quality @@ -77,7 +82,7 @@ public function getBrowser(string $code, int $width = null, int $height = null, * @return string */ - public function getCreditCard(string $code, int $width = null, int $height = null, int $quality = null): string + public function getCreditCard(string$code, int $width = null, int $height = null, int $quality = null): string { $path = str_replace(['{code}'], [$code], '/avatars/credit-cards/{code}'); @@ -110,12 +115,12 @@ public function getCreditCard(string $code, int $width = null, int $height = nul * website URL. * * - * @param string $url + * @param string$url * @throws AppwriteException * @return string */ - public function getFavicon(string $url): string + public function getFavicon(string$url): string { $path = str_replace([], [], '/avatars/favicon'); @@ -138,7 +143,8 @@ public function getFavicon(string $url): string * * You can use this endpoint to show different country flags icons to your * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. + * height and quality arguments to change the output settings. Country codes + * follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard. * * When one dimension is specified and the other is 0, the image is scaled * with preserved aspect ratio. If both dimensions are 0, the API provides an @@ -146,7 +152,7 @@ public function getFavicon(string $url): string * of image returned is 100x100px. * * - * @param string $code + * @param string$code * @param int $width * @param int $height * @param int $quality @@ -154,7 +160,7 @@ public function getFavicon(string $url): string * @return string */ - public function getFlag(string $code, int $width = null, int $height = null, int $quality = null): string + public function getFlag(string$code, int $width = null, int $height = null, int $quality = null): string { $path = str_replace(['{code}'], [$code], '/avatars/flags/{code}'); @@ -194,14 +200,14 @@ public function getFlag(string $code, int $width = null, int $height = null, int * of image returned is 400x400px. * * - * @param string $url + * @param string$url * @param int $width * @param int $height * @throws AppwriteException * @return string */ - public function getImage(string $url, int $width = null, int $height = null): string + public function getImage(string$url, int $width = null, int $height = null): string { $path = str_replace([], [], '/avatars/image'); @@ -247,16 +253,16 @@ public function getImage(string $url, int $width = null, int $height = null): st * of image returned is 100x100px. * * - * @param string $name + * @param string$name * @param int $width * @param int $height - * @param string $color - * @param string $background + * @param string$color + * @param string$background * @throws AppwriteException * @return string */ - public function getInitials(string $name = null, int $width = null, int $height = null, string $color = null, string $background = null): string + public function getInitials(string$name = null, int $width = null, int $height = null, string$color = null, string$background = null): string { $path = str_replace([], [], '/avatars/initials'); @@ -294,7 +300,7 @@ public function getInitials(string $name = null, int $width = null, int $height * parameters to change the size and style of the resulting image. * * - * @param string $text + * @param string$text * @param int $size * @param int $margin * @param bool $download @@ -302,7 +308,7 @@ public function getInitials(string $name = null, int $width = null, int $height * @return string */ - public function getQR(string $text, int $size = null, int $margin = null, bool $download = null): string + public function getQR(string$text, int $size = null, int $margin = null, bool $download = null): string { $path = str_replace([], [], '/avatars/qr'); diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index a86feb6..029cbad 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -9,64 +9,34 @@ class Databases extends Service { - protected string $databaseId; - - public function setDatabaseId(string $databaseId): void - { - $this->databaseId = $databaseId; - } - - public function getDatabaseId(string $databaseId): string - { - return $this->databaseId; - } - - public function __construct(Client $client, string $databaseId) + public function __construct(Client $client) { $this->client = $client; - $this->databaseId = $databaseId; } /** * List Databases * - * @param string $search - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param string $orderType + * Get a list of all databases from the current Appwrite project. You can use + * the search parameter to filter your results. + * + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function list(string $search = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, string $orderType = null): array + public function list(array $queries = null, string$search = null): array { $path = str_replace([], [], '/databases'); $params = []; - if (!is_null($search)) { - $params['search'] = $search; - } - - if (!is_null($limit)) { - $params['limit'] = $limit; - } - - if (!is_null($offset)) { - $params['offset'] = $offset; - } - - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; + if (!is_null($queries)) { + $params['queries'] = $queries; } - if (!is_null($orderType)) { - $params['orderType'] = $orderType; + if (!is_null($search)) { + $params['search'] = $search; } @@ -78,21 +48,28 @@ public function list(string $search = null, int $limit = null, int $offset = nul /** * Create Database * - * @param string $name + * Create a new Database. + * + * + * @param string$databaseId + * @param string$name * @throws AppwriteException * @return array */ - public function create(string $name): array + public function create(string$databaseId, string$name): array { $path = str_replace([], [], '/databases'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!is_null($this->databaseId)) { - $params['databaseId'] = $this->databaseId; + if (!is_null($databaseId)) { + $params['databaseId'] = $databaseId; } if (!is_null($name)) { @@ -108,15 +85,22 @@ public function create(string $name): array /** * Get Database * + * Get a database by its unique ID. This endpoint response returns a JSON + * object with the database metadata. + * + * @param string$databaseId * @throws AppwriteException * @return array */ - public function get(): array + public function get(string$databaseId): array { - $path = str_replace(['{databaseId}'], [$this->databaseId], '/databases/{databaseId}'); + $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } return $this->client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -126,16 +110,22 @@ public function get(): array /** * Update Database * - * @param string $name + * Update a database by its unique ID. + * + * @param string$databaseId + * @param string$name * @throws AppwriteException * @return array */ - public function update(string $name): array + public function update(string$databaseId, string$name): array { - $path = str_replace(['{databaseId}'], [$this->databaseId], '/databases/{databaseId}'); + $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } @@ -152,15 +142,22 @@ public function update(string $name): array /** * Delete Database * + * Delete a database by its unique ID. Only API keys with with databases.write + * scope can delete a database. + * + * @param string$databaseId * @throws AppwriteException * @return string */ - public function delete(): string + public function delete(string$databaseId): string { - $path = str_replace(['{databaseId}'], [$this->databaseId], '/databases/{databaseId}'); + $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } return $this->client->call(Client::METHOD_DELETE, $path, [ 'content-type' => 'application/json', @@ -170,43 +167,30 @@ public function delete(): string /** * List Collections * - * @param string $search - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param string $orderType + * Get a list of all collections that belong to the provided databaseId. You + * can use the search parameter to filter your results. + * + * @param string$databaseId + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function listCollections(string $search = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, string $orderType = null): array + public function listCollections(string$databaseId, array $queries = null, string$search = null): array { - $path = str_replace(['{databaseId}'], [$this->databaseId], '/databases/{databaseId}/collections'); + $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}/collections'); $params = []; - if (!is_null($search)) { - $params['search'] = $search; - } - - if (!is_null($limit)) { - $params['limit'] = $limit; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); } - - if (!is_null($offset)) { - $params['offset'] = $offset; - } - - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; + if (!is_null($queries)) { + $params['queries'] = $queries; } - if (!is_null($orderType)) { - $params['orderType'] = $orderType; + if (!is_null($search)) { + $params['search'] = $search; } @@ -218,34 +202,39 @@ public function listCollections(string $search = null, int $limit = null, int $o /** * Create Collection * - * @param string $collectionId - * @param string $name - * @param string $permission - * @param array $read - * @param array $write + * Create a new Collection. Before using this route, you should create a new + * database resource using either a [server + * integration](/docs/server/databases#databasesCreateCollection) API or + * directly from your database console. + * + * @param string$databaseId + * @param string$collectionId + * @param string$name + * @param array $permissions + * @param bool $documentSecurity * @throws AppwriteException * @return array */ - public function createCollection(string $collectionId, string $name, string $permission, array $read, array $write): array + public function createCollection(string$databaseId, string$collectionId, string$name, array $permissions, bool $documentSecurity): array { - $path = str_replace(['{databaseId}'], [$this->databaseId], '/databases/{databaseId}/collections'); + $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}/collections'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($permission)) { - throw new AppwriteException('Missing required parameter: "permission"'); + if (!isset($permissions)) { + throw new AppwriteException('Missing required parameter: "permissions"'); } - if (!isset($read)) { - throw new AppwriteException('Missing required parameter: "read"'); - } - if (!isset($write)) { - throw new AppwriteException('Missing required parameter: "write"'); + if (!isset($documentSecurity)) { + throw new AppwriteException('Missing required parameter: "documentSecurity"'); } if (!is_null($collectionId)) { $params['collectionId'] = $collectionId; @@ -255,16 +244,12 @@ public function createCollection(string $collectionId, string $name, string $per $params['name'] = $name; } - if (!is_null($permission)) { - $params['permission'] = $permission; - } - - if (!is_null($read)) { - $params['read'] = $read; + if (!is_null($permissions)) { + $params['permissions'] = $permissions; } - if (!is_null($write)) { - $params['write'] = $write; + if (!is_null($documentSecurity)) { + $params['documentSecurity'] = $documentSecurity; } @@ -276,16 +261,23 @@ public function createCollection(string $collectionId, string $name, string $per /** * Get Collection * - * @param string $collectionId + * Get a collection by its unique ID. This endpoint response returns a JSON + * object with the collection metadata. + * + * @param string$databaseId + * @param string$collectionId * @throws AppwriteException * @return array */ - public function getCollection(string $collectionId): array + public function getCollection(string$databaseId, string$collectionId): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -298,44 +290,45 @@ public function getCollection(string $collectionId): array /** * Update Collection * - * @param string $collectionId - * @param string $name - * @param string $permission - * @param array $read - * @param array $write + * Update a collection by its unique ID. + * + * @param string$databaseId + * @param string$collectionId + * @param string$name + * @param bool $documentSecurity + * @param array $permissions * @param bool $enabled * @throws AppwriteException * @return array */ - public function updateCollection(string $collectionId, string $name, string $permission, array $read = null, array $write = null, bool $enabled = null): array + public function updateCollection(string$databaseId, string$collectionId, string$name, bool $documentSecurity, array $permissions = null, bool $enabled = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($permission)) { - throw new AppwriteException('Missing required parameter: "permission"'); + if (!isset($documentSecurity)) { + throw new AppwriteException('Missing required parameter: "documentSecurity"'); } if (!is_null($name)) { $params['name'] = $name; } - if (!is_null($permission)) { - $params['permission'] = $permission; - } - - if (!is_null($read)) { - $params['read'] = $read; + if (!is_null($permissions)) { + $params['permissions'] = $permissions; } - if (!is_null($write)) { - $params['write'] = $write; + if (!is_null($documentSecurity)) { + $params['documentSecurity'] = $documentSecurity; } if (!is_null($enabled)) { @@ -351,16 +344,23 @@ public function updateCollection(string $collectionId, string $name, string $per /** * Delete Collection * - * @param string $collectionId + * Delete a collection by its unique ID. Only users with write permissions + * have access to delete this resource. + * + * @param string$databaseId + * @param string$collectionId * @throws AppwriteException * @return string */ - public function deleteCollection(string $collectionId): string + public function deleteCollection(string$databaseId, string$collectionId): string { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -373,16 +373,20 @@ public function deleteCollection(string $collectionId): string /** * List Attributes * - * @param string $collectionId + * @param string$databaseId + * @param string$collectionId * @throws AppwriteException * @return array */ - public function listAttributes(string $collectionId): array + public function listAttributes(string$databaseId, string$collectionId): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -395,8 +399,12 @@ public function listAttributes(string $collectionId): array /** * Create Boolean Attribute * - * @param string $collectionId - * @param string $key + * Create a boolean attribute. + * + * + * @param string$databaseId + * @param string$collectionId + * @param string$key * @param bool $required * @param bool $xdefault * @param bool $xarray @@ -404,11 +412,66 @@ public function listAttributes(string $collectionId): array * @return array */ - public function createBooleanAttribute(string $collectionId, string $key, bool $required, bool $xdefault = null, bool $xarray = null): array + public function createBooleanAttribute(string$databaseId, string$collectionId, string$key, bool $required, bool $xdefault = null, bool $xarray = null): array + { + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'); + + $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (!isset($collectionId)) { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (!isset($key)) { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (!isset($required)) { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (!is_null($key)) { + $params['key'] = $key; + } + + if (!is_null($required)) { + $params['required'] = $required; + } + + if (!is_null($xdefault)) { + $params['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $params['array'] = $xarray; + } + + + return $this->client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Create DateTime Attribute + * + * @param string$databaseId + * @param string$collectionId + * @param string$key + * @param bool $required + * @param string$xdefault + * @param bool $xarray + * @throws AppwriteException + * @return array + + */ + public function createDatetimeAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -443,20 +506,27 @@ public function createBooleanAttribute(string $collectionId, string $key, bool $ /** * Create Email Attribute * - * @param string $collectionId - * @param string $key + * Create an email attribute. + * + * + * @param string$databaseId + * @param string$collectionId + * @param string$key * @param bool $required - * @param string $xdefault + * @param string$xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createEmailAttribute(string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array + public function createEmailAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/email'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/email'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -491,21 +561,25 @@ public function createEmailAttribute(string $collectionId, string $key, bool $re /** * Create Enum Attribute * - * @param string $collectionId - * @param string $key + * @param string$databaseId + * @param string$collectionId + * @param string$key * @param array $elements * @param bool $required - * @param string $xdefault + * @param string$xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createEnumAttribute(string $collectionId, string $key, array $elements, bool $required, string $xdefault = null, bool $xarray = null): array + public function createEnumAttribute(string$databaseId, string$collectionId, string$key, array $elements, bool $required, string$xdefault = null, bool $xarray = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/enum'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/enum'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -547,8 +621,13 @@ public function createEnumAttribute(string $collectionId, string $key, array $el /** * Create Float Attribute * - * @param string $collectionId - * @param string $key + * Create a float attribute. Optionally, minimum and maximum values can be + * provided. + * + * + * @param string$databaseId + * @param string$collectionId + * @param string$key * @param bool $required * @param int $min * @param int $max @@ -558,11 +637,14 @@ public function createEnumAttribute(string $collectionId, string $key, array $el * @return array */ - public function createFloatAttribute(string $collectionId, string $key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array + public function createFloatAttribute(string$databaseId, string$collectionId, string$key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/float'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/float'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -605,8 +687,13 @@ public function createFloatAttribute(string $collectionId, string $key, bool $re /** * Create Integer Attribute * - * @param string $collectionId - * @param string $key + * Create an integer attribute. Optionally, minimum and maximum values can be + * provided. + * + * + * @param string$databaseId + * @param string$collectionId + * @param string$key * @param bool $required * @param int $min * @param int $max @@ -616,11 +703,14 @@ public function createFloatAttribute(string $collectionId, string $key, bool $re * @return array */ - public function createIntegerAttribute(string $collectionId, string $key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array + public function createIntegerAttribute(string$databaseId, string$collectionId, string$key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/integer'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/integer'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -663,20 +753,27 @@ public function createIntegerAttribute(string $collectionId, string $key, bool $ /** * Create IP Address Attribute * - * @param string $collectionId - * @param string $key + * Create IP address attribute. + * + * + * @param string$databaseId + * @param string$collectionId + * @param string$key * @param bool $required - * @param string $xdefault + * @param string$xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createIpAttribute(string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array + public function createIpAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/ip'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/ip'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -711,21 +808,28 @@ public function createIpAttribute(string $collectionId, string $key, bool $requi /** * Create String Attribute * - * @param string $collectionId - * @param string $key + * Create a string attribute. + * + * + * @param string$databaseId + * @param string$collectionId + * @param string$key * @param int $size * @param bool $required - * @param string $xdefault + * @param string$xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createStringAttribute(string $collectionId, string $key, int $size, bool $required, string $xdefault = null, bool $xarray = null): array + public function createStringAttribute(string$databaseId, string$collectionId, string$key, int $size, bool $required, string$xdefault = null, bool $xarray = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/string'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/string'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -767,20 +871,27 @@ public function createStringAttribute(string $collectionId, string $key, int $si /** * Create URL Attribute * - * @param string $collectionId - * @param string $key + * Create a URL attribute. + * + * + * @param string$databaseId + * @param string$collectionId + * @param string$key * @param bool $required - * @param string $xdefault + * @param string$xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createUrlAttribute(string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array + public function createUrlAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/url'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/url'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -815,17 +926,21 @@ public function createUrlAttribute(string $collectionId, string $key, bool $requ /** * Get Attribute * - * @param string $collectionId - * @param string $key + * @param string$databaseId + * @param string$collectionId + * @param string$key * @throws AppwriteException * @return array */ - public function getAttribute(string $collectionId, string $key): array + public function getAttribute(string$databaseId, string$collectionId, string$key): array { - $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$this->databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'); + $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -841,17 +956,21 @@ public function getAttribute(string $collectionId, string $key): array /** * Delete Attribute * - * @param string $collectionId - * @param string $key + * @param string$databaseId + * @param string$collectionId + * @param string$key * @throws AppwriteException * @return string */ - public function deleteAttribute(string $collectionId, string $key): string + public function deleteAttribute(string$databaseId, string$collectionId, string$key): string { - $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$this->databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'); + $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -867,23 +986,26 @@ public function deleteAttribute(string $collectionId, string $key): string /** * List Documents * - * @param string $collectionId + * Get a list of all the user's documents in a given collection. You can use + * the query params to filter your results. On admin mode, this endpoint will + * return a list of all of documents belonging to the provided collectionId. + * [Learn more about different API modes](/docs/admin). + * + * @param string$databaseId + * @param string$collectionId * @param array $queries - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param array $orderAttributes - * @param array $orderTypes * @throws AppwriteException * @return array */ - public function listDocuments(string $collectionId, array $queries = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, array $orderAttributes = null, array $orderTypes = null): array + public function listDocuments(string$databaseId, string$collectionId, array $queries = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/documents'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/documents'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -891,30 +1013,6 @@ public function listDocuments(string $collectionId, array $queries = null, int $ $params['queries'] = $queries; } - if (!is_null($limit)) { - $params['limit'] = $limit; - } - - if (!is_null($offset)) { - $params['offset'] = $offset; - } - - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; - } - - if (!is_null($orderAttributes)) { - $params['orderAttributes'] = $orderAttributes; - } - - if (!is_null($orderTypes)) { - $params['orderTypes'] = $orderTypes; - } - return $this->client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -924,20 +1022,28 @@ public function listDocuments(string $collectionId, array $queries = null, int $ /** * Create Document * - * @param string $collectionId - * @param string $documentId + * Create a new Document. Before using this route, you should create a new + * collection resource using either a [server + * integration](/docs/server/databases#databasesCreateCollection) API or + * directly from your database console. + * + * @param string$databaseId + * @param string$collectionId + * @param string$documentId * @param array $data - * @param array $read - * @param array $write + * @param array $permissions * @throws AppwriteException * @return array */ - public function createDocument(string $collectionId, string $documentId, array $data, array $read = null, array $write = null): array + public function createDocument(string$databaseId, string$collectionId, string$documentId, array $data, array $permissions = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/documents'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/documents'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -955,12 +1061,8 @@ public function createDocument(string $collectionId, string $documentId, array $ $params['data'] = $data; } - if (!is_null($read)) { - $params['read'] = $read; - } - - if (!is_null($write)) { - $params['write'] = $write; + if (!is_null($permissions)) { + $params['permissions'] = $permissions; } @@ -972,17 +1074,24 @@ public function createDocument(string $collectionId, string $documentId, array $ /** * Get Document * - * @param string $collectionId - * @param string $documentId + * Get a document by its unique ID. This endpoint response returns a JSON + * object with the document data. + * + * @param string$databaseId + * @param string$collectionId + * @param string$documentId * @throws AppwriteException * @return array */ - public function getDocument(string $collectionId, string $documentId): array + public function getDocument(string$databaseId, string$collectionId, string$documentId): array { - $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$this->databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); + $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -998,20 +1107,26 @@ public function getDocument(string $collectionId, string $documentId): array /** * Update Document * - * @param string $collectionId - * @param string $documentId + * Update a document by its unique ID. Using the patch method you can pass + * only specific fields that will get updated. + * + * @param string$databaseId + * @param string$collectionId + * @param string$documentId * @param array $data - * @param array $read - * @param array $write + * @param array $permissions * @throws AppwriteException * @return array */ - public function updateDocument(string $collectionId, string $documentId, array $data = null, array $read = null, array $write = null): array + public function updateDocument(string$databaseId, string$collectionId, string$documentId, array $data = null, array $permissions = null): array { - $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$this->databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); + $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -1022,12 +1137,8 @@ public function updateDocument(string $collectionId, string $documentId, array $ $params['data'] = $data; } - if (!is_null($read)) { - $params['read'] = $read; - } - - if (!is_null($write)) { - $params['write'] = $write; + if (!is_null($permissions)) { + $params['permissions'] = $permissions; } @@ -1039,17 +1150,23 @@ public function updateDocument(string $collectionId, string $documentId, array $ /** * Delete Document * - * @param string $collectionId - * @param string $documentId + * Delete a document by its unique ID. + * + * @param string$databaseId + * @param string$collectionId + * @param string$documentId * @throws AppwriteException * @return string */ - public function deleteDocument(string $collectionId, string $documentId): string + public function deleteDocument(string$databaseId, string$collectionId, string$documentId): string { - $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$this->databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); + $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -1065,16 +1182,20 @@ public function deleteDocument(string $collectionId, string $documentId): string /** * List Indexes * - * @param string $collectionId + * @param string$databaseId + * @param string$collectionId * @throws AppwriteException * @return array */ - public function listIndexes(string $collectionId): array + public function listIndexes(string$databaseId, string$collectionId): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/indexes'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/indexes'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -1087,20 +1208,24 @@ public function listIndexes(string $collectionId): array /** * Create Index * - * @param string $collectionId - * @param string $key - * @param string $type + * @param string$databaseId + * @param string$collectionId + * @param string$key + * @param string$type * @param array $attributes * @param array $orders * @throws AppwriteException * @return array */ - public function createIndex(string $collectionId, string $key, string $type, array $attributes, array $orders = null): array + public function createIndex(string$databaseId, string$collectionId, string$key, string$type, array $attributes, array $orders = null): array { - $path = str_replace(['{databaseId}', '{collectionId}'], [$this->databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/indexes'); + $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/indexes'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -1138,17 +1263,21 @@ public function createIndex(string $collectionId, string $key, string $type, arr /** * Get Index * - * @param string $collectionId - * @param string $key + * @param string$databaseId + * @param string$collectionId + * @param string$key * @throws AppwriteException * @return array */ - public function getIndex(string $collectionId, string $key): array + public function getIndex(string$databaseId, string$collectionId, string$key): array { - $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$this->databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'); + $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } @@ -1164,17 +1293,21 @@ public function getIndex(string $collectionId, string $key): array /** * Delete Index * - * @param string $collectionId - * @param string $key + * @param string$databaseId + * @param string$collectionId + * @param string$key * @throws AppwriteException * @return string */ - public function deleteIndex(string $collectionId, string $key): string + public function deleteIndex(string$databaseId, string$collectionId, string$key): string { - $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$this->databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'); + $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'); $params = []; + if (!isset($databaseId)) { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } if (!isset($collectionId)) { throw new AppwriteException('Missing required parameter: "collectionId"'); } diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index e378e71..6f670da 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -9,49 +9,34 @@ class Functions extends Service { + public function __construct(Client $client) + { + $this->client = $client; + } + /** * List Functions * * Get a list of all the project's functions. You can use the query params to * filter your results. * - * @param string $search - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param string $orderType + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function list(string $search = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, string $orderType = null): array + public function list(array $queries = null, string$search = null): array { $path = str_replace([], [], '/functions'); $params = []; - if (!is_null($search)) { - $params['search'] = $search; - } - - if (!is_null($limit)) { - $params['limit'] = $limit; + if (!is_null($queries)) { + $params['queries'] = $queries; } - if (!is_null($offset)) { - $params['offset'] = $offset; - } - - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; - } - - if (!is_null($orderType)) { - $params['orderType'] = $orderType; + if (!is_null($search)) { + $params['search'] = $search; } @@ -67,19 +52,18 @@ public function list(string $search = null, int $limit = null, int $offset = nul * [permissions](/docs/permissions) to allow different project users or team * with access to execute the function using the client API. * - * @param string $functionId - * @param string $name + * @param string$functionId + * @param string$name * @param array $execute - * @param string $runtime - * @param array $vars + * @param string$runtime * @param array $events - * @param string $schedule + * @param string$schedule * @param int $timeout * @throws AppwriteException * @return array */ - public function create(string $functionId, string $name, array $execute, string $runtime, array $vars = null, array $events = null, string $schedule = null, int $timeout = null): array + public function create(string$functionId, string$name, array $execute, string$runtime, array $events = null, string$schedule = null, int $timeout = null): array { $path = str_replace([], [], '/functions'); @@ -112,10 +96,6 @@ public function create(string $functionId, string $name, array $execute, string $params['runtime'] = $runtime; } - if (!is_null($vars)) { - $params['vars'] = $vars; - } - if (!is_null($events)) { $params['events'] = $events; } @@ -159,12 +139,12 @@ public function listRuntimes(): array * * Get a function by its unique ID. * - * @param string $functionId + * @param string$functionId * @throws AppwriteException * @return array */ - public function get(string $functionId): array + public function get(string$functionId): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -183,18 +163,17 @@ public function get(string $functionId): array * * Update function by its unique ID. * - * @param string $functionId - * @param string $name + * @param string$functionId + * @param string$name * @param array $execute - * @param array $vars * @param array $events - * @param string $schedule + * @param string$schedule * @param int $timeout * @throws AppwriteException * @return array */ - public function update(string $functionId, string $name, array $execute, array $vars = null, array $events = null, string $schedule = null, int $timeout = null): array + public function update(string$functionId, string$name, array $execute, array $events = null, string$schedule = null, int $timeout = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -216,10 +195,6 @@ public function update(string $functionId, string $name, array $execute, array $ $params['execute'] = $execute; } - if (!is_null($vars)) { - $params['vars'] = $vars; - } - if (!is_null($events)) { $params['events'] = $events; } @@ -243,12 +218,12 @@ public function update(string $functionId, string $name, array $execute, array $ * * Delete a function by its unique ID. * - * @param string $functionId + * @param string$functionId * @throws AppwriteException * @return string */ - public function delete(string $functionId): string + public function delete(string$functionId): string { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -268,18 +243,14 @@ public function delete(string $functionId): string * Get a list of all the project's code deployments. You can use the query * params to filter your results. * - * @param string $functionId - * @param string $search - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param string $orderType + * @param string$functionId + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function listDeployments(string $functionId, string $search = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, string $orderType = null): array + public function listDeployments(string$functionId, array $queries = null, string$search = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/deployments'); @@ -287,28 +258,12 @@ public function listDeployments(string $functionId, string $search = null, int $ if (!isset($functionId)) { throw new AppwriteException('Missing required parameter: "functionId"'); } - if (!is_null($search)) { - $params['search'] = $search; - } - - if (!is_null($limit)) { - $params['limit'] = $limit; - } - - if (!is_null($offset)) { - $params['offset'] = $offset; - } - - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; + if (!is_null($queries)) { + $params['queries'] = $queries; } - if (!is_null($orderType)) { - $params['orderType'] = $orderType; + if (!is_null($search)) { + $params['search'] = $search; } @@ -331,15 +286,15 @@ public function listDeployments(string $functionId, string $search = null, int $ * * Use the "command" param to set the entry point used to execute your code. * - * @param string $functionId - * @param string $entrypoint + * @param string$functionId + * @param string$entrypoint * @param InputFile $code * @param bool $activate * @throws AppwriteException * @return array */ - public function createDeployment(string $functionId, string $entrypoint, InputFile $code, bool $activate, callable $onProgress = null): array + public function createDeployment(string$functionId, string$entrypoint, InputFile $code, bool $activate, callable $onProgress = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/deployments'); @@ -448,13 +403,13 @@ public function createDeployment(string $functionId, string $entrypoint, InputFi * * Get a code deployment by its unique ID. * - * @param string $functionId - * @param string $deploymentId + * @param string$functionId + * @param string$deploymentId * @throws AppwriteException * @return array */ - public function getDeployment(string $functionId, string $deploymentId): array + public function getDeployment(string$functionId, string$deploymentId): array { $path = str_replace(['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], '/functions/{functionId}/deployments/{deploymentId}'); @@ -478,13 +433,13 @@ public function getDeployment(string $functionId, string $deploymentId): array * this endpoint to switch the code deployment that should be executed by the * execution endpoint. * - * @param string $functionId - * @param string $deploymentId + * @param string$functionId + * @param string$deploymentId * @throws AppwriteException * @return array */ - public function updateDeployment(string $functionId, string $deploymentId): array + public function updateDeployment(string$functionId, string$deploymentId): array { $path = str_replace(['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], '/functions/{functionId}/deployments/{deploymentId}'); @@ -506,13 +461,13 @@ public function updateDeployment(string $functionId, string $deploymentId): arra * * Delete a code deployment by its unique ID. * - * @param string $functionId - * @param string $deploymentId + * @param string$functionId + * @param string$deploymentId * @throws AppwriteException * @return string */ - public function deleteDeployment(string $functionId, string $deploymentId): string + public function deleteDeployment(string$functionId, string$deploymentId): string { $path = str_replace(['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], '/functions/{functionId}/deployments/{deploymentId}'); @@ -532,14 +487,14 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri /** * Retry Build * - * @param string $functionId - * @param string $deploymentId - * @param string $buildId + * @param string$functionId + * @param string$deploymentId + * @param string$buildId * @throws AppwriteException * @return string */ - public function retryBuild(string $functionId, string $deploymentId, string $buildId): string + public function retryBuild(string$functionId, string$deploymentId, string$buildId): string { $path = str_replace(['{functionId}', '{deploymentId}', '{buildId}'], [$functionId, $deploymentId, $buildId], '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'); @@ -567,17 +522,14 @@ public function retryBuild(string $functionId, string $deploymentId, string $bui * return a list of all of the project's executions. [Learn more about * different API modes](/docs/admin). * - * @param string $functionId - * @param int $limit - * @param int $offset - * @param string $search - * @param string $cursor - * @param string $cursorDirection + * @param string$functionId + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function listExecutions(string $functionId, int $limit = null, int $offset = null, string $search = null, string $cursor = null, string $cursorDirection = null): array + public function listExecutions(string$functionId, array $queries = null, string$search = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions'); @@ -585,26 +537,14 @@ public function listExecutions(string $functionId, int $limit = null, int $offse if (!isset($functionId)) { throw new AppwriteException('Missing required parameter: "functionId"'); } - if (!is_null($limit)) { - $params['limit'] = $limit; - } - - if (!is_null($offset)) { - $params['offset'] = $offset; + if (!is_null($queries)) { + $params['queries'] = $queries; } if (!is_null($search)) { $params['search'] = $search; } - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; - } - return $this->client->call(Client::METHOD_GET, $path, [ 'content-type' => 'application/json', @@ -619,14 +559,14 @@ public function listExecutions(string $functionId, int $limit = null, int $offse * updates on the current execution status. Once this endpoint is called, your * function execution process will start asynchronously. * - * @param string $functionId - * @param string $data + * @param string$functionId + * @param string$data * @param bool $async * @throws AppwriteException * @return array */ - public function createExecution(string $functionId, string $data = null, bool $async = null): array + public function createExecution(string$functionId, string$data = null, bool $async = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions'); @@ -653,13 +593,13 @@ public function createExecution(string $functionId, string $data = null, bool $a * * Get a function execution log by its unique ID. * - * @param string $functionId - * @param string $executionId + * @param string$functionId + * @param string$executionId * @throws AppwriteException * @return array */ - public function getExecution(string $functionId, string $executionId): array + public function getExecution(string$functionId, string$executionId): array { $path = str_replace(['{functionId}', '{executionId}'], [$functionId, $executionId], '/functions/{functionId}/executions/{executionId}'); @@ -675,4 +615,176 @@ public function getExecution(string $functionId, string $executionId): array 'content-type' => 'application/json', ], $params); } + + /** + * List Variables + * + * Get a list of all variables of a specific function. + * + * @param string$functionId + * @param array $queries + * @param string$search + * @throws AppwriteException + * @return array + + */ + public function listVariables(string$functionId, array $queries = null, string$search = null): array + { + $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/variables'); + + $params = []; + if (!isset($functionId)) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (!is_null($queries)) { + $params['queries'] = $queries; + } + + if (!is_null($search)) { + $params['search'] = $search; + } + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Create Variable + * + * Create a new function variable. These variables can be accessed within + * function in the `env` object under the request variable. + * + * @param string$functionId + * @param string$key + * @param string$value + * @throws AppwriteException + * @return array + + */ + public function createVariable(string$functionId, string$key, string$value): array + { + $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/variables'); + + $params = []; + if (!isset($functionId)) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (!isset($key)) { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (!isset($value)) { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (!is_null($key)) { + $params['key'] = $key; + } + + if (!is_null($value)) { + $params['value'] = $value; + } + + + return $this->client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Variable + * + * Get a variable by its unique ID. + * + * @param string$functionId + * @param string$variableId + * @throws AppwriteException + * @return array + + */ + public function getVariable(string$functionId, string$variableId): array + { + $path = str_replace(['{functionId}', '{variableId}'], [$functionId, $variableId], '/functions/{functionId}/variables/{variableId}'); + + $params = []; + if (!isset($functionId)) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (!isset($variableId)) { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Update Variable + * + * Update variable by its unique ID. + * + * @param string$functionId + * @param string$variableId + * @param string$key + * @param string$value + * @throws AppwriteException + * @return array + + */ + public function updateVariable(string$functionId, string$variableId, string$key, string$value = null): array + { + $path = str_replace(['{functionId}', '{variableId}'], [$functionId, $variableId], '/functions/{functionId}/variables/{variableId}'); + + $params = []; + if (!isset($functionId)) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (!isset($variableId)) { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + if (!isset($key)) { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (!is_null($key)) { + $params['key'] = $key; + } + + if (!is_null($value)) { + $params['value'] = $value; + } + + + return $this->client->call(Client::METHOD_PUT, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Delete Variable + * + * Delete a variable by its unique ID. + * + * @param string$functionId + * @param string$variableId + * @throws AppwriteException + * @return string + + */ + public function deleteVariable(string$functionId, string$variableId): string + { + $path = str_replace(['{functionId}', '{variableId}'], [$functionId, $variableId], '/functions/{functionId}/variables/{variableId}'); + + $params = []; + if (!isset($functionId)) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (!isset($variableId)) { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + return $this->client->call(Client::METHOD_DELETE, $path, [ + 'content-type' => 'application/json', + ], $params); + } } diff --git a/src/Appwrite/Services/Health.php b/src/Appwrite/Services/Health.php index f1ea6bc..3c9bd84 100644 --- a/src/Appwrite/Services/Health.php +++ b/src/Appwrite/Services/Health.php @@ -9,6 +9,11 @@ class Health extends Service { + public function __construct(Client $client) + { + $this->client = $client; + } + /** * Get HTTP * diff --git a/src/Appwrite/Services/Locale.php b/src/Appwrite/Services/Locale.php index bfda8fe..cfc3d62 100644 --- a/src/Appwrite/Services/Locale.php +++ b/src/Appwrite/Services/Locale.php @@ -9,6 +9,11 @@ class Locale extends Service { + public function __construct(Client $client) + { + $this->client = $client; + } + /** * Get User Locale * diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index f1e9f0b..bc6b15a 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -9,49 +9,34 @@ class Storage extends Service { + public function __construct(Client $client) + { + $this->client = $client; + } + /** * List buckets * * Get a list of all the storage buckets. You can use the query params to * filter your results. * - * @param string $search - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param string $orderType + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function listBuckets(string $search = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, string $orderType = null): array + public function listBuckets(array $queries = null, string$search = null): array { $path = str_replace([], [], '/storage/buckets'); $params = []; - if (!is_null($search)) { - $params['search'] = $search; - } - - if (!is_null($limit)) { - $params['limit'] = $limit; + if (!is_null($queries)) { + $params['queries'] = $queries; } - if (!is_null($offset)) { - $params['offset'] = $offset; - } - - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; - } - - if (!is_null($orderType)) { - $params['orderType'] = $orderType; + if (!is_null($search)) { + $params['search'] = $search; } @@ -65,21 +50,21 @@ public function listBuckets(string $search = null, int $limit = null, int $offse * * Create a new storage bucket. * - * @param string $bucketId - * @param string $name - * @param string $permission - * @param array $read - * @param array $write + * @param string$bucketId + * @param string$name + * @param bool $fileSecurity + * @param array $permissions * @param bool $enabled * @param int $maximumFileSize * @param array $allowedFileExtensions + * @param string$compression * @param bool $encryption * @param bool $antivirus * @throws AppwriteException * @return array */ - public function createBucket(string $bucketId, string $name, string $permission, array $read = null, array $write = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, bool $encryption = null, bool $antivirus = null): array + public function createBucket(string$bucketId, string$name, bool $fileSecurity, array $permissions = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string$compression = null, bool $encryption = null, bool $antivirus = null): array { $path = str_replace([], [], '/storage/buckets'); @@ -90,8 +75,8 @@ public function createBucket(string $bucketId, string $name, string $permission, if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($permission)) { - throw new AppwriteException('Missing required parameter: "permission"'); + if (!isset($fileSecurity)) { + throw new AppwriteException('Missing required parameter: "fileSecurity"'); } if (!is_null($bucketId)) { $params['bucketId'] = $bucketId; @@ -101,16 +86,12 @@ public function createBucket(string $bucketId, string $name, string $permission, $params['name'] = $name; } - if (!is_null($permission)) { - $params['permission'] = $permission; - } - - if (!is_null($read)) { - $params['read'] = $read; + if (!is_null($permissions)) { + $params['permissions'] = $permissions; } - if (!is_null($write)) { - $params['write'] = $write; + if (!is_null($fileSecurity)) { + $params['fileSecurity'] = $fileSecurity; } if (!is_null($enabled)) { @@ -125,6 +106,10 @@ public function createBucket(string $bucketId, string $name, string $permission, $params['allowedFileExtensions'] = $allowedFileExtensions; } + if (!is_null($compression)) { + $params['compression'] = $compression; + } + if (!is_null($encryption)) { $params['encryption'] = $encryption; } @@ -145,12 +130,12 @@ public function createBucket(string $bucketId, string $name, string $permission, * Get a storage bucket by its unique ID. This endpoint response returns a * JSON object with the storage bucket metadata. * - * @param string $bucketId + * @param string$bucketId * @throws AppwriteException * @return array */ - public function getBucket(string $bucketId): array + public function getBucket(string$bucketId): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -169,21 +154,21 @@ public function getBucket(string $bucketId): array * * Update a storage bucket by its unique ID. * - * @param string $bucketId - * @param string $name - * @param string $permission - * @param array $read - * @param array $write + * @param string$bucketId + * @param string$name + * @param bool $fileSecurity + * @param array $permissions * @param bool $enabled * @param int $maximumFileSize * @param array $allowedFileExtensions + * @param string$compression * @param bool $encryption * @param bool $antivirus * @throws AppwriteException * @return array */ - public function updateBucket(string $bucketId, string $name, string $permission, array $read = null, array $write = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, bool $encryption = null, bool $antivirus = null): array + public function updateBucket(string$bucketId, string$name, bool $fileSecurity, array $permissions = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string$compression = null, bool $encryption = null, bool $antivirus = null): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -194,23 +179,19 @@ public function updateBucket(string $bucketId, string $name, string $permission, if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($permission)) { - throw new AppwriteException('Missing required parameter: "permission"'); + if (!isset($fileSecurity)) { + throw new AppwriteException('Missing required parameter: "fileSecurity"'); } if (!is_null($name)) { $params['name'] = $name; } - if (!is_null($permission)) { - $params['permission'] = $permission; - } - - if (!is_null($read)) { - $params['read'] = $read; + if (!is_null($permissions)) { + $params['permissions'] = $permissions; } - if (!is_null($write)) { - $params['write'] = $write; + if (!is_null($fileSecurity)) { + $params['fileSecurity'] = $fileSecurity; } if (!is_null($enabled)) { @@ -225,6 +206,10 @@ public function updateBucket(string $bucketId, string $name, string $permission, $params['allowedFileExtensions'] = $allowedFileExtensions; } + if (!is_null($compression)) { + $params['compression'] = $compression; + } + if (!is_null($encryption)) { $params['encryption'] = $encryption; } @@ -244,12 +229,12 @@ public function updateBucket(string $bucketId, string $name, string $permission, * * Delete a storage bucket by its unique ID. * - * @param string $bucketId + * @param string$bucketId * @throws AppwriteException * @return string */ - public function deleteBucket(string $bucketId): string + public function deleteBucket(string$bucketId): string { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -270,18 +255,14 @@ public function deleteBucket(string $bucketId): string * 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). * - * @param string $bucketId - * @param string $search - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param string $orderType + * @param string$bucketId + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function listFiles(string $bucketId, string $search = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, string $orderType = null): array + public function listFiles(string$bucketId, array $queries = null, string$search = null): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}/files'); @@ -289,28 +270,12 @@ public function listFiles(string $bucketId, string $search = null, int $limit = if (!isset($bucketId)) { throw new AppwriteException('Missing required parameter: "bucketId"'); } - if (!is_null($search)) { - $params['search'] = $search; - } - - if (!is_null($limit)) { - $params['limit'] = $limit; - } - - if (!is_null($offset)) { - $params['offset'] = $offset; - } - - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; + if (!is_null($queries)) { + $params['queries'] = $queries; } - if (!is_null($orderType)) { - $params['orderType'] = $orderType; + if (!is_null($search)) { + $params['search'] = $search; } @@ -324,8 +289,8 @@ public function listFiles(string $bucketId, string $search = null, int $limit = * * Create a new file. Before using this route, you should create a new bucket * resource using either a [server - * integration](/docs/server/database#storageCreateBucket) API or directly - * from your Appwrite console. + * integration](/docs/server/storage#storageCreateBucket) API or directly from + * your Appwrite console. * * Larger files should be uploaded using multiple requests with the * [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) @@ -341,16 +306,15 @@ public function listFiles(string $bucketId, string $search = null, int $limit = * chunking logic will be managed by the SDK internally. * * - * @param string $bucketId - * @param string $fileId + * @param string$bucketId + * @param string$fileId * @param InputFile $file - * @param array $read - * @param array $write + * @param array $permissions * @throws AppwriteException * @return array */ - public function createFile(string $bucketId, string $fileId, InputFile $file, array $read = null, array $write = null, callable $onProgress = null): array + public function createFile(string$bucketId, string$fileId, InputFile $file, array $permissions = null, callable $onProgress = null): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}/files'); @@ -372,12 +336,8 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ar $params['file'] = $file; } - if (!is_null($read)) { - $params['read'] = $read; - } - - if (!is_null($write)) { - $params['write'] = $write; + if (!is_null($permissions)) { + $params['permissions'] = $permissions; } @@ -468,13 +428,13 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ar * Get a file by its unique ID. This endpoint response returns a JSON object * with the file metadata. * - * @param string $bucketId - * @param string $fileId + * @param string$bucketId + * @param string$fileId * @throws AppwriteException * @return array */ - public function getFile(string $bucketId, string $fileId): array + public function getFile(string$bucketId, string$fileId): array { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}'); @@ -497,15 +457,14 @@ public function getFile(string $bucketId, string $fileId): array * Update a file by its unique ID. Only users with write permissions have * access to update this resource. * - * @param string $bucketId - * @param string $fileId - * @param array $read - * @param array $write + * @param string$bucketId + * @param string$fileId + * @param array $permissions * @throws AppwriteException * @return array */ - public function updateFile(string $bucketId, string $fileId, array $read = null, array $write = null): array + public function updateFile(string$bucketId, string$fileId, array $permissions = null): array { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}'); @@ -516,12 +475,8 @@ public function updateFile(string $bucketId, string $fileId, array $read = null, if (!isset($fileId)) { throw new AppwriteException('Missing required parameter: "fileId"'); } - if (!is_null($read)) { - $params['read'] = $read; - } - - if (!is_null($write)) { - $params['write'] = $write; + if (!is_null($permissions)) { + $params['permissions'] = $permissions; } @@ -536,13 +491,13 @@ public function updateFile(string $bucketId, string $fileId, array $read = null, * Delete a file by its unique ID. Only users with write permissions have * access to delete this resource. * - * @param string $bucketId - * @param string $fileId + * @param string$bucketId + * @param string$fileId * @throws AppwriteException * @return string */ - public function deleteFile(string $bucketId, string $fileId): string + public function deleteFile(string$bucketId, string$fileId): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}'); @@ -566,13 +521,13 @@ public function deleteFile(string $bucketId, string $fileId): string * 'Content-Disposition: attachment' header that tells the browser to start * downloading the file to user downloads directory. * - * @param string $bucketId - * @param string $fileId + * @param string$bucketId + * @param string$fileId * @throws AppwriteException * @return string */ - public function getFileDownload(string $bucketId, string $fileId): string + public function getFileDownload(string$bucketId, string$fileId): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/download'); @@ -598,24 +553,24 @@ public function getFileDownload(string $bucketId, string $fileId): string * string arguments for cutting and resizing your preview image. Preview is * supported only for image files smaller than 10MB. * - * @param string $bucketId - * @param string $fileId + * @param string$bucketId + * @param string$fileId * @param int $width * @param int $height - * @param string $gravity + * @param string$gravity * @param int $quality * @param int $borderWidth - * @param string $borderColor + * @param string$borderColor * @param int $borderRadius * @param int $opacity * @param int $rotation - * @param string $background - * @param string $output + * @param string$background + * @param string$output * @throws AppwriteException * @return string */ - public function getFilePreview(string $bucketId, string $fileId, int $width = null, int $height = null, string $gravity = null, int $quality = null, int $borderWidth = null, string $borderColor = null, int $borderRadius = null, int $opacity = null, int $rotation = null, string $background = null, string $output = null): string + public function getFilePreview(string$bucketId, string$fileId, int $width = null, int $height = null, string$gravity = null, int $quality = null, int $borderWidth = null, string$borderColor = null, int $borderRadius = null, int $opacity = null, int $rotation = null, string$background = null, string$output = null): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/preview'); @@ -683,13 +638,13 @@ public function getFilePreview(string $bucketId, string $fileId, int $width = nu * download method but returns with no 'Content-Disposition: attachment' * header. * - * @param string $bucketId - * @param string $fileId + * @param string$bucketId + * @param string$fileId * @throws AppwriteException * @return string */ - public function getFileView(string $bucketId, string $fileId): string + public function getFileView(string$bucketId, string$fileId): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/view'); diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index 7e6ca4c..923a47c 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -9,6 +9,11 @@ class Teams extends Service { + public function __construct(Client $client) + { + $this->client = $client; + } + /** * List Teams * @@ -18,43 +23,23 @@ class Teams extends Service * In admin mode, this endpoint returns a list of all the teams in the current * project. [Learn more about different API modes](/docs/admin). * - * @param string $search - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param string $orderType + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function list(string $search = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, string $orderType = null): array + public function list(array $queries = null, string$search = null): array { $path = str_replace([], [], '/teams'); $params = []; - if (!is_null($search)) { - $params['search'] = $search; - } - - if (!is_null($limit)) { - $params['limit'] = $limit; - } - - if (!is_null($offset)) { - $params['offset'] = $offset; + if (!is_null($queries)) { + $params['queries'] = $queries; } - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; - } - - if (!is_null($orderType)) { - $params['orderType'] = $orderType; + if (!is_null($search)) { + $params['search'] = $search; } @@ -70,14 +55,14 @@ public function list(string $search = null, int $limit = null, int $offset = nul * 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. * - * @param string $teamId - * @param string $name + * @param string$teamId + * @param string$name * @param array $roles * @throws AppwriteException * @return array */ - public function create(string $teamId, string $name, array $roles = null): array + public function create(string$teamId, string$name, array $roles = null): array { $path = str_replace([], [], '/teams'); @@ -111,12 +96,12 @@ public function create(string $teamId, string $name, array $roles = null): array * * Get a team by its ID. All team members have read access for this resource. * - * @param string $teamId + * @param string$teamId * @throws AppwriteException * @return array */ - public function get(string $teamId): array + public function get(string$teamId): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); @@ -136,13 +121,13 @@ public function get(string $teamId): array * Update a team using its ID. Only members with the owner role can update the * team. * - * @param string $teamId - * @param string $name + * @param string$teamId + * @param string$name * @throws AppwriteException * @return array */ - public function update(string $teamId, string $name): array + public function update(string$teamId, string$name): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); @@ -169,12 +154,12 @@ public function update(string $teamId, string $name): array * Delete a team using its ID. Only team members with the owner role can * delete the team. * - * @param string $teamId + * @param string$teamId * @throws AppwriteException * @return string */ - public function delete(string $teamId): string + public function delete(string$teamId): string { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); @@ -194,18 +179,14 @@ public function delete(string $teamId): string * Use this endpoint to list a team's members using the team's ID. All team * members have read access to this endpoint. * - * @param string $teamId - * @param string $search - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param string $orderType + * @param string$teamId + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function getMemberships(string $teamId, string $search = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, string $orderType = null): array + public function getMemberships(string$teamId, array $queries = null, string$search = null): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); @@ -213,28 +194,12 @@ public function getMemberships(string $teamId, string $search = null, int $limit if (!isset($teamId)) { throw new AppwriteException('Missing required parameter: "teamId"'); } - if (!is_null($search)) { - $params['search'] = $search; - } - - if (!is_null($limit)) { - $params['limit'] = $limit; - } - - if (!is_null($offset)) { - $params['offset'] = $offset; + if (!is_null($queries)) { + $params['queries'] = $queries; } - if (!is_null($cursor)) { - $params['cursor'] = $cursor; - } - - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; - } - - if (!is_null($orderType)) { - $params['orderType'] = $orderType; + if (!is_null($search)) { + $params['search'] = $search; } @@ -262,16 +227,16 @@ public function getMemberships(string $teamId, string $search = null, int $limit * the only valid redirect URL's are the once from domains you have set when * adding your platforms in the console interface. * - * @param string $teamId - * @param string $email + * @param string$teamId + * @param string$email * @param array $roles - * @param string $url - * @param string $name + * @param string$url + * @param string$name * @throws AppwriteException * @return array */ - public function createMembership(string $teamId, string $email, array $roles, string $url, string $name = null): array + public function createMembership(string$teamId, string$email, array $roles, string$url, string$name = null): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); @@ -316,13 +281,13 @@ public function createMembership(string $teamId, string $email, array $roles, st * Get a team member by the membership unique id. All team members have read * access for this resource. * - * @param string $teamId - * @param string $membershipId + * @param string$teamId + * @param string$membershipId * @throws AppwriteException * @return array */ - public function getMembership(string $teamId, string $membershipId): array + public function getMembership(string$teamId, string$membershipId): array { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); @@ -346,14 +311,14 @@ public function getMembership(string $teamId, string $membershipId): array * have access to this endpoint. Learn more about [roles and * permissions](/docs/permissions). * - * @param string $teamId - * @param string $membershipId + * @param string$teamId + * @param string$membershipId * @param array $roles * @throws AppwriteException * @return array */ - public function updateMembershipRoles(string $teamId, string $membershipId, array $roles): array + public function updateMembershipRoles(string$teamId, string$membershipId, array $roles): array { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); @@ -384,13 +349,13 @@ public function updateMembershipRoles(string $teamId, string $membershipId, arra * the membership of any other team member. You can also use this endpoint to * delete a user membership even if it is not accepted. * - * @param string $teamId - * @param string $membershipId + * @param string$teamId + * @param string$membershipId * @throws AppwriteException * @return string */ - public function deleteMembership(string $teamId, string $membershipId): string + public function deleteMembership(string$teamId, string$membershipId): string { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); @@ -418,15 +383,15 @@ public function deleteMembership(string $teamId, string $membershipId): string * created. * * - * @param string $teamId - * @param string $membershipId - * @param string $userId - * @param string $secret + * @param string$teamId + * @param string$membershipId + * @param string$userId + * @param string$secret * @throws AppwriteException * @return array */ - public function updateMembershipStatus(string $teamId, string $membershipId, string $userId, string $secret): array + public function updateMembershipStatus(string$teamId, string$membershipId, string$userId, string$secret): array { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}/status'); diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index 2bd52ca..acbe14b 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -9,73 +9,265 @@ class Users extends Service { + public function __construct(Client $client) + { + $this->client = $client; + } + /** * List Users * * Get a list of all the project's users. You can use the query params to * filter your results. * - * @param string $search - * @param int $limit - * @param int $offset - * @param string $cursor - * @param string $cursorDirection - * @param string $orderType + * @param array $queries + * @param string$search * @throws AppwriteException * @return array */ - public function list(string $search = null, int $limit = null, int $offset = null, string $cursor = null, string $cursorDirection = null, string $orderType = null): array + public function list(array $queries = null, string$search = null): array { $path = str_replace([], [], '/users'); $params = []; + if (!is_null($queries)) { + $params['queries'] = $queries; + } + if (!is_null($search)) { $params['search'] = $search; } - if (!is_null($limit)) { - $params['limit'] = $limit; + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Create User + * + * Create a new user. + * + * @param string$userId + * @param string$email + * @param string$phone + * @param string$password + * @param string$name + * @throws AppwriteException + * @return array + + */ + public function create(string$userId, string$email = null, string$phone = null, string$password = null, string$name = null): array + { + $path = str_replace([], [], '/users'); + + $params = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!is_null($userId)) { + $params['userId'] = $userId; } - if (!is_null($offset)) { - $params['offset'] = $offset; + if (!is_null($email)) { + $params['email'] = $email; } - if (!is_null($cursor)) { - $params['cursor'] = $cursor; + if (!is_null($phone)) { + $params['phone'] = $phone; } - if (!is_null($cursorDirection)) { - $params['cursorDirection'] = $cursorDirection; + if (!is_null($password)) { + $params['password'] = $password; } - if (!is_null($orderType)) { - $params['orderType'] = $orderType; + if (!is_null($name)) { + $params['name'] = $name; } - return $this->client->call(Client::METHOD_GET, $path, [ + return $this->client->call(Client::METHOD_POST, $path, [ 'content-type' => 'application/json', ], $params); } /** - * Create User + * Create User with Argon2 Password * - * Create a new user. + * Create a new user. Password provided must be hashed with the + * [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST + * /users](/docs/server/users#usersCreate) endpoint to create users with a + * plain text password. * - * @param string $userId - * @param string $email - * @param string $password - * @param string $name + * @param string$userId + * @param string$email + * @param string$password + * @param string$name * @throws AppwriteException * @return array */ - public function create(string $userId, string $email, string $password, string $name = null): array + public function createArgon2User(string$userId, string$email, string$password, string$name = null): array { - $path = str_replace([], [], '/users'); + $path = str_replace([], [], '/users/argon2'); + + $params = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!isset($password)) { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (!is_null($userId)) { + $params['userId'] = $userId; + } + + if (!is_null($email)) { + $params['email'] = $email; + } + + if (!is_null($password)) { + $params['password'] = $password; + } + + if (!is_null($name)) { + $params['name'] = $name; + } + + + return $this->client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Create User with Bcrypt Password + * + * Create a new user. Password provided must be hashed with the + * [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST + * /users](/docs/server/users#usersCreate) endpoint to create users with a + * plain text password. + * + * @param string$userId + * @param string$email + * @param string$password + * @param string$name + * @throws AppwriteException + * @return array + + */ + public function createBcryptUser(string$userId, string$email, string$password, string$name = null): array + { + $path = str_replace([], [], '/users/bcrypt'); + + $params = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!isset($password)) { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (!is_null($userId)) { + $params['userId'] = $userId; + } + + if (!is_null($email)) { + $params['email'] = $email; + } + + if (!is_null($password)) { + $params['password'] = $password; + } + + if (!is_null($name)) { + $params['name'] = $name; + } + + + return $this->client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Create User with MD5 Password + * + * Create a new user. Password provided must be hashed with the + * [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST + * /users](/docs/server/users#usersCreate) endpoint to create users with a + * plain text password. + * + * @param string$userId + * @param string$email + * @param string$password + * @param string$name + * @throws AppwriteException + * @return array + + */ + public function createMD5User(string$userId, string$email, string$password, string$name = null): array + { + $path = str_replace([], [], '/users/md5'); + + $params = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!isset($password)) { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (!is_null($userId)) { + $params['userId'] = $userId; + } + + if (!is_null($email)) { + $params['email'] = $email; + } + + if (!is_null($password)) { + $params['password'] = $password; + } + + if (!is_null($name)) { + $params['name'] = $name; + } + + + return $this->client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Create User with PHPass Password + * + * Create a new user. Password provided must be hashed with the + * [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST + * /users](/docs/server/users#usersCreate) endpoint to create users with a + * plain text password. + * + * @param string$userId + * @param string$email + * @param string$password + * @param string$name + * @throws AppwriteException + * @return array + + */ + public function createPHPassUser(string$userId, string$email, string$password, string$name = null): array + { + $path = str_replace([], [], '/users/phpass'); $params = []; if (!isset($userId)) { @@ -109,17 +301,242 @@ public function create(string $userId, string $email, string $password, string $ ], $params); } + /** + * Create User with Scrypt Password + * + * Create a new user. Password provided must be hashed with the + * [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST + * /users](/docs/server/users#usersCreate) endpoint to create users with a + * plain text password. + * + * @param string$userId + * @param string$email + * @param string$password + * @param string$passwordSalt + * @param int $passwordCpu + * @param int $passwordMemory + * @param int $passwordParallel + * @param int $passwordLength + * @param string$name + * @throws AppwriteException + * @return array + + */ + public function createScryptUser(string$userId, string$email, string$password, string$passwordSalt, int $passwordCpu, int $passwordMemory, int $passwordParallel, int $passwordLength, string$name = null): array + { + $path = str_replace([], [], '/users/scrypt'); + + $params = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!isset($password)) { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (!isset($passwordSalt)) { + throw new AppwriteException('Missing required parameter: "passwordSalt"'); + } + if (!isset($passwordCpu)) { + throw new AppwriteException('Missing required parameter: "passwordCpu"'); + } + if (!isset($passwordMemory)) { + throw new AppwriteException('Missing required parameter: "passwordMemory"'); + } + if (!isset($passwordParallel)) { + throw new AppwriteException('Missing required parameter: "passwordParallel"'); + } + if (!isset($passwordLength)) { + throw new AppwriteException('Missing required parameter: "passwordLength"'); + } + if (!is_null($userId)) { + $params['userId'] = $userId; + } + + if (!is_null($email)) { + $params['email'] = $email; + } + + if (!is_null($password)) { + $params['password'] = $password; + } + + if (!is_null($passwordSalt)) { + $params['passwordSalt'] = $passwordSalt; + } + + if (!is_null($passwordCpu)) { + $params['passwordCpu'] = $passwordCpu; + } + + if (!is_null($passwordMemory)) { + $params['passwordMemory'] = $passwordMemory; + } + + if (!is_null($passwordParallel)) { + $params['passwordParallel'] = $passwordParallel; + } + + if (!is_null($passwordLength)) { + $params['passwordLength'] = $passwordLength; + } + + if (!is_null($name)) { + $params['name'] = $name; + } + + + return $this->client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Create User with Scrypt Modified Password + * + * Create a new user. Password provided must be hashed with the [Scrypt + * Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) + * algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint + * to create users with a plain text password. + * + * @param string$userId + * @param string$email + * @param string$password + * @param string$passwordSalt + * @param string$passwordSaltSeparator + * @param string$passwordSignerKey + * @param string$name + * @throws AppwriteException + * @return array + + */ + public function createScryptModifiedUser(string$userId, string$email, string$password, string$passwordSalt, string$passwordSaltSeparator, string$passwordSignerKey, string$name = null): array + { + $path = str_replace([], [], '/users/scrypt-modified'); + + $params = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!isset($password)) { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (!isset($passwordSalt)) { + throw new AppwriteException('Missing required parameter: "passwordSalt"'); + } + if (!isset($passwordSaltSeparator)) { + throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"'); + } + if (!isset($passwordSignerKey)) { + throw new AppwriteException('Missing required parameter: "passwordSignerKey"'); + } + if (!is_null($userId)) { + $params['userId'] = $userId; + } + + if (!is_null($email)) { + $params['email'] = $email; + } + + if (!is_null($password)) { + $params['password'] = $password; + } + + if (!is_null($passwordSalt)) { + $params['passwordSalt'] = $passwordSalt; + } + + if (!is_null($passwordSaltSeparator)) { + $params['passwordSaltSeparator'] = $passwordSaltSeparator; + } + + if (!is_null($passwordSignerKey)) { + $params['passwordSignerKey'] = $passwordSignerKey; + } + + if (!is_null($name)) { + $params['name'] = $name; + } + + + return $this->client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Create User with SHA Password + * + * Create a new user. Password provided must be hashed with the + * [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use + * the [POST /users](/docs/server/users#usersCreate) endpoint to create users + * with a plain text password. + * + * @param string$userId + * @param string$email + * @param string$password + * @param string$passwordVersion + * @param string$name + * @throws AppwriteException + * @return array + + */ + public function createSHAUser(string$userId, string$email, string$password, string$passwordVersion = null, string$name = null): array + { + $path = str_replace([], [], '/users/sha'); + + $params = []; + if (!isset($userId)) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (!isset($email)) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (!isset($password)) { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (!is_null($userId)) { + $params['userId'] = $userId; + } + + if (!is_null($email)) { + $params['email'] = $email; + } + + if (!is_null($password)) { + $params['password'] = $password; + } + + if (!is_null($passwordVersion)) { + $params['passwordVersion'] = $passwordVersion; + } + + if (!is_null($name)) { + $params['name'] = $name; + } + + + return $this->client->call(Client::METHOD_POST, $path, [ + 'content-type' => 'application/json', + ], $params); + } + /** * Get User * * Get a user by its unique ID. * - * @param string $userId + * @param string$userId * @throws AppwriteException * @return array */ - public function get(string $userId): array + public function get(string$userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}'); @@ -142,12 +559,12 @@ public function get(string $userId): array * ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) * endpoint instead. * - * @param string $userId + * @param string$userId * @throws AppwriteException * @return string */ - public function delete(string $userId): string + public function delete(string$userId): string { $path = str_replace(['{userId}'], [$userId], '/users/{userId}'); @@ -166,13 +583,13 @@ public function delete(string $userId): string * * Update the user email by its unique ID. * - * @param string $userId - * @param string $email + * @param string$userId + * @param string$email * @throws AppwriteException * @return array */ - public function updateEmail(string $userId, string $email): array + public function updateEmail(string$userId, string$email): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/email'); @@ -198,14 +615,13 @@ public function updateEmail(string $userId, string $email): array * * Get the user activity logs list by its unique ID. * - * @param string $userId - * @param int $limit - * @param int $offset + * @param string$userId + * @param array $queries * @throws AppwriteException * @return array */ - public function getLogs(string $userId, int $limit = null, int $offset = null): array + public function getLogs(string$userId, array $queries = null): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/logs'); @@ -213,12 +629,8 @@ public function getLogs(string $userId, int $limit = null, int $offset = null): if (!isset($userId)) { throw new AppwriteException('Missing required parameter: "userId"'); } - if (!is_null($limit)) { - $params['limit'] = $limit; - } - - if (!is_null($offset)) { - $params['offset'] = $offset; + if (!is_null($queries)) { + $params['queries'] = $queries; } @@ -232,12 +644,12 @@ public function getLogs(string $userId, int $limit = null, int $offset = null): * * Get the user membership list by its unique ID. * - * @param string $userId + * @param string$userId * @throws AppwriteException * @return array */ - public function getMemberships(string $userId): array + public function getMemberships(string$userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/memberships'); @@ -256,13 +668,13 @@ public function getMemberships(string $userId): array * * Update the user name by its unique ID. * - * @param string $userId - * @param string $name + * @param string$userId + * @param string$name * @throws AppwriteException * @return array */ - public function updateName(string $userId, string $name): array + public function updateName(string$userId, string$name): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/name'); @@ -288,13 +700,13 @@ public function updateName(string $userId, string $name): array * * Update the user password by its unique ID. * - * @param string $userId - * @param string $password + * @param string$userId + * @param string$password * @throws AppwriteException * @return array */ - public function updatePassword(string $userId, string $password): array + public function updatePassword(string$userId, string$password): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/password'); @@ -320,13 +732,13 @@ public function updatePassword(string $userId, string $password): array * * Update the user phone by its unique ID. * - * @param string $userId - * @param string $number + * @param string$userId + * @param string$number * @throws AppwriteException * @return array */ - public function updatePhone(string $userId, string $number): array + public function updatePhone(string$userId, string$number): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/phone'); @@ -352,12 +764,12 @@ public function updatePhone(string $userId, string $number): array * * Get the user preferences by its unique ID. * - * @param string $userId + * @param string$userId * @throws AppwriteException * @return array */ - public function getPrefs(string $userId): array + public function getPrefs(string$userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); @@ -378,13 +790,13 @@ public function getPrefs(string $userId): array * as is, and replaces any previous value. The maximum allowed prefs size is * 64kB and throws error if exceeded. * - * @param string $userId + * @param string$userId * @param array $prefs * @throws AppwriteException * @return array */ - public function updatePrefs(string $userId, array $prefs): array + public function updatePrefs(string$userId, array $prefs): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); @@ -410,12 +822,12 @@ public function updatePrefs(string $userId, array $prefs): array * * Get the user sessions list by its unique ID. * - * @param string $userId + * @param string$userId * @throws AppwriteException * @return array */ - public function getSessions(string $userId): array + public function getSessions(string$userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); @@ -434,12 +846,12 @@ public function getSessions(string $userId): array * * Delete all user's sessions by using the user's unique ID. * - * @param string $userId + * @param string$userId * @throws AppwriteException * @return string */ - public function deleteSessions(string $userId): string + public function deleteSessions(string$userId): string { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); @@ -458,13 +870,13 @@ public function deleteSessions(string $userId): string * * Delete a user sessions by its unique ID. * - * @param string $userId - * @param string $sessionId + * @param string$userId + * @param string$sessionId * @throws AppwriteException * @return string */ - public function deleteSession(string $userId, string $sessionId): string + public function deleteSession(string$userId, string$sessionId): string { $path = str_replace(['{userId}', '{sessionId}'], [$userId, $sessionId], '/users/{userId}/sessions/{sessionId}'); @@ -487,13 +899,13 @@ public function deleteSession(string $userId, string $sessionId): string * Update the user status by its unique ID. Use this endpoint as an * alternative to deleting a user if you want to keep user's ID reserved. * - * @param string $userId + * @param string$userId * @param bool $status * @throws AppwriteException * @return array */ - public function updateStatus(string $userId, bool $status): array + public function updateStatus(string$userId, bool $status): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/status'); @@ -519,13 +931,13 @@ public function updateStatus(string $userId, bool $status): array * * Update the user email verification status by its unique ID. * - * @param string $userId + * @param string$userId * @param bool $emailVerification * @throws AppwriteException * @return array */ - public function updateEmailVerification(string $userId, bool $emailVerification): array + public function updateEmailVerification(string$userId, bool $emailVerification): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/verification'); @@ -551,13 +963,13 @@ public function updateEmailVerification(string $userId, bool $emailVerification) * * Update the user phone verification status by its unique ID. * - * @param string $userId + * @param string$userId * @param bool $phoneVerification * @throws AppwriteException * @return array */ - public function updatePhoneVerification(string $userId, bool $phoneVerification): array + public function updatePhoneVerification(string$userId, bool $phoneVerification): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/verification/phone'); From d0e536831a53314e7fba22ddfcb6033bd5c9b0e2 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 5 Sep 2022 02:01:20 +0400 Subject: [PATCH 2/4] feat: update for 1.0.0-RC1ush --- docs/databases.md | 2 +- docs/examples/databases/create-collection.md | 2 +- docs/examples/databases/update-collection.md | 2 +- docs/examples/storage/create-bucket.md | 2 +- docs/examples/storage/update-bucket.md | 2 +- src/Appwrite/Services/Account.php | 66 ++--- src/Appwrite/Services/Avatars.php | 32 +-- src/Appwrite/Services/Databases.php | 245 +++++++++---------- src/Appwrite/Services/Functions.php | 122 ++++----- src/Appwrite/Services/Storage.php | 94 ++++--- src/Appwrite/Services/Teams.php | 68 ++--- src/Appwrite/Services/Users.php | 170 ++++++------- 12 files changed, 396 insertions(+), 411 deletions(-) diff --git a/docs/databases.md b/docs/databases.md index 6d02b7b..2cd7b23 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -204,7 +204,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| default | string | Default value for the attribute in ISO 8601 format. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | ## Create Email Attribute diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index bde7c9e..a7d98c0 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -13,4 +13,4 @@ $client $databases = new Databases($client); -$result = $databases->createCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]', ["read("any")"], false); \ No newline at end of file +$result = $databases->createCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]'); \ No newline at end of file diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 1ce3ff3..df03c9b 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -13,4 +13,4 @@ $client $databases = new Databases($client); -$result = $databases->updateCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]', false); \ No newline at end of file +$result = $databases->updateCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]'); \ No newline at end of file diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index 27d7a3d..b1aedf5 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -13,4 +13,4 @@ $client $storage = new Storage($client); -$result = $storage->createBucket('[BUCKET_ID]', '[NAME]', false); \ No newline at end of file +$result = $storage->createBucket('[BUCKET_ID]', '[NAME]'); \ No newline at end of file diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 07c6f83..667833b 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -13,4 +13,4 @@ $client $storage = new Storage($client); -$result = $storage->updateBucket('[BUCKET_ID]', '[NAME]', false); \ No newline at end of file +$result = $storage->updateBucket('[BUCKET_ID]', '[NAME]'); \ No newline at end of file diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 9971d50..81e0514 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -46,13 +46,13 @@ public function get(): array * one, by passing an email address and a new password. * * - * @param string$email - * @param string$password + * @param string $email + * @param string $password * @throws AppwriteException * @return array */ - public function updateEmail(string$email, string$password): array + public function updateEmail(string $email, string $password): array { $path = str_replace([], [], '/account/email'); @@ -108,12 +108,12 @@ public function getLogs(array $queries = null): array * * Update currently logged in user account name. * - * @param string$name + * @param string $name * @throws AppwriteException * @return array */ - public function updateName(string$name): array + public function updateName(string $name): array { $path = str_replace([], [], '/account/name'); @@ -138,13 +138,13 @@ public function updateName(string$name): array * to pass in the new password, and the old password. For users created with * OAuth, Team Invites and Magic URL, oldPassword is optional. * - * @param string$password - * @param string$oldPassword + * @param string $password + * @param string $oldPassword * @throws AppwriteException * @return array */ - public function updatePassword(string$password, string$oldPassword = null): array + public function updatePassword(string $password, string $oldPassword = null): array { $path = str_replace([], [], '/account/password'); @@ -175,13 +175,13 @@ public function updatePassword(string$password, string$oldPassword = null): arra * /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) * endpoint to send a confirmation SMS. * - * @param string$phone - * @param string$password + * @param string $phone + * @param string $password * @throws AppwriteException * @return array */ - public function updatePhone(string$phone, string$password): array + public function updatePhone(string $phone, string $password): array { $path = str_replace([], [], '/account/phone'); @@ -268,13 +268,13 @@ public function updatePrefs(array $prefs): array * complete the process. The verification link sent to the user's email * address is valid for 1 hour. * - * @param string$email - * @param string$url + * @param string $email + * @param string $url * @throws AppwriteException * @return array */ - public function createRecovery(string$email, string$url): array + public function createRecovery(string $email, string $url): array { $path = str_replace([], [], '/account/recovery'); @@ -312,15 +312,15 @@ public function createRecovery(string$email, string$url): array * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param string$userId - * @param string$secret - * @param string$password - * @param string$passwordAgain + * @param string $userId + * @param string $secret + * @param string $password + * @param string $passwordAgain * @throws AppwriteException * @return array */ - public function updateRecovery(string$userId, string$secret, string$password, string$passwordAgain): array + public function updateRecovery(string $userId, string $secret, string $password, string $passwordAgain): array { $path = str_replace([], [], '/account/recovery'); @@ -407,12 +407,12 @@ public function deleteSessions(): string * Use this endpoint to get a logged in user's session using a Session ID. * Inputting 'current' will return the current session being used. * - * @param string$sessionId + * @param string $sessionId * @throws AppwriteException * @return array */ - public function getSession(string$sessionId): array + public function getSession(string $sessionId): array { $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); @@ -433,12 +433,12 @@ public function getSession(string$sessionId): array * If session was created using an OAuth provider, this route can be used to * "refresh" the access token. * - * @param string$sessionId + * @param string $sessionId * @throws AppwriteException * @return array */ - public function updateSession(string$sessionId): array + public function updateSession(string $sessionId): array { $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); @@ -460,12 +460,12 @@ public function updateSession(string$sessionId): array * Session ID argument, only the unique session ID provided is deleted. * * - * @param string$sessionId + * @param string $sessionId * @throws AppwriteException * @return string */ - public function deleteSession(string$sessionId): string + public function deleteSession(string $sessionId): string { $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); @@ -520,12 +520,12 @@ public function updateStatus(): array * adding your platforms in the console interface. * * - * @param string$url + * @param string $url * @throws AppwriteException * @return array */ - public function createVerification(string$url): array + public function createVerification(string $url): array { $path = str_replace([], [], '/account/verification'); @@ -551,13 +551,13 @@ public function createVerification(string$url): array * to verify the user email ownership. If confirmed this route will return a * 200 status code. * - * @param string$userId - * @param string$secret + * @param string $userId + * @param string $secret * @throws AppwriteException * @return array */ - public function updateVerification(string$userId, string$secret): array + public function updateVerification(string $userId, string $secret): array { $path = str_replace([], [], '/account/verification'); @@ -615,13 +615,13 @@ public function createPhoneVerification(): array * verify the user email ownership. If confirmed this route will return a 200 * status code. * - * @param string$userId - * @param string$secret + * @param string $userId + * @param string $secret * @throws AppwriteException * @return array */ - public function updatePhoneVerification(string$userId, string$secret): array + public function updatePhoneVerification(string $userId, string $secret): array { $path = str_replace([], [], '/account/verification/phone'); diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index 82af493..dfd4b29 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -27,7 +27,7 @@ public function __construct(Client $client) * image at source quality. If dimensions are not specified, the default size * of image returned is 100x100px. * - * @param string$code + * @param string $code * @param int $width * @param int $height * @param int $quality @@ -35,7 +35,7 @@ public function __construct(Client $client) * @return string */ - public function getBrowser(string$code, int $width = null, int $height = null, int $quality = null): string + public function getBrowser(string $code, int $width = null, int $height = null, int $quality = null): string { $path = str_replace(['{code}'], [$code], '/avatars/browsers/{code}'); @@ -74,7 +74,7 @@ public function getBrowser(string$code, int $width = null, int $height = null, i * of image returned is 100x100px. * * - * @param string$code + * @param string $code * @param int $width * @param int $height * @param int $quality @@ -82,7 +82,7 @@ public function getBrowser(string$code, int $width = null, int $height = null, i * @return string */ - public function getCreditCard(string$code, int $width = null, int $height = null, int $quality = null): string + public function getCreditCard(string $code, int $width = null, int $height = null, int $quality = null): string { $path = str_replace(['{code}'], [$code], '/avatars/credit-cards/{code}'); @@ -115,12 +115,12 @@ public function getCreditCard(string$code, int $width = null, int $height = null * website URL. * * - * @param string$url + * @param string $url * @throws AppwriteException * @return string */ - public function getFavicon(string$url): string + public function getFavicon(string $url): string { $path = str_replace([], [], '/avatars/favicon'); @@ -152,7 +152,7 @@ public function getFavicon(string$url): string * of image returned is 100x100px. * * - * @param string$code + * @param string $code * @param int $width * @param int $height * @param int $quality @@ -160,7 +160,7 @@ public function getFavicon(string$url): string * @return string */ - public function getFlag(string$code, int $width = null, int $height = null, int $quality = null): string + public function getFlag(string $code, int $width = null, int $height = null, int $quality = null): string { $path = str_replace(['{code}'], [$code], '/avatars/flags/{code}'); @@ -200,14 +200,14 @@ public function getFlag(string$code, int $width = null, int $height = null, int * of image returned is 400x400px. * * - * @param string$url + * @param string $url * @param int $width * @param int $height * @throws AppwriteException * @return string */ - public function getImage(string$url, int $width = null, int $height = null): string + public function getImage(string $url, int $width = null, int $height = null): string { $path = str_replace([], [], '/avatars/image'); @@ -253,16 +253,16 @@ public function getImage(string$url, int $width = null, int $height = null): str * of image returned is 100x100px. * * - * @param string$name + * @param string $name * @param int $width * @param int $height - * @param string$color - * @param string$background + * @param string $color + * @param string $background * @throws AppwriteException * @return string */ - public function getInitials(string$name = null, int $width = null, int $height = null, string$color = null, string$background = null): string + public function getInitials(string $name = null, int $width = null, int $height = null, string $color = null, string $background = null): string { $path = str_replace([], [], '/avatars/initials'); @@ -300,7 +300,7 @@ public function getInitials(string$name = null, int $width = null, int $height = * parameters to change the size and style of the resulting image. * * - * @param string$text + * @param string $text * @param int $size * @param int $margin * @param bool $download @@ -308,7 +308,7 @@ public function getInitials(string$name = null, int $width = null, int $height = * @return string */ - public function getQR(string$text, int $size = null, int $margin = null, bool $download = null): string + public function getQR(string $text, int $size = null, int $margin = null, bool $download = null): string { $path = str_replace([], [], '/avatars/qr'); diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 029cbad..5bbbc74 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -21,12 +21,12 @@ public function __construct(Client $client) * the search parameter to filter your results. * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function list(array $queries = null, string$search = null): array + public function list(array $queries = null, string $search = null): array { $path = str_replace([], [], '/databases'); @@ -51,13 +51,13 @@ public function list(array $queries = null, string$search = null): array * Create a new Database. * * - * @param string$databaseId - * @param string$name + * @param string $databaseId + * @param string $name * @throws AppwriteException * @return array */ - public function create(string$databaseId, string$name): array + public function create(string $databaseId, string $name): array { $path = str_replace([], [], '/databases'); @@ -88,12 +88,12 @@ public function create(string$databaseId, string$name): array * Get a database by its unique ID. This endpoint response returns a JSON * object with the database metadata. * - * @param string$databaseId + * @param string $databaseId * @throws AppwriteException * @return array */ - public function get(string$databaseId): array + public function get(string $databaseId): array { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}'); @@ -112,13 +112,13 @@ public function get(string$databaseId): array * * Update a database by its unique ID. * - * @param string$databaseId - * @param string$name + * @param string $databaseId + * @param string $name * @throws AppwriteException * @return array */ - public function update(string$databaseId, string$name): array + public function update(string $databaseId, string $name): array { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}'); @@ -145,12 +145,12 @@ public function update(string$databaseId, string$name): array * Delete a database by its unique ID. Only API keys with with databases.write * scope can delete a database. * - * @param string$databaseId + * @param string $databaseId * @throws AppwriteException * @return string */ - public function delete(string$databaseId): string + public function delete(string $databaseId): string { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}'); @@ -170,14 +170,14 @@ public function delete(string$databaseId): string * Get a list of all collections that belong to the provided databaseId. You * can use the search parameter to filter your results. * - * @param string$databaseId + * @param string $databaseId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listCollections(string$databaseId, array $queries = null, string$search = null): array + public function listCollections(string $databaseId, array $queries = null, string $search = null): array { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}/collections'); @@ -207,16 +207,16 @@ public function listCollections(string$databaseId, array $queries = null, string * integration](/docs/server/databases#databasesCreateCollection) API or * directly from your database console. * - * @param string$databaseId - * @param string$collectionId - * @param string$name + * @param string $databaseId + * @param string $collectionId + * @param string $name * @param array $permissions * @param bool $documentSecurity * @throws AppwriteException * @return array */ - public function createCollection(string$databaseId, string$collectionId, string$name, array $permissions, bool $documentSecurity): array + public function createCollection(string $databaseId, string $collectionId, string $name, array $permissions = null, bool $documentSecurity = null): array { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}/collections'); @@ -230,12 +230,6 @@ public function createCollection(string$databaseId, string$collectionId, string$ if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($permissions)) { - throw new AppwriteException('Missing required parameter: "permissions"'); - } - if (!isset($documentSecurity)) { - throw new AppwriteException('Missing required parameter: "documentSecurity"'); - } if (!is_null($collectionId)) { $params['collectionId'] = $collectionId; } @@ -264,13 +258,13 @@ public function createCollection(string$databaseId, string$collectionId, string$ * Get a collection by its unique ID. This endpoint response returns a JSON * object with the collection metadata. * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @throws AppwriteException * @return array */ - public function getCollection(string$databaseId, string$collectionId): array + public function getCollection(string $databaseId, string $collectionId): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); @@ -292,17 +286,17 @@ public function getCollection(string$databaseId, string$collectionId): array * * Update a collection by its unique ID. * - * @param string$databaseId - * @param string$collectionId - * @param string$name - * @param bool $documentSecurity + * @param string $databaseId + * @param string $collectionId + * @param string $name * @param array $permissions + * @param bool $documentSecurity * @param bool $enabled * @throws AppwriteException * @return array */ - public function updateCollection(string$databaseId, string$collectionId, string$name, bool $documentSecurity, array $permissions = null, bool $enabled = null): array + public function updateCollection(string $databaseId, string $collectionId, string $name, array $permissions = null, bool $documentSecurity = null, bool $enabled = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); @@ -316,9 +310,6 @@ public function updateCollection(string$databaseId, string$collectionId, string$ if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($documentSecurity)) { - throw new AppwriteException('Missing required parameter: "documentSecurity"'); - } if (!is_null($name)) { $params['name'] = $name; } @@ -347,13 +338,13 @@ public function updateCollection(string$databaseId, string$collectionId, string$ * Delete a collection by its unique ID. Only users with write permissions * have access to delete this resource. * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @throws AppwriteException * @return string */ - public function deleteCollection(string$databaseId, string$collectionId): string + public function deleteCollection(string $databaseId, string $collectionId): string { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); @@ -373,13 +364,13 @@ public function deleteCollection(string$databaseId, string$collectionId): string /** * List Attributes * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @throws AppwriteException * @return array */ - public function listAttributes(string$databaseId, string$collectionId): array + public function listAttributes(string $databaseId, string $collectionId): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes'); @@ -402,9 +393,9 @@ public function listAttributes(string$databaseId, string$collectionId): array * Create a boolean attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required * @param bool $xdefault * @param bool $xarray @@ -412,7 +403,7 @@ public function listAttributes(string$databaseId, string$collectionId): array * @return array */ - public function createBooleanAttribute(string$databaseId, string$collectionId, string$key, bool $required, bool $xdefault = null, bool $xarray = null): array + public function createBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, bool $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'); @@ -454,17 +445,17 @@ public function createBooleanAttribute(string$databaseId, string$collectionId, s /** * Create DateTime Attribute * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createDatetimeAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array + public function createDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'); @@ -509,17 +500,17 @@ public function createDatetimeAttribute(string$databaseId, string$collectionId, * Create an email attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createEmailAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array + public function createEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/email'); @@ -561,18 +552,18 @@ public function createEmailAttribute(string$databaseId, string$collectionId, str /** * Create Enum Attribute * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param array $elements * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createEnumAttribute(string$databaseId, string$collectionId, string$key, array $elements, bool $required, string$xdefault = null, bool $xarray = null): array + public function createEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/enum'); @@ -625,9 +616,9 @@ public function createEnumAttribute(string$databaseId, string$collectionId, stri * provided. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required * @param int $min * @param int $max @@ -637,7 +628,7 @@ public function createEnumAttribute(string$databaseId, string$collectionId, stri * @return array */ - public function createFloatAttribute(string$databaseId, string$collectionId, string$key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array + public function createFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/float'); @@ -691,9 +682,9 @@ public function createFloatAttribute(string$databaseId, string$collectionId, str * provided. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required * @param int $min * @param int $max @@ -703,7 +694,7 @@ public function createFloatAttribute(string$databaseId, string$collectionId, str * @return array */ - public function createIntegerAttribute(string$databaseId, string$collectionId, string$key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array + public function createIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/integer'); @@ -756,17 +747,17 @@ public function createIntegerAttribute(string$databaseId, string$collectionId, s * Create IP address attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createIpAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array + public function createIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/ip'); @@ -811,18 +802,18 @@ public function createIpAttribute(string$databaseId, string$collectionId, string * Create a string attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param int $size * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createStringAttribute(string$databaseId, string$collectionId, string$key, int $size, bool $required, string$xdefault = null, bool $xarray = null): array + public function createStringAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/string'); @@ -874,17 +865,17 @@ public function createStringAttribute(string$databaseId, string$collectionId, st * Create a URL attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createUrlAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array + public function createUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/url'); @@ -926,14 +917,14 @@ public function createUrlAttribute(string$databaseId, string$collectionId, strin /** * Get Attribute * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @throws AppwriteException * @return array */ - public function getAttribute(string$databaseId, string$collectionId, string$key): array + public function getAttribute(string $databaseId, string $collectionId, string $key): array { $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'); @@ -956,14 +947,14 @@ public function getAttribute(string$databaseId, string$collectionId, string$key) /** * Delete Attribute * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @throws AppwriteException * @return string */ - public function deleteAttribute(string$databaseId, string$collectionId, string$key): string + public function deleteAttribute(string $databaseId, string $collectionId, string $key): string { $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'); @@ -991,14 +982,14 @@ public function deleteAttribute(string$databaseId, string$collectionId, string$k * return a list of all of documents belonging to the provided collectionId. * [Learn more about different API modes](/docs/admin). * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @param array $queries * @throws AppwriteException * @return array */ - public function listDocuments(string$databaseId, string$collectionId, array $queries = null): array + public function listDocuments(string $databaseId, string $collectionId, array $queries = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/documents'); @@ -1027,16 +1018,16 @@ public function listDocuments(string$databaseId, string$collectionId, array $que * integration](/docs/server/databases#databasesCreateCollection) API or * directly from your database console. * - * @param string$databaseId - * @param string$collectionId - * @param string$documentId + * @param string $databaseId + * @param string $collectionId + * @param string $documentId * @param array $data * @param array $permissions * @throws AppwriteException * @return array */ - public function createDocument(string$databaseId, string$collectionId, string$documentId, array $data, array $permissions = null): array + public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, array $permissions = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/documents'); @@ -1077,14 +1068,14 @@ public function createDocument(string$databaseId, string$collectionId, string$do * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * - * @param string$databaseId - * @param string$collectionId - * @param string$documentId + * @param string $databaseId + * @param string $collectionId + * @param string $documentId * @throws AppwriteException * @return array */ - public function getDocument(string$databaseId, string$collectionId, string$documentId): array + public function getDocument(string $databaseId, string $collectionId, string $documentId): array { $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); @@ -1110,16 +1101,16 @@ public function getDocument(string$databaseId, string$collectionId, string$docum * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. * - * @param string$databaseId - * @param string$collectionId - * @param string$documentId + * @param string $databaseId + * @param string $collectionId + * @param string $documentId * @param array $data * @param array $permissions * @throws AppwriteException * @return array */ - public function updateDocument(string$databaseId, string$collectionId, string$documentId, array $data = null, array $permissions = null): array + public function updateDocument(string $databaseId, string $collectionId, string $documentId, array $data = null, array $permissions = null): array { $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); @@ -1152,14 +1143,14 @@ public function updateDocument(string$databaseId, string$collectionId, string$do * * Delete a document by its unique ID. * - * @param string$databaseId - * @param string$collectionId - * @param string$documentId + * @param string $databaseId + * @param string $collectionId + * @param string $documentId * @throws AppwriteException * @return string */ - public function deleteDocument(string$databaseId, string$collectionId, string$documentId): string + public function deleteDocument(string $databaseId, string $collectionId, string $documentId): string { $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); @@ -1182,13 +1173,13 @@ public function deleteDocument(string$databaseId, string$collectionId, string$do /** * List Indexes * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @throws AppwriteException * @return array */ - public function listIndexes(string$databaseId, string$collectionId): array + public function listIndexes(string $databaseId, string $collectionId): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/indexes'); @@ -1208,17 +1199,17 @@ public function listIndexes(string$databaseId, string$collectionId): array /** * Create Index * - * @param string$databaseId - * @param string$collectionId - * @param string$key - * @param string$type + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param string $type * @param array $attributes * @param array $orders * @throws AppwriteException * @return array */ - public function createIndex(string$databaseId, string$collectionId, string$key, string$type, array $attributes, array $orders = null): array + public function createIndex(string $databaseId, string $collectionId, string $key, string $type, array $attributes, array $orders = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/indexes'); @@ -1263,14 +1254,14 @@ public function createIndex(string$databaseId, string$collectionId, string$key, /** * Get Index * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @throws AppwriteException * @return array */ - public function getIndex(string$databaseId, string$collectionId, string$key): array + public function getIndex(string $databaseId, string $collectionId, string $key): array { $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'); @@ -1293,14 +1284,14 @@ public function getIndex(string$databaseId, string$collectionId, string$key): ar /** * Delete Index * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @throws AppwriteException * @return string */ - public function deleteIndex(string$databaseId, string$collectionId, string$key): string + public function deleteIndex(string $databaseId, string $collectionId, string $key): string { $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'); diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index 6f670da..5531f7e 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -21,12 +21,12 @@ public function __construct(Client $client) * filter your results. * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function list(array $queries = null, string$search = null): array + public function list(array $queries = null, string $search = null): array { $path = str_replace([], [], '/functions'); @@ -52,18 +52,18 @@ public function list(array $queries = null, string$search = null): array * [permissions](/docs/permissions) to allow different project users or team * with access to execute the function using the client API. * - * @param string$functionId - * @param string$name + * @param string $functionId + * @param string $name * @param array $execute - * @param string$runtime + * @param string $runtime * @param array $events - * @param string$schedule + * @param string $schedule * @param int $timeout * @throws AppwriteException * @return array */ - public function create(string$functionId, string$name, array $execute, string$runtime, array $events = null, string$schedule = null, int $timeout = null): array + public function create(string $functionId, string $name, array $execute, string $runtime, array $events = null, string $schedule = null, int $timeout = null): array { $path = str_replace([], [], '/functions'); @@ -139,12 +139,12 @@ public function listRuntimes(): array * * Get a function by its unique ID. * - * @param string$functionId + * @param string $functionId * @throws AppwriteException * @return array */ - public function get(string$functionId): array + public function get(string $functionId): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -163,17 +163,17 @@ public function get(string$functionId): array * * Update function by its unique ID. * - * @param string$functionId - * @param string$name + * @param string $functionId + * @param string $name * @param array $execute * @param array $events - * @param string$schedule + * @param string $schedule * @param int $timeout * @throws AppwriteException * @return array */ - public function update(string$functionId, string$name, array $execute, array $events = null, string$schedule = null, int $timeout = null): array + public function update(string $functionId, string $name, array $execute, array $events = null, string $schedule = null, int $timeout = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -218,12 +218,12 @@ public function update(string$functionId, string$name, array $execute, array $ev * * Delete a function by its unique ID. * - * @param string$functionId + * @param string $functionId * @throws AppwriteException * @return string */ - public function delete(string$functionId): string + public function delete(string $functionId): string { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -243,14 +243,14 @@ public function delete(string$functionId): string * Get a list of all the project's code deployments. You can use the query * params to filter your results. * - * @param string$functionId + * @param string $functionId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listDeployments(string$functionId, array $queries = null, string$search = null): array + public function listDeployments(string $functionId, array $queries = null, string $search = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/deployments'); @@ -286,15 +286,15 @@ public function listDeployments(string$functionId, array $queries = null, string * * Use the "command" param to set the entry point used to execute your code. * - * @param string$functionId - * @param string$entrypoint + * @param string $functionId + * @param string $entrypoint * @param InputFile $code * @param bool $activate * @throws AppwriteException * @return array */ - public function createDeployment(string$functionId, string$entrypoint, InputFile $code, bool $activate, callable $onProgress = null): array + public function createDeployment(string $functionId, string $entrypoint, InputFile $code, bool $activate, callable $onProgress = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/deployments'); @@ -403,13 +403,13 @@ public function createDeployment(string$functionId, string$entrypoint, InputFile * * Get a code deployment by its unique ID. * - * @param string$functionId - * @param string$deploymentId + * @param string $functionId + * @param string $deploymentId * @throws AppwriteException * @return array */ - public function getDeployment(string$functionId, string$deploymentId): array + public function getDeployment(string $functionId, string $deploymentId): array { $path = str_replace(['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], '/functions/{functionId}/deployments/{deploymentId}'); @@ -433,13 +433,13 @@ public function getDeployment(string$functionId, string$deploymentId): array * this endpoint to switch the code deployment that should be executed by the * execution endpoint. * - * @param string$functionId - * @param string$deploymentId + * @param string $functionId + * @param string $deploymentId * @throws AppwriteException * @return array */ - public function updateDeployment(string$functionId, string$deploymentId): array + public function updateDeployment(string $functionId, string $deploymentId): array { $path = str_replace(['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], '/functions/{functionId}/deployments/{deploymentId}'); @@ -461,13 +461,13 @@ public function updateDeployment(string$functionId, string$deploymentId): array * * Delete a code deployment by its unique ID. * - * @param string$functionId - * @param string$deploymentId + * @param string $functionId + * @param string $deploymentId * @throws AppwriteException * @return string */ - public function deleteDeployment(string$functionId, string$deploymentId): string + public function deleteDeployment(string $functionId, string $deploymentId): string { $path = str_replace(['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], '/functions/{functionId}/deployments/{deploymentId}'); @@ -487,14 +487,14 @@ public function deleteDeployment(string$functionId, string$deploymentId): string /** * Retry Build * - * @param string$functionId - * @param string$deploymentId - * @param string$buildId + * @param string $functionId + * @param string $deploymentId + * @param string $buildId * @throws AppwriteException * @return string */ - public function retryBuild(string$functionId, string$deploymentId, string$buildId): string + public function retryBuild(string $functionId, string $deploymentId, string $buildId): string { $path = str_replace(['{functionId}', '{deploymentId}', '{buildId}'], [$functionId, $deploymentId, $buildId], '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'); @@ -522,14 +522,14 @@ public function retryBuild(string$functionId, string$deploymentId, string$buildI * return a list of all of the project's executions. [Learn more about * different API modes](/docs/admin). * - * @param string$functionId + * @param string $functionId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listExecutions(string$functionId, array $queries = null, string$search = null): array + public function listExecutions(string $functionId, array $queries = null, string $search = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions'); @@ -559,14 +559,14 @@ public function listExecutions(string$functionId, array $queries = null, string$ * updates on the current execution status. Once this endpoint is called, your * function execution process will start asynchronously. * - * @param string$functionId - * @param string$data + * @param string $functionId + * @param string $data * @param bool $async * @throws AppwriteException * @return array */ - public function createExecution(string$functionId, string$data = null, bool $async = null): array + public function createExecution(string $functionId, string $data = null, bool $async = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions'); @@ -593,13 +593,13 @@ public function createExecution(string$functionId, string$data = null, bool $asy * * Get a function execution log by its unique ID. * - * @param string$functionId - * @param string$executionId + * @param string $functionId + * @param string $executionId * @throws AppwriteException * @return array */ - public function getExecution(string$functionId, string$executionId): array + public function getExecution(string $functionId, string $executionId): array { $path = str_replace(['{functionId}', '{executionId}'], [$functionId, $executionId], '/functions/{functionId}/executions/{executionId}'); @@ -621,14 +621,14 @@ public function getExecution(string$functionId, string$executionId): array * * Get a list of all variables of a specific function. * - * @param string$functionId + * @param string $functionId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listVariables(string$functionId, array $queries = null, string$search = null): array + public function listVariables(string $functionId, array $queries = null, string $search = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/variables'); @@ -656,14 +656,14 @@ public function listVariables(string$functionId, array $queries = null, string$s * Create a new function variable. These variables can be accessed within * function in the `env` object under the request variable. * - * @param string$functionId - * @param string$key - * @param string$value + * @param string $functionId + * @param string $key + * @param string $value * @throws AppwriteException * @return array */ - public function createVariable(string$functionId, string$key, string$value): array + public function createVariable(string $functionId, string $key, string $value): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/variables'); @@ -696,13 +696,13 @@ public function createVariable(string$functionId, string$key, string$value): arr * * Get a variable by its unique ID. * - * @param string$functionId - * @param string$variableId + * @param string $functionId + * @param string $variableId * @throws AppwriteException * @return array */ - public function getVariable(string$functionId, string$variableId): array + public function getVariable(string $functionId, string $variableId): array { $path = str_replace(['{functionId}', '{variableId}'], [$functionId, $variableId], '/functions/{functionId}/variables/{variableId}'); @@ -724,15 +724,15 @@ public function getVariable(string$functionId, string$variableId): array * * Update variable by its unique ID. * - * @param string$functionId - * @param string$variableId - * @param string$key - * @param string$value + * @param string $functionId + * @param string $variableId + * @param string $key + * @param string $value * @throws AppwriteException * @return array */ - public function updateVariable(string$functionId, string$variableId, string$key, string$value = null): array + public function updateVariable(string $functionId, string $variableId, string $key, string $value = null): array { $path = str_replace(['{functionId}', '{variableId}'], [$functionId, $variableId], '/functions/{functionId}/variables/{variableId}'); @@ -765,13 +765,13 @@ public function updateVariable(string$functionId, string$variableId, string$key, * * Delete a variable by its unique ID. * - * @param string$functionId - * @param string$variableId + * @param string $functionId + * @param string $variableId * @throws AppwriteException * @return string */ - public function deleteVariable(string$functionId, string$variableId): string + public function deleteVariable(string $functionId, string $variableId): string { $path = str_replace(['{functionId}', '{variableId}'], [$functionId, $variableId], '/functions/{functionId}/variables/{variableId}'); diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index bc6b15a..b20087e 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -21,12 +21,12 @@ public function __construct(Client $client) * filter your results. * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listBuckets(array $queries = null, string$search = null): array + public function listBuckets(array $queries = null, string $search = null): array { $path = str_replace([], [], '/storage/buckets'); @@ -50,21 +50,21 @@ public function listBuckets(array $queries = null, string$search = null): array * * Create a new storage bucket. * - * @param string$bucketId - * @param string$name - * @param bool $fileSecurity + * @param string $bucketId + * @param string $name * @param array $permissions + * @param bool $fileSecurity * @param bool $enabled * @param int $maximumFileSize * @param array $allowedFileExtensions - * @param string$compression + * @param string $compression * @param bool $encryption * @param bool $antivirus * @throws AppwriteException * @return array */ - public function createBucket(string$bucketId, string$name, bool $fileSecurity, array $permissions = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string$compression = null, bool $encryption = null, bool $antivirus = null): array + public function createBucket(string $bucketId, string $name, array $permissions = null, bool $fileSecurity = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string $compression = null, bool $encryption = null, bool $antivirus = null): array { $path = str_replace([], [], '/storage/buckets'); @@ -75,9 +75,6 @@ public function createBucket(string$bucketId, string$name, bool $fileSecurity, a if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($fileSecurity)) { - throw new AppwriteException('Missing required parameter: "fileSecurity"'); - } if (!is_null($bucketId)) { $params['bucketId'] = $bucketId; } @@ -130,12 +127,12 @@ public function createBucket(string$bucketId, string$name, bool $fileSecurity, a * Get a storage bucket by its unique ID. This endpoint response returns a * JSON object with the storage bucket metadata. * - * @param string$bucketId + * @param string $bucketId * @throws AppwriteException * @return array */ - public function getBucket(string$bucketId): array + public function getBucket(string $bucketId): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -154,21 +151,21 @@ public function getBucket(string$bucketId): array * * Update a storage bucket by its unique ID. * - * @param string$bucketId - * @param string$name - * @param bool $fileSecurity + * @param string $bucketId + * @param string $name * @param array $permissions + * @param bool $fileSecurity * @param bool $enabled * @param int $maximumFileSize * @param array $allowedFileExtensions - * @param string$compression + * @param string $compression * @param bool $encryption * @param bool $antivirus * @throws AppwriteException * @return array */ - public function updateBucket(string$bucketId, string$name, bool $fileSecurity, array $permissions = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string$compression = null, bool $encryption = null, bool $antivirus = null): array + public function updateBucket(string $bucketId, string $name, array $permissions = null, bool $fileSecurity = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string $compression = null, bool $encryption = null, bool $antivirus = null): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -179,9 +176,6 @@ public function updateBucket(string$bucketId, string$name, bool $fileSecurity, a if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($fileSecurity)) { - throw new AppwriteException('Missing required parameter: "fileSecurity"'); - } if (!is_null($name)) { $params['name'] = $name; } @@ -229,12 +223,12 @@ public function updateBucket(string$bucketId, string$name, bool $fileSecurity, a * * Delete a storage bucket by its unique ID. * - * @param string$bucketId + * @param string $bucketId * @throws AppwriteException * @return string */ - public function deleteBucket(string$bucketId): string + public function deleteBucket(string $bucketId): string { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -255,14 +249,14 @@ public function deleteBucket(string$bucketId): string * 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). * - * @param string$bucketId + * @param string $bucketId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listFiles(string$bucketId, array $queries = null, string$search = null): array + public function listFiles(string $bucketId, array $queries = null, string $search = null): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}/files'); @@ -306,15 +300,15 @@ public function listFiles(string$bucketId, array $queries = null, string$search * chunking logic will be managed by the SDK internally. * * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @param InputFile $file * @param array $permissions * @throws AppwriteException * @return array */ - public function createFile(string$bucketId, string$fileId, InputFile $file, array $permissions = null, callable $onProgress = null): array + public function createFile(string $bucketId, string $fileId, InputFile $file, array $permissions = null, callable $onProgress = null): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}/files'); @@ -428,13 +422,13 @@ public function createFile(string$bucketId, string$fileId, InputFile $file, arra * Get a file by its unique ID. This endpoint response returns a JSON object * with the file metadata. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @throws AppwriteException * @return array */ - public function getFile(string$bucketId, string$fileId): array + public function getFile(string $bucketId, string $fileId): array { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}'); @@ -457,14 +451,14 @@ public function getFile(string$bucketId, string$fileId): array * Update a file by its unique ID. Only users with write permissions have * access to update this resource. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @param array $permissions * @throws AppwriteException * @return array */ - public function updateFile(string$bucketId, string$fileId, array $permissions = null): array + public function updateFile(string $bucketId, string $fileId, array $permissions = null): array { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}'); @@ -491,13 +485,13 @@ public function updateFile(string$bucketId, string$fileId, array $permissions = * Delete a file by its unique ID. Only users with write permissions have * access to delete this resource. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @throws AppwriteException * @return string */ - public function deleteFile(string$bucketId, string$fileId): string + public function deleteFile(string $bucketId, string $fileId): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}'); @@ -521,13 +515,13 @@ public function deleteFile(string$bucketId, string$fileId): string * 'Content-Disposition: attachment' header that tells the browser to start * downloading the file to user downloads directory. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @throws AppwriteException * @return string */ - public function getFileDownload(string$bucketId, string$fileId): string + public function getFileDownload(string $bucketId, string $fileId): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/download'); @@ -553,24 +547,24 @@ public function getFileDownload(string$bucketId, string$fileId): string * string arguments for cutting and resizing your preview image. Preview is * supported only for image files smaller than 10MB. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @param int $width * @param int $height - * @param string$gravity + * @param string $gravity * @param int $quality * @param int $borderWidth - * @param string$borderColor + * @param string $borderColor * @param int $borderRadius * @param int $opacity * @param int $rotation - * @param string$background - * @param string$output + * @param string $background + * @param string $output * @throws AppwriteException * @return string */ - public function getFilePreview(string$bucketId, string$fileId, int $width = null, int $height = null, string$gravity = null, int $quality = null, int $borderWidth = null, string$borderColor = null, int $borderRadius = null, int $opacity = null, int $rotation = null, string$background = null, string$output = null): string + public function getFilePreview(string $bucketId, string $fileId, int $width = null, int $height = null, string $gravity = null, int $quality = null, int $borderWidth = null, string $borderColor = null, int $borderRadius = null, int $opacity = null, int $rotation = null, string $background = null, string $output = null): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/preview'); @@ -638,13 +632,13 @@ public function getFilePreview(string$bucketId, string$fileId, int $width = null * download method but returns with no 'Content-Disposition: attachment' * header. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @throws AppwriteException * @return string */ - public function getFileView(string$bucketId, string$fileId): string + public function getFileView(string $bucketId, string $fileId): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/view'); diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index 923a47c..9459787 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -24,12 +24,12 @@ public function __construct(Client $client) * project. [Learn more about different API modes](/docs/admin). * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function list(array $queries = null, string$search = null): array + public function list(array $queries = null, string $search = null): array { $path = str_replace([], [], '/teams'); @@ -55,14 +55,14 @@ public function list(array $queries = null, string$search = null): array * 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. * - * @param string$teamId - * @param string$name + * @param string $teamId + * @param string $name * @param array $roles * @throws AppwriteException * @return array */ - public function create(string$teamId, string$name, array $roles = null): array + public function create(string $teamId, string $name, array $roles = null): array { $path = str_replace([], [], '/teams'); @@ -96,12 +96,12 @@ public function create(string$teamId, string$name, array $roles = null): array * * Get a team by its ID. All team members have read access for this resource. * - * @param string$teamId + * @param string $teamId * @throws AppwriteException * @return array */ - public function get(string$teamId): array + public function get(string $teamId): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); @@ -121,13 +121,13 @@ public function get(string$teamId): array * Update a team using its ID. Only members with the owner role can update the * team. * - * @param string$teamId - * @param string$name + * @param string $teamId + * @param string $name * @throws AppwriteException * @return array */ - public function update(string$teamId, string$name): array + public function update(string $teamId, string $name): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); @@ -154,12 +154,12 @@ public function update(string$teamId, string$name): array * Delete a team using its ID. Only team members with the owner role can * delete the team. * - * @param string$teamId + * @param string $teamId * @throws AppwriteException * @return string */ - public function delete(string$teamId): string + public function delete(string $teamId): string { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); @@ -179,14 +179,14 @@ public function delete(string$teamId): string * Use this endpoint to list a team's members using the team's ID. All team * members have read access to this endpoint. * - * @param string$teamId + * @param string $teamId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function getMemberships(string$teamId, array $queries = null, string$search = null): array + public function getMemberships(string $teamId, array $queries = null, string $search = null): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); @@ -227,16 +227,16 @@ public function getMemberships(string$teamId, array $queries = null, string$sear * the only valid redirect URL's are the once from domains you have set when * adding your platforms in the console interface. * - * @param string$teamId - * @param string$email + * @param string $teamId + * @param string $email * @param array $roles - * @param string$url - * @param string$name + * @param string $url + * @param string $name * @throws AppwriteException * @return array */ - public function createMembership(string$teamId, string$email, array $roles, string$url, string$name = null): array + public function createMembership(string $teamId, string $email, array $roles, string $url, string $name = null): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); @@ -281,13 +281,13 @@ public function createMembership(string$teamId, string$email, array $roles, stri * Get a team member by the membership unique id. All team members have read * access for this resource. * - * @param string$teamId - * @param string$membershipId + * @param string $teamId + * @param string $membershipId * @throws AppwriteException * @return array */ - public function getMembership(string$teamId, string$membershipId): array + public function getMembership(string $teamId, string $membershipId): array { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); @@ -311,14 +311,14 @@ public function getMembership(string$teamId, string$membershipId): array * have access to this endpoint. Learn more about [roles and * permissions](/docs/permissions). * - * @param string$teamId - * @param string$membershipId + * @param string $teamId + * @param string $membershipId * @param array $roles * @throws AppwriteException * @return array */ - public function updateMembershipRoles(string$teamId, string$membershipId, array $roles): array + public function updateMembershipRoles(string $teamId, string $membershipId, array $roles): array { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); @@ -349,13 +349,13 @@ public function updateMembershipRoles(string$teamId, string$membershipId, array * the membership of any other team member. You can also use this endpoint to * delete a user membership even if it is not accepted. * - * @param string$teamId - * @param string$membershipId + * @param string $teamId + * @param string $membershipId * @throws AppwriteException * @return string */ - public function deleteMembership(string$teamId, string$membershipId): string + public function deleteMembership(string $teamId, string $membershipId): string { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); @@ -383,15 +383,15 @@ public function deleteMembership(string$teamId, string$membershipId): string * created. * * - * @param string$teamId - * @param string$membershipId - * @param string$userId - * @param string$secret + * @param string $teamId + * @param string $membershipId + * @param string $userId + * @param string $secret * @throws AppwriteException * @return array */ - public function updateMembershipStatus(string$teamId, string$membershipId, string$userId, string$secret): array + public function updateMembershipStatus(string $teamId, string $membershipId, string $userId, string $secret): array { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}/status'); diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index acbe14b..94219e0 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -21,12 +21,12 @@ public function __construct(Client $client) * filter your results. * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function list(array $queries = null, string$search = null): array + public function list(array $queries = null, string $search = null): array { $path = str_replace([], [], '/users'); @@ -50,16 +50,16 @@ public function list(array $queries = null, string$search = null): array * * Create a new user. * - * @param string$userId - * @param string$email - * @param string$phone - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $phone + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function create(string$userId, string$email = null, string$phone = null, string$password = null, string$name = null): array + public function create(string $userId, string $email = null, string $phone = null, string $password = null, string $name = null): array { $path = str_replace([], [], '/users'); @@ -101,15 +101,15 @@ public function create(string$userId, string$email = null, string$phone = null, * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function createArgon2User(string$userId, string$email, string$password, string$name = null): array + public function createArgon2User(string $userId, string $email, string $password, string $name = null): array { $path = str_replace([], [], '/users/argon2'); @@ -153,15 +153,15 @@ public function createArgon2User(string$userId, string$email, string$password, s * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function createBcryptUser(string$userId, string$email, string$password, string$name = null): array + public function createBcryptUser(string $userId, string $email, string $password, string $name = null): array { $path = str_replace([], [], '/users/bcrypt'); @@ -205,15 +205,15 @@ public function createBcryptUser(string$userId, string$email, string$password, s * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function createMD5User(string$userId, string$email, string$password, string$name = null): array + public function createMD5User(string $userId, string $email, string $password, string $name = null): array { $path = str_replace([], [], '/users/md5'); @@ -257,15 +257,15 @@ public function createMD5User(string$userId, string$email, string$password, stri * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function createPHPassUser(string$userId, string$email, string$password, string$name = null): array + public function createPHPassUser(string $userId, string $email, string $password, string $name = null): array { $path = str_replace([], [], '/users/phpass'); @@ -309,20 +309,20 @@ public function createPHPassUser(string$userId, string$email, string$password, s * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$passwordSalt + * @param string $userId + * @param string $email + * @param string $password + * @param string $passwordSalt * @param int $passwordCpu * @param int $passwordMemory * @param int $passwordParallel * @param int $passwordLength - * @param string$name + * @param string $name * @throws AppwriteException * @return array */ - public function createScryptUser(string$userId, string$email, string$password, string$passwordSalt, int $passwordCpu, int $passwordMemory, int $passwordParallel, int $passwordLength, string$name = null): array + public function createScryptUser(string $userId, string $email, string $password, string $passwordSalt, int $passwordCpu, int $passwordMemory, int $passwordParallel, int $passwordLength, string $name = null): array { $path = str_replace([], [], '/users/scrypt'); @@ -401,18 +401,18 @@ public function createScryptUser(string$userId, string$email, string$password, s * algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint * to create users with a plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$passwordSalt - * @param string$passwordSaltSeparator - * @param string$passwordSignerKey - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $passwordSalt + * @param string $passwordSaltSeparator + * @param string $passwordSignerKey + * @param string $name * @throws AppwriteException * @return array */ - public function createScryptModifiedUser(string$userId, string$email, string$password, string$passwordSalt, string$passwordSaltSeparator, string$passwordSignerKey, string$name = null): array + public function createScryptModifiedUser(string $userId, string $email, string $password, string $passwordSalt, string $passwordSaltSeparator, string $passwordSignerKey, string $name = null): array { $path = str_replace([], [], '/users/scrypt-modified'); @@ -477,16 +477,16 @@ public function createScryptModifiedUser(string$userId, string$email, string$pas * the [POST /users](/docs/server/users#usersCreate) endpoint to create users * with a plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$passwordVersion - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $passwordVersion + * @param string $name * @throws AppwriteException * @return array */ - public function createSHAUser(string$userId, string$email, string$password, string$passwordVersion = null, string$name = null): array + public function createSHAUser(string $userId, string $email, string $password, string $passwordVersion = null, string $name = null): array { $path = str_replace([], [], '/users/sha'); @@ -531,12 +531,12 @@ public function createSHAUser(string$userId, string$email, string$password, stri * * Get a user by its unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return array */ - public function get(string$userId): array + public function get(string $userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}'); @@ -559,12 +559,12 @@ public function get(string$userId): array * ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) * endpoint instead. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return string */ - public function delete(string$userId): string + public function delete(string $userId): string { $path = str_replace(['{userId}'], [$userId], '/users/{userId}'); @@ -583,13 +583,13 @@ public function delete(string$userId): string * * Update the user email by its unique ID. * - * @param string$userId - * @param string$email + * @param string $userId + * @param string $email * @throws AppwriteException * @return array */ - public function updateEmail(string$userId, string$email): array + public function updateEmail(string $userId, string $email): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/email'); @@ -615,13 +615,13 @@ public function updateEmail(string$userId, string$email): array * * Get the user activity logs list by its unique ID. * - * @param string$userId + * @param string $userId * @param array $queries * @throws AppwriteException * @return array */ - public function getLogs(string$userId, array $queries = null): array + public function getLogs(string $userId, array $queries = null): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/logs'); @@ -644,12 +644,12 @@ public function getLogs(string$userId, array $queries = null): array * * Get the user membership list by its unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return array */ - public function getMemberships(string$userId): array + public function getMemberships(string $userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/memberships'); @@ -668,13 +668,13 @@ public function getMemberships(string$userId): array * * Update the user name by its unique ID. * - * @param string$userId - * @param string$name + * @param string $userId + * @param string $name * @throws AppwriteException * @return array */ - public function updateName(string$userId, string$name): array + public function updateName(string $userId, string $name): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/name'); @@ -700,13 +700,13 @@ public function updateName(string$userId, string$name): array * * Update the user password by its unique ID. * - * @param string$userId - * @param string$password + * @param string $userId + * @param string $password * @throws AppwriteException * @return array */ - public function updatePassword(string$userId, string$password): array + public function updatePassword(string $userId, string $password): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/password'); @@ -732,13 +732,13 @@ public function updatePassword(string$userId, string$password): array * * Update the user phone by its unique ID. * - * @param string$userId - * @param string$number + * @param string $userId + * @param string $number * @throws AppwriteException * @return array */ - public function updatePhone(string$userId, string$number): array + public function updatePhone(string $userId, string $number): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/phone'); @@ -764,12 +764,12 @@ public function updatePhone(string$userId, string$number): array * * Get the user preferences by its unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return array */ - public function getPrefs(string$userId): array + public function getPrefs(string $userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); @@ -790,13 +790,13 @@ public function getPrefs(string$userId): array * as is, and replaces any previous value. The maximum allowed prefs size is * 64kB and throws error if exceeded. * - * @param string$userId + * @param string $userId * @param array $prefs * @throws AppwriteException * @return array */ - public function updatePrefs(string$userId, array $prefs): array + public function updatePrefs(string $userId, array $prefs): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); @@ -822,12 +822,12 @@ public function updatePrefs(string$userId, array $prefs): array * * Get the user sessions list by its unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return array */ - public function getSessions(string$userId): array + public function getSessions(string $userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); @@ -846,12 +846,12 @@ public function getSessions(string$userId): array * * Delete all user's sessions by using the user's unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return string */ - public function deleteSessions(string$userId): string + public function deleteSessions(string $userId): string { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); @@ -870,13 +870,13 @@ public function deleteSessions(string$userId): string * * Delete a user sessions by its unique ID. * - * @param string$userId - * @param string$sessionId + * @param string $userId + * @param string $sessionId * @throws AppwriteException * @return string */ - public function deleteSession(string$userId, string$sessionId): string + public function deleteSession(string $userId, string $sessionId): string { $path = str_replace(['{userId}', '{sessionId}'], [$userId, $sessionId], '/users/{userId}/sessions/{sessionId}'); @@ -899,13 +899,13 @@ public function deleteSession(string$userId, string$sessionId): string * Update the user status by its unique ID. Use this endpoint as an * alternative to deleting a user if you want to keep user's ID reserved. * - * @param string$userId + * @param string $userId * @param bool $status * @throws AppwriteException * @return array */ - public function updateStatus(string$userId, bool $status): array + public function updateStatus(string $userId, bool $status): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/status'); @@ -931,13 +931,13 @@ public function updateStatus(string$userId, bool $status): array * * Update the user email verification status by its unique ID. * - * @param string$userId + * @param string $userId * @param bool $emailVerification * @throws AppwriteException * @return array */ - public function updateEmailVerification(string$userId, bool $emailVerification): array + public function updateEmailVerification(string $userId, bool $emailVerification): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/verification'); @@ -963,13 +963,13 @@ public function updateEmailVerification(string$userId, bool $emailVerification): * * Update the user phone verification status by its unique ID. * - * @param string$userId + * @param string $userId * @param bool $phoneVerification * @throws AppwriteException * @return array */ - public function updatePhoneVerification(string$userId, bool $phoneVerification): array + public function updatePhoneVerification(string $userId, bool $phoneVerification): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/verification/phone'); From 717c3adde3636dc8fd2bf371081fe9313d307277 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 5 Sep 2022 02:01:20 +0400 Subject: [PATCH 3/4] feat: update for 1.0.0-RC1 --- docs/databases.md | 2 +- docs/examples/databases/create-collection.md | 2 +- docs/examples/databases/update-collection.md | 2 +- docs/examples/storage/create-bucket.md | 2 +- docs/examples/storage/update-bucket.md | 2 +- src/Appwrite/Services/Account.php | 66 ++--- src/Appwrite/Services/Avatars.php | 32 +-- src/Appwrite/Services/Databases.php | 245 +++++++++---------- src/Appwrite/Services/Functions.php | 122 ++++----- src/Appwrite/Services/Storage.php | 94 ++++--- src/Appwrite/Services/Teams.php | 68 ++--- src/Appwrite/Services/Users.php | 170 ++++++------- 12 files changed, 396 insertions(+), 411 deletions(-) diff --git a/docs/databases.md b/docs/databases.md index 6d02b7b..2cd7b23 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -204,7 +204,7 @@ POST https://HOSTNAME/v1/databases/{databaseId}/collections/{collectionId}/attri | collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| default | string | Default value for the attribute in ISO 8601 format. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | ## Create Email Attribute diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index bde7c9e..a7d98c0 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -13,4 +13,4 @@ $client $databases = new Databases($client); -$result = $databases->createCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]', ["read("any")"], false); \ No newline at end of file +$result = $databases->createCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]'); \ No newline at end of file diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 1ce3ff3..df03c9b 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -13,4 +13,4 @@ $client $databases = new Databases($client); -$result = $databases->updateCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]', false); \ No newline at end of file +$result = $databases->updateCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]'); \ No newline at end of file diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index 27d7a3d..b1aedf5 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -13,4 +13,4 @@ $client $storage = new Storage($client); -$result = $storage->createBucket('[BUCKET_ID]', '[NAME]', false); \ No newline at end of file +$result = $storage->createBucket('[BUCKET_ID]', '[NAME]'); \ No newline at end of file diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 07c6f83..667833b 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -13,4 +13,4 @@ $client $storage = new Storage($client); -$result = $storage->updateBucket('[BUCKET_ID]', '[NAME]', false); \ No newline at end of file +$result = $storage->updateBucket('[BUCKET_ID]', '[NAME]'); \ No newline at end of file diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 9971d50..81e0514 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -46,13 +46,13 @@ public function get(): array * one, by passing an email address and a new password. * * - * @param string$email - * @param string$password + * @param string $email + * @param string $password * @throws AppwriteException * @return array */ - public function updateEmail(string$email, string$password): array + public function updateEmail(string $email, string $password): array { $path = str_replace([], [], '/account/email'); @@ -108,12 +108,12 @@ public function getLogs(array $queries = null): array * * Update currently logged in user account name. * - * @param string$name + * @param string $name * @throws AppwriteException * @return array */ - public function updateName(string$name): array + public function updateName(string $name): array { $path = str_replace([], [], '/account/name'); @@ -138,13 +138,13 @@ public function updateName(string$name): array * to pass in the new password, and the old password. For users created with * OAuth, Team Invites and Magic URL, oldPassword is optional. * - * @param string$password - * @param string$oldPassword + * @param string $password + * @param string $oldPassword * @throws AppwriteException * @return array */ - public function updatePassword(string$password, string$oldPassword = null): array + public function updatePassword(string $password, string $oldPassword = null): array { $path = str_replace([], [], '/account/password'); @@ -175,13 +175,13 @@ public function updatePassword(string$password, string$oldPassword = null): arra * /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) * endpoint to send a confirmation SMS. * - * @param string$phone - * @param string$password + * @param string $phone + * @param string $password * @throws AppwriteException * @return array */ - public function updatePhone(string$phone, string$password): array + public function updatePhone(string $phone, string $password): array { $path = str_replace([], [], '/account/phone'); @@ -268,13 +268,13 @@ public function updatePrefs(array $prefs): array * complete the process. The verification link sent to the user's email * address is valid for 1 hour. * - * @param string$email - * @param string$url + * @param string $email + * @param string $url * @throws AppwriteException * @return array */ - public function createRecovery(string$email, string$url): array + public function createRecovery(string $email, string $url): array { $path = str_replace([], [], '/account/recovery'); @@ -312,15 +312,15 @@ public function createRecovery(string$email, string$url): array * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param string$userId - * @param string$secret - * @param string$password - * @param string$passwordAgain + * @param string $userId + * @param string $secret + * @param string $password + * @param string $passwordAgain * @throws AppwriteException * @return array */ - public function updateRecovery(string$userId, string$secret, string$password, string$passwordAgain): array + public function updateRecovery(string $userId, string $secret, string $password, string $passwordAgain): array { $path = str_replace([], [], '/account/recovery'); @@ -407,12 +407,12 @@ public function deleteSessions(): string * Use this endpoint to get a logged in user's session using a Session ID. * Inputting 'current' will return the current session being used. * - * @param string$sessionId + * @param string $sessionId * @throws AppwriteException * @return array */ - public function getSession(string$sessionId): array + public function getSession(string $sessionId): array { $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); @@ -433,12 +433,12 @@ public function getSession(string$sessionId): array * If session was created using an OAuth provider, this route can be used to * "refresh" the access token. * - * @param string$sessionId + * @param string $sessionId * @throws AppwriteException * @return array */ - public function updateSession(string$sessionId): array + public function updateSession(string $sessionId): array { $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); @@ -460,12 +460,12 @@ public function updateSession(string$sessionId): array * Session ID argument, only the unique session ID provided is deleted. * * - * @param string$sessionId + * @param string $sessionId * @throws AppwriteException * @return string */ - public function deleteSession(string$sessionId): string + public function deleteSession(string $sessionId): string { $path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}'); @@ -520,12 +520,12 @@ public function updateStatus(): array * adding your platforms in the console interface. * * - * @param string$url + * @param string $url * @throws AppwriteException * @return array */ - public function createVerification(string$url): array + public function createVerification(string $url): array { $path = str_replace([], [], '/account/verification'); @@ -551,13 +551,13 @@ public function createVerification(string$url): array * to verify the user email ownership. If confirmed this route will return a * 200 status code. * - * @param string$userId - * @param string$secret + * @param string $userId + * @param string $secret * @throws AppwriteException * @return array */ - public function updateVerification(string$userId, string$secret): array + public function updateVerification(string $userId, string $secret): array { $path = str_replace([], [], '/account/verification'); @@ -615,13 +615,13 @@ public function createPhoneVerification(): array * verify the user email ownership. If confirmed this route will return a 200 * status code. * - * @param string$userId - * @param string$secret + * @param string $userId + * @param string $secret * @throws AppwriteException * @return array */ - public function updatePhoneVerification(string$userId, string$secret): array + public function updatePhoneVerification(string $userId, string $secret): array { $path = str_replace([], [], '/account/verification/phone'); diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index 82af493..dfd4b29 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -27,7 +27,7 @@ public function __construct(Client $client) * image at source quality. If dimensions are not specified, the default size * of image returned is 100x100px. * - * @param string$code + * @param string $code * @param int $width * @param int $height * @param int $quality @@ -35,7 +35,7 @@ public function __construct(Client $client) * @return string */ - public function getBrowser(string$code, int $width = null, int $height = null, int $quality = null): string + public function getBrowser(string $code, int $width = null, int $height = null, int $quality = null): string { $path = str_replace(['{code}'], [$code], '/avatars/browsers/{code}'); @@ -74,7 +74,7 @@ public function getBrowser(string$code, int $width = null, int $height = null, i * of image returned is 100x100px. * * - * @param string$code + * @param string $code * @param int $width * @param int $height * @param int $quality @@ -82,7 +82,7 @@ public function getBrowser(string$code, int $width = null, int $height = null, i * @return string */ - public function getCreditCard(string$code, int $width = null, int $height = null, int $quality = null): string + public function getCreditCard(string $code, int $width = null, int $height = null, int $quality = null): string { $path = str_replace(['{code}'], [$code], '/avatars/credit-cards/{code}'); @@ -115,12 +115,12 @@ public function getCreditCard(string$code, int $width = null, int $height = null * website URL. * * - * @param string$url + * @param string $url * @throws AppwriteException * @return string */ - public function getFavicon(string$url): string + public function getFavicon(string $url): string { $path = str_replace([], [], '/avatars/favicon'); @@ -152,7 +152,7 @@ public function getFavicon(string$url): string * of image returned is 100x100px. * * - * @param string$code + * @param string $code * @param int $width * @param int $height * @param int $quality @@ -160,7 +160,7 @@ public function getFavicon(string$url): string * @return string */ - public function getFlag(string$code, int $width = null, int $height = null, int $quality = null): string + public function getFlag(string $code, int $width = null, int $height = null, int $quality = null): string { $path = str_replace(['{code}'], [$code], '/avatars/flags/{code}'); @@ -200,14 +200,14 @@ public function getFlag(string$code, int $width = null, int $height = null, int * of image returned is 400x400px. * * - * @param string$url + * @param string $url * @param int $width * @param int $height * @throws AppwriteException * @return string */ - public function getImage(string$url, int $width = null, int $height = null): string + public function getImage(string $url, int $width = null, int $height = null): string { $path = str_replace([], [], '/avatars/image'); @@ -253,16 +253,16 @@ public function getImage(string$url, int $width = null, int $height = null): str * of image returned is 100x100px. * * - * @param string$name + * @param string $name * @param int $width * @param int $height - * @param string$color - * @param string$background + * @param string $color + * @param string $background * @throws AppwriteException * @return string */ - public function getInitials(string$name = null, int $width = null, int $height = null, string$color = null, string$background = null): string + public function getInitials(string $name = null, int $width = null, int $height = null, string $color = null, string $background = null): string { $path = str_replace([], [], '/avatars/initials'); @@ -300,7 +300,7 @@ public function getInitials(string$name = null, int $width = null, int $height = * parameters to change the size and style of the resulting image. * * - * @param string$text + * @param string $text * @param int $size * @param int $margin * @param bool $download @@ -308,7 +308,7 @@ public function getInitials(string$name = null, int $width = null, int $height = * @return string */ - public function getQR(string$text, int $size = null, int $margin = null, bool $download = null): string + public function getQR(string $text, int $size = null, int $margin = null, bool $download = null): string { $path = str_replace([], [], '/avatars/qr'); diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 029cbad..5bbbc74 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -21,12 +21,12 @@ public function __construct(Client $client) * the search parameter to filter your results. * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function list(array $queries = null, string$search = null): array + public function list(array $queries = null, string $search = null): array { $path = str_replace([], [], '/databases'); @@ -51,13 +51,13 @@ public function list(array $queries = null, string$search = null): array * Create a new Database. * * - * @param string$databaseId - * @param string$name + * @param string $databaseId + * @param string $name * @throws AppwriteException * @return array */ - public function create(string$databaseId, string$name): array + public function create(string $databaseId, string $name): array { $path = str_replace([], [], '/databases'); @@ -88,12 +88,12 @@ public function create(string$databaseId, string$name): array * Get a database by its unique ID. This endpoint response returns a JSON * object with the database metadata. * - * @param string$databaseId + * @param string $databaseId * @throws AppwriteException * @return array */ - public function get(string$databaseId): array + public function get(string $databaseId): array { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}'); @@ -112,13 +112,13 @@ public function get(string$databaseId): array * * Update a database by its unique ID. * - * @param string$databaseId - * @param string$name + * @param string $databaseId + * @param string $name * @throws AppwriteException * @return array */ - public function update(string$databaseId, string$name): array + public function update(string $databaseId, string $name): array { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}'); @@ -145,12 +145,12 @@ public function update(string$databaseId, string$name): array * Delete a database by its unique ID. Only API keys with with databases.write * scope can delete a database. * - * @param string$databaseId + * @param string $databaseId * @throws AppwriteException * @return string */ - public function delete(string$databaseId): string + public function delete(string $databaseId): string { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}'); @@ -170,14 +170,14 @@ public function delete(string$databaseId): string * Get a list of all collections that belong to the provided databaseId. You * can use the search parameter to filter your results. * - * @param string$databaseId + * @param string $databaseId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listCollections(string$databaseId, array $queries = null, string$search = null): array + public function listCollections(string $databaseId, array $queries = null, string $search = null): array { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}/collections'); @@ -207,16 +207,16 @@ public function listCollections(string$databaseId, array $queries = null, string * integration](/docs/server/databases#databasesCreateCollection) API or * directly from your database console. * - * @param string$databaseId - * @param string$collectionId - * @param string$name + * @param string $databaseId + * @param string $collectionId + * @param string $name * @param array $permissions * @param bool $documentSecurity * @throws AppwriteException * @return array */ - public function createCollection(string$databaseId, string$collectionId, string$name, array $permissions, bool $documentSecurity): array + public function createCollection(string $databaseId, string $collectionId, string $name, array $permissions = null, bool $documentSecurity = null): array { $path = str_replace(['{databaseId}'], [$databaseId], '/databases/{databaseId}/collections'); @@ -230,12 +230,6 @@ public function createCollection(string$databaseId, string$collectionId, string$ if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($permissions)) { - throw new AppwriteException('Missing required parameter: "permissions"'); - } - if (!isset($documentSecurity)) { - throw new AppwriteException('Missing required parameter: "documentSecurity"'); - } if (!is_null($collectionId)) { $params['collectionId'] = $collectionId; } @@ -264,13 +258,13 @@ public function createCollection(string$databaseId, string$collectionId, string$ * Get a collection by its unique ID. This endpoint response returns a JSON * object with the collection metadata. * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @throws AppwriteException * @return array */ - public function getCollection(string$databaseId, string$collectionId): array + public function getCollection(string $databaseId, string $collectionId): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); @@ -292,17 +286,17 @@ public function getCollection(string$databaseId, string$collectionId): array * * Update a collection by its unique ID. * - * @param string$databaseId - * @param string$collectionId - * @param string$name - * @param bool $documentSecurity + * @param string $databaseId + * @param string $collectionId + * @param string $name * @param array $permissions + * @param bool $documentSecurity * @param bool $enabled * @throws AppwriteException * @return array */ - public function updateCollection(string$databaseId, string$collectionId, string$name, bool $documentSecurity, array $permissions = null, bool $enabled = null): array + public function updateCollection(string $databaseId, string $collectionId, string $name, array $permissions = null, bool $documentSecurity = null, bool $enabled = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); @@ -316,9 +310,6 @@ public function updateCollection(string$databaseId, string$collectionId, string$ if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($documentSecurity)) { - throw new AppwriteException('Missing required parameter: "documentSecurity"'); - } if (!is_null($name)) { $params['name'] = $name; } @@ -347,13 +338,13 @@ public function updateCollection(string$databaseId, string$collectionId, string$ * Delete a collection by its unique ID. Only users with write permissions * have access to delete this resource. * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @throws AppwriteException * @return string */ - public function deleteCollection(string$databaseId, string$collectionId): string + public function deleteCollection(string $databaseId, string $collectionId): string { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}'); @@ -373,13 +364,13 @@ public function deleteCollection(string$databaseId, string$collectionId): string /** * List Attributes * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @throws AppwriteException * @return array */ - public function listAttributes(string$databaseId, string$collectionId): array + public function listAttributes(string $databaseId, string $collectionId): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes'); @@ -402,9 +393,9 @@ public function listAttributes(string$databaseId, string$collectionId): array * Create a boolean attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required * @param bool $xdefault * @param bool $xarray @@ -412,7 +403,7 @@ public function listAttributes(string$databaseId, string$collectionId): array * @return array */ - public function createBooleanAttribute(string$databaseId, string$collectionId, string$key, bool $required, bool $xdefault = null, bool $xarray = null): array + public function createBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, bool $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'); @@ -454,17 +445,17 @@ public function createBooleanAttribute(string$databaseId, string$collectionId, s /** * Create DateTime Attribute * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createDatetimeAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array + public function createDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'); @@ -509,17 +500,17 @@ public function createDatetimeAttribute(string$databaseId, string$collectionId, * Create an email attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createEmailAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array + public function createEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/email'); @@ -561,18 +552,18 @@ public function createEmailAttribute(string$databaseId, string$collectionId, str /** * Create Enum Attribute * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param array $elements * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createEnumAttribute(string$databaseId, string$collectionId, string$key, array $elements, bool $required, string$xdefault = null, bool $xarray = null): array + public function createEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/enum'); @@ -625,9 +616,9 @@ public function createEnumAttribute(string$databaseId, string$collectionId, stri * provided. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required * @param int $min * @param int $max @@ -637,7 +628,7 @@ public function createEnumAttribute(string$databaseId, string$collectionId, stri * @return array */ - public function createFloatAttribute(string$databaseId, string$collectionId, string$key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array + public function createFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/float'); @@ -691,9 +682,9 @@ public function createFloatAttribute(string$databaseId, string$collectionId, str * provided. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required * @param int $min * @param int $max @@ -703,7 +694,7 @@ public function createFloatAttribute(string$databaseId, string$collectionId, str * @return array */ - public function createIntegerAttribute(string$databaseId, string$collectionId, string$key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array + public function createIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, int $min = null, int $max = null, int $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/integer'); @@ -756,17 +747,17 @@ public function createIntegerAttribute(string$databaseId, string$collectionId, s * Create IP address attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createIpAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array + public function createIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/ip'); @@ -811,18 +802,18 @@ public function createIpAttribute(string$databaseId, string$collectionId, string * Create a string attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param int $size * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createStringAttribute(string$databaseId, string$collectionId, string$key, int $size, bool $required, string$xdefault = null, bool $xarray = null): array + public function createStringAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/string'); @@ -874,17 +865,17 @@ public function createStringAttribute(string$databaseId, string$collectionId, st * Create a URL attribute. * * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @param bool $required - * @param string$xdefault + * @param string $xdefault * @param bool $xarray * @throws AppwriteException * @return array */ - public function createUrlAttribute(string$databaseId, string$collectionId, string$key, bool $required, string$xdefault = null, bool $xarray = null): array + public function createUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, string $xdefault = null, bool $xarray = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/attributes/url'); @@ -926,14 +917,14 @@ public function createUrlAttribute(string$databaseId, string$collectionId, strin /** * Get Attribute * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @throws AppwriteException * @return array */ - public function getAttribute(string$databaseId, string$collectionId, string$key): array + public function getAttribute(string $databaseId, string $collectionId, string $key): array { $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'); @@ -956,14 +947,14 @@ public function getAttribute(string$databaseId, string$collectionId, string$key) /** * Delete Attribute * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @throws AppwriteException * @return string */ - public function deleteAttribute(string$databaseId, string$collectionId, string$key): string + public function deleteAttribute(string $databaseId, string $collectionId, string $key): string { $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'); @@ -991,14 +982,14 @@ public function deleteAttribute(string$databaseId, string$collectionId, string$k * return a list of all of documents belonging to the provided collectionId. * [Learn more about different API modes](/docs/admin). * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @param array $queries * @throws AppwriteException * @return array */ - public function listDocuments(string$databaseId, string$collectionId, array $queries = null): array + public function listDocuments(string $databaseId, string $collectionId, array $queries = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/documents'); @@ -1027,16 +1018,16 @@ public function listDocuments(string$databaseId, string$collectionId, array $que * integration](/docs/server/databases#databasesCreateCollection) API or * directly from your database console. * - * @param string$databaseId - * @param string$collectionId - * @param string$documentId + * @param string $databaseId + * @param string $collectionId + * @param string $documentId * @param array $data * @param array $permissions * @throws AppwriteException * @return array */ - public function createDocument(string$databaseId, string$collectionId, string$documentId, array $data, array $permissions = null): array + public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, array $permissions = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/documents'); @@ -1077,14 +1068,14 @@ public function createDocument(string$databaseId, string$collectionId, string$do * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * - * @param string$databaseId - * @param string$collectionId - * @param string$documentId + * @param string $databaseId + * @param string $collectionId + * @param string $documentId * @throws AppwriteException * @return array */ - public function getDocument(string$databaseId, string$collectionId, string$documentId): array + public function getDocument(string $databaseId, string $collectionId, string $documentId): array { $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); @@ -1110,16 +1101,16 @@ public function getDocument(string$databaseId, string$collectionId, string$docum * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. * - * @param string$databaseId - * @param string$collectionId - * @param string$documentId + * @param string $databaseId + * @param string $collectionId + * @param string $documentId * @param array $data * @param array $permissions * @throws AppwriteException * @return array */ - public function updateDocument(string$databaseId, string$collectionId, string$documentId, array $data = null, array $permissions = null): array + public function updateDocument(string $databaseId, string $collectionId, string $documentId, array $data = null, array $permissions = null): array { $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); @@ -1152,14 +1143,14 @@ public function updateDocument(string$databaseId, string$collectionId, string$do * * Delete a document by its unique ID. * - * @param string$databaseId - * @param string$collectionId - * @param string$documentId + * @param string $databaseId + * @param string $collectionId + * @param string $documentId * @throws AppwriteException * @return string */ - public function deleteDocument(string$databaseId, string$collectionId, string$documentId): string + public function deleteDocument(string $databaseId, string $collectionId, string $documentId): string { $path = str_replace(['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'); @@ -1182,13 +1173,13 @@ public function deleteDocument(string$databaseId, string$collectionId, string$do /** * List Indexes * - * @param string$databaseId - * @param string$collectionId + * @param string $databaseId + * @param string $collectionId * @throws AppwriteException * @return array */ - public function listIndexes(string$databaseId, string$collectionId): array + public function listIndexes(string $databaseId, string $collectionId): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/indexes'); @@ -1208,17 +1199,17 @@ public function listIndexes(string$databaseId, string$collectionId): array /** * Create Index * - * @param string$databaseId - * @param string$collectionId - * @param string$key - * @param string$type + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param string $type * @param array $attributes * @param array $orders * @throws AppwriteException * @return array */ - public function createIndex(string$databaseId, string$collectionId, string$key, string$type, array $attributes, array $orders = null): array + public function createIndex(string $databaseId, string $collectionId, string $key, string $type, array $attributes, array $orders = null): array { $path = str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], '/databases/{databaseId}/collections/{collectionId}/indexes'); @@ -1263,14 +1254,14 @@ public function createIndex(string$databaseId, string$collectionId, string$key, /** * Get Index * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @throws AppwriteException * @return array */ - public function getIndex(string$databaseId, string$collectionId, string$key): array + public function getIndex(string $databaseId, string $collectionId, string $key): array { $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'); @@ -1293,14 +1284,14 @@ public function getIndex(string$databaseId, string$collectionId, string$key): ar /** * Delete Index * - * @param string$databaseId - * @param string$collectionId - * @param string$key + * @param string $databaseId + * @param string $collectionId + * @param string $key * @throws AppwriteException * @return string */ - public function deleteIndex(string$databaseId, string$collectionId, string$key): string + public function deleteIndex(string $databaseId, string $collectionId, string $key): string { $path = str_replace(['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'); diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index 6f670da..5531f7e 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -21,12 +21,12 @@ public function __construct(Client $client) * filter your results. * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function list(array $queries = null, string$search = null): array + public function list(array $queries = null, string $search = null): array { $path = str_replace([], [], '/functions'); @@ -52,18 +52,18 @@ public function list(array $queries = null, string$search = null): array * [permissions](/docs/permissions) to allow different project users or team * with access to execute the function using the client API. * - * @param string$functionId - * @param string$name + * @param string $functionId + * @param string $name * @param array $execute - * @param string$runtime + * @param string $runtime * @param array $events - * @param string$schedule + * @param string $schedule * @param int $timeout * @throws AppwriteException * @return array */ - public function create(string$functionId, string$name, array $execute, string$runtime, array $events = null, string$schedule = null, int $timeout = null): array + public function create(string $functionId, string $name, array $execute, string $runtime, array $events = null, string $schedule = null, int $timeout = null): array { $path = str_replace([], [], '/functions'); @@ -139,12 +139,12 @@ public function listRuntimes(): array * * Get a function by its unique ID. * - * @param string$functionId + * @param string $functionId * @throws AppwriteException * @return array */ - public function get(string$functionId): array + public function get(string $functionId): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -163,17 +163,17 @@ public function get(string$functionId): array * * Update function by its unique ID. * - * @param string$functionId - * @param string$name + * @param string $functionId + * @param string $name * @param array $execute * @param array $events - * @param string$schedule + * @param string $schedule * @param int $timeout * @throws AppwriteException * @return array */ - public function update(string$functionId, string$name, array $execute, array $events = null, string$schedule = null, int $timeout = null): array + public function update(string $functionId, string $name, array $execute, array $events = null, string $schedule = null, int $timeout = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -218,12 +218,12 @@ public function update(string$functionId, string$name, array $execute, array $ev * * Delete a function by its unique ID. * - * @param string$functionId + * @param string $functionId * @throws AppwriteException * @return string */ - public function delete(string$functionId): string + public function delete(string $functionId): string { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}'); @@ -243,14 +243,14 @@ public function delete(string$functionId): string * Get a list of all the project's code deployments. You can use the query * params to filter your results. * - * @param string$functionId + * @param string $functionId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listDeployments(string$functionId, array $queries = null, string$search = null): array + public function listDeployments(string $functionId, array $queries = null, string $search = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/deployments'); @@ -286,15 +286,15 @@ public function listDeployments(string$functionId, array $queries = null, string * * Use the "command" param to set the entry point used to execute your code. * - * @param string$functionId - * @param string$entrypoint + * @param string $functionId + * @param string $entrypoint * @param InputFile $code * @param bool $activate * @throws AppwriteException * @return array */ - public function createDeployment(string$functionId, string$entrypoint, InputFile $code, bool $activate, callable $onProgress = null): array + public function createDeployment(string $functionId, string $entrypoint, InputFile $code, bool $activate, callable $onProgress = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/deployments'); @@ -403,13 +403,13 @@ public function createDeployment(string$functionId, string$entrypoint, InputFile * * Get a code deployment by its unique ID. * - * @param string$functionId - * @param string$deploymentId + * @param string $functionId + * @param string $deploymentId * @throws AppwriteException * @return array */ - public function getDeployment(string$functionId, string$deploymentId): array + public function getDeployment(string $functionId, string $deploymentId): array { $path = str_replace(['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], '/functions/{functionId}/deployments/{deploymentId}'); @@ -433,13 +433,13 @@ public function getDeployment(string$functionId, string$deploymentId): array * this endpoint to switch the code deployment that should be executed by the * execution endpoint. * - * @param string$functionId - * @param string$deploymentId + * @param string $functionId + * @param string $deploymentId * @throws AppwriteException * @return array */ - public function updateDeployment(string$functionId, string$deploymentId): array + public function updateDeployment(string $functionId, string $deploymentId): array { $path = str_replace(['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], '/functions/{functionId}/deployments/{deploymentId}'); @@ -461,13 +461,13 @@ public function updateDeployment(string$functionId, string$deploymentId): array * * Delete a code deployment by its unique ID. * - * @param string$functionId - * @param string$deploymentId + * @param string $functionId + * @param string $deploymentId * @throws AppwriteException * @return string */ - public function deleteDeployment(string$functionId, string$deploymentId): string + public function deleteDeployment(string $functionId, string $deploymentId): string { $path = str_replace(['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], '/functions/{functionId}/deployments/{deploymentId}'); @@ -487,14 +487,14 @@ public function deleteDeployment(string$functionId, string$deploymentId): string /** * Retry Build * - * @param string$functionId - * @param string$deploymentId - * @param string$buildId + * @param string $functionId + * @param string $deploymentId + * @param string $buildId * @throws AppwriteException * @return string */ - public function retryBuild(string$functionId, string$deploymentId, string$buildId): string + public function retryBuild(string $functionId, string $deploymentId, string $buildId): string { $path = str_replace(['{functionId}', '{deploymentId}', '{buildId}'], [$functionId, $deploymentId, $buildId], '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'); @@ -522,14 +522,14 @@ public function retryBuild(string$functionId, string$deploymentId, string$buildI * return a list of all of the project's executions. [Learn more about * different API modes](/docs/admin). * - * @param string$functionId + * @param string $functionId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listExecutions(string$functionId, array $queries = null, string$search = null): array + public function listExecutions(string $functionId, array $queries = null, string $search = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions'); @@ -559,14 +559,14 @@ public function listExecutions(string$functionId, array $queries = null, string$ * updates on the current execution status. Once this endpoint is called, your * function execution process will start asynchronously. * - * @param string$functionId - * @param string$data + * @param string $functionId + * @param string $data * @param bool $async * @throws AppwriteException * @return array */ - public function createExecution(string$functionId, string$data = null, bool $async = null): array + public function createExecution(string $functionId, string $data = null, bool $async = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions'); @@ -593,13 +593,13 @@ public function createExecution(string$functionId, string$data = null, bool $asy * * Get a function execution log by its unique ID. * - * @param string$functionId - * @param string$executionId + * @param string $functionId + * @param string $executionId * @throws AppwriteException * @return array */ - public function getExecution(string$functionId, string$executionId): array + public function getExecution(string $functionId, string $executionId): array { $path = str_replace(['{functionId}', '{executionId}'], [$functionId, $executionId], '/functions/{functionId}/executions/{executionId}'); @@ -621,14 +621,14 @@ public function getExecution(string$functionId, string$executionId): array * * Get a list of all variables of a specific function. * - * @param string$functionId + * @param string $functionId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listVariables(string$functionId, array $queries = null, string$search = null): array + public function listVariables(string $functionId, array $queries = null, string $search = null): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/variables'); @@ -656,14 +656,14 @@ public function listVariables(string$functionId, array $queries = null, string$s * Create a new function variable. These variables can be accessed within * function in the `env` object under the request variable. * - * @param string$functionId - * @param string$key - * @param string$value + * @param string $functionId + * @param string $key + * @param string $value * @throws AppwriteException * @return array */ - public function createVariable(string$functionId, string$key, string$value): array + public function createVariable(string $functionId, string $key, string $value): array { $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/variables'); @@ -696,13 +696,13 @@ public function createVariable(string$functionId, string$key, string$value): arr * * Get a variable by its unique ID. * - * @param string$functionId - * @param string$variableId + * @param string $functionId + * @param string $variableId * @throws AppwriteException * @return array */ - public function getVariable(string$functionId, string$variableId): array + public function getVariable(string $functionId, string $variableId): array { $path = str_replace(['{functionId}', '{variableId}'], [$functionId, $variableId], '/functions/{functionId}/variables/{variableId}'); @@ -724,15 +724,15 @@ public function getVariable(string$functionId, string$variableId): array * * Update variable by its unique ID. * - * @param string$functionId - * @param string$variableId - * @param string$key - * @param string$value + * @param string $functionId + * @param string $variableId + * @param string $key + * @param string $value * @throws AppwriteException * @return array */ - public function updateVariable(string$functionId, string$variableId, string$key, string$value = null): array + public function updateVariable(string $functionId, string $variableId, string $key, string $value = null): array { $path = str_replace(['{functionId}', '{variableId}'], [$functionId, $variableId], '/functions/{functionId}/variables/{variableId}'); @@ -765,13 +765,13 @@ public function updateVariable(string$functionId, string$variableId, string$key, * * Delete a variable by its unique ID. * - * @param string$functionId - * @param string$variableId + * @param string $functionId + * @param string $variableId * @throws AppwriteException * @return string */ - public function deleteVariable(string$functionId, string$variableId): string + public function deleteVariable(string $functionId, string $variableId): string { $path = str_replace(['{functionId}', '{variableId}'], [$functionId, $variableId], '/functions/{functionId}/variables/{variableId}'); diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index bc6b15a..b20087e 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -21,12 +21,12 @@ public function __construct(Client $client) * filter your results. * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listBuckets(array $queries = null, string$search = null): array + public function listBuckets(array $queries = null, string $search = null): array { $path = str_replace([], [], '/storage/buckets'); @@ -50,21 +50,21 @@ public function listBuckets(array $queries = null, string$search = null): array * * Create a new storage bucket. * - * @param string$bucketId - * @param string$name - * @param bool $fileSecurity + * @param string $bucketId + * @param string $name * @param array $permissions + * @param bool $fileSecurity * @param bool $enabled * @param int $maximumFileSize * @param array $allowedFileExtensions - * @param string$compression + * @param string $compression * @param bool $encryption * @param bool $antivirus * @throws AppwriteException * @return array */ - public function createBucket(string$bucketId, string$name, bool $fileSecurity, array $permissions = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string$compression = null, bool $encryption = null, bool $antivirus = null): array + public function createBucket(string $bucketId, string $name, array $permissions = null, bool $fileSecurity = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string $compression = null, bool $encryption = null, bool $antivirus = null): array { $path = str_replace([], [], '/storage/buckets'); @@ -75,9 +75,6 @@ public function createBucket(string$bucketId, string$name, bool $fileSecurity, a if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($fileSecurity)) { - throw new AppwriteException('Missing required parameter: "fileSecurity"'); - } if (!is_null($bucketId)) { $params['bucketId'] = $bucketId; } @@ -130,12 +127,12 @@ public function createBucket(string$bucketId, string$name, bool $fileSecurity, a * Get a storage bucket by its unique ID. This endpoint response returns a * JSON object with the storage bucket metadata. * - * @param string$bucketId + * @param string $bucketId * @throws AppwriteException * @return array */ - public function getBucket(string$bucketId): array + public function getBucket(string $bucketId): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -154,21 +151,21 @@ public function getBucket(string$bucketId): array * * Update a storage bucket by its unique ID. * - * @param string$bucketId - * @param string$name - * @param bool $fileSecurity + * @param string $bucketId + * @param string $name * @param array $permissions + * @param bool $fileSecurity * @param bool $enabled * @param int $maximumFileSize * @param array $allowedFileExtensions - * @param string$compression + * @param string $compression * @param bool $encryption * @param bool $antivirus * @throws AppwriteException * @return array */ - public function updateBucket(string$bucketId, string$name, bool $fileSecurity, array $permissions = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string$compression = null, bool $encryption = null, bool $antivirus = null): array + public function updateBucket(string $bucketId, string $name, array $permissions = null, bool $fileSecurity = null, bool $enabled = null, int $maximumFileSize = null, array $allowedFileExtensions = null, string $compression = null, bool $encryption = null, bool $antivirus = null): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -179,9 +176,6 @@ public function updateBucket(string$bucketId, string$name, bool $fileSecurity, a if (!isset($name)) { throw new AppwriteException('Missing required parameter: "name"'); } - if (!isset($fileSecurity)) { - throw new AppwriteException('Missing required parameter: "fileSecurity"'); - } if (!is_null($name)) { $params['name'] = $name; } @@ -229,12 +223,12 @@ public function updateBucket(string$bucketId, string$name, bool $fileSecurity, a * * Delete a storage bucket by its unique ID. * - * @param string$bucketId + * @param string $bucketId * @throws AppwriteException * @return string */ - public function deleteBucket(string$bucketId): string + public function deleteBucket(string $bucketId): string { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}'); @@ -255,14 +249,14 @@ public function deleteBucket(string$bucketId): string * 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). * - * @param string$bucketId + * @param string $bucketId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function listFiles(string$bucketId, array $queries = null, string$search = null): array + public function listFiles(string $bucketId, array $queries = null, string $search = null): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}/files'); @@ -306,15 +300,15 @@ public function listFiles(string$bucketId, array $queries = null, string$search * chunking logic will be managed by the SDK internally. * * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @param InputFile $file * @param array $permissions * @throws AppwriteException * @return array */ - public function createFile(string$bucketId, string$fileId, InputFile $file, array $permissions = null, callable $onProgress = null): array + public function createFile(string $bucketId, string $fileId, InputFile $file, array $permissions = null, callable $onProgress = null): array { $path = str_replace(['{bucketId}'], [$bucketId], '/storage/buckets/{bucketId}/files'); @@ -428,13 +422,13 @@ public function createFile(string$bucketId, string$fileId, InputFile $file, arra * Get a file by its unique ID. This endpoint response returns a JSON object * with the file metadata. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @throws AppwriteException * @return array */ - public function getFile(string$bucketId, string$fileId): array + public function getFile(string $bucketId, string $fileId): array { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}'); @@ -457,14 +451,14 @@ public function getFile(string$bucketId, string$fileId): array * Update a file by its unique ID. Only users with write permissions have * access to update this resource. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @param array $permissions * @throws AppwriteException * @return array */ - public function updateFile(string$bucketId, string$fileId, array $permissions = null): array + public function updateFile(string $bucketId, string $fileId, array $permissions = null): array { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}'); @@ -491,13 +485,13 @@ public function updateFile(string$bucketId, string$fileId, array $permissions = * Delete a file by its unique ID. Only users with write permissions have * access to delete this resource. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @throws AppwriteException * @return string */ - public function deleteFile(string$bucketId, string$fileId): string + public function deleteFile(string $bucketId, string $fileId): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}'); @@ -521,13 +515,13 @@ public function deleteFile(string$bucketId, string$fileId): string * 'Content-Disposition: attachment' header that tells the browser to start * downloading the file to user downloads directory. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @throws AppwriteException * @return string */ - public function getFileDownload(string$bucketId, string$fileId): string + public function getFileDownload(string $bucketId, string $fileId): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/download'); @@ -553,24 +547,24 @@ public function getFileDownload(string$bucketId, string$fileId): string * string arguments for cutting and resizing your preview image. Preview is * supported only for image files smaller than 10MB. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @param int $width * @param int $height - * @param string$gravity + * @param string $gravity * @param int $quality * @param int $borderWidth - * @param string$borderColor + * @param string $borderColor * @param int $borderRadius * @param int $opacity * @param int $rotation - * @param string$background - * @param string$output + * @param string $background + * @param string $output * @throws AppwriteException * @return string */ - public function getFilePreview(string$bucketId, string$fileId, int $width = null, int $height = null, string$gravity = null, int $quality = null, int $borderWidth = null, string$borderColor = null, int $borderRadius = null, int $opacity = null, int $rotation = null, string$background = null, string$output = null): string + public function getFilePreview(string $bucketId, string $fileId, int $width = null, int $height = null, string $gravity = null, int $quality = null, int $borderWidth = null, string $borderColor = null, int $borderRadius = null, int $opacity = null, int $rotation = null, string $background = null, string $output = null): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/preview'); @@ -638,13 +632,13 @@ public function getFilePreview(string$bucketId, string$fileId, int $width = null * download method but returns with no 'Content-Disposition: attachment' * header. * - * @param string$bucketId - * @param string$fileId + * @param string $bucketId + * @param string $fileId * @throws AppwriteException * @return string */ - public function getFileView(string$bucketId, string$fileId): string + public function getFileView(string $bucketId, string $fileId): string { $path = str_replace(['{bucketId}', '{fileId}'], [$bucketId, $fileId], '/storage/buckets/{bucketId}/files/{fileId}/view'); diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index 923a47c..9459787 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -24,12 +24,12 @@ public function __construct(Client $client) * project. [Learn more about different API modes](/docs/admin). * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function list(array $queries = null, string$search = null): array + public function list(array $queries = null, string $search = null): array { $path = str_replace([], [], '/teams'); @@ -55,14 +55,14 @@ public function list(array $queries = null, string$search = null): array * 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. * - * @param string$teamId - * @param string$name + * @param string $teamId + * @param string $name * @param array $roles * @throws AppwriteException * @return array */ - public function create(string$teamId, string$name, array $roles = null): array + public function create(string $teamId, string $name, array $roles = null): array { $path = str_replace([], [], '/teams'); @@ -96,12 +96,12 @@ public function create(string$teamId, string$name, array $roles = null): array * * Get a team by its ID. All team members have read access for this resource. * - * @param string$teamId + * @param string $teamId * @throws AppwriteException * @return array */ - public function get(string$teamId): array + public function get(string $teamId): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); @@ -121,13 +121,13 @@ public function get(string$teamId): array * Update a team using its ID. Only members with the owner role can update the * team. * - * @param string$teamId - * @param string$name + * @param string $teamId + * @param string $name * @throws AppwriteException * @return array */ - public function update(string$teamId, string$name): array + public function update(string $teamId, string $name): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); @@ -154,12 +154,12 @@ public function update(string$teamId, string$name): array * Delete a team using its ID. Only team members with the owner role can * delete the team. * - * @param string$teamId + * @param string $teamId * @throws AppwriteException * @return string */ - public function delete(string$teamId): string + public function delete(string $teamId): string { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}'); @@ -179,14 +179,14 @@ public function delete(string$teamId): string * Use this endpoint to list a team's members using the team's ID. All team * members have read access to this endpoint. * - * @param string$teamId + * @param string $teamId * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function getMemberships(string$teamId, array $queries = null, string$search = null): array + public function getMemberships(string $teamId, array $queries = null, string $search = null): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); @@ -227,16 +227,16 @@ public function getMemberships(string$teamId, array $queries = null, string$sear * the only valid redirect URL's are the once from domains you have set when * adding your platforms in the console interface. * - * @param string$teamId - * @param string$email + * @param string $teamId + * @param string $email * @param array $roles - * @param string$url - * @param string$name + * @param string $url + * @param string $name * @throws AppwriteException * @return array */ - public function createMembership(string$teamId, string$email, array $roles, string$url, string$name = null): array + public function createMembership(string $teamId, string $email, array $roles, string $url, string $name = null): array { $path = str_replace(['{teamId}'], [$teamId], '/teams/{teamId}/memberships'); @@ -281,13 +281,13 @@ public function createMembership(string$teamId, string$email, array $roles, stri * Get a team member by the membership unique id. All team members have read * access for this resource. * - * @param string$teamId - * @param string$membershipId + * @param string $teamId + * @param string $membershipId * @throws AppwriteException * @return array */ - public function getMembership(string$teamId, string$membershipId): array + public function getMembership(string $teamId, string $membershipId): array { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); @@ -311,14 +311,14 @@ public function getMembership(string$teamId, string$membershipId): array * have access to this endpoint. Learn more about [roles and * permissions](/docs/permissions). * - * @param string$teamId - * @param string$membershipId + * @param string $teamId + * @param string $membershipId * @param array $roles * @throws AppwriteException * @return array */ - public function updateMembershipRoles(string$teamId, string$membershipId, array $roles): array + public function updateMembershipRoles(string $teamId, string $membershipId, array $roles): array { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); @@ -349,13 +349,13 @@ public function updateMembershipRoles(string$teamId, string$membershipId, array * the membership of any other team member. You can also use this endpoint to * delete a user membership even if it is not accepted. * - * @param string$teamId - * @param string$membershipId + * @param string $teamId + * @param string $membershipId * @throws AppwriteException * @return string */ - public function deleteMembership(string$teamId, string$membershipId): string + public function deleteMembership(string $teamId, string $membershipId): string { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}'); @@ -383,15 +383,15 @@ public function deleteMembership(string$teamId, string$membershipId): string * created. * * - * @param string$teamId - * @param string$membershipId - * @param string$userId - * @param string$secret + * @param string $teamId + * @param string $membershipId + * @param string $userId + * @param string $secret * @throws AppwriteException * @return array */ - public function updateMembershipStatus(string$teamId, string$membershipId, string$userId, string$secret): array + public function updateMembershipStatus(string $teamId, string $membershipId, string $userId, string $secret): array { $path = str_replace(['{teamId}', '{membershipId}'], [$teamId, $membershipId], '/teams/{teamId}/memberships/{membershipId}/status'); diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index acbe14b..94219e0 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -21,12 +21,12 @@ public function __construct(Client $client) * filter your results. * * @param array $queries - * @param string$search + * @param string $search * @throws AppwriteException * @return array */ - public function list(array $queries = null, string$search = null): array + public function list(array $queries = null, string $search = null): array { $path = str_replace([], [], '/users'); @@ -50,16 +50,16 @@ public function list(array $queries = null, string$search = null): array * * Create a new user. * - * @param string$userId - * @param string$email - * @param string$phone - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $phone + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function create(string$userId, string$email = null, string$phone = null, string$password = null, string$name = null): array + public function create(string $userId, string $email = null, string $phone = null, string $password = null, string $name = null): array { $path = str_replace([], [], '/users'); @@ -101,15 +101,15 @@ public function create(string$userId, string$email = null, string$phone = null, * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function createArgon2User(string$userId, string$email, string$password, string$name = null): array + public function createArgon2User(string $userId, string $email, string $password, string $name = null): array { $path = str_replace([], [], '/users/argon2'); @@ -153,15 +153,15 @@ public function createArgon2User(string$userId, string$email, string$password, s * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function createBcryptUser(string$userId, string$email, string$password, string$name = null): array + public function createBcryptUser(string $userId, string $email, string $password, string $name = null): array { $path = str_replace([], [], '/users/bcrypt'); @@ -205,15 +205,15 @@ public function createBcryptUser(string$userId, string$email, string$password, s * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function createMD5User(string$userId, string$email, string$password, string$name = null): array + public function createMD5User(string $userId, string $email, string $password, string $name = null): array { $path = str_replace([], [], '/users/md5'); @@ -257,15 +257,15 @@ public function createMD5User(string$userId, string$email, string$password, stri * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $name * @throws AppwriteException * @return array */ - public function createPHPassUser(string$userId, string$email, string$password, string$name = null): array + public function createPHPassUser(string $userId, string $email, string $password, string $name = null): array { $path = str_replace([], [], '/users/phpass'); @@ -309,20 +309,20 @@ public function createPHPassUser(string$userId, string$email, string$password, s * /users](/docs/server/users#usersCreate) endpoint to create users with a * plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$passwordSalt + * @param string $userId + * @param string $email + * @param string $password + * @param string $passwordSalt * @param int $passwordCpu * @param int $passwordMemory * @param int $passwordParallel * @param int $passwordLength - * @param string$name + * @param string $name * @throws AppwriteException * @return array */ - public function createScryptUser(string$userId, string$email, string$password, string$passwordSalt, int $passwordCpu, int $passwordMemory, int $passwordParallel, int $passwordLength, string$name = null): array + public function createScryptUser(string $userId, string $email, string $password, string $passwordSalt, int $passwordCpu, int $passwordMemory, int $passwordParallel, int $passwordLength, string $name = null): array { $path = str_replace([], [], '/users/scrypt'); @@ -401,18 +401,18 @@ public function createScryptUser(string$userId, string$email, string$password, s * algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint * to create users with a plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$passwordSalt - * @param string$passwordSaltSeparator - * @param string$passwordSignerKey - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $passwordSalt + * @param string $passwordSaltSeparator + * @param string $passwordSignerKey + * @param string $name * @throws AppwriteException * @return array */ - public function createScryptModifiedUser(string$userId, string$email, string$password, string$passwordSalt, string$passwordSaltSeparator, string$passwordSignerKey, string$name = null): array + public function createScryptModifiedUser(string $userId, string $email, string $password, string $passwordSalt, string $passwordSaltSeparator, string $passwordSignerKey, string $name = null): array { $path = str_replace([], [], '/users/scrypt-modified'); @@ -477,16 +477,16 @@ public function createScryptModifiedUser(string$userId, string$email, string$pas * the [POST /users](/docs/server/users#usersCreate) endpoint to create users * with a plain text password. * - * @param string$userId - * @param string$email - * @param string$password - * @param string$passwordVersion - * @param string$name + * @param string $userId + * @param string $email + * @param string $password + * @param string $passwordVersion + * @param string $name * @throws AppwriteException * @return array */ - public function createSHAUser(string$userId, string$email, string$password, string$passwordVersion = null, string$name = null): array + public function createSHAUser(string $userId, string $email, string $password, string $passwordVersion = null, string $name = null): array { $path = str_replace([], [], '/users/sha'); @@ -531,12 +531,12 @@ public function createSHAUser(string$userId, string$email, string$password, stri * * Get a user by its unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return array */ - public function get(string$userId): array + public function get(string $userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}'); @@ -559,12 +559,12 @@ public function get(string$userId): array * ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) * endpoint instead. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return string */ - public function delete(string$userId): string + public function delete(string $userId): string { $path = str_replace(['{userId}'], [$userId], '/users/{userId}'); @@ -583,13 +583,13 @@ public function delete(string$userId): string * * Update the user email by its unique ID. * - * @param string$userId - * @param string$email + * @param string $userId + * @param string $email * @throws AppwriteException * @return array */ - public function updateEmail(string$userId, string$email): array + public function updateEmail(string $userId, string $email): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/email'); @@ -615,13 +615,13 @@ public function updateEmail(string$userId, string$email): array * * Get the user activity logs list by its unique ID. * - * @param string$userId + * @param string $userId * @param array $queries * @throws AppwriteException * @return array */ - public function getLogs(string$userId, array $queries = null): array + public function getLogs(string $userId, array $queries = null): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/logs'); @@ -644,12 +644,12 @@ public function getLogs(string$userId, array $queries = null): array * * Get the user membership list by its unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return array */ - public function getMemberships(string$userId): array + public function getMemberships(string $userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/memberships'); @@ -668,13 +668,13 @@ public function getMemberships(string$userId): array * * Update the user name by its unique ID. * - * @param string$userId - * @param string$name + * @param string $userId + * @param string $name * @throws AppwriteException * @return array */ - public function updateName(string$userId, string$name): array + public function updateName(string $userId, string $name): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/name'); @@ -700,13 +700,13 @@ public function updateName(string$userId, string$name): array * * Update the user password by its unique ID. * - * @param string$userId - * @param string$password + * @param string $userId + * @param string $password * @throws AppwriteException * @return array */ - public function updatePassword(string$userId, string$password): array + public function updatePassword(string $userId, string $password): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/password'); @@ -732,13 +732,13 @@ public function updatePassword(string$userId, string$password): array * * Update the user phone by its unique ID. * - * @param string$userId - * @param string$number + * @param string $userId + * @param string $number * @throws AppwriteException * @return array */ - public function updatePhone(string$userId, string$number): array + public function updatePhone(string $userId, string $number): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/phone'); @@ -764,12 +764,12 @@ public function updatePhone(string$userId, string$number): array * * Get the user preferences by its unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return array */ - public function getPrefs(string$userId): array + public function getPrefs(string $userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); @@ -790,13 +790,13 @@ public function getPrefs(string$userId): array * as is, and replaces any previous value. The maximum allowed prefs size is * 64kB and throws error if exceeded. * - * @param string$userId + * @param string $userId * @param array $prefs * @throws AppwriteException * @return array */ - public function updatePrefs(string$userId, array $prefs): array + public function updatePrefs(string $userId, array $prefs): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); @@ -822,12 +822,12 @@ public function updatePrefs(string$userId, array $prefs): array * * Get the user sessions list by its unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return array */ - public function getSessions(string$userId): array + public function getSessions(string $userId): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); @@ -846,12 +846,12 @@ public function getSessions(string$userId): array * * Delete all user's sessions by using the user's unique ID. * - * @param string$userId + * @param string $userId * @throws AppwriteException * @return string */ - public function deleteSessions(string$userId): string + public function deleteSessions(string $userId): string { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions'); @@ -870,13 +870,13 @@ public function deleteSessions(string$userId): string * * Delete a user sessions by its unique ID. * - * @param string$userId - * @param string$sessionId + * @param string $userId + * @param string $sessionId * @throws AppwriteException * @return string */ - public function deleteSession(string$userId, string$sessionId): string + public function deleteSession(string $userId, string $sessionId): string { $path = str_replace(['{userId}', '{sessionId}'], [$userId, $sessionId], '/users/{userId}/sessions/{sessionId}'); @@ -899,13 +899,13 @@ public function deleteSession(string$userId, string$sessionId): string * Update the user status by its unique ID. Use this endpoint as an * alternative to deleting a user if you want to keep user's ID reserved. * - * @param string$userId + * @param string $userId * @param bool $status * @throws AppwriteException * @return array */ - public function updateStatus(string$userId, bool $status): array + public function updateStatus(string $userId, bool $status): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/status'); @@ -931,13 +931,13 @@ public function updateStatus(string$userId, bool $status): array * * Update the user email verification status by its unique ID. * - * @param string$userId + * @param string $userId * @param bool $emailVerification * @throws AppwriteException * @return array */ - public function updateEmailVerification(string$userId, bool $emailVerification): array + public function updateEmailVerification(string $userId, bool $emailVerification): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/verification'); @@ -963,13 +963,13 @@ public function updateEmailVerification(string$userId, bool $emailVerification): * * Update the user phone verification status by its unique ID. * - * @param string$userId + * @param string $userId * @param bool $phoneVerification * @throws AppwriteException * @return array */ - public function updatePhoneVerification(string$userId, bool $phoneVerification): array + public function updatePhoneVerification(string $userId, bool $phoneVerification): array { $path = str_replace(['{userId}'], [$userId], '/users/{userId}/verification/phone'); From b767e072d207ed3b8cf70d2bbd81960c680c52db Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 5 Sep 2022 20:41:59 +0400 Subject: [PATCH 4/4] feat: update for 1.0.0-RC1 --- docs/avatars.md | 1 - src/Appwrite/Client.php | 2 +- src/Appwrite/Services/Avatars.php | 7 +------ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/docs/avatars.md b/docs/avatars.md index 96baee4..c778d2e 100644 --- a/docs/avatars.md +++ b/docs/avatars.md @@ -113,7 +113,6 @@ When one dimension is specified and the other is 0, the image is scaled with pre | name | string | Full Name. When empty, current user name or email will be used. Max length: 128 chars. | | | width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100. | 500 | | height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100. | 500 | -| color | string | Changes text color. By default a random color will be picked and stay will persistent to the given name. | | | background | string | Changes background color. By default a random color will be picked and stay will persistent to the given name. | | ## Get QR Code diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 5658317..159e41e 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -40,7 +40,7 @@ class Client 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '6.1.0-RC1', + 'x-sdk-version'=> '7.0.0-RC1', ]; /** diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index dfd4b29..e53579f 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -256,13 +256,12 @@ public function getImage(string $url, int $width = null, int $height = null): st * @param string $name * @param int $width * @param int $height - * @param string $color * @param string $background * @throws AppwriteException * @return string */ - public function getInitials(string $name = null, int $width = null, int $height = null, string $color = null, string $background = null): string + public function getInitials(string $name = null, int $width = null, int $height = null, string $background = null): string { $path = str_replace([], [], '/avatars/initials'); @@ -279,10 +278,6 @@ public function getInitials(string $name = null, int $width = null, int $height $params['height'] = $height; } - if (!is_null($color)) { - $params['color'] = $color; - } - if (!is_null($background)) { $params['background'] = $background; }