From 39fdc6e2eb5cffef1e6f451310af2d1aff884f95 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 18 Jul 2025 12:48:19 +1200 Subject: [PATCH 1/4] Add inc/dec --- README.md | 6 +- .../java/databases/create-document.md | 1 + .../databases/decrement-document-attribute.md | 27 +++ .../databases/increment-document-attribute.md | 27 +++ .../kotlin/databases/create-document.md | 1 + .../databases/decrement-document-attribute.md | 18 ++ .../databases/increment-document-attribute.md | 18 ++ library/src/main/java/io/appwrite/Client.kt | 2 +- .../java/io/appwrite/enums/ImageFormat.kt | 4 +- .../main/java/io/appwrite/models/Document.kt | 10 ++ .../java/io/appwrite/services/Databases.kt | 160 +++++++++++++++++- 11 files changed, 267 insertions(+), 7 deletions(-) create mode 100644 docs/examples/java/databases/decrement-document-attribute.md create mode 100644 docs/examples/java/databases/increment-document-attribute.md create mode 100644 docs/examples/kotlin/databases/decrement-document-attribute.md create mode 100644 docs/examples/kotlin/databases/increment-document-attribute.md diff --git a/README.md b/README.md index 6bfc46c3..745f21ca 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.1.0") +implementation("io.appwrite:sdk-for-android:8.2.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.1.0 + 8.2.0 ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 7fb129bb..3625d963 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,6 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // .setJWT(""); // Your secret JSON Web Token diff --git a/docs/examples/java/databases/decrement-document-attribute.md b/docs/examples/java/databases/decrement-document-attribute.md new file mode 100644 index 00000000..de6a4ab4 --- /dev/null +++ b/docs/examples/java/databases/decrement-document-attribute.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.decrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // min (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/increment-document-attribute.md b/docs/examples/java/databases/increment-document-attribute.md new file mode 100644 index 00000000..94ffa9d7 --- /dev/null +++ b/docs/examples/java/databases/increment-document-attribute.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.incrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // max (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 0bafb315..38f93894 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,6 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // .setJWT("") // Your secret JSON Web Token diff --git a/docs/examples/kotlin/databases/decrement-document-attribute.md b/docs/examples/kotlin/databases/decrement-document-attribute.md new file mode 100644 index 00000000..c500fa86 --- /dev/null +++ b/docs/examples/kotlin/databases/decrement-document-attribute.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.decrementDocumentAttribute( + databaseId = "", + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + min = 0, // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/increment-document-attribute.md b/docs/examples/kotlin/databases/increment-document-attribute.md new file mode 100644 index 00000000..0ae6b02d --- /dev/null +++ b/docs/examples/kotlin/databases/increment-document-attribute.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.incrementDocumentAttribute( + databaseId = "", + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + max = 0, // (optional) +) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 5f12d7f6..bf0480fa 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.1.0", + "x-sdk-version" to "8.2.0", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt index c3dea067..8e74806f 100644 --- a/library/src/main/java/io/appwrite/enums/ImageFormat.kt +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -14,7 +14,9 @@ enum class ImageFormat(val value: String) { @SerializedName("heic") HEIC("heic"), @SerializedName("avif") - AVIF("avif"); + AVIF("avif"), + @SerializedName("gif") + GIF("gif"); override fun toString() = value } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Document.kt b/library/src/main/java/io/appwrite/models/Document.kt index 01204de2..c0dfe61c 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -13,6 +13,12 @@ data class Document( @SerializedName("\$id") val id: String, + /** + * Document automatically incrementing ID. + */ + @SerializedName("\$sequence") + val sequence: Long, + /** * Collection ID. */ @@ -51,6 +57,7 @@ data class Document( ) { fun toMap(): Map = mapOf( "\$id" to id as Any, + "\$sequence" to sequence as Any, "\$collectionId" to collectionId as Any, "\$databaseId" to databaseId as Any, "\$createdAt" to createdAt as Any, @@ -62,6 +69,7 @@ data class Document( companion object { operator fun invoke( id: String, + sequence: Long, collectionId: String, databaseId: String, createdAt: String, @@ -70,6 +78,7 @@ data class Document( data: Map ) = Document>( id, + sequence, collectionId, databaseId, createdAt, @@ -84,6 +93,7 @@ data class Document( nestedType: Class ) = Document( id = map["\$id"] as String, + sequence = (map["\$sequence"] as Number).toLong(), collectionId = map["\$collectionId"] as String, databaseId = map["\$databaseId"] as String, createdAt = map["\$createdAt"] as String, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 2601af20..edc10f52 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -212,7 +212,7 @@ class Databases(client: Client) : Service(client) { ) /** - * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. * @param collectionId Collection ID. @@ -257,7 +257,7 @@ class Databases(client: Client) : Service(client) { } /** - * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. * @param collectionId Collection ID. @@ -388,4 +388,160 @@ class Databases(client: Client) : Service(client) { } + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to decrement the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "min" to min, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to decrement the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + ): io.appwrite.models.Document> = decrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + min, + nestedType = classOf(), + ) + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "max" to max, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + ): io.appwrite.models.Document> = incrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + max, + nestedType = classOf(), + ) + } \ No newline at end of file From 49bf798964ead5c527ad984400a99379c51938df Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Jul 2025 16:14:53 +0000 Subject: [PATCH 2/4] chore: regenerate --- README.md | 8 +- .../java/databases/create-document.md | 1 - .../java/databases/upsert-document.md | 6 +- docs/examples/java/tables/create-row.md | 28 ++ docs/examples/java/tables/create-rows.md | 25 + .../delete-row.md} | 13 +- .../get-row.md} | 14 +- docs/examples/java/tables/list-rows.md | 24 + docs/examples/java/tables/update-row.md | 26 ++ docs/examples/java/tables/upsert-row.md | 26 ++ .../kotlin/databases/create-document.md | 1 - .../kotlin/databases/upsert-document.md | 6 +- docs/examples/kotlin/tables/create-row.md | 19 + docs/examples/kotlin/tables/create-rows.md | 16 + .../delete-row.md} | 13 +- .../get-row.md} | 14 +- docs/examples/kotlin/tables/list-rows.md | 15 + docs/examples/kotlin/tables/update-row.md | 17 + docs/examples/kotlin/tables/upsert-row.md | 17 + library/src/main/java/io/appwrite/Client.kt | 4 +- .../java/io/appwrite/models/ContinentList.kt | 2 +- .../java/io/appwrite/models/CountryList.kt | 2 +- .../java/io/appwrite/models/CurrencyList.kt | 2 +- .../java/io/appwrite/models/DocumentList.kt | 2 +- .../java/io/appwrite/models/ExecutionList.kt | 2 +- .../main/java/io/appwrite/models/FileList.kt | 2 +- .../java/io/appwrite/models/IdentityList.kt | 2 +- .../java/io/appwrite/models/LanguageList.kt | 2 +- .../java/io/appwrite/models/LocaleCodeList.kt | 2 +- .../main/java/io/appwrite/models/LogList.kt | 2 +- .../java/io/appwrite/models/MembershipList.kt | 2 +- .../main/java/io/appwrite/models/PhoneList.kt | 2 +- .../src/main/java/io/appwrite/models/Row.kt | 105 +++++ .../main/java/io/appwrite/models/RowList.kt | 46 ++ .../java/io/appwrite/models/SessionList.kt | 2 +- .../main/java/io/appwrite/models/TeamList.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 6 + .../java/io/appwrite/services/Databases.kt | 225 +++------ .../main/java/io/appwrite/services/Tables.kt | 435 ++++++++++++++++++ 39 files changed, 908 insertions(+), 230 deletions(-) create mode 100644 docs/examples/java/tables/create-row.md create mode 100644 docs/examples/java/tables/create-rows.md rename docs/examples/java/{databases/decrement-document-attribute.md => tables/delete-row.md} (64%) rename docs/examples/java/{databases/increment-document-attribute.md => tables/get-row.md} (64%) create mode 100644 docs/examples/java/tables/list-rows.md create mode 100644 docs/examples/java/tables/update-row.md create mode 100644 docs/examples/java/tables/upsert-row.md create mode 100644 docs/examples/kotlin/tables/create-row.md create mode 100644 docs/examples/kotlin/tables/create-rows.md rename docs/examples/kotlin/{databases/decrement-document-attribute.md => tables/delete-row.md} (50%) rename docs/examples/kotlin/{databases/increment-document-attribute.md => tables/get-row.md} (50%) create mode 100644 docs/examples/kotlin/tables/list-rows.md create mode 100644 docs/examples/kotlin/tables/update-row.md create mode 100644 docs/examples/kotlin/tables/upsert-row.md create mode 100644 library/src/main/java/io/appwrite/models/Row.kt create mode 100644 library/src/main/java/io/appwrite/models/RowList.kt create mode 100644 library/src/main/java/io/appwrite/services/Tables.kt diff --git a/README.md b/README.md index 745f21ca..5ced4530 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ ![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/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 Android 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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.2.0") +implementation("io.appwrite:sdk-for-android:9.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.2.0 + 9.0.0 ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 3625d963..7fb129bb 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,7 +4,6 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // .setJWT(""); // Your secret JSON Web Token diff --git a/docs/examples/java/databases/upsert-document.md b/docs/examples/java/databases/upsert-document.md index 868576b9..ba7336f3 100644 --- a/docs/examples/java/databases/upsert-document.md +++ b/docs/examples/java/databases/upsert-document.md @@ -4,7 +4,9 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT(""); // Your secret JSON Web Token Databases databases = new Databases(client); @@ -12,8 +14,6 @@ databases.upsertDocument( "", // databaseId "", // collectionId "", // documentId - mapOf( "a" to "b" ), // data - listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tables/create-row.md b/docs/examples/java/tables/create-row.md new file mode 100644 index 00000000..8102b82c --- /dev/null +++ b/docs/examples/java/tables/create-row.md @@ -0,0 +1,28 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT(""); // Your secret JSON Web Token + +Tables tables = new Tables(client); + +tables.createRow( + "", // databaseId + "", // tableId + "", // rowId + mapOf( "a" to "b" ), // data + listOf("read("any")"), // permissions (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tables/create-rows.md b/docs/examples/java/tables/create-rows.md new file mode 100644 index 00000000..26f5d677 --- /dev/null +++ b/docs/examples/java/tables/create-rows.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // + .setKey(""); // + +Tables tables = new Tables(client); + +tables.createRows( + "", // databaseId + "", // tableId + listOf(), // rows + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/decrement-document-attribute.md b/docs/examples/java/tables/delete-row.md similarity index 64% rename from docs/examples/java/databases/decrement-document-attribute.md rename to docs/examples/java/tables/delete-row.md index de6a4ab4..596a8b7a 100644 --- a/docs/examples/java/databases/decrement-document-attribute.md +++ b/docs/examples/java/tables/delete-row.md @@ -1,20 +1,17 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Databases; +import io.appwrite.services.Tables; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Databases databases = new Databases(client); +Tables tables = new Tables(client); -databases.decrementDocumentAttribute( +tables.deleteRow( "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 0, // value (optional) - 0, // min (optional) + "", // tableId + "", // rowId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/increment-document-attribute.md b/docs/examples/java/tables/get-row.md similarity index 64% rename from docs/examples/java/databases/increment-document-attribute.md rename to docs/examples/java/tables/get-row.md index 94ffa9d7..882a1953 100644 --- a/docs/examples/java/databases/increment-document-attribute.md +++ b/docs/examples/java/tables/get-row.md @@ -1,20 +1,18 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Databases; +import io.appwrite.services.Tables; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Databases databases = new Databases(client); +Tables tables = new Tables(client); -databases.incrementDocumentAttribute( +tables.getRow( "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 0, // value (optional) - 0, // max (optional) + "", // tableId + "", // rowId + listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tables/list-rows.md b/docs/examples/java/tables/list-rows.md new file mode 100644 index 00000000..4d375702 --- /dev/null +++ b/docs/examples/java/tables/list-rows.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Tables tables = new Tables(client); + +tables.listRows( + "", // databaseId + "", // tableId + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tables/update-row.md b/docs/examples/java/tables/update-row.md new file mode 100644 index 00000000..0421c9cf --- /dev/null +++ b/docs/examples/java/tables/update-row.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Tables tables = new Tables(client); + +tables.updateRow( + "", // databaseId + "", // tableId + "", // rowId + mapOf( "a" to "b" ), // data (optional) + listOf("read("any")"), // permissions (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tables/upsert-row.md b/docs/examples/java/tables/upsert-row.md new file mode 100644 index 00000000..a8be0cfc --- /dev/null +++ b/docs/examples/java/tables/upsert-row.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT(""); // Your secret JSON Web Token + +Tables tables = new Tables(client); + +tables.upsertRow( + "", // databaseId + "", // tableId + "", // rowId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 38f93894..0bafb315 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,7 +4,6 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // .setJWT("") // Your secret JSON Web Token diff --git a/docs/examples/kotlin/databases/upsert-document.md b/docs/examples/kotlin/databases/upsert-document.md index a31dfc87..7939fde2 100644 --- a/docs/examples/kotlin/databases/upsert-document.md +++ b/docs/examples/kotlin/databases/upsert-document.md @@ -4,7 +4,9 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT("") // Your secret JSON Web Token val databases = Databases(client) @@ -12,6 +14,4 @@ val result = databases.upsertDocument( databaseId = "", collectionId = "", documentId = "", - data = mapOf( "a" to "b" ), - permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/create-row.md b/docs/examples/kotlin/tables/create-row.md new file mode 100644 index 00000000..8c581bf1 --- /dev/null +++ b/docs/examples/kotlin/tables/create-row.md @@ -0,0 +1,19 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT("") // Your secret JSON Web Token + +val tables = Tables(client) + +val result = tables.createRow( + databaseId = "", + tableId = "", + rowId = "", + data = mapOf( "a" to "b" ), + permissions = listOf("read("any")"), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/create-rows.md b/docs/examples/kotlin/tables/create-rows.md new file mode 100644 index 00000000..1fde9c50 --- /dev/null +++ b/docs/examples/kotlin/tables/create-rows.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // + .setKey("") // + +val tables = Tables(client) + +val result = tables.createRows( + databaseId = "", + tableId = "", + rows = listOf(), +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/decrement-document-attribute.md b/docs/examples/kotlin/tables/delete-row.md similarity index 50% rename from docs/examples/kotlin/databases/decrement-document-attribute.md rename to docs/examples/kotlin/tables/delete-row.md index c500fa86..ffa3229f 100644 --- a/docs/examples/kotlin/databases/decrement-document-attribute.md +++ b/docs/examples/kotlin/tables/delete-row.md @@ -1,18 +1,15 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Databases +import io.appwrite.services.Tables val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val databases = Databases(client) +val tables = Tables(client) -val result = databases.decrementDocumentAttribute( +val result = tables.deleteRow( databaseId = "", - collectionId = "", - documentId = "", - attribute = "", - value = 0, // (optional) - min = 0, // (optional) + tableId = "", + rowId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/increment-document-attribute.md b/docs/examples/kotlin/tables/get-row.md similarity index 50% rename from docs/examples/kotlin/databases/increment-document-attribute.md rename to docs/examples/kotlin/tables/get-row.md index 0ae6b02d..15dabff3 100644 --- a/docs/examples/kotlin/databases/increment-document-attribute.md +++ b/docs/examples/kotlin/tables/get-row.md @@ -1,18 +1,16 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Databases +import io.appwrite.services.Tables val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val databases = Databases(client) +val tables = Tables(client) -val result = databases.incrementDocumentAttribute( +val result = tables.getRow( databaseId = "", - collectionId = "", - documentId = "", - attribute = "", - value = 0, // (optional) - max = 0, // (optional) + tableId = "", + rowId = "", + queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/list-rows.md b/docs/examples/kotlin/tables/list-rows.md new file mode 100644 index 00000000..ff365439 --- /dev/null +++ b/docs/examples/kotlin/tables/list-rows.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tables = Tables(client) + +val result = tables.listRows( + databaseId = "", + tableId = "", + queries = listOf(), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/update-row.md b/docs/examples/kotlin/tables/update-row.md new file mode 100644 index 00000000..e9b515ce --- /dev/null +++ b/docs/examples/kotlin/tables/update-row.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tables = Tables(client) + +val result = tables.updateRow( + databaseId = "", + tableId = "", + rowId = "", + data = mapOf( "a" to "b" ), // (optional) + permissions = listOf("read("any")"), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/upsert-row.md b/docs/examples/kotlin/tables/upsert-row.md new file mode 100644 index 00000000..6b7cb666 --- /dev/null +++ b/docs/examples/kotlin/tables/upsert-row.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT("") // Your secret JSON Web Token + +val tables = Tables(client) + +val result = tables.upsertRow( + databaseId = "", + tableId = "", + rowId = "", +) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index bf0480fa..10f92555 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,8 +87,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.2.0", - "x-appwrite-response-format" to "1.7.0" + "x-sdk-version" to "9.0.0", + "x-appwrite-response-format" to "1.8.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index fdd490a3..a6ec3103 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ContinentList( /** - * Total number of continents documents that matched your query. + * Total number of continents rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index 350a8940..546cf739 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CountryList( /** - * Total number of countries documents that matched your query. + * Total number of countries rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index fe1e0013..95dec926 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CurrencyList( /** - * Total number of currencies documents that matched your query. + * Total number of currencies rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index fa3dd202..6f405791 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class DocumentList( /** - * Total number of documents documents that matched your query. + * Total number of documents rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index 322aeee7..ac11e4fb 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ExecutionList( /** - * Total number of executions documents that matched your query. + * Total number of executions rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/FileList.kt b/library/src/main/java/io/appwrite/models/FileList.kt index 5af18f1f..ba69ea8c 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class FileList( /** - * Total number of files documents that matched your query. + * Total number of files rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/IdentityList.kt b/library/src/main/java/io/appwrite/models/IdentityList.kt index 1cbb07d7..2e1a33a2 100644 --- a/library/src/main/java/io/appwrite/models/IdentityList.kt +++ b/library/src/main/java/io/appwrite/models/IdentityList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class IdentityList( /** - * Total number of identities documents that matched your query. + * Total number of identities rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index 07559b92..ab78452c 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LanguageList( /** - * Total number of languages documents that matched your query. + * Total number of languages rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt index 3973a031..6f473330 100644 --- a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt +++ b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LocaleCodeList( /** - * Total number of localeCodes documents that matched your query. + * Total number of localeCodes rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index b9f381c9..d2e0b009 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LogList( /** - * Total number of logs documents that matched your query. + * Total number of logs rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index 7feaaaaf..efcffc47 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class MembershipList( /** - * Total number of memberships documents that matched your query. + * Total number of memberships rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index b17de4fa..675295f6 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class PhoneList( /** - * Total number of phones documents that matched your query. + * Total number of phones rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/Row.kt b/library/src/main/java/io/appwrite/models/Row.kt new file mode 100644 index 00000000..bb5c14ff --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Row.kt @@ -0,0 +1,105 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Row + */ +data class Row( + /** + * Row ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Row automatically incrementing ID. + */ + @SerializedName("\$sequence") + val sequence: Long, + + /** + * Table ID. + */ + @SerializedName("\$tableId") + val tableId: String, + + /** + * Database ID. + */ + @SerializedName("\$databaseId") + val databaseId: String, + + /** + * Row creation date in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Row update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + @SerializedName("\$permissions") + val permissions: List, + + /** + * Additional properties + */ + @SerializedName("data") + val data: T +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$sequence" to sequence as Any, + "\$tableId" to tableId as Any, + "\$databaseId" to databaseId as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, + "data" to data!!.jsonCast(to = Map::class.java) + ) + + companion object { + operator fun invoke( + id: String, + sequence: Long, + tableId: String, + databaseId: String, + createdAt: String, + updatedAt: String, + permissions: List, + data: Map + ) = Row>( + id, + sequence, + tableId, + databaseId, + createdAt, + updatedAt, + permissions, + data + ) + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + nestedType: Class + ) = Row( + id = map["\$id"] as String, + sequence = (map["\$sequence"] as Number).toLong(), + tableId = map["\$tableId"] as String, + databaseId = map["\$databaseId"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, + data = map.jsonCast(to = nestedType) + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/RowList.kt b/library/src/main/java/io/appwrite/models/RowList.kt new file mode 100644 index 00000000..289f39b7 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/RowList.kt @@ -0,0 +1,46 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Rows List + */ +data class RowList( + /** + * Total number of rows rows that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of rows. + */ + @SerializedName("rows") + val rows: List>, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "rows" to rows.map { it.toMap() } as Any, + ) + + companion object { + operator fun invoke( + total: Long, + rows: List>>, + ) = RowList>( + total, + rows, + ) + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + nestedType: Class + ) = RowList( + total = (map["total"] as Number).toLong(), + rows = (map["rows"] as List>).map { Row.from(map = it, nestedType) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/SessionList.kt b/library/src/main/java/io/appwrite/models/SessionList.kt index c7080e6f..13e0c36f 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class SessionList( /** - * Total number of sessions documents that matched your query. + * Total number of sessions rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/TeamList.kt b/library/src/main/java/io/appwrite/models/TeamList.kt index 17ccd6bb..f1a19688 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class TeamList( /** - * Total number of teams documents that matched your query. + * Total number of teams rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index f50f0741..bebf4db3 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -1067,6 +1067,9 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ + @Deprecated( + message = "This API has been deprecated." + ) suspend fun updateMagicURLSession( userId: String, secret: String, @@ -1174,6 +1177,9 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ + @Deprecated( + message = "This API has been deprecated." + ) suspend fun updatePhoneSession( userId: String, secret: String, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index edc10f52..d219644b 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -23,6 +23,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.listRows"), + since = "1.8.0" + ) @JvmOverloads suspend fun listDocuments( databaseId: String, @@ -61,6 +66,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.listRows"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( @@ -84,6 +94,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.createRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun createDocument( databaseId: String, @@ -129,6 +144,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.createRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocument( @@ -155,6 +175,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.getRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun getDocument( databaseId: String, @@ -196,6 +221,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.getRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( @@ -217,17 +247,17 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. - * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. - * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @JvmOverloads + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.upsertRow"), + since = "1.8.0" + ) suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, - data: Any, - permissions: List? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -236,8 +266,6 @@ class Databases(client: Client) : Service(client) { .replace("{documentId}", documentId) val apiParams = mutableMapOf( - "data" to data, - "permissions" to permissions, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -262,24 +290,22 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. - * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. - * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @JvmOverloads + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.upsertRow"), + since = "1.8.0" + ) @Throws(AppwriteException::class) suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, - data: Any, - permissions: List? = null, ): io.appwrite.models.Document> = upsertDocument( databaseId, collectionId, documentId, - data, - permissions, nestedType = classOf(), ) @@ -293,6 +319,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.updateRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun updateDocument( databaseId: String, @@ -338,6 +369,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.updateRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun updateDocument( @@ -363,6 +399,11 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @return [Any] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.deleteRow"), + since = "1.8.0" + ) suspend fun deleteDocument( databaseId: String, collectionId: String, @@ -388,160 +429,4 @@ class Databases(client: Client) : Service(client) { } - /** - * Decrement a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to decrement the attribute by. The value must be a number. - * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - suspend fun decrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - min: Double? = null, - nestedType: Class, - ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" - .replace("{databaseId}", databaseId) - .replace("{collectionId}", collectionId) - .replace("{documentId}", documentId) - .replace("{attribute}", attribute) - - val apiParams = mutableMapOf( - "value" to value, - "min" to min, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Document = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Document.from(map = it as Map, nestedType) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Decrement a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to decrement the attribute by. The value must be a number. - * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun decrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - min: Double? = null, - ): io.appwrite.models.Document> = decrementDocumentAttribute( - databaseId, - collectionId, - documentId, - attribute, - value, - min, - nestedType = classOf(), - ) - - /** - * Increment a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to increment the attribute by. The value must be a number. - * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - suspend fun incrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - max: Double? = null, - nestedType: Class, - ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" - .replace("{databaseId}", databaseId) - .replace("{collectionId}", collectionId) - .replace("{documentId}", documentId) - .replace("{attribute}", attribute) - - val apiParams = mutableMapOf( - "value" to value, - "max" to max, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Document = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Document.from(map = it as Map, nestedType) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Increment a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to increment the attribute by. The value must be a number. - * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun incrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - max: Double? = null, - ): io.appwrite.models.Document> = incrementDocumentAttribute( - databaseId, - collectionId, - documentId, - attribute, - value, - max, - nestedType = classOf(), - ) - } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Tables.kt b/library/src/main/java/io/appwrite/services/Tables.kt new file mode 100644 index 00000000..f1ff34da --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Tables.kt @@ -0,0 +1,435 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.Service +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * The Tables service allows you to create structured tables of rows, query and filter lists of rows +**/ +class Tables(client: Client) : Service(client) { + + /** + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.RowList] + */ + @JvmOverloads + suspend fun listRows( + databaseId: String, + tableId: String, + queries: List? = null, + nestedType: Class, + ): io.appwrite.models.RowList { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.RowList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.RowList.from(map = it as Map, nestedType) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.RowList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listRows( + databaseId: String, + tableId: String, + queries: List? = null, + ): io.appwrite.models.RowList> = listRows( + databaseId, + tableId, + queries, + nestedType = classOf(), + ) + + /** + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param data Row data as JSON object. + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + + val apiParams = mutableMapOf( + "rowId" to rowId, + "data" to data, + "permissions" to permissions, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param data Row data as JSON object. + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: List? = null, + ): io.appwrite.models.Row> = createRow( + databaseId, + tableId, + rowId, + data, + permissions, + nestedType = classOf(), + ) + + /** + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rows Array of documents data as JSON objects. + * @return [io.appwrite.models.RowList] + */ + suspend fun createRows( + databaseId: String, + tableId: String, + rows: List, + nestedType: Class, + ): io.appwrite.models.RowList { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + + val apiParams = mutableMapOf( + "rows" to rows, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.RowList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.RowList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rows Array of documents data as JSON objects. + * @return [io.appwrite.models.RowList] + */ + @Throws(AppwriteException::class) + suspend fun createRows( + databaseId: String, + tableId: String, + rows: List, + ): io.appwrite.models.RowList> = createRows( + databaseId, + tableId, + rows, + nestedType = classOf(), + ) + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param rowId Row ID. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param rowId Row ID. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: List? = null, + ): io.appwrite.models.Row> = getRow( + databaseId, + tableId, + rowId, + queries, + nestedType = classOf(), + ) + + /** + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @return [io.appwrite.models.Row] + */ + suspend fun upsertRow( + databaseId: String, + tableId: String, + rowId: String, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @return [io.appwrite.models.Row] + */ + @Throws(AppwriteException::class) + suspend fun upsertRow( + databaseId: String, + tableId: String, + rowId: String, + ): io.appwrite.models.Row> = upsertRow( + databaseId, + tableId, + rowId, + nestedType = classOf(), + ) + + /** + * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param data Row data as JSON object. Include only columns and value pairs to be updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = null, + permissions: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + "data" to data, + "permissions" to permissions, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param data Row data as JSON object. Include only columns and value pairs to be updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = null, + permissions: List? = null, + ): io.appwrite.models.Row> = updateRow( + databaseId, + tableId, + rowId, + data, + permissions, + nestedType = classOf(), + ) + + /** + * Delete a row by its unique ID. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param rowId Row ID. + * @return [Any] + */ + suspend fun deleteRow( + databaseId: String, + tableId: String, + rowId: String, + ): Any { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + +} \ No newline at end of file From a52f013463eb61619fa9e75be67ffb4831eb7f60 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:35:45 +0000 Subject: [PATCH 3/4] chore: regen --- README.md | 8 +- .../java/databases/create-document.md | 4 +- .../decrement-document-attribute.md} | 13 +- .../increment-document-attribute.md} | 15 +- .../java/databases/upsert-document.md | 6 +- docs/examples/java/tables/create-row.md | 28 -- docs/examples/java/tables/create-rows.md | 25 - docs/examples/java/tables/delete-row.md | 24 - docs/examples/java/tables/get-row.md | 25 - docs/examples/java/tables/upsert-row.md | 26 -- .../kotlin/databases/create-document.md | 4 +- .../decrement-document-attribute.md} | 15 +- .../increment-document-attribute.md} | 14 +- .../kotlin/databases/upsert-document.md | 6 +- docs/examples/kotlin/tables/create-row.md | 19 - docs/examples/kotlin/tables/create-rows.md | 16 - docs/examples/kotlin/tables/delete-row.md | 15 - docs/examples/kotlin/tables/list-rows.md | 15 - docs/examples/kotlin/tables/upsert-row.md | 17 - library/src/main/java/io/appwrite/Client.kt | 4 +- .../java/io/appwrite/models/ContinentList.kt | 2 +- .../java/io/appwrite/models/CountryList.kt | 2 +- .../java/io/appwrite/models/CurrencyList.kt | 2 +- .../java/io/appwrite/models/DocumentList.kt | 2 +- .../java/io/appwrite/models/ExecutionList.kt | 2 +- .../main/java/io/appwrite/models/FileList.kt | 2 +- .../java/io/appwrite/models/IdentityList.kt | 2 +- .../java/io/appwrite/models/LanguageList.kt | 2 +- .../java/io/appwrite/models/LocaleCodeList.kt | 2 +- .../main/java/io/appwrite/models/LogList.kt | 2 +- .../java/io/appwrite/models/MembershipList.kt | 2 +- .../main/java/io/appwrite/models/PhoneList.kt | 2 +- .../src/main/java/io/appwrite/models/Row.kt | 105 ----- .../main/java/io/appwrite/models/RowList.kt | 46 -- .../java/io/appwrite/models/SessionList.kt | 2 +- .../main/java/io/appwrite/models/TeamList.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 6 - .../java/io/appwrite/services/Databases.kt | 225 ++++++--- .../main/java/io/appwrite/services/Tables.kt | 435 ------------------ 39 files changed, 230 insertions(+), 914 deletions(-) rename docs/examples/java/{tables/list-rows.md => databases/decrement-document-attribute.md} (64%) rename docs/examples/java/{tables/update-row.md => databases/increment-document-attribute.md} (64%) delete mode 100644 docs/examples/java/tables/create-row.md delete mode 100644 docs/examples/java/tables/create-rows.md delete mode 100644 docs/examples/java/tables/delete-row.md delete mode 100644 docs/examples/java/tables/get-row.md delete mode 100644 docs/examples/java/tables/upsert-row.md rename docs/examples/kotlin/{tables/update-row.md => databases/decrement-document-attribute.md} (50%) rename docs/examples/kotlin/{tables/get-row.md => databases/increment-document-attribute.md} (50%) delete mode 100644 docs/examples/kotlin/tables/create-row.md delete mode 100644 docs/examples/kotlin/tables/create-rows.md delete mode 100644 docs/examples/kotlin/tables/delete-row.md delete mode 100644 docs/examples/kotlin/tables/list-rows.md delete mode 100644 docs/examples/kotlin/tables/upsert-row.md delete mode 100644 library/src/main/java/io/appwrite/models/Row.kt delete mode 100644 library/src/main/java/io/appwrite/models/RowList.kt delete mode 100644 library/src/main/java/io/appwrite/services/Tables.kt diff --git a/README.md b/README.md index 5ced4530..745f21ca 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ ![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/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 Android 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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:9.0.0") +implementation("io.appwrite:sdk-for-android:8.2.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 9.0.0 + 8.2.0 ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 7fb129bb..4804d751 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,9 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT(""); // Your secret JSON Web Token + .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/tables/list-rows.md b/docs/examples/java/databases/decrement-document-attribute.md similarity index 64% rename from docs/examples/java/tables/list-rows.md rename to docs/examples/java/databases/decrement-document-attribute.md index 4d375702..de6a4ab4 100644 --- a/docs/examples/java/tables/list-rows.md +++ b/docs/examples/java/databases/decrement-document-attribute.md @@ -1,17 +1,20 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; +import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Tables tables = new Tables(client); +Databases databases = new Databases(client); -tables.listRows( +databases.decrementDocumentAttribute( "", // databaseId - "", // tableId - listOf(), // queries (optional) + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // min (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tables/update-row.md b/docs/examples/java/databases/increment-document-attribute.md similarity index 64% rename from docs/examples/java/tables/update-row.md rename to docs/examples/java/databases/increment-document-attribute.md index 0421c9cf..94ffa9d7 100644 --- a/docs/examples/java/tables/update-row.md +++ b/docs/examples/java/databases/increment-document-attribute.md @@ -1,19 +1,20 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; +import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Tables tables = new Tables(client); +Databases databases = new Databases(client); -tables.updateRow( +databases.incrementDocumentAttribute( "", // databaseId - "", // tableId - "", // rowId - mapOf( "a" to "b" ), // data (optional) - listOf("read("any")"), // permissions (optional) + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // max (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/upsert-document.md b/docs/examples/java/databases/upsert-document.md index ba7336f3..868576b9 100644 --- a/docs/examples/java/databases/upsert-document.md +++ b/docs/examples/java/databases/upsert-document.md @@ -4,9 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT(""); // Your secret JSON Web Token + .setProject(""); // Your project ID Databases databases = new Databases(client); @@ -14,6 +12,8 @@ databases.upsertDocument( "", // databaseId "", // collectionId "", // documentId + mapOf( "a" to "b" ), // data + listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tables/create-row.md b/docs/examples/java/tables/create-row.md deleted file mode 100644 index 8102b82c..00000000 --- a/docs/examples/java/tables/create-row.md +++ /dev/null @@ -1,28 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT(""); // Your secret JSON Web Token - -Tables tables = new Tables(client); - -tables.createRow( - "", // databaseId - "", // tableId - "", // rowId - mapOf( "a" to "b" ), // data - listOf("read("any")"), // permissions (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/tables/create-rows.md b/docs/examples/java/tables/create-rows.md deleted file mode 100644 index 26f5d677..00000000 --- a/docs/examples/java/tables/create-rows.md +++ /dev/null @@ -1,25 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // - .setKey(""); // - -Tables tables = new Tables(client); - -tables.createRows( - "", // databaseId - "", // tableId - listOf(), // rows - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/tables/delete-row.md b/docs/examples/java/tables/delete-row.md deleted file mode 100644 index 596a8b7a..00000000 --- a/docs/examples/java/tables/delete-row.md +++ /dev/null @@ -1,24 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Tables tables = new Tables(client); - -tables.deleteRow( - "", // databaseId - "", // tableId - "", // rowId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/tables/get-row.md b/docs/examples/java/tables/get-row.md deleted file mode 100644 index 882a1953..00000000 --- a/docs/examples/java/tables/get-row.md +++ /dev/null @@ -1,25 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Tables tables = new Tables(client); - -tables.getRow( - "", // databaseId - "", // tableId - "", // rowId - listOf(), // queries (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/tables/upsert-row.md b/docs/examples/java/tables/upsert-row.md deleted file mode 100644 index a8be0cfc..00000000 --- a/docs/examples/java/tables/upsert-row.md +++ /dev/null @@ -1,26 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT(""); // Your secret JSON Web Token - -Tables tables = new Tables(client); - -tables.upsertRow( - "", // databaseId - "", // tableId - "", // rowId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 0bafb315..849a636a 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,9 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT("") // Your secret JSON Web Token + .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/tables/update-row.md b/docs/examples/kotlin/databases/decrement-document-attribute.md similarity index 50% rename from docs/examples/kotlin/tables/update-row.md rename to docs/examples/kotlin/databases/decrement-document-attribute.md index e9b515ce..c500fa86 100644 --- a/docs/examples/kotlin/tables/update-row.md +++ b/docs/examples/kotlin/databases/decrement-document-attribute.md @@ -1,17 +1,18 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables +import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tables = Tables(client) +val databases = Databases(client) -val result = tables.updateRow( +val result = databases.decrementDocumentAttribute( databaseId = "", - tableId = "", - rowId = "", - data = mapOf( "a" to "b" ), // (optional) - permissions = listOf("read("any")"), // (optional) + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + min = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/get-row.md b/docs/examples/kotlin/databases/increment-document-attribute.md similarity index 50% rename from docs/examples/kotlin/tables/get-row.md rename to docs/examples/kotlin/databases/increment-document-attribute.md index 15dabff3..0ae6b02d 100644 --- a/docs/examples/kotlin/tables/get-row.md +++ b/docs/examples/kotlin/databases/increment-document-attribute.md @@ -1,16 +1,18 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables +import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tables = Tables(client) +val databases = Databases(client) -val result = tables.getRow( +val result = databases.incrementDocumentAttribute( databaseId = "", - tableId = "", - rowId = "", - queries = listOf(), // (optional) + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + max = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/upsert-document.md b/docs/examples/kotlin/databases/upsert-document.md index 7939fde2..a31dfc87 100644 --- a/docs/examples/kotlin/databases/upsert-document.md +++ b/docs/examples/kotlin/databases/upsert-document.md @@ -4,9 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT("") // Your secret JSON Web Token + .setProject("") // Your project ID val databases = Databases(client) @@ -14,4 +12,6 @@ val result = databases.upsertDocument( databaseId = "", collectionId = "", documentId = "", + data = mapOf( "a" to "b" ), + permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/create-row.md b/docs/examples/kotlin/tables/create-row.md deleted file mode 100644 index 8c581bf1..00000000 --- a/docs/examples/kotlin/tables/create-row.md +++ /dev/null @@ -1,19 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT("") // Your secret JSON Web Token - -val tables = Tables(client) - -val result = tables.createRow( - databaseId = "", - tableId = "", - rowId = "", - data = mapOf( "a" to "b" ), - permissions = listOf("read("any")"), // (optional) -) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/create-rows.md b/docs/examples/kotlin/tables/create-rows.md deleted file mode 100644 index 1fde9c50..00000000 --- a/docs/examples/kotlin/tables/create-rows.md +++ /dev/null @@ -1,16 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // - .setKey("") // - -val tables = Tables(client) - -val result = tables.createRows( - databaseId = "", - tableId = "", - rows = listOf(), -) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/delete-row.md b/docs/examples/kotlin/tables/delete-row.md deleted file mode 100644 index ffa3229f..00000000 --- a/docs/examples/kotlin/tables/delete-row.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val tables = Tables(client) - -val result = tables.deleteRow( - databaseId = "", - tableId = "", - rowId = "", -) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/list-rows.md b/docs/examples/kotlin/tables/list-rows.md deleted file mode 100644 index ff365439..00000000 --- a/docs/examples/kotlin/tables/list-rows.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val tables = Tables(client) - -val result = tables.listRows( - databaseId = "", - tableId = "", - queries = listOf(), // (optional) -) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/upsert-row.md b/docs/examples/kotlin/tables/upsert-row.md deleted file mode 100644 index 6b7cb666..00000000 --- a/docs/examples/kotlin/tables/upsert-row.md +++ /dev/null @@ -1,17 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT("") // Your secret JSON Web Token - -val tables = Tables(client) - -val result = tables.upsertRow( - databaseId = "", - tableId = "", - rowId = "", -) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 10f92555..bf0480fa 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,8 +87,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "9.0.0", - "x-appwrite-response-format" to "1.8.0" + "x-sdk-version" to "8.2.0", + "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index a6ec3103..fdd490a3 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ContinentList( /** - * Total number of continents rows that matched your query. + * Total number of continents documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index 546cf739..350a8940 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CountryList( /** - * Total number of countries rows that matched your query. + * Total number of countries documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index 95dec926..fe1e0013 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CurrencyList( /** - * Total number of currencies rows that matched your query. + * Total number of currencies documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index 6f405791..fa3dd202 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class DocumentList( /** - * Total number of documents rows that matched your query. + * Total number of documents documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index ac11e4fb..322aeee7 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ExecutionList( /** - * Total number of executions rows that matched your query. + * Total number of executions documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/FileList.kt b/library/src/main/java/io/appwrite/models/FileList.kt index ba69ea8c..5af18f1f 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class FileList( /** - * Total number of files rows that matched your query. + * Total number of files documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/IdentityList.kt b/library/src/main/java/io/appwrite/models/IdentityList.kt index 2e1a33a2..1cbb07d7 100644 --- a/library/src/main/java/io/appwrite/models/IdentityList.kt +++ b/library/src/main/java/io/appwrite/models/IdentityList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class IdentityList( /** - * Total number of identities rows that matched your query. + * Total number of identities documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index ab78452c..07559b92 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LanguageList( /** - * Total number of languages rows that matched your query. + * Total number of languages documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt index 6f473330..3973a031 100644 --- a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt +++ b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LocaleCodeList( /** - * Total number of localeCodes rows that matched your query. + * Total number of localeCodes documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index d2e0b009..b9f381c9 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LogList( /** - * Total number of logs rows that matched your query. + * Total number of logs documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index efcffc47..7feaaaaf 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class MembershipList( /** - * Total number of memberships rows that matched your query. + * Total number of memberships documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index 675295f6..b17de4fa 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class PhoneList( /** - * Total number of phones rows that matched your query. + * Total number of phones documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/Row.kt b/library/src/main/java/io/appwrite/models/Row.kt deleted file mode 100644 index bb5c14ff..00000000 --- a/library/src/main/java/io/appwrite/models/Row.kt +++ /dev/null @@ -1,105 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Row - */ -data class Row( - /** - * Row ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * Row automatically incrementing ID. - */ - @SerializedName("\$sequence") - val sequence: Long, - - /** - * Table ID. - */ - @SerializedName("\$tableId") - val tableId: String, - - /** - * Database ID. - */ - @SerializedName("\$databaseId") - val databaseId: String, - - /** - * Row creation date in ISO 8601 format. - */ - @SerializedName("\$createdAt") - val createdAt: String, - - /** - * Row update date in ISO 8601 format. - */ - @SerializedName("\$updatedAt") - val updatedAt: String, - - /** - * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - @SerializedName("\$permissions") - val permissions: List, - - /** - * Additional properties - */ - @SerializedName("data") - val data: T -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$sequence" to sequence as Any, - "\$tableId" to tableId as Any, - "\$databaseId" to databaseId as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "\$permissions" to permissions as Any, - "data" to data!!.jsonCast(to = Map::class.java) - ) - - companion object { - operator fun invoke( - id: String, - sequence: Long, - tableId: String, - databaseId: String, - createdAt: String, - updatedAt: String, - permissions: List, - data: Map - ) = Row>( - id, - sequence, - tableId, - databaseId, - createdAt, - updatedAt, - permissions, - data - ) - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - nestedType: Class - ) = Row( - id = map["\$id"] as String, - sequence = (map["\$sequence"] as Number).toLong(), - tableId = map["\$tableId"] as String, - databaseId = map["\$databaseId"] as String, - createdAt = map["\$createdAt"] as String, - updatedAt = map["\$updatedAt"] as String, - permissions = map["\$permissions"] as List, - data = map.jsonCast(to = nestedType) - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/RowList.kt b/library/src/main/java/io/appwrite/models/RowList.kt deleted file mode 100644 index 289f39b7..00000000 --- a/library/src/main/java/io/appwrite/models/RowList.kt +++ /dev/null @@ -1,46 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Rows List - */ -data class RowList( - /** - * Total number of rows rows that matched your query. - */ - @SerializedName("total") - val total: Long, - - /** - * List of rows. - */ - @SerializedName("rows") - val rows: List>, - -) { - fun toMap(): Map = mapOf( - "total" to total as Any, - "rows" to rows.map { it.toMap() } as Any, - ) - - companion object { - operator fun invoke( - total: Long, - rows: List>>, - ) = RowList>( - total, - rows, - ) - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - nestedType: Class - ) = RowList( - total = (map["total"] as Number).toLong(), - rows = (map["rows"] as List>).map { Row.from(map = it, nestedType) }, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/SessionList.kt b/library/src/main/java/io/appwrite/models/SessionList.kt index 13e0c36f..c7080e6f 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class SessionList( /** - * Total number of sessions rows that matched your query. + * Total number of sessions documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/TeamList.kt b/library/src/main/java/io/appwrite/models/TeamList.kt index f1a19688..17ccd6bb 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class TeamList( /** - * Total number of teams rows that matched your query. + * Total number of teams documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index bebf4db3..f50f0741 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -1067,9 +1067,6 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ - @Deprecated( - message = "This API has been deprecated." - ) suspend fun updateMagicURLSession( userId: String, secret: String, @@ -1177,9 +1174,6 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ - @Deprecated( - message = "This API has been deprecated." - ) suspend fun updatePhoneSession( userId: String, secret: String, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index d219644b..edc10f52 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -23,11 +23,6 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.listRows"), - since = "1.8.0" - ) @JvmOverloads suspend fun listDocuments( databaseId: String, @@ -66,11 +61,6 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.listRows"), - since = "1.8.0" - ) @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( @@ -94,11 +84,6 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.createRow"), - since = "1.8.0" - ) @JvmOverloads suspend fun createDocument( databaseId: String, @@ -144,11 +129,6 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.createRow"), - since = "1.8.0" - ) @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocument( @@ -175,11 +155,6 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.getRow"), - since = "1.8.0" - ) @JvmOverloads suspend fun getDocument( databaseId: String, @@ -221,11 +196,6 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.getRow"), - since = "1.8.0" - ) @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( @@ -247,17 +217,17 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. + * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.upsertRow"), - since = "1.8.0" - ) + @JvmOverloads suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, + data: Any, + permissions: List? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -266,6 +236,8 @@ class Databases(client: Client) : Service(client) { .replace("{documentId}", documentId) val apiParams = mutableMapOf( + "data" to data, + "permissions" to permissions, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -290,22 +262,24 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. + * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.upsertRow"), - since = "1.8.0" - ) + @JvmOverloads @Throws(AppwriteException::class) suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, + data: Any, + permissions: List? = null, ): io.appwrite.models.Document> = upsertDocument( databaseId, collectionId, documentId, + data, + permissions, nestedType = classOf(), ) @@ -319,11 +293,6 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.updateRow"), - since = "1.8.0" - ) @JvmOverloads suspend fun updateDocument( databaseId: String, @@ -369,11 +338,6 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.updateRow"), - since = "1.8.0" - ) @JvmOverloads @Throws(AppwriteException::class) suspend fun updateDocument( @@ -399,11 +363,6 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @return [Any] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.deleteRow"), - since = "1.8.0" - ) suspend fun deleteDocument( databaseId: String, collectionId: String, @@ -429,4 +388,160 @@ class Databases(client: Client) : Service(client) { } + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to decrement the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "min" to min, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to decrement the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + ): io.appwrite.models.Document> = decrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + min, + nestedType = classOf(), + ) + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "max" to max, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + ): io.appwrite.models.Document> = incrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + max, + nestedType = classOf(), + ) + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Tables.kt b/library/src/main/java/io/appwrite/services/Tables.kt deleted file mode 100644 index f1ff34da..00000000 --- a/library/src/main/java/io/appwrite/services/Tables.kt +++ /dev/null @@ -1,435 +0,0 @@ -package io.appwrite.services - -import android.net.Uri -import io.appwrite.Client -import io.appwrite.Service -import io.appwrite.models.* -import io.appwrite.enums.* -import io.appwrite.exceptions.AppwriteException -import io.appwrite.extensions.classOf -import okhttp3.Cookie -import java.io.File - -/** - * The Tables service allows you to create structured tables of rows, query and filter lists of rows -**/ -class Tables(client: Client) : Service(client) { - - /** - * Get a list of all the user's rows in a given table. You can use the query params to filter your results. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @return [io.appwrite.models.RowList] - */ - @JvmOverloads - suspend fun listRows( - databaseId: String, - tableId: String, - queries: List? = null, - nestedType: Class, - ): io.appwrite.models.RowList { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - - val apiParams = mutableMapOf( - "queries" to queries, - ) - val apiHeaders = mutableMapOf( - ) - val converter: (Any) -> io.appwrite.models.RowList = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.RowList.from(map = it as Map, nestedType) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Get a list of all the user's rows in a given table. You can use the query params to filter your results. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @return [io.appwrite.models.RowList] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listRows( - databaseId: String, - tableId: String, - queries: List? = null, - ): io.appwrite.models.RowList> = listRows( - databaseId, - tableId, - queries, - nestedType = classOf(), - ) - - /** - * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. - * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param data Row data as JSON object. - * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - suspend fun createRow( - databaseId: String, - tableId: String, - rowId: String, - data: Any, - permissions: List? = null, - nestedType: Class, - ): io.appwrite.models.Row { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - - val apiParams = mutableMapOf( - "rowId" to rowId, - "data" to data, - "permissions" to permissions, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Row = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Row.from(map = it as Map, nestedType) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. - * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param data Row data as JSON object. - * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createRow( - databaseId: String, - tableId: String, - rowId: String, - data: Any, - permissions: List? = null, - ): io.appwrite.models.Row> = createRow( - databaseId, - tableId, - rowId, - data, - permissions, - nestedType = classOf(), - ) - - /** - * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. - * @param rows Array of documents data as JSON objects. - * @return [io.appwrite.models.RowList] - */ - suspend fun createRows( - databaseId: String, - tableId: String, - rows: List, - nestedType: Class, - ): io.appwrite.models.RowList { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - - val apiParams = mutableMapOf( - "rows" to rows, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.RowList = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.RowList.from(map = it as Map, nestedType) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. - * @param rows Array of documents data as JSON objects. - * @return [io.appwrite.models.RowList] - */ - @Throws(AppwriteException::class) - suspend fun createRows( - databaseId: String, - tableId: String, - rows: List, - ): io.appwrite.models.RowList> = createRows( - databaseId, - tableId, - rows, - nestedType = classOf(), - ) - - /** - * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param rowId Row ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - suspend fun getRow( - databaseId: String, - tableId: String, - rowId: String, - queries: List? = null, - nestedType: Class, - ): io.appwrite.models.Row { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - .replace("{rowId}", rowId) - - val apiParams = mutableMapOf( - "queries" to queries, - ) - val apiHeaders = mutableMapOf( - ) - val converter: (Any) -> io.appwrite.models.Row = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Row.from(map = it as Map, nestedType) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param rowId Row ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getRow( - databaseId: String, - tableId: String, - rowId: String, - queries: List? = null, - ): io.appwrite.models.Row> = getRow( - databaseId, - tableId, - rowId, - queries, - nestedType = classOf(), - ) - - /** - * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. - * @param rowId Row ID. - * @return [io.appwrite.models.Row] - */ - suspend fun upsertRow( - databaseId: String, - tableId: String, - rowId: String, - nestedType: Class, - ): io.appwrite.models.Row { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - .replace("{rowId}", rowId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Row = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Row.from(map = it as Map, nestedType) - } - return client.call( - "PUT", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. - * @param rowId Row ID. - * @return [io.appwrite.models.Row] - */ - @Throws(AppwriteException::class) - suspend fun upsertRow( - databaseId: String, - tableId: String, - rowId: String, - ): io.appwrite.models.Row> = upsertRow( - databaseId, - tableId, - rowId, - nestedType = classOf(), - ) - - /** - * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * - * @param databaseId Database ID. - * @param tableId Table ID. - * @param rowId Row ID. - * @param data Row data as JSON object. Include only columns and value pairs to be updated. - * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - suspend fun updateRow( - databaseId: String, - tableId: String, - rowId: String, - data: Any? = null, - permissions: List? = null, - nestedType: Class, - ): io.appwrite.models.Row { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - .replace("{rowId}", rowId) - - val apiParams = mutableMapOf( - "data" to data, - "permissions" to permissions, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Row = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Row.from(map = it as Map, nestedType) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * - * @param databaseId Database ID. - * @param tableId Table ID. - * @param rowId Row ID. - * @param data Row data as JSON object. Include only columns and value pairs to be updated. - * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateRow( - databaseId: String, - tableId: String, - rowId: String, - data: Any? = null, - permissions: List? = null, - ): io.appwrite.models.Row> = updateRow( - databaseId, - tableId, - rowId, - data, - permissions, - nestedType = classOf(), - ) - - /** - * Delete a row by its unique ID. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param rowId Row ID. - * @return [Any] - */ - suspend fun deleteRow( - databaseId: String, - tableId: String, - rowId: String, - ): Any { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - .replace("{rowId}", rowId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - return client.call( - "DELETE", - apiPath, - apiHeaders, - apiParams, - responseType = Any::class.java, - ) - } - - -} \ No newline at end of file From b36d2af7e125a6e858c7714cbc5bd5a65f727cb6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:39:21 +0000 Subject: [PATCH 4/4] chore: add changelog --- CHANGELOG.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8406e637..38d0c4be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,23 @@ # Change Log +## 8.2.0 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `gif` support to `ImageFormat` enum +* Add `sequence` support to `Document` model + +## 8.1.0 + +* Add `devKeys` support to `Client` service +* Add `upsertDocument` support to `Databases` service + ## 8.0.0 * Add `token` param to `getFilePreview` and `getFileView` for File tokens usage * Update default `quality` for `getFilePreview` from 0 to -1 * Remove `Gif` from ImageFormat enum -* Remove `search` param from `listExecutions` method \ No newline at end of file +* Remove `search` param from `listExecutions` method + +## 7.0.1 + +* Fix requests failing by removing `Content-Type` header from `GET` and `HEAD` requests