diff --git a/CHANGELOG.md b/CHANGELOG.md index 40c3275..422b08c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 12.2.0 + +* Add transaction support for Databases and TablesDB + ## 12.1.0 * Deprecate `createVerification` method in `Account` service diff --git a/README.md b/README.md index e7345cf..16b349c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-kotlin:12.1.0") +implementation("io.appwrite:sdk-for-kotlin:12.2.0") ``` ### Maven @@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-kotlin - 12.1.0 + 12.2.0 ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index d5e777d..9c6357d 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -21,6 +21,7 @@ databases.createDocument( "isAdmin" to false ), // data listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/create-documents.md b/docs/examples/java/databases/create-documents.md index 0de0c27..3a45409 100644 --- a/docs/examples/java/databases/create-documents.md +++ b/docs/examples/java/databases/create-documents.md @@ -13,6 +13,7 @@ databases.createDocuments( "", // databaseId "", // collectionId listOf(), // documents + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/create-operations.md b/docs/examples/java/databases/create-operations.md new file mode 100644 index 0000000..2dad8a1 --- /dev/null +++ b/docs/examples/java/databases/create-operations.md @@ -0,0 +1,34 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.createOperations( + "", // transactionId + listOf( + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ), // operations (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/databases/create-transaction.md b/docs/examples/java/databases/create-transaction.md new file mode 100644 index 0000000..5fb7c59 --- /dev/null +++ b/docs/examples/java/databases/create-transaction.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.createTransaction( + 60, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/databases/decrement-document-attribute.md b/docs/examples/java/databases/decrement-document-attribute.md index a44cc51..a852083 100644 --- a/docs/examples/java/databases/decrement-document-attribute.md +++ b/docs/examples/java/databases/decrement-document-attribute.md @@ -16,6 +16,7 @@ databases.decrementDocumentAttribute( "", // attribute 0, // value (optional) 0, // min (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index f6e6209..2f7003b 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -13,6 +13,7 @@ databases.deleteDocument( "", // databaseId "", // collectionId "", // documentId + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/delete-documents.md b/docs/examples/java/databases/delete-documents.md index e8394b1..958c40c 100644 --- a/docs/examples/java/databases/delete-documents.md +++ b/docs/examples/java/databases/delete-documents.md @@ -13,6 +13,7 @@ databases.deleteDocuments( "", // databaseId "", // collectionId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/delete-transaction.md b/docs/examples/java/databases/delete-transaction.md new file mode 100644 index 0000000..200bbbd --- /dev/null +++ b/docs/examples/java/databases/delete-transaction.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.deleteTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index 2719073..489447f 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -14,6 +14,7 @@ databases.getDocument( "", // collectionId "", // documentId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/get-transaction.md b/docs/examples/java/databases/get-transaction.md new file mode 100644 index 0000000..d896ca0 --- /dev/null +++ b/docs/examples/java/databases/get-transaction.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.getTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/databases/increment-document-attribute.md b/docs/examples/java/databases/increment-document-attribute.md index b5b5054..be837d0 100644 --- a/docs/examples/java/databases/increment-document-attribute.md +++ b/docs/examples/java/databases/increment-document-attribute.md @@ -16,6 +16,7 @@ databases.incrementDocumentAttribute( "", // attribute 0, // value (optional) 0, // max (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 36982c0..1e84348 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -13,6 +13,7 @@ databases.listDocuments( "", // databaseId "", // collectionId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/list-transactions.md b/docs/examples/java/databases/list-transactions.md new file mode 100644 index 0000000..281fc12 --- /dev/null +++ b/docs/examples/java/databases/list-transactions.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.listTransactions( + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index f7b05c9..f3019ab 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -15,6 +15,7 @@ databases.updateDocument( "", // documentId mapOf( "a" to "b" ), // data (optional) listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/update-documents.md b/docs/examples/java/databases/update-documents.md index b4138b4..a685ac8 100644 --- a/docs/examples/java/databases/update-documents.md +++ b/docs/examples/java/databases/update-documents.md @@ -14,6 +14,7 @@ databases.updateDocuments( "", // collectionId mapOf( "a" to "b" ), // data (optional) listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/update-transaction.md b/docs/examples/java/databases/update-transaction.md new file mode 100644 index 0000000..8479ed3 --- /dev/null +++ b/docs/examples/java/databases/update-transaction.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateTransaction( + "", // transactionId + false, // commit (optional) + false, // rollback (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/databases/upsert-document.md b/docs/examples/java/databases/upsert-document.md index daa4414..39864b9 100644 --- a/docs/examples/java/databases/upsert-document.md +++ b/docs/examples/java/databases/upsert-document.md @@ -15,6 +15,7 @@ databases.upsertDocument( "", // documentId mapOf( "a" to "b" ), // data listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/upsert-documents.md b/docs/examples/java/databases/upsert-documents.md index 95e9a33..b8fcd87 100644 --- a/docs/examples/java/databases/upsert-documents.md +++ b/docs/examples/java/databases/upsert-documents.md @@ -13,6 +13,7 @@ databases.upsertDocuments( "", // databaseId "", // collectionId listOf(), // documents + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/messaging/create-push.md b/docs/examples/java/messaging/create-push.md index 277ab96..14e8ca2 100644 --- a/docs/examples/java/messaging/create-push.md +++ b/docs/examples/java/messaging/create-push.md @@ -18,7 +18,7 @@ messaging.createPush( listOf(), // targets (optional) mapOf( "a" to "b" ), // data (optional) "", // action (optional) - "[ID1:ID2]", // image (optional) + "", // image (optional) "", // icon (optional) "", // sound (optional) "", // color (optional) diff --git a/docs/examples/java/messaging/update-push.md b/docs/examples/java/messaging/update-push.md index b7038de..ce56683 100644 --- a/docs/examples/java/messaging/update-push.md +++ b/docs/examples/java/messaging/update-push.md @@ -18,7 +18,7 @@ messaging.updatePush( "", // body (optional) mapOf( "a" to "b" ), // data (optional) "", // action (optional) - "[ID1:ID2]", // image (optional) + "", // image (optional) "", // icon (optional) "", // sound (optional) "", // color (optional) diff --git a/docs/examples/java/tablesdb/create-operations.md b/docs/examples/java/tablesdb/create-operations.md new file mode 100644 index 0000000..9504f62 --- /dev/null +++ b/docs/examples/java/tablesdb/create-operations.md @@ -0,0 +1,34 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.createOperations( + "", // transactionId + listOf( + { + "action": "create", + "databaseId": "", + "tableId": "", + "rowId": "", + "data": { + "name": "Walter O'Brien" + } + } + ), // operations (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tablesdb/create-row.md b/docs/examples/java/tablesdb/create-row.md index 6c7d847..d041511 100644 --- a/docs/examples/java/tablesdb/create-row.md +++ b/docs/examples/java/tablesdb/create-row.md @@ -21,6 +21,7 @@ tablesDB.createRow( "isAdmin" to false ), // data listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/create-rows.md b/docs/examples/java/tablesdb/create-rows.md index 21bdd21..956d812 100644 --- a/docs/examples/java/tablesdb/create-rows.md +++ b/docs/examples/java/tablesdb/create-rows.md @@ -13,6 +13,7 @@ tablesDB.createRows( "", // databaseId "", // tableId listOf(), // rows + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/create-transaction.md b/docs/examples/java/tablesdb/create-transaction.md new file mode 100644 index 0000000..3529956 --- /dev/null +++ b/docs/examples/java/tablesdb/create-transaction.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.createTransaction( + 60, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tablesdb/decrement-row-column.md b/docs/examples/java/tablesdb/decrement-row-column.md index b9f250f..78a8116 100644 --- a/docs/examples/java/tablesdb/decrement-row-column.md +++ b/docs/examples/java/tablesdb/decrement-row-column.md @@ -16,6 +16,7 @@ tablesDB.decrementRowColumn( "", // column 0, // value (optional) 0, // min (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/delete-row.md b/docs/examples/java/tablesdb/delete-row.md index fd66525..5da1ba0 100644 --- a/docs/examples/java/tablesdb/delete-row.md +++ b/docs/examples/java/tablesdb/delete-row.md @@ -13,6 +13,7 @@ tablesDB.deleteRow( "", // databaseId "", // tableId "", // rowId + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/delete-rows.md b/docs/examples/java/tablesdb/delete-rows.md index 43b772e..80ca0bb 100644 --- a/docs/examples/java/tablesdb/delete-rows.md +++ b/docs/examples/java/tablesdb/delete-rows.md @@ -13,6 +13,7 @@ tablesDB.deleteRows( "", // databaseId "", // tableId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/delete-transaction.md b/docs/examples/java/tablesdb/delete-transaction.md new file mode 100644 index 0000000..816b6e5 --- /dev/null +++ b/docs/examples/java/tablesdb/delete-transaction.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.deleteTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tablesdb/get-row.md b/docs/examples/java/tablesdb/get-row.md index 03cf3fb..d642ebc 100644 --- a/docs/examples/java/tablesdb/get-row.md +++ b/docs/examples/java/tablesdb/get-row.md @@ -14,6 +14,7 @@ tablesDB.getRow( "", // tableId "", // rowId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/get-transaction.md b/docs/examples/java/tablesdb/get-transaction.md new file mode 100644 index 0000000..dab07dc --- /dev/null +++ b/docs/examples/java/tablesdb/get-transaction.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.getTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tablesdb/increment-row-column.md b/docs/examples/java/tablesdb/increment-row-column.md index db48d05..3371572 100644 --- a/docs/examples/java/tablesdb/increment-row-column.md +++ b/docs/examples/java/tablesdb/increment-row-column.md @@ -16,6 +16,7 @@ tablesDB.incrementRowColumn( "", // column 0, // value (optional) 0, // max (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/list-rows.md b/docs/examples/java/tablesdb/list-rows.md index 52cf2a1..96520e2 100644 --- a/docs/examples/java/tablesdb/list-rows.md +++ b/docs/examples/java/tablesdb/list-rows.md @@ -13,6 +13,7 @@ tablesDB.listRows( "", // databaseId "", // tableId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/list-transactions.md b/docs/examples/java/tablesdb/list-transactions.md new file mode 100644 index 0000000..acc4902 --- /dev/null +++ b/docs/examples/java/tablesdb/list-transactions.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.listTransactions( + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tablesdb/update-row.md b/docs/examples/java/tablesdb/update-row.md index bedc816..b4f9631 100644 --- a/docs/examples/java/tablesdb/update-row.md +++ b/docs/examples/java/tablesdb/update-row.md @@ -15,6 +15,7 @@ tablesDB.updateRow( "", // rowId mapOf( "a" to "b" ), // data (optional) listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/update-rows.md b/docs/examples/java/tablesdb/update-rows.md index 169b57c..7d39e44 100644 --- a/docs/examples/java/tablesdb/update-rows.md +++ b/docs/examples/java/tablesdb/update-rows.md @@ -14,6 +14,7 @@ tablesDB.updateRows( "", // tableId mapOf( "a" to "b" ), // data (optional) listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/update-transaction.md b/docs/examples/java/tablesdb/update-transaction.md new file mode 100644 index 0000000..f043d5d --- /dev/null +++ b/docs/examples/java/tablesdb/update-transaction.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.updateTransaction( + "", // transactionId + false, // commit (optional) + false, // rollback (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tablesdb/upsert-row.md b/docs/examples/java/tablesdb/upsert-row.md index d6155fc..b6a986e 100644 --- a/docs/examples/java/tablesdb/upsert-row.md +++ b/docs/examples/java/tablesdb/upsert-row.md @@ -15,6 +15,7 @@ tablesDB.upsertRow( "", // rowId mapOf( "a" to "b" ), // data (optional) listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/upsert-rows.md b/docs/examples/java/tablesdb/upsert-rows.md index da15f6a..c4b2bf3 100644 --- a/docs/examples/java/tablesdb/upsert-rows.md +++ b/docs/examples/java/tablesdb/upsert-rows.md @@ -13,6 +13,7 @@ tablesDB.upsertRows( "", // databaseId "", // tableId listOf(), // rows + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 1c1d628..46cb711 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -20,5 +20,6 @@ val response = databases.createDocument( "age" to 30, "isAdmin" to false ), - permissions = listOf("read("any")") // optional + permissions = listOf("read("any")"), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/create-documents.md b/docs/examples/kotlin/databases/create-documents.md index 41a98dc..114d5cc 100644 --- a/docs/examples/kotlin/databases/create-documents.md +++ b/docs/examples/kotlin/databases/create-documents.md @@ -12,5 +12,6 @@ val databases = Databases(client) val response = databases.createDocuments( databaseId = "", collectionId = "", - documents = listOf() + documents = listOf(), + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/create-operations.md b/docs/examples/kotlin/databases/create-operations.md new file mode 100644 index 0000000..1c74181 --- /dev/null +++ b/docs/examples/kotlin/databases/create-operations.md @@ -0,0 +1,25 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.createOperations( + transactionId = "", + operations = listOf( + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ) // optional +) diff --git a/docs/examples/kotlin/databases/create-transaction.md b/docs/examples/kotlin/databases/create-transaction.md new file mode 100644 index 0000000..83ff583 --- /dev/null +++ b/docs/examples/kotlin/databases/create-transaction.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.createTransaction( + ttl = 60 // optional +) diff --git a/docs/examples/kotlin/databases/decrement-document-attribute.md b/docs/examples/kotlin/databases/decrement-document-attribute.md index d0226c0..3ccd662 100644 --- a/docs/examples/kotlin/databases/decrement-document-attribute.md +++ b/docs/examples/kotlin/databases/decrement-document-attribute.md @@ -15,5 +15,6 @@ val response = databases.decrementDocumentAttribute( documentId = "", attribute = "", value = 0, // optional - min = 0 // optional + min = 0, // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index a9eea6b..3be4372 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -12,5 +12,6 @@ val databases = Databases(client) val response = databases.deleteDocument( databaseId = "", collectionId = "", - documentId = "" + documentId = "", + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/delete-documents.md b/docs/examples/kotlin/databases/delete-documents.md index c4caa63..9b9ea26 100644 --- a/docs/examples/kotlin/databases/delete-documents.md +++ b/docs/examples/kotlin/databases/delete-documents.md @@ -12,5 +12,6 @@ val databases = Databases(client) val response = databases.deleteDocuments( databaseId = "", collectionId = "", - queries = listOf() // optional + queries = listOf(), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/delete-transaction.md b/docs/examples/kotlin/databases/delete-transaction.md new file mode 100644 index 0000000..ef11e9f --- /dev/null +++ b/docs/examples/kotlin/databases/delete-transaction.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.deleteTransaction( + transactionId = "" +) diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index d21a198..98855d0 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -13,5 +13,6 @@ val response = databases.getDocument( databaseId = "", collectionId = "", documentId = "", - queries = listOf() // optional + queries = listOf(), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/get-transaction.md b/docs/examples/kotlin/databases/get-transaction.md new file mode 100644 index 0000000..1e44376 --- /dev/null +++ b/docs/examples/kotlin/databases/get-transaction.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.getTransaction( + transactionId = "" +) diff --git a/docs/examples/kotlin/databases/increment-document-attribute.md b/docs/examples/kotlin/databases/increment-document-attribute.md index b56ed91..fb35886 100644 --- a/docs/examples/kotlin/databases/increment-document-attribute.md +++ b/docs/examples/kotlin/databases/increment-document-attribute.md @@ -15,5 +15,6 @@ val response = databases.incrementDocumentAttribute( documentId = "", attribute = "", value = 0, // optional - max = 0 // optional + max = 0, // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index ed9cb31..ab75493 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -12,5 +12,6 @@ val databases = Databases(client) val response = databases.listDocuments( databaseId = "", collectionId = "", - queries = listOf() // optional + queries = listOf(), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/list-transactions.md b/docs/examples/kotlin/databases/list-transactions.md new file mode 100644 index 0000000..0d122b1 --- /dev/null +++ b/docs/examples/kotlin/databases/list-transactions.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.listTransactions( + queries = listOf() // optional +) diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 4dd0349..c64a705 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -14,5 +14,6 @@ val response = databases.updateDocument( collectionId = "", documentId = "", data = mapOf( "a" to "b" ), // optional - permissions = listOf("read("any")") // optional + permissions = listOf("read("any")"), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/update-documents.md b/docs/examples/kotlin/databases/update-documents.md index 9d6c2b5..b5b76fc 100644 --- a/docs/examples/kotlin/databases/update-documents.md +++ b/docs/examples/kotlin/databases/update-documents.md @@ -13,5 +13,6 @@ val response = databases.updateDocuments( databaseId = "", collectionId = "", data = mapOf( "a" to "b" ), // optional - queries = listOf() // optional + queries = listOf(), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/update-transaction.md b/docs/examples/kotlin/databases/update-transaction.md new file mode 100644 index 0000000..834d0dc --- /dev/null +++ b/docs/examples/kotlin/databases/update-transaction.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateTransaction( + transactionId = "", + commit = false, // optional + rollback = false // optional +) diff --git a/docs/examples/kotlin/databases/upsert-document.md b/docs/examples/kotlin/databases/upsert-document.md index d8be0e1..d6d6800 100644 --- a/docs/examples/kotlin/databases/upsert-document.md +++ b/docs/examples/kotlin/databases/upsert-document.md @@ -14,5 +14,6 @@ val response = databases.upsertDocument( collectionId = "", documentId = "", data = mapOf( "a" to "b" ), - permissions = listOf("read("any")") // optional + permissions = listOf("read("any")"), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/databases/upsert-documents.md b/docs/examples/kotlin/databases/upsert-documents.md index ca861c6..db9e2b3 100644 --- a/docs/examples/kotlin/databases/upsert-documents.md +++ b/docs/examples/kotlin/databases/upsert-documents.md @@ -12,5 +12,6 @@ val databases = Databases(client) val response = databases.upsertDocuments( databaseId = "", collectionId = "", - documents = listOf() + documents = listOf(), + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/messaging/create-push.md b/docs/examples/kotlin/messaging/create-push.md index 5b07f53..d0d765a 100644 --- a/docs/examples/kotlin/messaging/create-push.md +++ b/docs/examples/kotlin/messaging/create-push.md @@ -18,7 +18,7 @@ val response = messaging.createPush( targets = listOf(), // optional data = mapOf( "a" to "b" ), // optional action = "", // optional - image = "[ID1:ID2]", // optional + image = "", // optional icon = "", // optional sound = "", // optional color = "", // optional diff --git a/docs/examples/kotlin/messaging/update-push.md b/docs/examples/kotlin/messaging/update-push.md index 710a37e..0b9c4c6 100644 --- a/docs/examples/kotlin/messaging/update-push.md +++ b/docs/examples/kotlin/messaging/update-push.md @@ -18,7 +18,7 @@ val response = messaging.updatePush( body = "", // optional data = mapOf( "a" to "b" ), // optional action = "", // optional - image = "[ID1:ID2]", // optional + image = "", // optional icon = "", // optional sound = "", // optional color = "", // optional diff --git a/docs/examples/kotlin/tablesdb/create-operations.md b/docs/examples/kotlin/tablesdb/create-operations.md new file mode 100644 index 0000000..40c98d1 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/create-operations.md @@ -0,0 +1,25 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tablesDB = TablesDB(client) + +val response = tablesDB.createOperations( + transactionId = "", + operations = listOf( + { + "action": "create", + "databaseId": "", + "tableId": "", + "rowId": "", + "data": { + "name": "Walter O'Brien" + } + } + ) // optional +) diff --git a/docs/examples/kotlin/tablesdb/create-row.md b/docs/examples/kotlin/tablesdb/create-row.md index 774800d..b060389 100644 --- a/docs/examples/kotlin/tablesdb/create-row.md +++ b/docs/examples/kotlin/tablesdb/create-row.md @@ -20,5 +20,6 @@ val response = tablesDB.createRow( "age" to 30, "isAdmin" to false ), - permissions = listOf("read("any")") // optional + permissions = listOf("read("any")"), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/create-rows.md b/docs/examples/kotlin/tablesdb/create-rows.md index 1da47b5..8cef602 100644 --- a/docs/examples/kotlin/tablesdb/create-rows.md +++ b/docs/examples/kotlin/tablesdb/create-rows.md @@ -12,5 +12,6 @@ val tablesDB = TablesDB(client) val response = tablesDB.createRows( databaseId = "", tableId = "", - rows = listOf() + rows = listOf(), + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/create-transaction.md b/docs/examples/kotlin/tablesdb/create-transaction.md new file mode 100644 index 0000000..3138570 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/create-transaction.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tablesDB = TablesDB(client) + +val response = tablesDB.createTransaction( + ttl = 60 // optional +) diff --git a/docs/examples/kotlin/tablesdb/decrement-row-column.md b/docs/examples/kotlin/tablesdb/decrement-row-column.md index e284ec3..30a8d54 100644 --- a/docs/examples/kotlin/tablesdb/decrement-row-column.md +++ b/docs/examples/kotlin/tablesdb/decrement-row-column.md @@ -15,5 +15,6 @@ val response = tablesDB.decrementRowColumn( rowId = "", column = "", value = 0, // optional - min = 0 // optional + min = 0, // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/delete-row.md b/docs/examples/kotlin/tablesdb/delete-row.md index f24b935..6ba7d60 100644 --- a/docs/examples/kotlin/tablesdb/delete-row.md +++ b/docs/examples/kotlin/tablesdb/delete-row.md @@ -12,5 +12,6 @@ val tablesDB = TablesDB(client) val response = tablesDB.deleteRow( databaseId = "", tableId = "", - rowId = "" + rowId = "", + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/delete-rows.md b/docs/examples/kotlin/tablesdb/delete-rows.md index c915a5c..da2b709 100644 --- a/docs/examples/kotlin/tablesdb/delete-rows.md +++ b/docs/examples/kotlin/tablesdb/delete-rows.md @@ -12,5 +12,6 @@ val tablesDB = TablesDB(client) val response = tablesDB.deleteRows( databaseId = "", tableId = "", - queries = listOf() // optional + queries = listOf(), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/delete-transaction.md b/docs/examples/kotlin/tablesdb/delete-transaction.md new file mode 100644 index 0000000..2ef1f27 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/delete-transaction.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tablesDB = TablesDB(client) + +val response = tablesDB.deleteTransaction( + transactionId = "" +) diff --git a/docs/examples/kotlin/tablesdb/get-row.md b/docs/examples/kotlin/tablesdb/get-row.md index ec54631..f92a1cc 100644 --- a/docs/examples/kotlin/tablesdb/get-row.md +++ b/docs/examples/kotlin/tablesdb/get-row.md @@ -13,5 +13,6 @@ val response = tablesDB.getRow( databaseId = "", tableId = "", rowId = "", - queries = listOf() // optional + queries = listOf(), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/get-transaction.md b/docs/examples/kotlin/tablesdb/get-transaction.md new file mode 100644 index 0000000..f4467dc --- /dev/null +++ b/docs/examples/kotlin/tablesdb/get-transaction.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tablesDB = TablesDB(client) + +val response = tablesDB.getTransaction( + transactionId = "" +) diff --git a/docs/examples/kotlin/tablesdb/increment-row-column.md b/docs/examples/kotlin/tablesdb/increment-row-column.md index cac151e..af3676e 100644 --- a/docs/examples/kotlin/tablesdb/increment-row-column.md +++ b/docs/examples/kotlin/tablesdb/increment-row-column.md @@ -15,5 +15,6 @@ val response = tablesDB.incrementRowColumn( rowId = "", column = "", value = 0, // optional - max = 0 // optional + max = 0, // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/list-rows.md b/docs/examples/kotlin/tablesdb/list-rows.md index b0f5df4..711e4e1 100644 --- a/docs/examples/kotlin/tablesdb/list-rows.md +++ b/docs/examples/kotlin/tablesdb/list-rows.md @@ -12,5 +12,6 @@ val tablesDB = TablesDB(client) val response = tablesDB.listRows( databaseId = "", tableId = "", - queries = listOf() // optional + queries = listOf(), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/list-transactions.md b/docs/examples/kotlin/tablesdb/list-transactions.md new file mode 100644 index 0000000..a060b9f --- /dev/null +++ b/docs/examples/kotlin/tablesdb/list-transactions.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tablesDB = TablesDB(client) + +val response = tablesDB.listTransactions( + queries = listOf() // optional +) diff --git a/docs/examples/kotlin/tablesdb/update-row.md b/docs/examples/kotlin/tablesdb/update-row.md index 9c5248f..0fefb78 100644 --- a/docs/examples/kotlin/tablesdb/update-row.md +++ b/docs/examples/kotlin/tablesdb/update-row.md @@ -14,5 +14,6 @@ val response = tablesDB.updateRow( tableId = "", rowId = "", data = mapOf( "a" to "b" ), // optional - permissions = listOf("read("any")") // optional + permissions = listOf("read("any")"), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/update-rows.md b/docs/examples/kotlin/tablesdb/update-rows.md index c285d5b..61041a7 100644 --- a/docs/examples/kotlin/tablesdb/update-rows.md +++ b/docs/examples/kotlin/tablesdb/update-rows.md @@ -13,5 +13,6 @@ val response = tablesDB.updateRows( databaseId = "", tableId = "", data = mapOf( "a" to "b" ), // optional - queries = listOf() // optional + queries = listOf(), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/update-transaction.md b/docs/examples/kotlin/tablesdb/update-transaction.md new file mode 100644 index 0000000..a3797ca --- /dev/null +++ b/docs/examples/kotlin/tablesdb/update-transaction.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tablesDB = TablesDB(client) + +val response = tablesDB.updateTransaction( + transactionId = "", + commit = false, // optional + rollback = false // optional +) diff --git a/docs/examples/kotlin/tablesdb/upsert-row.md b/docs/examples/kotlin/tablesdb/upsert-row.md index 3fcbc61..5bcc73b 100644 --- a/docs/examples/kotlin/tablesdb/upsert-row.md +++ b/docs/examples/kotlin/tablesdb/upsert-row.md @@ -14,5 +14,6 @@ val response = tablesDB.upsertRow( tableId = "", rowId = "", data = mapOf( "a" to "b" ), // optional - permissions = listOf("read("any")") // optional + permissions = listOf("read("any")"), // optional + transactionId = "" // optional ) diff --git a/docs/examples/kotlin/tablesdb/upsert-rows.md b/docs/examples/kotlin/tablesdb/upsert-rows.md index 7059c60..2f08375 100644 --- a/docs/examples/kotlin/tablesdb/upsert-rows.md +++ b/docs/examples/kotlin/tablesdb/upsert-rows.md @@ -12,5 +12,6 @@ val tablesDB = TablesDB(client) val response = tablesDB.upsertRows( databaseId = "", tableId = "", - rows = listOf() + rows = listOf(), + transactionId = "" // optional ) diff --git a/src/main/kotlin/io/appwrite/Client.kt b/src/main/kotlin/io/appwrite/Client.kt index 579ff22..4a1836c 100644 --- a/src/main/kotlin/io/appwrite/Client.kt +++ b/src/main/kotlin/io/appwrite/Client.kt @@ -58,11 +58,11 @@ class Client @JvmOverloads constructor( init { headers = mutableMapOf( "content-type" to "application/json", - "user-agent" to "AppwriteKotlinSDK/12.1.0 ${System.getProperty("http.agent")}", + "user-agent" to "AppwriteKotlinSDK/12.2.0 ${System.getProperty("http.agent")}", "x-sdk-name" to "Kotlin", "x-sdk-platform" to "server", "x-sdk-language" to "kotlin", - "x-sdk-version" to "12.1.0", + "x-sdk-version" to "12.2.0", "x-appwrite-response-format" to "1.8.0", ) diff --git a/src/main/kotlin/io/appwrite/models/Transaction.kt b/src/main/kotlin/io/appwrite/models/Transaction.kt new file mode 100644 index 0000000..baf32d3 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/Transaction.kt @@ -0,0 +1,70 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Transaction + */ +data class Transaction( + /** + * Transaction ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Transaction creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Transaction update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + */ + @SerializedName("status") + val status: String, + + /** + * Number of operations in the transaction. + */ + @SerializedName("operations") + val operations: Long, + + /** + * Expiration time in ISO 8601 format. + */ + @SerializedName("expiresAt") + val expiresAt: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "status" to status as Any, + "operations" to operations as Any, + "expiresAt" to expiresAt as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Transaction( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + status = map["status"] as String, + operations = (map["operations"] as Number).toLong(), + expiresAt = map["expiresAt"] as String, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/TransactionList.kt b/src/main/kotlin/io/appwrite/models/TransactionList.kt new file mode 100644 index 0000000..1233ed4 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/TransactionList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Transaction List + */ +data class TransactionList( + /** + * Total number of transactions that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of transactions. + */ + @SerializedName("transactions") + val transactions: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "transactions" to transactions.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = TransactionList( + total = (map["total"] as Number).toLong(), + transactions = (map["transactions"] as List>).map { Transaction.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/services/Databases.kt b/src/main/kotlin/io/appwrite/services/Databases.kt index 59dd769..cba2637 100644 --- a/src/main/kotlin/io/appwrite/services/Databases.kt +++ b/src/main/kotlin/io/appwrite/services/Databases.kt @@ -94,6 +94,199 @@ class Databases(client: Client) : Service(client) { ) } + /** + * List transactions across all databases. + * + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @return [io.appwrite.models.TransactionList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listTransactions( + queries: List? = null, + ): io.appwrite.models.TransactionList { + val apiPath = "/databases/transactions" + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.TransactionList = { + io.appwrite.models.TransactionList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.TransactionList::class.java, + converter, + ) + } + + /** + * Create a new transaction. + * + * @param ttl Seconds before the transaction expires. + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createTransaction( + ttl: Long? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/databases/transactions" + + val apiParams = mutableMapOf( + "ttl" to ttl, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + /** + * Get a transaction by its unique ID. + * + * @param transactionId Transaction ID. + * @return [io.appwrite.models.Transaction] + */ + @Throws(AppwriteException::class) + suspend fun getTransaction( + transactionId: String, + ): io.appwrite.models.Transaction { + val apiPath = "/databases/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + /** + * Update a transaction, to either commit or roll back its operations. + * + * @param transactionId Transaction ID. + * @param commit Commit transaction? + * @param rollback Rollback transaction? + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateTransaction( + transactionId: String, + commit: Boolean? = null, + rollback: Boolean? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/databases/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + "commit" to commit, + "rollback" to rollback, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + /** + * Delete a transaction by its unique ID. + * + * @param transactionId Transaction ID. + * @return [Any] + */ + @Throws(AppwriteException::class) + suspend fun deleteTransaction( + transactionId: String, + ): Any { + val apiPath = "/databases/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + /** + * Create multiple operations in a single transaction. + * + * @param transactionId Transaction ID. + * @param operations Array of staged operations. + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createOperations( + transactionId: String, + operations: List? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/databases/transactions/{transactionId}/operations" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + "operations" to operations, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + /** * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. * @@ -1911,6 +2104,7 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @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. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -1923,6 +2117,7 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.DocumentList { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -1931,6 +2126,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( ) @@ -1953,6 +2149,7 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @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. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -1965,10 +2162,12 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.DocumentList> = listDocuments( databaseId, collectionId, queries, + transactionId, nestedType = classOf(), ) @@ -1980,6 +2179,7 @@ class Databases(client: Client) : Service(client) { * @param documentId Document 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 Document 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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -1994,6 +2194,7 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -2004,6 +2205,7 @@ class Databases(client: Client) : Service(client) { "documentId" to documentId, "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2029,6 +2231,7 @@ class Databases(client: Client) : Service(client) { * @param documentId Document 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 Document 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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2043,12 +2246,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = createDocument( databaseId, collectionId, documentId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -2058,17 +2263,20 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. * @param documents Array of documents data as JSON objects. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.DocumentList] */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead.", replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createRows") ) + @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocuments( databaseId: String, collectionId: String, documents: List, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.DocumentList { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -2077,6 +2285,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "documents" to documents, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2100,21 +2309,25 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. * @param documents Array of documents data as JSON objects. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.DocumentList] */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead.", replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createRows") ) + @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocuments( databaseId: String, collectionId: String, documents: List, + transactionId: String? = null, ): io.appwrite.models.DocumentList> = createDocuments( databaseId, collectionId, documents, + transactionId, nestedType = classOf(), ) @@ -2125,17 +2338,20 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documents Array of document data as JSON objects. May contain partial documents. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.DocumentList] */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead.", replaceWith = ReplaceWith("io.appwrite.services.TablesDB.upsertRows") ) + @JvmOverloads @Throws(AppwriteException::class) suspend fun upsertDocuments( databaseId: String, collectionId: String, documents: List, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.DocumentList { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -2144,6 +2360,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "documents" to documents, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2168,21 +2385,25 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documents Array of document data as JSON objects. May contain partial documents. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.DocumentList] */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead.", replaceWith = ReplaceWith("io.appwrite.services.TablesDB.upsertRows") ) + @JvmOverloads @Throws(AppwriteException::class) suspend fun upsertDocuments( databaseId: String, collectionId: String, documents: List, + transactionId: String? = null, ): io.appwrite.models.DocumentList> = upsertDocuments( databaseId, collectionId, documents, + transactionId, nestedType = classOf(), ) @@ -2193,6 +2414,7 @@ class Databases(client: Client) : Service(client) { * @param collectionId Collection ID. * @param data Document data as JSON object. Include only attribute and value pairs to be updated. * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -2206,6 +2428,7 @@ class Databases(client: Client) : Service(client) { collectionId: String, data: Any? = null, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.DocumentList { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -2215,6 +2438,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2239,6 +2463,7 @@ class Databases(client: Client) : Service(client) { * @param collectionId Collection ID. * @param data Document data as JSON object. Include only attribute and value pairs to be updated. * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -2252,11 +2477,13 @@ class Databases(client: Client) : Service(client) { collectionId: String, data: Any? = null, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.DocumentList> = updateDocuments( databaseId, collectionId, data, queries, + transactionId, nestedType = classOf(), ) @@ -2266,6 +2493,7 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -2278,6 +2506,7 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.DocumentList { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -2286,6 +2515,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2309,6 +2539,7 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -2321,10 +2552,12 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.DocumentList> = deleteDocuments( databaseId, collectionId, queries, + transactionId, nestedType = classOf(), ) @@ -2335,6 +2568,7 @@ class Databases(client: Client) : Service(client) { * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document 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. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2348,6 +2582,7 @@ class Databases(client: Client) : Service(client) { collectionId: String, documentId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -2357,6 +2592,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( ) @@ -2380,6 +2616,7 @@ class Databases(client: Client) : Service(client) { * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document 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. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2393,11 +2630,13 @@ class Databases(client: Client) : Service(client) { collectionId: String, documentId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = getDocument( databaseId, collectionId, documentId, queries, + transactionId, nestedType = classOf(), ) @@ -2409,6 +2648,7 @@ class Databases(client: Client) : Service(client) { * @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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2423,6 +2663,7 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -2433,6 +2674,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2458,6 +2700,7 @@ class Databases(client: Client) : Service(client) { * @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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2472,12 +2715,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = upsertDocument( databaseId, collectionId, documentId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -2489,6 +2734,7 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @param data Document data as JSON object. Include only attribute 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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2503,6 +2749,7 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -2513,6 +2760,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2538,6 +2786,7 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @param data Document data as JSON object. Include only attribute 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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2552,12 +2801,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = updateDocument( databaseId, collectionId, documentId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -2567,17 +2818,20 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document ID. + * @param transactionId Transaction ID for staging the operation. * @return [Any] */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.", replaceWith = ReplaceWith("io.appwrite.services.TablesDB.deleteRow") ) + @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteDocument( databaseId: String, collectionId: String, documentId: String, + transactionId: String? = null, ): Any { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) @@ -2585,6 +2839,7 @@ class Databases(client: Client) : Service(client) { .replace("{documentId}", documentId) val apiParams = mutableMapOf( + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2607,6 +2862,7 @@ class Databases(client: Client) : Service(client) { * @param attribute Attribute key. * @param value Value to increment 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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2622,6 +2878,7 @@ class Databases(client: Client) : Service(client) { attribute: String, value: Double? = null, min: Double? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" @@ -2633,6 +2890,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "value" to value, "min" to min, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2659,6 +2917,7 @@ class Databases(client: Client) : Service(client) { * @param attribute Attribute key. * @param value Value to increment 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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2674,6 +2933,7 @@ class Databases(client: Client) : Service(client) { attribute: String, value: Double? = null, min: Double? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = decrementDocumentAttribute( databaseId, collectionId, @@ -2681,6 +2941,7 @@ class Databases(client: Client) : Service(client) { attribute, value, min, + transactionId, nestedType = classOf(), ) @@ -2693,6 +2954,7 @@ class Databases(client: Client) : Service(client) { * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2708,6 +2970,7 @@ class Databases(client: Client) : Service(client) { attribute: String, value: Double? = null, max: Double? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" @@ -2719,6 +2982,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "value" to value, "max" to max, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2745,6 +3009,7 @@ class Databases(client: Client) : Service(client) { * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -2760,6 +3025,7 @@ class Databases(client: Client) : Service(client) { attribute: String, value: Double? = null, max: Double? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = incrementDocumentAttribute( databaseId, collectionId, @@ -2767,6 +3033,7 @@ class Databases(client: Client) : Service(client) { attribute, value, max, + transactionId, nestedType = classOf(), ) @@ -2867,7 +3134,7 @@ class Databases(client: Client) : Service(client) { } /** - * Get index by ID. + * Get an index by its unique ID. * * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). diff --git a/src/main/kotlin/io/appwrite/services/TablesDb.kt b/src/main/kotlin/io/appwrite/services/TablesDb.kt index 34bbd70..24e664a 100644 --- a/src/main/kotlin/io/appwrite/services/TablesDb.kt +++ b/src/main/kotlin/io/appwrite/services/TablesDb.kt @@ -86,6 +86,199 @@ class TablesDB(client: Client) : Service(client) { ) } + /** + * List transactions across all databases. + * + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @return [io.appwrite.models.TransactionList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listTransactions( + queries: List? = null, + ): io.appwrite.models.TransactionList { + val apiPath = "/tablesdb/transactions" + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.TransactionList = { + io.appwrite.models.TransactionList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.TransactionList::class.java, + converter, + ) + } + + /** + * Create a new transaction. + * + * @param ttl Seconds before the transaction expires. + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createTransaction( + ttl: Long? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/tablesdb/transactions" + + val apiParams = mutableMapOf( + "ttl" to ttl, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + /** + * Get a transaction by its unique ID. + * + * @param transactionId Transaction ID. + * @return [io.appwrite.models.Transaction] + */ + @Throws(AppwriteException::class) + suspend fun getTransaction( + transactionId: String, + ): io.appwrite.models.Transaction { + val apiPath = "/tablesdb/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + /** + * Update a transaction, to either commit or roll back its operations. + * + * @param transactionId Transaction ID. + * @param commit Commit transaction? + * @param rollback Rollback transaction? + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateTransaction( + transactionId: String, + commit: Boolean? = null, + rollback: Boolean? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/tablesdb/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + "commit" to commit, + "rollback" to rollback, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + /** + * Delete a transaction by its unique ID. + * + * @param transactionId Transaction ID. + * @return [Any] + */ + @Throws(AppwriteException::class) + suspend fun deleteTransaction( + transactionId: String, + ): Any { + val apiPath = "/tablesdb/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + /** + * Create multiple operations in a single transaction. + * + * @param transactionId Transaction ID. + * @param operations Array of staged operations. + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createOperations( + transactionId: String, + operations: List? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/tablesdb/transactions/{transactionId}/operations" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + "operations" to operations, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + /** * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. * @@ -1911,6 +2104,7 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @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. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -1919,6 +2113,7 @@ class TablesDB(client: Client) : Service(client) { databaseId: String, tableId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.RowList { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -1927,6 +2122,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( ) @@ -1949,6 +2145,7 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @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. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -1957,10 +2154,12 @@ class TablesDB(client: Client) : Service(client) { databaseId: String, tableId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.RowList> = listRows( databaseId, tableId, queries, + transactionId, nestedType = classOf(), ) @@ -1972,6 +2171,7 @@ class TablesDB(client: Client) : Service(client) { * @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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -1982,6 +2182,7 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -1992,6 +2193,7 @@ class TablesDB(client: Client) : Service(client) { "rowId" to rowId, "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2017,6 +2219,7 @@ class TablesDB(client: Client) : Service(client) { * @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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2027,12 +2230,14 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = createRow( databaseId, tableId, rowId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -2042,13 +2247,16 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. * @param rows Array of rows data as JSON objects. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.RowList] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun createRows( databaseId: String, tableId: String, rows: List, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.RowList { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -2057,6 +2265,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "rows" to rows, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2080,17 +2289,21 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. * @param rows Array of rows data as JSON objects. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.RowList] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun createRows( databaseId: String, tableId: String, rows: List, + transactionId: String? = null, ): io.appwrite.models.RowList> = createRows( databaseId, tableId, rows, + transactionId, nestedType = classOf(), ) @@ -2101,13 +2314,16 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. * @param rows Array of row data as JSON objects. May contain partial rows. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.RowList] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun upsertRows( databaseId: String, tableId: String, rows: List, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.RowList { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -2116,6 +2332,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "rows" to rows, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2140,17 +2357,21 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. * @param rows Array of row data as JSON objects. May contain partial rows. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.RowList] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun upsertRows( databaseId: String, tableId: String, rows: List, + transactionId: String? = null, ): io.appwrite.models.RowList> = upsertRows( databaseId, tableId, rows, + transactionId, nestedType = classOf(), ) @@ -2161,6 +2382,7 @@ class TablesDB(client: Client) : Service(client) { * @param tableId Table ID. * @param data Row data as JSON object. Include only column and value pairs to be updated. * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -2170,6 +2392,7 @@ class TablesDB(client: Client) : Service(client) { tableId: String, data: Any? = null, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.RowList { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -2179,6 +2402,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2203,6 +2427,7 @@ class TablesDB(client: Client) : Service(client) { * @param tableId Table ID. * @param data Row data as JSON object. Include only column and value pairs to be updated. * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -2212,11 +2437,13 @@ class TablesDB(client: Client) : Service(client) { tableId: String, data: Any? = null, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.RowList> = updateRows( databaseId, tableId, data, queries, + transactionId, nestedType = classOf(), ) @@ -2226,6 +2453,7 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -2234,6 +2462,7 @@ class TablesDB(client: Client) : Service(client) { databaseId: String, tableId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.RowList { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -2242,6 +2471,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2265,6 +2495,7 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @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. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -2273,10 +2504,12 @@ class TablesDB(client: Client) : Service(client) { databaseId: String, tableId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.RowList> = deleteRows( databaseId, tableId, queries, + transactionId, nestedType = classOf(), ) @@ -2287,6 +2520,7 @@ class TablesDB(client: Client) : Service(client) { * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @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. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2296,6 +2530,7 @@ class TablesDB(client: Client) : Service(client) { tableId: String, rowId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" @@ -2305,6 +2540,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( ) @@ -2328,6 +2564,7 @@ class TablesDB(client: Client) : Service(client) { * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @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. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2337,11 +2574,13 @@ class TablesDB(client: Client) : Service(client) { tableId: String, rowId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = getRow( databaseId, tableId, rowId, queries, + transactionId, nestedType = classOf(), ) @@ -2353,6 +2592,7 @@ class TablesDB(client: Client) : Service(client) { * @param rowId Row ID. * @param data Row data as JSON object. Include all required columns of the row 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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2363,6 +2603,7 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" @@ -2373,6 +2614,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2398,6 +2640,7 @@ class TablesDB(client: Client) : Service(client) { * @param rowId Row ID. * @param data Row data as JSON object. Include all required columns of the row 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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2408,12 +2651,14 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = upsertRow( databaseId, tableId, rowId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -2425,6 +2670,7 @@ class TablesDB(client: Client) : Service(client) { * @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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2435,6 +2681,7 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" @@ -2445,6 +2692,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2470,6 +2718,7 @@ class TablesDB(client: Client) : Service(client) { * @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). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2480,12 +2729,14 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = updateRow( databaseId, tableId, rowId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -2495,13 +2746,16 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param rowId Row ID. + * @param transactionId Transaction ID for staging the operation. * @return [Any] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteRow( databaseId: String, tableId: String, rowId: String, + transactionId: String? = null, ): Any { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .replace("{databaseId}", databaseId) @@ -2509,6 +2763,7 @@ class TablesDB(client: Client) : Service(client) { .replace("{rowId}", rowId) val apiParams = mutableMapOf( + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2531,6 +2786,7 @@ class TablesDB(client: Client) : Service(client) { * @param column Column key. * @param value Value to increment the column by. The value must be a number. * @param min Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2542,6 +2798,7 @@ class TablesDB(client: Client) : Service(client) { column: String, value: Double? = null, min: Double? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" @@ -2553,6 +2810,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "value" to value, "min" to min, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2579,6 +2837,7 @@ class TablesDB(client: Client) : Service(client) { * @param column Column key. * @param value Value to increment the column by. The value must be a number. * @param min Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2590,6 +2849,7 @@ class TablesDB(client: Client) : Service(client) { column: String, value: Double? = null, min: Double? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = decrementRowColumn( databaseId, tableId, @@ -2597,6 +2857,7 @@ class TablesDB(client: Client) : Service(client) { column, value, min, + transactionId, nestedType = classOf(), ) @@ -2609,6 +2870,7 @@ class TablesDB(client: Client) : Service(client) { * @param column Column key. * @param value Value to increment the column by. The value must be a number. * @param max Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2620,6 +2882,7 @@ class TablesDB(client: Client) : Service(client) { column: String, value: Double? = null, max: Double? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" @@ -2631,6 +2894,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "value" to value, "max" to max, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -2657,6 +2921,7 @@ class TablesDB(client: Client) : Service(client) { * @param column Column key. * @param value Value to increment the column by. The value must be a number. * @param max Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -2668,6 +2933,7 @@ class TablesDB(client: Client) : Service(client) { column: String, value: Double? = null, max: Double? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = incrementRowColumn( databaseId, tableId, @@ -2675,6 +2941,7 @@ class TablesDB(client: Client) : Service(client) { column, value, max, + transactionId, nestedType = classOf(), )