chore: regen

This commit is contained in:
root
2025-07-24 06:35:45 +00:00
parent 49bf798964
commit a52f013463
39 changed files with 230 additions and 914 deletions
+4 -4
View File
@@ -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:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-android</artifactId>
<version>9.0.0</version>
<version>8.2.0</version>
</dependency>
</dependencies>
```
@@ -4,9 +4,7 @@ import io.appwrite.services.Databases;
Client client = new Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setSession("") // The user session to authenticate with
.setKey("") //
.setJWT("<YOUR_JWT>"); // Your secret JSON Web Token
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
Databases databases = new Databases(client);
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
Tables tables = new Tables(client);
Databases databases = new Databases(client);
tables.listRows(
databases.decrementDocumentAttribute(
"<DATABASE_ID>", // databaseId
"<TABLE_ID>", // tableId
listOf(), // queries (optional)
"<COLLECTION_ID>", // collectionId
"<DOCUMENT_ID>", // documentId
"", // attribute
0, // value (optional)
0, // min (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
Tables tables = new Tables(client);
Databases databases = new Databases(client);
tables.updateRow(
databases.incrementDocumentAttribute(
"<DATABASE_ID>", // databaseId
"<TABLE_ID>", // tableId
"<ROW_ID>", // rowId
mapOf( "a" to "b" ), // data (optional)
listOf("read("any")"), // permissions (optional)
"<COLLECTION_ID>", // collectionId
"<DOCUMENT_ID>", // documentId
"", // attribute
0, // value (optional)
0, // max (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
@@ -4,9 +4,7 @@ import io.appwrite.services.Databases;
Client client = new Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setSession("") // The user session to authenticate with
.setKey("") //
.setJWT("<YOUR_JWT>"); // Your secret JSON Web Token
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
Databases databases = new Databases(client);
@@ -14,6 +12,8 @@ databases.upsertDocument(
"<DATABASE_ID>", // databaseId
"<COLLECTION_ID>", // collectionId
"<DOCUMENT_ID>", // documentId
mapOf( "a" to "b" ), // data
listOf("read("any")"), // permissions (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
-28
View File
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setSession("") // The user session to authenticate with
.setKey("") //
.setJWT("<YOUR_JWT>"); // Your secret JSON Web Token
Tables tables = new Tables(client);
tables.createRow(
"<DATABASE_ID>", // databaseId
"<TABLE_ID>", // tableId
"<ROW_ID>", // 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());
})
);
-25
View File
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setAdmin("") //
.setKey(""); //
Tables tables = new Tables(client);
tables.createRows(
"<DATABASE_ID>", // databaseId
"<TABLE_ID>", // tableId
listOf(), // rows
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}
Log.d("Appwrite", result.toString());
})
);
-24
View File
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
Tables tables = new Tables(client);
tables.deleteRow(
"<DATABASE_ID>", // databaseId
"<TABLE_ID>", // tableId
"<ROW_ID>", // rowId
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}
Log.d("Appwrite", result.toString());
})
);
-25
View File
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
Tables tables = new Tables(client);
tables.getRow(
"<DATABASE_ID>", // databaseId
"<TABLE_ID>", // tableId
"<ROW_ID>", // rowId
listOf(), // queries (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}
Log.d("Appwrite", result.toString());
})
);
-26
View File
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setSession("") // The user session to authenticate with
.setKey("") //
.setJWT("<YOUR_JWT>"); // Your secret JSON Web Token
Tables tables = new Tables(client);
tables.upsertRow(
"<DATABASE_ID>", // databaseId
"<TABLE_ID>", // tableId
"<ROW_ID>", // rowId
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}
Log.d("Appwrite", result.toString());
})
);
@@ -4,9 +4,7 @@ import io.appwrite.services.Databases
val client = Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setSession("") // The user session to authenticate with
.setKey("") //
.setJWT("<YOUR_JWT>") // Your secret JSON Web Token
.setProject("<YOUR_PROJECT_ID>") // Your project ID
val databases = Databases(client)
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
val tables = Tables(client)
val databases = Databases(client)
val result = tables.updateRow(
val result = databases.decrementDocumentAttribute(
databaseId = "<DATABASE_ID>",
tableId = "<TABLE_ID>",
rowId = "<ROW_ID>",
data = mapOf( "a" to "b" ), // (optional)
permissions = listOf("read("any")"), // (optional)
collectionId = "<COLLECTION_ID>",
documentId = "<DOCUMENT_ID>",
attribute = "",
value = 0, // (optional)
min = 0, // (optional)
)
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
val tables = Tables(client)
val databases = Databases(client)
val result = tables.getRow(
val result = databases.incrementDocumentAttribute(
databaseId = "<DATABASE_ID>",
tableId = "<TABLE_ID>",
rowId = "<ROW_ID>",
queries = listOf(), // (optional)
collectionId = "<COLLECTION_ID>",
documentId = "<DOCUMENT_ID>",
attribute = "",
value = 0, // (optional)
max = 0, // (optional)
)
@@ -4,9 +4,7 @@ import io.appwrite.services.Databases
val client = Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setSession("") // The user session to authenticate with
.setKey("") //
.setJWT("<YOUR_JWT>") // Your secret JSON Web Token
.setProject("<YOUR_PROJECT_ID>") // Your project ID
val databases = Databases(client)
@@ -14,4 +12,6 @@ val result = databases.upsertDocument(
databaseId = "<DATABASE_ID>",
collectionId = "<COLLECTION_ID>",
documentId = "<DOCUMENT_ID>",
data = mapOf( "a" to "b" ),
permissions = listOf("read("any")"), // (optional)
)
-19
View File
@@ -1,19 +0,0 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Tables
val client = Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setSession("") // The user session to authenticate with
.setKey("") //
.setJWT("<YOUR_JWT>") // Your secret JSON Web Token
val tables = Tables(client)
val result = tables.createRow(
databaseId = "<DATABASE_ID>",
tableId = "<TABLE_ID>",
rowId = "<ROW_ID>",
data = mapOf( "a" to "b" ),
permissions = listOf("read("any")"), // (optional)
)
@@ -1,16 +0,0 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Tables
val client = Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setAdmin("") //
.setKey("") //
val tables = Tables(client)
val result = tables.createRows(
databaseId = "<DATABASE_ID>",
tableId = "<TABLE_ID>",
rows = listOf(),
)
-15
View File
@@ -1,15 +0,0 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Tables
val client = Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
val tables = Tables(client)
val result = tables.deleteRow(
databaseId = "<DATABASE_ID>",
tableId = "<TABLE_ID>",
rowId = "<ROW_ID>",
)
-15
View File
@@ -1,15 +0,0 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Tables
val client = Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
val tables = Tables(client)
val result = tables.listRows(
databaseId = "<DATABASE_ID>",
tableId = "<TABLE_ID>",
queries = listOf(), // (optional)
)
-17
View File
@@ -1,17 +0,0 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Tables
val client = Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setSession("") // The user session to authenticate with
.setKey("") //
.setJWT("<YOUR_JWT>") // Your secret JSON Web Token
val tables = Tables(client)
val result = tables.upsertRow(
databaseId = "<DATABASE_ID>",
tableId = "<TABLE_ID>",
rowId = "<ROW_ID>",
)
+2 -2
View File
@@ -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()
@@ -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,
@@ -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,
@@ -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,
@@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast
*/
data class DocumentList<T>(
/**
* Total number of documents rows that matched your query.
* Total number of documents documents that matched your query.
*/
@SerializedName("total")
val total: Long,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -1,105 +0,0 @@
package io.appwrite.models
import com.google.gson.annotations.SerializedName
import io.appwrite.extensions.jsonCast
/**
* Row
*/
data class Row<T>(
/**
* 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<String>,
/**
* Additional properties
*/
@SerializedName("data")
val data: T
) {
fun toMap(): Map<String, Any> = 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<String>,
data: Map<String, Any>
) = Row<Map<String, Any>>(
id,
sequence,
tableId,
databaseId,
createdAt,
updatedAt,
permissions,
data
)
@Suppress("UNCHECKED_CAST")
fun <T> from(
map: Map<String, Any>,
nestedType: Class<T>
) = Row<T>(
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<String>,
data = map.jsonCast(to = nestedType)
)
}
}
@@ -1,46 +0,0 @@
package io.appwrite.models
import com.google.gson.annotations.SerializedName
import io.appwrite.extensions.jsonCast
/**
* Rows List
*/
data class RowList<T>(
/**
* Total number of rows rows that matched your query.
*/
@SerializedName("total")
val total: Long,
/**
* List of rows.
*/
@SerializedName("rows")
val rows: List<Row<T>>,
) {
fun toMap(): Map<String, Any> = mapOf(
"total" to total as Any,
"rows" to rows.map { it.toMap() } as Any,
)
companion object {
operator fun invoke(
total: Long,
rows: List<Row<Map<String, Any>>>,
) = RowList<Map<String, Any>>(
total,
rows,
)
@Suppress("UNCHECKED_CAST")
fun <T> from(
map: Map<String, Any>,
nestedType: Class<T>
) = RowList<T>(
total = (map["total"] as Number).toLong(),
rows = (map["rows"] as List<Map<String, Any>>).map { Row.from(map = it, nestedType) },
)
}
}
@@ -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,
@@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast
*/
data class TeamList<T>(
/**
* Total number of teams rows that matched your query.
* Total number of teams documents that matched your query.
*/
@SerializedName("total")
val total: Long,
@@ -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,
@@ -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<T>]
*/
@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 <T> 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<T>]
*/
@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<T>]
*/
@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 <T> 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<T>]
*/
@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<T>]
*/
@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 <T> 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<T>]
*/
@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<T>]
*/
@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 <T> upsertDocument(
databaseId: String,
collectionId: String,
documentId: String,
data: Any,
permissions: List<String>? = null,
nestedType: Class<T>,
): io.appwrite.models.Document<T> {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}"
@@ -266,6 +236,8 @@ class Databases(client: Client) : Service(client) {
.replace("{documentId}", documentId)
val apiParams = mutableMapOf<String, Any?>(
"data" to data,
"permissions" to permissions,
)
val apiHeaders = mutableMapOf<String, String>(
"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<T>]
*/
@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<String>? = null,
): io.appwrite.models.Document<Map<String, Any>> = 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<T>]
*/
@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 <T> 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<T>]
*/
@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<T>]
*/
@JvmOverloads
suspend fun <T> decrementDocumentAttribute(
databaseId: String,
collectionId: String,
documentId: String,
attribute: String,
value: Double? = null,
min: Double? = null,
nestedType: Class<T>,
): io.appwrite.models.Document<T> {
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<String, Any?>(
"value" to value,
"min" to min,
)
val apiHeaders = mutableMapOf<String, String>(
"content-type" to "application/json",
)
val converter: (Any) -> io.appwrite.models.Document<T> = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.Document.from(map = it as Map<String, Any>, 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<T>]
*/
@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<Map<String, Any>> = 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<T>]
*/
@JvmOverloads
suspend fun <T> incrementDocumentAttribute(
databaseId: String,
collectionId: String,
documentId: String,
attribute: String,
value: Double? = null,
max: Double? = null,
nestedType: Class<T>,
): io.appwrite.models.Document<T> {
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<String, Any?>(
"value" to value,
"max" to max,
)
val apiHeaders = mutableMapOf<String, String>(
"content-type" to "application/json",
)
val converter: (Any) -> io.appwrite.models.Document<T> = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.Document.from(map = it as Map<String, Any>, 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<T>]
*/
@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<Map<String, Any>> = incrementDocumentAttribute(
databaseId,
collectionId,
documentId,
attribute,
value,
max,
nestedType = classOf(),
)
}
@@ -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&#039;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<T>]
*/
@JvmOverloads
suspend fun <T> listRows(
databaseId: String,
tableId: String,
queries: List<String>? = null,
nestedType: Class<T>,
): io.appwrite.models.RowList<T> {
val apiPath = "/databases/{databaseId}/tables/{tableId}/rows"
.replace("{databaseId}", databaseId)
.replace("{tableId}", tableId)
val apiParams = mutableMapOf<String, Any?>(
"queries" to queries,
)
val apiHeaders = mutableMapOf<String, String>(
)
val converter: (Any) -> io.appwrite.models.RowList<T> = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.RowList.from(map = it as Map<String, Any>, nestedType)
}
return client.call(
"GET",
apiPath,
apiHeaders,
apiParams,
responseType = classOf(),
converter,
)
}
/**
* Get a list of all the user&#039;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<T>]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun listRows(
databaseId: String,
tableId: String,
queries: List<String>? = null,
): io.appwrite.models.RowList<Map<String, Any>> = 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<T>]
*/
@JvmOverloads
suspend fun <T> createRow(
databaseId: String,
tableId: String,
rowId: String,
data: Any,
permissions: List<String>? = null,
nestedType: Class<T>,
): io.appwrite.models.Row<T> {
val apiPath = "/databases/{databaseId}/tables/{tableId}/rows"
.replace("{databaseId}", databaseId)
.replace("{tableId}", tableId)
val apiParams = mutableMapOf<String, Any?>(
"rowId" to rowId,
"data" to data,
"permissions" to permissions,
)
val apiHeaders = mutableMapOf<String, String>(
"content-type" to "application/json",
)
val converter: (Any) -> io.appwrite.models.Row<T> = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.Row.from(map = it as Map<String, Any>, 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<T>]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun createRow(
databaseId: String,
tableId: String,
rowId: String,
data: Any,
permissions: List<String>? = null,
): io.appwrite.models.Row<Map<String, Any>> = 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<T>]
*/
suspend fun <T> createRows(
databaseId: String,
tableId: String,
rows: List<Any>,
nestedType: Class<T>,
): io.appwrite.models.RowList<T> {
val apiPath = "/databases/{databaseId}/tables/{tableId}/rows"
.replace("{databaseId}", databaseId)
.replace("{tableId}", tableId)
val apiParams = mutableMapOf<String, Any?>(
"rows" to rows,
)
val apiHeaders = mutableMapOf<String, String>(
"content-type" to "application/json",
)
val converter: (Any) -> io.appwrite.models.RowList<T> = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.RowList.from(map = it as Map<String, Any>, 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<T>]
*/
@Throws(AppwriteException::class)
suspend fun createRows(
databaseId: String,
tableId: String,
rows: List<Any>,
): io.appwrite.models.RowList<Map<String, Any>> = 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<T>]
*/
@JvmOverloads
suspend fun <T> getRow(
databaseId: String,
tableId: String,
rowId: String,
queries: List<String>? = null,
nestedType: Class<T>,
): io.appwrite.models.Row<T> {
val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}"
.replace("{databaseId}", databaseId)
.replace("{tableId}", tableId)
.replace("{rowId}", rowId)
val apiParams = mutableMapOf<String, Any?>(
"queries" to queries,
)
val apiHeaders = mutableMapOf<String, String>(
)
val converter: (Any) -> io.appwrite.models.Row<T> = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.Row.from(map = it as Map<String, Any>, 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<T>]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getRow(
databaseId: String,
tableId: String,
rowId: String,
queries: List<String>? = null,
): io.appwrite.models.Row<Map<String, Any>> = 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<T>]
*/
suspend fun <T> upsertRow(
databaseId: String,
tableId: String,
rowId: String,
nestedType: Class<T>,
): io.appwrite.models.Row<T> {
val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}"
.replace("{databaseId}", databaseId)
.replace("{tableId}", tableId)
.replace("{rowId}", rowId)
val apiParams = mutableMapOf<String, Any?>(
)
val apiHeaders = mutableMapOf<String, String>(
"content-type" to "application/json",
)
val converter: (Any) -> io.appwrite.models.Row<T> = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.Row.from(map = it as Map<String, Any>, 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<T>]
*/
@Throws(AppwriteException::class)
suspend fun upsertRow(
databaseId: String,
tableId: String,
rowId: String,
): io.appwrite.models.Row<Map<String, Any>> = 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<T>]
*/
@JvmOverloads
suspend fun <T> updateRow(
databaseId: String,
tableId: String,
rowId: String,
data: Any? = null,
permissions: List<String>? = null,
nestedType: Class<T>,
): io.appwrite.models.Row<T> {
val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}"
.replace("{databaseId}", databaseId)
.replace("{tableId}", tableId)
.replace("{rowId}", rowId)
val apiParams = mutableMapOf<String, Any?>(
"data" to data,
"permissions" to permissions,
)
val apiHeaders = mutableMapOf<String, String>(
"content-type" to "application/json",
)
val converter: (Any) -> io.appwrite.models.Row<T> = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.Row.from(map = it as Map<String, Any>, 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<T>]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateRow(
databaseId: String,
tableId: String,
rowId: String,
data: Any? = null,
permissions: List<String>? = null,
): io.appwrite.models.Row<Map<String, Any>> = 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<String, Any?>(
)
val apiHeaders = mutableMapOf<String, String>(
"content-type" to "application/json",
)
return client.call(
"DELETE",
apiPath,
apiHeaders,
apiParams,
responseType = Any::class.java,
)
}
}