diff --git a/LICENSE.md b/LICENSE.md index 90528c4..47cfdfb 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index 277e7d6..a1cb66c 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-kotlin.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-kotlin.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.2.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.2.1-blue.svg?style=flat-square) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.2.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-kotlin/releases).** +**This SDK is compatible with Appwrite server version 1.3.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-kotlin/releases).** > This is the Kotlin SDK for integrating with Appwrite from your Kotlin server-side code. If you're looking for the Android SDK you should check [appwrite/sdk-for-android](https://github.com/appwrite/sdk-for-android) @@ -39,7 +39,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-kotlin:1.2.0") +implementation("io.appwrite:sdk-for-kotlin:1.3.0") ``` ### Maven @@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-kotlin - 1.2.0 + 1.3.0 ``` diff --git a/build.gradle b/build.gradle index 658e8f0..181fbfb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id "org.jetbrains.kotlin.jvm" version '1.6.10' + id "org.jetbrains.kotlin.jvm" version '1.8.0' id "java-library" id "io.github.gradle-nexus.publish-plugin" version "1.1.0" } diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 03c5feb..d86eef3 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -10,7 +10,7 @@ Client client = new Client() Account account = new Account(client); account.updatePassword( - "password", + "", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/create-relationship-attribute.md b/docs/examples/java/databases/create-relationship-attribute.md new file mode 100644 index 0000000..190d08a --- /dev/null +++ b/docs/examples/java/databases/create-relationship-attribute.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://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.createRelationshipAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "[RELATED_COLLECTION_ID]", + "oneToOne", + 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 5461088..ffc747f 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -12,7 +12,7 @@ Databases databases = new Databases(client); databases.getDocument( "[DATABASE_ID]", "[COLLECTION_ID]", - "[DOCUMENT_ID]" + "[DOCUMENT_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/update-boolean-attribute.md b/docs/examples/java/databases/update-boolean-attribute.md new file mode 100644 index 0000000..3cdd441 --- /dev/null +++ b/docs/examples/java/databases/update-boolean-attribute.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateBooleanAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + false, + false + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/databases/update-datetime-attribute.md b/docs/examples/java/databases/update-datetime-attribute.md new file mode 100644 index 0000000..60bc7ab --- /dev/null +++ b/docs/examples/java/databases/update-datetime-attribute.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateDatetimeAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + false, + "" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/databases/update-email-attribute.md b/docs/examples/java/databases/update-email-attribute.md new file mode 100644 index 0000000..36beb4f --- /dev/null +++ b/docs/examples/java/databases/update-email-attribute.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateEmailAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + false, + "email@example.com" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/databases/update-enum-attribute.md b/docs/examples/java/databases/update-enum-attribute.md new file mode 100644 index 0000000..230caf0 --- /dev/null +++ b/docs/examples/java/databases/update-enum-attribute.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateEnumAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + listOf(), + false, + "[DEFAULT]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/databases/update-float-attribute.md b/docs/examples/java/databases/update-float-attribute.md new file mode 100644 index 0000000..413060f --- /dev/null +++ b/docs/examples/java/databases/update-float-attribute.md @@ -0,0 +1,28 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateFloatAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + false, + 0, + 0, + 0 + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/databases/update-integer-attribute.md b/docs/examples/java/databases/update-integer-attribute.md new file mode 100644 index 0000000..986431a --- /dev/null +++ b/docs/examples/java/databases/update-integer-attribute.md @@ -0,0 +1,28 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateIntegerAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + false, + 0, + 0, + 0 + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/databases/update-ip-attribute.md b/docs/examples/java/databases/update-ip-attribute.md new file mode 100644 index 0000000..42f7ae0 --- /dev/null +++ b/docs/examples/java/databases/update-ip-attribute.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateIpAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + false, + "" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/databases/update-relationship-attribute.md b/docs/examples/java/databases/update-relationship-attribute.md new file mode 100644 index 0000000..d2726f3 --- /dev/null +++ b/docs/examples/java/databases/update-relationship-attribute.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateRelationshipAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/databases/update-string-attribute.md b/docs/examples/java/databases/update-string-attribute.md new file mode 100644 index 0000000..fd18847 --- /dev/null +++ b/docs/examples/java/databases/update-string-attribute.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateStringAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + false, + "[DEFAULT]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/databases/update-url-attribute.md b/docs/examples/java/databases/update-url-attribute.md new file mode 100644 index 0000000..9a74490 --- /dev/null +++ b/docs/examples/java/databases/update-url-attribute.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateUrlAttribute( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "", + false, + "https://example.com" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/functions/create.md b/docs/examples/java/functions/create.md index aac8c64..f0afd09 100644 --- a/docs/examples/java/functions/create.md +++ b/docs/examples/java/functions/create.md @@ -12,7 +12,6 @@ Functions functions = new Functions(client); functions.create( "[FUNCTION_ID]", "[NAME]", - listOf("any"), "node-14.5", new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/functions/update.md b/docs/examples/java/functions/update.md index 8157cbb..8889212 100644 --- a/docs/examples/java/functions/update.md +++ b/docs/examples/java/functions/update.md @@ -12,7 +12,6 @@ Functions functions = new Functions(client); functions.update( "[FUNCTION_ID]", "[NAME]", - listOf("any"), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index f4afed4..c05030d 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -11,7 +11,6 @@ Teams teams = new Teams(client); teams.createMembership( "[TEAM_ID]", - "email@example.com", listOf(), "https://example.com", new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md new file mode 100644 index 0000000..44e28d4 --- /dev/null +++ b/docs/examples/java/teams/get-prefs.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +Teams teams = new Teams(client); + +teams.getPrefs( + "[TEAM_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/teams/update.md b/docs/examples/java/teams/update-name.md similarity index 97% rename from docs/examples/java/teams/update.md rename to docs/examples/java/teams/update-name.md index b8ca109..65f18fc 100644 --- a/docs/examples/java/teams/update.md +++ b/docs/examples/java/teams/update-name.md @@ -9,7 +9,7 @@ Client client = new Client() Teams teams = new Teams(client); -teams.update( +teams.updateName( "[TEAM_ID]", "[NAME]" new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md new file mode 100644 index 0000000..dbdb11a --- /dev/null +++ b/docs/examples/java/teams/update-prefs.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; + +Client client = new Client() + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +Teams teams = new Teams(client); + +teams.updatePrefs( + "[TEAM_ID]", + mapOf( "a" to "b" ) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); diff --git a/docs/examples/java/users/update-password.md b/docs/examples/java/users/update-password.md index 6d6a9d3..c5d071f 100644 --- a/docs/examples/java/users/update-password.md +++ b/docs/examples/java/users/update-password.md @@ -11,7 +11,7 @@ Users users = new Users(client); users.updatePassword( "[USER_ID]", - "password" + "" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index 0b22998..ab5b63a 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updatePassword( - password = "password", + password = "", ) diff --git a/docs/examples/kotlin/databases/create-relationship-attribute.md b/docs/examples/kotlin/databases/create-relationship-attribute.md new file mode 100644 index 0000000..a2102ec --- /dev/null +++ b/docs/examples/kotlin/databases/create-relationship-attribute.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.createRelationshipAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + relatedCollectionId = "[RELATED_COLLECTION_ID]", + type = "oneToOne", +) diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 8c3ce7c..05c6106 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -11,5 +11,5 @@ val databases = Databases(client) val response = databases.getDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]" + documentId = "[DOCUMENT_ID]", ) diff --git a/docs/examples/kotlin/databases/update-boolean-attribute.md b/docs/examples/kotlin/databases/update-boolean-attribute.md new file mode 100644 index 0000000..a30814a --- /dev/null +++ b/docs/examples/kotlin/databases/update-boolean-attribute.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateBooleanAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", + required = false, + default = false +) diff --git a/docs/examples/kotlin/databases/update-datetime-attribute.md b/docs/examples/kotlin/databases/update-datetime-attribute.md new file mode 100644 index 0000000..c907e3c --- /dev/null +++ b/docs/examples/kotlin/databases/update-datetime-attribute.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateDatetimeAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", + required = false, + default = "" +) diff --git a/docs/examples/kotlin/databases/update-email-attribute.md b/docs/examples/kotlin/databases/update-email-attribute.md new file mode 100644 index 0000000..6b8976d --- /dev/null +++ b/docs/examples/kotlin/databases/update-email-attribute.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateEmailAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", + required = false, + default = "email@example.com" +) diff --git a/docs/examples/kotlin/databases/update-enum-attribute.md b/docs/examples/kotlin/databases/update-enum-attribute.md new file mode 100644 index 0000000..e46fde5 --- /dev/null +++ b/docs/examples/kotlin/databases/update-enum-attribute.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateEnumAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", + elements = listOf(), + required = false, + default = "[DEFAULT]" +) diff --git a/docs/examples/kotlin/databases/update-float-attribute.md b/docs/examples/kotlin/databases/update-float-attribute.md new file mode 100644 index 0000000..bb497f5 --- /dev/null +++ b/docs/examples/kotlin/databases/update-float-attribute.md @@ -0,0 +1,19 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateFloatAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", + required = false, + min = 0, + max = 0, + default = 0 +) diff --git a/docs/examples/kotlin/databases/update-integer-attribute.md b/docs/examples/kotlin/databases/update-integer-attribute.md new file mode 100644 index 0000000..a37ab21 --- /dev/null +++ b/docs/examples/kotlin/databases/update-integer-attribute.md @@ -0,0 +1,19 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateIntegerAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", + required = false, + min = 0, + max = 0, + default = 0 +) diff --git a/docs/examples/kotlin/databases/update-ip-attribute.md b/docs/examples/kotlin/databases/update-ip-attribute.md new file mode 100644 index 0000000..b54649e --- /dev/null +++ b/docs/examples/kotlin/databases/update-ip-attribute.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateIpAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", + required = false, + default = "" +) diff --git a/docs/examples/kotlin/databases/update-relationship-attribute.md b/docs/examples/kotlin/databases/update-relationship-attribute.md new file mode 100644 index 0000000..38e353d --- /dev/null +++ b/docs/examples/kotlin/databases/update-relationship-attribute.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateRelationshipAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", +) diff --git a/docs/examples/kotlin/databases/update-string-attribute.md b/docs/examples/kotlin/databases/update-string-attribute.md new file mode 100644 index 0000000..73889f8 --- /dev/null +++ b/docs/examples/kotlin/databases/update-string-attribute.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateStringAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", + required = false, + default = "[DEFAULT]" +) diff --git a/docs/examples/kotlin/databases/update-url-attribute.md b/docs/examples/kotlin/databases/update-url-attribute.md new file mode 100644 index 0000000..c053210 --- /dev/null +++ b/docs/examples/kotlin/databases/update-url-attribute.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateUrlAttribute( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + key = "", + required = false, + default = "https://example.com" +) diff --git a/docs/examples/kotlin/functions/create.md b/docs/examples/kotlin/functions/create.md index 9456721..e302dc7 100644 --- a/docs/examples/kotlin/functions/create.md +++ b/docs/examples/kotlin/functions/create.md @@ -11,6 +11,5 @@ val functions = Functions(client) val response = functions.create( functionId = "[FUNCTION_ID]", name = "[NAME]", - execute = listOf("any"), runtime = "node-14.5", ) diff --git a/docs/examples/kotlin/functions/update.md b/docs/examples/kotlin/functions/update.md index ace7b68..3768665 100644 --- a/docs/examples/kotlin/functions/update.md +++ b/docs/examples/kotlin/functions/update.md @@ -11,5 +11,4 @@ val functions = Functions(client) val response = functions.update( functionId = "[FUNCTION_ID]", name = "[NAME]", - execute = listOf("any"), ) diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 19432de..8cca697 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -10,7 +10,6 @@ val teams = Teams(client) val response = teams.createMembership( teamId = "[TEAM_ID]", - email = "email@example.com", roles = listOf(), url = "https://example.com", ) diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md new file mode 100644 index 0000000..0f8164c --- /dev/null +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token + +val teams = Teams(client) + +val response = teams.getPrefs( + teamId = "[TEAM_ID]" +) diff --git a/docs/examples/kotlin/teams/update.md b/docs/examples/kotlin/teams/update-name.md similarity index 91% rename from docs/examples/kotlin/teams/update.md rename to docs/examples/kotlin/teams/update-name.md index 50a315c..f237f38 100644 --- a/docs/examples/kotlin/teams/update.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.update( +val response = teams.updateName( teamId = "[TEAM_ID]", name = "[NAME]" ) diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md new file mode 100644 index 0000000..70b3e0c --- /dev/null +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token + +val teams = Teams(client) + +val response = teams.updatePrefs( + teamId = "[TEAM_ID]", + prefs = mapOf( "a" to "b" ) +) diff --git a/docs/examples/kotlin/users/update-password.md b/docs/examples/kotlin/users/update-password.md index b5e10a8..ba96188 100644 --- a/docs/examples/kotlin/users/update-password.md +++ b/docs/examples/kotlin/users/update-password.md @@ -10,5 +10,5 @@ val users = Users(client) val response = users.updatePassword( userId = "[USER_ID]", - password = "password" + password = "" ) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4605298..60c76b3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/Client.kt b/src/main/kotlin/io/appwrite/Client.kt index d9b1e33..54c81bd 100644 --- a/src/main/kotlin/io/appwrite/Client.kt +++ b/src/main/kotlin/io/appwrite/Client.kt @@ -65,7 +65,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Kotlin", "x-sdk-platform" to "server", "x-sdk-language" to "kotlin", - "x-sdk-version" to "1.2.0", + "x-sdk-version" to "1.3.0", "x-appwrite-response-format" to "1.0.0" ) config = mutableMapOf() diff --git a/src/main/kotlin/io/appwrite/Query.kt b/src/main/kotlin/io/appwrite/Query.kt index 2d33a02..ad1f3ed 100644 --- a/src/main/kotlin/io/appwrite/Query.kt +++ b/src/main/kotlin/io/appwrite/Query.kt @@ -16,6 +16,22 @@ class Query { fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value) + fun isNull(attribute: String) = "isNull(\"${attribute}\")" + + fun isNotNull(attribute: String) = "isNotNull(\"${attribute}\")" + + fun between(attribute: String, start: Int, end: Int) = Query.addQuery(attribute, "between", listOf(start, end)) + + fun between(attribute: String, start: Double, end: Double) = Query.addQuery(attribute, "between", listOf(start, end)) + + fun between(attribute: String, start: String, end: String) = Query.addQuery(attribute, "between", listOf(start, end)) + + fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value) + + fun endsWith(attribute: String, value: String) = Query.addQuery(attribute, "endsWith", value) + + fun select(attributes: List) = "select([${attributes.joinToString(",") { "\"$it\"" }}])" + fun orderAsc(attribute: String) = "orderAsc(\"${attribute}\")" fun orderDesc(attribute: String) = "orderDesc(\"${attribute}\")" diff --git a/src/main/kotlin/io/appwrite/models/Account.kt b/src/main/kotlin/io/appwrite/models/Account.kt deleted file mode 100644 index 1b87beb..0000000 --- a/src/main/kotlin/io/appwrite/models/Account.kt +++ /dev/null @@ -1,146 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Account - */ -data class Account( - /** - * User ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * User creation date in ISO 8601 format. - */ - @SerializedName("\$createdAt") - val createdAt: String, - - /** - * User update date in ISO 8601 format. - */ - @SerializedName("\$updatedAt") - val updatedAt: String, - - /** - * User name. - */ - @SerializedName("name") - val name: String, - - /** - * User registration date in ISO 8601 format. - */ - @SerializedName("registration") - val registration: String, - - /** - * User status. Pass `true` for enabled and `false` for disabled. - */ - @SerializedName("status") - val status: Boolean, - - /** - * Password update time in ISO 8601 format. - */ - @SerializedName("passwordUpdate") - val passwordUpdate: String, - - /** - * User email address. - */ - @SerializedName("email") - val email: String, - - /** - * User phone number in E.164 format. - */ - @SerializedName("phone") - val phone: String, - - /** - * Email verification status. - */ - @SerializedName("emailVerification") - val emailVerification: Boolean, - - /** - * Phone verification status. - */ - @SerializedName("phoneVerification") - val phoneVerification: Boolean, - - /** - * User preferences as a key-value object - */ - @SerializedName("prefs") - val prefs: Preferences, - -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "name" to name as Any, - "registration" to registration as Any, - "status" to status as Any, - "passwordUpdate" to passwordUpdate as Any, - "email" to email as Any, - "phone" to phone as Any, - "emailVerification" to emailVerification as Any, - "phoneVerification" to phoneVerification as Any, - "prefs" to prefs.toMap() as Any, - ) - - companion object { - operator fun invoke( - id: String, - createdAt: String, - updatedAt: String, - name: String, - registration: String, - status: Boolean, - passwordUpdate: String, - email: String, - phone: String, - emailVerification: Boolean, - phoneVerification: Boolean, - prefs: Preferences>, - ) = Account>( - id, - createdAt, - updatedAt, - name, - registration, - status, - passwordUpdate, - email, - phone, - emailVerification, - phoneVerification, - prefs, - ) - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - nestedType: Class - ) = Account( - id = map["\$id"] as String, - createdAt = map["\$createdAt"] as String, - updatedAt = map["\$updatedAt"] as String, - name = map["name"] as String, - registration = map["registration"] as String, - status = map["status"] as Boolean, - passwordUpdate = map["passwordUpdate"] as String, - email = map["email"] as String, - phone = map["phone"] as String, - emailVerification = map["emailVerification"] as Boolean, - phoneVerification = map["phoneVerification"] as Boolean, - prefs = Preferences.from(map = map["prefs"] as Map, nestedType), - ) - } -} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/AttributeRelationship.kt b/src/main/kotlin/io/appwrite/models/AttributeRelationship.kt new file mode 100644 index 0000000..8fbdc72 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/AttributeRelationship.kt @@ -0,0 +1,110 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AttributeRelationship + */ +data class AttributeRelationship( + /** + * Attribute Key. + */ + @SerializedName("key") + val key: String, + + /** + * Attribute type. + */ + @SerializedName("type") + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + @SerializedName("status") + val status: String, + + /** + * Is attribute required? + */ + @SerializedName("required") + val required: Boolean, + + /** + * Is attribute an array? + */ + @SerializedName("array") + var array: Boolean?, + + /** + * The ID of the related collection. + */ + @SerializedName("relatedCollection") + val relatedCollection: String, + + /** + * The type of the relationship. + */ + @SerializedName("relationType") + val relationType: String, + + /** + * Is the relationship two-way? + */ + @SerializedName("twoWay") + val twoWay: Boolean, + + /** + * The key of the two-way relationship. + */ + @SerializedName("twoWayKey") + val twoWayKey: String, + + /** + * How deleting the parent document will propagate to child documents. + */ + @SerializedName("onDelete") + val onDelete: String, + + /** + * Whether this is the parent or child side of the relationship + */ + @SerializedName("side") + val side: String, + +) { + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "relatedCollection" to relatedCollection as Any, + "relationType" to relationType as Any, + "twoWay" to twoWay as Any, + "twoWayKey" to twoWayKey as Any, + "onDelete" to onDelete as Any, + "side" to side as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AttributeRelationship( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean?, + relatedCollection = map["relatedCollection"] as String, + relationType = map["relationType"] as String, + twoWay = map["twoWay"] as Boolean, + twoWayKey = map["twoWayKey"] as String, + onDelete = map["onDelete"] as String, + side = map["side"] as String, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/Locale.kt b/src/main/kotlin/io/appwrite/models/Locale.kt index 4327545..abe4a0e 100644 --- a/src/main/kotlin/io/appwrite/models/Locale.kt +++ b/src/main/kotlin/io/appwrite/models/Locale.kt @@ -38,7 +38,7 @@ data class Locale( val continent: String, /** - * True if country is part of the Europian Union. + * True if country is part of the European Union. */ @SerializedName("eu") val eu: Boolean, diff --git a/src/main/kotlin/io/appwrite/models/Team.kt b/src/main/kotlin/io/appwrite/models/Team.kt index 76f7cb2..0723b90 100644 --- a/src/main/kotlin/io/appwrite/models/Team.kt +++ b/src/main/kotlin/io/appwrite/models/Team.kt @@ -6,7 +6,7 @@ import io.appwrite.extensions.jsonCast /** * Team */ -data class Team( +data class Team( /** * Team ID. */ @@ -37,6 +37,12 @@ data class Team( @SerializedName("total") val total: Long, + /** + * Team preferences as a key-value object + */ + @SerializedName("prefs") + val prefs: Preferences, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -44,19 +50,37 @@ data class Team( "\$updatedAt" to updatedAt as Any, "name" to name as Any, "total" to total as Any, + "prefs" to prefs.toMap() as Any, ) companion object { + operator fun invoke( + id: String, + createdAt: String, + updatedAt: String, + name: String, + total: Long, + prefs: Preferences>, + ) = Team>( + id, + createdAt, + updatedAt, + name, + total, + prefs, + ) @Suppress("UNCHECKED_CAST") - fun from( + fun from( map: Map, - ) = Team( + nestedType: Class + ) = Team( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, name = map["name"] as String, total = (map["total"] as Number).toLong(), + prefs = Preferences.from(map = map["prefs"] as Map, nestedType), ) } } \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/TeamList.kt b/src/main/kotlin/io/appwrite/models/TeamList.kt index ab76ed6..17ccd6b 100644 --- a/src/main/kotlin/io/appwrite/models/TeamList.kt +++ b/src/main/kotlin/io/appwrite/models/TeamList.kt @@ -6,7 +6,7 @@ import io.appwrite.extensions.jsonCast /** * Teams List */ -data class TeamList( +data class TeamList( /** * Total number of teams documents that matched your query. */ @@ -17,7 +17,7 @@ data class TeamList( * List of teams. */ @SerializedName("teams") - val teams: List, + val teams: List>, ) { fun toMap(): Map = mapOf( @@ -26,13 +26,21 @@ data class TeamList( ) companion object { + operator fun invoke( + total: Long, + teams: List>>, + ) = TeamList>( + total, + teams, + ) @Suppress("UNCHECKED_CAST") - fun from( + fun from( map: Map, - ) = TeamList( + nestedType: Class + ) = TeamList( total = (map["total"] as Number).toLong(), - teams = (map["teams"] as List>).map { Team.from(map = it) }, + teams = (map["teams"] as List>).map { Team.from(map = it, nestedType) }, ) } } \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/User.kt b/src/main/kotlin/io/appwrite/models/User.kt index 9a5a38d..81551e6 100644 --- a/src/main/kotlin/io/appwrite/models/User.kt +++ b/src/main/kotlin/io/appwrite/models/User.kt @@ -35,19 +35,19 @@ data class User( * Hashed user password. */ @SerializedName("password") - val password: String, + var password: String?, /** * Password hashing algorithm. */ @SerializedName("hash") - val hash: String, + var hash: String?, /** * Password hashing algorithm configuration. */ @SerializedName("hashOptions") - val hashOptions: Any, + var hashOptions: Any?, /** * User registration date in ISO 8601 format. @@ -122,9 +122,9 @@ data class User( createdAt: String, updatedAt: String, name: String, - password: String, - hash: String, - hashOptions: Any, + password: String?, + hash: String?, + hashOptions: Any?, registration: String, status: Boolean, passwordUpdate: String, @@ -160,9 +160,9 @@ data class User( createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, name = map["name"] as String, - password = map["password"] as String, - hash = map["hash"] as String, - hashOptions = map["hashOptions"] as Any, + password = map["password"] as? String?, + hash = map["hash"] as? String?, + hashOptions = map["hashOptions"] as? Any?, registration = map["registration"] as String, status = map["status"] as Boolean, passwordUpdate = map["passwordUpdate"] as String, diff --git a/src/main/kotlin/io/appwrite/services/Account.kt b/src/main/kotlin/io/appwrite/services/Account.kt index da2f370..3198443 100644 --- a/src/main/kotlin/io/appwrite/services/Account.kt +++ b/src/main/kotlin/io/appwrite/services/Account.kt @@ -19,12 +19,12 @@ class Account : Service { * * Get currently logged in user data as JSON object. * - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun get( nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account" val params = mutableMapOf( @@ -32,9 +32,9 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -50,11 +50,11 @@ class Account : Service { * * Get currently logged in user data as JSON object. * - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun get( - ) = get( + ): io.appwrite.models.User> = get( nestedType = classOf(), ) @@ -65,14 +65,14 @@ class Account : Service { * * @param email User email. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updateEmail( email: String, password: String, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/email" val params = mutableMapOf( @@ -82,9 +82,9 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -102,13 +102,13 @@ class Account : Service { * * @param email User email. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updateEmail( email: String, password: String, - ) = updateEmail( + ): io.appwrite.models.User> = updateEmail( email, password, nestedType = classOf(), @@ -119,7 +119,7 @@ class Account : Service { * * Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only supported methods are limit and offset + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @return [io.appwrite.models.LogList] */ @JvmOverloads @@ -136,8 +136,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { - io.appwrite.models.LogList.from(map = it as Map) - } + io.appwrite.models.LogList.from(map = it as Map) + } return client.call( "GET", path, @@ -154,13 +154,13 @@ class Account : Service { * Update currently logged in user account name. * * @param name User name. Max length: 128 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updateName( name: String, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/name" val params = mutableMapOf( @@ -169,9 +169,9 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -188,12 +188,12 @@ class Account : Service { * Update currently logged in user account name. * * @param name User name. Max length: 128 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updateName( name: String, - ) = updateName( + ): io.appwrite.models.User> = updateName( name, nestedType = classOf(), ) @@ -205,7 +205,7 @@ class Account : Service { * * @param password New user password. Must be at least 8 chars. * @param oldPassword Current user password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) @@ -213,7 +213,7 @@ class Account : Service { password: String, oldPassword: String? = null, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/password" val params = mutableMapOf( @@ -223,9 +223,9 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -243,14 +243,14 @@ class Account : Service { * * @param password New user password. Must be at least 8 chars. * @param oldPassword Current user password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePassword( password: String, oldPassword: String? = null, - ) = updatePassword( + ): io.appwrite.models.User> = updatePassword( password, oldPassword, nestedType = classOf(), @@ -263,14 +263,14 @@ class Account : Service { * * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updatePhone( phone: String, password: String, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/phone" val params = mutableMapOf( @@ -280,9 +280,9 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -300,13 +300,13 @@ class Account : Service { * * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updatePhone( phone: String, password: String, - ) = updatePhone( + ): io.appwrite.models.User> = updatePhone( phone, password, nestedType = classOf(), @@ -331,8 +331,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { - io.appwrite.models.Preferences.from(map = it as Map, nestedType) - } + io.appwrite.models.Preferences.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -352,7 +352,7 @@ class Account : Service { */ @Throws(AppwriteException::class) suspend fun getPrefs( - ) = getPrefs( + ): io.appwrite.models.Preferences> = getPrefs( nestedType = classOf(), ) @@ -362,13 +362,13 @@ class Account : Service { * Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. * * @param prefs Prefs key-value JSON object. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Any, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/prefs" val params = mutableMapOf( @@ -377,9 +377,9 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -396,12 +396,12 @@ class Account : Service { * Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. * * @param prefs Prefs key-value JSON object. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Any, - ) = updatePrefs( + ): io.appwrite.models.User> = updatePrefs( prefs, nestedType = classOf(), ) @@ -430,8 +430,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -472,8 +472,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "PUT", path, @@ -502,8 +502,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { - io.appwrite.models.SessionList.from(map = it as Map) - } + io.appwrite.models.SessionList.from(map = it as Map) + } return client.call( "GET", path, @@ -561,8 +561,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it as Map) - } + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "GET", path, @@ -594,8 +594,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it as Map) - } + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "PATCH", path, @@ -640,12 +640,12 @@ class Account : Service { * * Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. * - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updateStatus( nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/status" val params = mutableMapOf( @@ -653,9 +653,9 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -671,11 +671,11 @@ class Account : Service { * * Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. * - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updateStatus( - ) = updateStatus( + ): io.appwrite.models.User> = updateStatus( nestedType = classOf(), ) @@ -700,8 +700,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -736,8 +736,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "PUT", path, @@ -766,8 +766,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -802,8 +802,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "PUT", path, diff --git a/src/main/kotlin/io/appwrite/services/Databases.kt b/src/main/kotlin/io/appwrite/services/Databases.kt index 6769b73..63a4782 100644 --- a/src/main/kotlin/io/appwrite/services/Databases.kt +++ b/src/main/kotlin/io/appwrite/services/Databases.kt @@ -19,7 +19,7 @@ class Databases : Service { * * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name + * @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. You may filter on the following attributes: name * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.DatabaseList] */ @@ -39,8 +39,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DatabaseList = { - io.appwrite.models.DatabaseList.from(map = it as Map) - } + io.appwrite.models.DatabaseList.from(map = it as Map) + } return client.call( "GET", path, @@ -56,7 +56,7 @@ class Databases : Service { * * Create a new Database. * - * @param databaseId Unique Id. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param databaseId Unique 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 name Collection name. Max length: 128 chars. * @return [io.appwrite.models.Database] */ @@ -75,8 +75,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Database = { - io.appwrite.models.Database.from(map = it as Map) - } + io.appwrite.models.Database.from(map = it as Map) + } return client.call( "POST", path, @@ -108,8 +108,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Database = { - io.appwrite.models.Database.from(map = it as Map) - } + io.appwrite.models.Database.from(map = it as Map) + } return client.call( "GET", path, @@ -144,8 +144,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Database = { - io.appwrite.models.Database.from(map = it as Map) - } + io.appwrite.models.Database.from(map = it as Map) + } return client.call( "PUT", path, @@ -191,7 +191,7 @@ class Databases : Service { * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. * * @param databaseId Database ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + * @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. You may filter on the following attributes: name, enabled, documentSecurity * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.CollectionList] */ @@ -213,8 +213,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CollectionList = { - io.appwrite.models.CollectionList.from(map = it as Map) - } + io.appwrite.models.CollectionList.from(map = it as Map) + } return client.call( "GET", path, @@ -231,9 +231,9 @@ class Databases : Service { * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. - * @param collectionId Unique Id. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param collectionId Unique 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 name Collection name. Max length: 128 chars. - * @param permissions An array of permissions strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions). * @param documentSecurity Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.Collection] */ @@ -259,8 +259,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Collection = { - io.appwrite.models.Collection.from(map = it as Map) - } + io.appwrite.models.Collection.from(map = it as Map) + } return client.call( "POST", path, @@ -295,8 +295,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Collection = { - io.appwrite.models.Collection.from(map = it as Map) - } + io.appwrite.models.Collection.from(map = it as Map) + } return client.call( "GET", path, @@ -315,7 +315,7 @@ class Databases : Service { * @param databaseId Database ID. * @param collectionId Collection ID. * @param name Collection name. Max length: 128 chars. - * @param permissions An array of permission strings. By default the current permission are inherited. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions). * @param documentSecurity Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions). * @param enabled Is collection enabled? * @return [io.appwrite.models.Collection] @@ -344,8 +344,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Collection = { - io.appwrite.models.Collection.from(map = it as Map) - } + io.appwrite.models.Collection.from(map = it as Map) + } return client.call( "PUT", path, @@ -412,8 +412,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeList = { - io.appwrite.models.AttributeList.from(map = it as Map) - } + io.appwrite.models.AttributeList.from(map = it as Map) + } return client.call( "GET", path, @@ -461,8 +461,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeBoolean = { - io.appwrite.models.AttributeBoolean.from(map = it as Map) - } + io.appwrite.models.AttributeBoolean.from(map = it as Map) + } return client.call( "POST", path, @@ -473,6 +473,51 @@ class Databases : Service { ) } + /** + * Update Boolean Attribute + * + * + * + * @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 key Attribute Key. + * @param required Is attribute required? + * @param default Default value for attribute when not provided. Cannot be set when attribute is required. + * @return [io.appwrite.models.AttributeBoolean] + */ + @Throws(AppwriteException::class) + suspend fun updateBooleanAttribute( + databaseId: String, + collectionId: String, + key: String, + required: Boolean, + default: Boolean? = null, + ): io.appwrite.models.AttributeBoolean { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "required" to required, + "default" to default, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeBoolean = { + io.appwrite.models.AttributeBoolean.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeBoolean::class.java, + converter, + ) + } + /** * Create DateTime Attribute * @@ -510,8 +555,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeDatetime = { - io.appwrite.models.AttributeDatetime.from(map = it as Map) - } + io.appwrite.models.AttributeDatetime.from(map = it as Map) + } return client.call( "POST", path, @@ -522,6 +567,51 @@ class Databases : Service { ) } + /** + * Update DateTime Attribute + * + * + * + * @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 key Attribute Key. + * @param required Is attribute required? + * @param default Default value for attribute when not provided. Cannot be set when attribute is required. + * @return [io.appwrite.models.AttributeDatetime] + */ + @Throws(AppwriteException::class) + suspend fun updateDatetimeAttribute( + databaseId: String, + collectionId: String, + key: String, + required: Boolean, + default: String? = null, + ): io.appwrite.models.AttributeDatetime { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "required" to required, + "default" to default, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeDatetime = { + io.appwrite.models.AttributeDatetime.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeDatetime::class.java, + converter, + ) + } + /** * Create Email Attribute * @@ -559,8 +649,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeEmail = { - io.appwrite.models.AttributeEmail.from(map = it as Map) - } + io.appwrite.models.AttributeEmail.from(map = it as Map) + } return client.call( "POST", path, @@ -571,6 +661,51 @@ class Databases : Service { ) } + /** + * Update Email Attribute + * + * Update an email attribute. Changing the `default` value will not update already existing documents. + * + * @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 key Attribute Key. + * @param required Is attribute required? + * @param default Default value for attribute when not provided. Cannot be set when attribute is required. + * @return [io.appwrite.models.AttributeEmail] + */ + @Throws(AppwriteException::class) + suspend fun updateEmailAttribute( + databaseId: String, + collectionId: String, + key: String, + required: Boolean, + default: String? = null, + ): io.appwrite.models.AttributeEmail { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "required" to required, + "default" to default, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeEmail = { + io.appwrite.models.AttributeEmail.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeEmail::class.java, + converter, + ) + } + /** * Create Enum Attribute * @@ -611,8 +746,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeEnum = { - io.appwrite.models.AttributeEnum.from(map = it as Map) - } + io.appwrite.models.AttributeEnum.from(map = it as Map) + } return client.call( "POST", path, @@ -623,6 +758,54 @@ class Databases : Service { ) } + /** + * Update Enum Attribute + * + * Update an enum attribute. Changing the `default` value will not update already existing documents. + * + * @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 key Attribute Key. + * @param elements Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 4096 characters long. + * @param required Is attribute required? + * @param default Default value for attribute when not provided. Cannot be set when attribute is required. + * @return [io.appwrite.models.AttributeEnum] + */ + @Throws(AppwriteException::class) + suspend fun updateEnumAttribute( + databaseId: String, + collectionId: String, + key: String, + elements: List, + required: Boolean, + default: String? = null, + ): io.appwrite.models.AttributeEnum { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "elements" to elements, + "required" to required, + "default" to default, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeEnum = { + io.appwrite.models.AttributeEnum.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeEnum::class.java, + converter, + ) + } + /** * Create Float Attribute * @@ -666,8 +849,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeFloat = { - io.appwrite.models.AttributeFloat.from(map = it as Map) - } + io.appwrite.models.AttributeFloat.from(map = it as Map) + } return client.call( "POST", path, @@ -678,6 +861,57 @@ class Databases : Service { ) } + /** + * Update Float Attribute + * + * Update a float attribute. Changing the `default` value will not update already existing documents. + * + * @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 key Attribute Key. + * @param required Is attribute required? + * @param min Minimum value to enforce on new documents + * @param max Maximum value to enforce on new documents + * @param default Default value for attribute when not provided. Cannot be set when attribute is required. + * @return [io.appwrite.models.AttributeFloat] + */ + @Throws(AppwriteException::class) + suspend fun updateFloatAttribute( + databaseId: String, + collectionId: String, + key: String, + required: Boolean, + min: Double, + max: Double, + default: Double? = null, + ): io.appwrite.models.AttributeFloat { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "required" to required, + "min" to min, + "max" to max, + "default" to default, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeFloat = { + io.appwrite.models.AttributeFloat.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeFloat::class.java, + converter, + ) + } + /** * Create Integer Attribute * @@ -721,8 +955,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeInteger = { - io.appwrite.models.AttributeInteger.from(map = it as Map) - } + io.appwrite.models.AttributeInteger.from(map = it as Map) + } return client.call( "POST", path, @@ -733,6 +967,57 @@ class Databases : Service { ) } + /** + * Update Integer Attribute + * + * Update an integer attribute. Changing the `default` value will not update already existing documents. + * + * @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 key Attribute Key. + * @param required Is attribute required? + * @param min Minimum value to enforce on new documents + * @param max Maximum value to enforce on new documents + * @param default Default value for attribute when not provided. Cannot be set when attribute is required. + * @return [io.appwrite.models.AttributeInteger] + */ + @Throws(AppwriteException::class) + suspend fun updateIntegerAttribute( + databaseId: String, + collectionId: String, + key: String, + required: Boolean, + min: Long, + max: Long, + default: Long? = null, + ): io.appwrite.models.AttributeInteger { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "required" to required, + "min" to min, + "max" to max, + "default" to default, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeInteger = { + io.appwrite.models.AttributeInteger.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeInteger::class.java, + converter, + ) + } + /** * Create IP Address Attribute * @@ -770,8 +1055,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeIp = { - io.appwrite.models.AttributeIp.from(map = it as Map) - } + io.appwrite.models.AttributeIp.from(map = it as Map) + } return client.call( "POST", path, @@ -782,6 +1067,106 @@ class Databases : Service { ) } + /** + * Update IP Address Attribute + * + * Update an ip attribute. Changing the `default` value will not update already existing documents. + * + * @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 key Attribute Key. + * @param required Is attribute required? + * @param default Default value for attribute when not provided. Cannot be set when attribute is required. + * @return [io.appwrite.models.AttributeIp] + */ + @Throws(AppwriteException::class) + suspend fun updateIpAttribute( + databaseId: String, + collectionId: String, + key: String, + required: Boolean, + default: String? = null, + ): io.appwrite.models.AttributeIp { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "required" to required, + "default" to default, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeIp = { + io.appwrite.models.AttributeIp.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeIp::class.java, + converter, + ) + } + + /** + * Create Relationship Attribute + * + * Create relationship attribute. [Learn more about relationship attributes](docs/databases-relationships#relationship-attributes). + * + * @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 relatedCollectionId Related Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param type Relation type + * @param twoWay Is Two Way? + * @param key Attribute Key. + * @param twoWayKey Two Way Attribute Key. + * @param onDelete Constraints option + * @return [io.appwrite.models.AttributeRelationship] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createRelationshipAttribute( + databaseId: String, + collectionId: String, + relatedCollectionId: String, + type: String, + twoWay: Boolean? = null, + key: String? = null, + twoWayKey: String? = null, + onDelete: String? = null, + ): io.appwrite.models.AttributeRelationship { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + + val params = mutableMapOf( + "relatedCollectionId" to relatedCollectionId, + "type" to type, + "twoWay" to twoWay, + "key" to key, + "twoWayKey" to twoWayKey, + "onDelete" to onDelete, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeRelationship = { + io.appwrite.models.AttributeRelationship.from(map = it as Map) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.AttributeRelationship::class.java, + converter, + ) + } + /** * Create String Attribute * @@ -822,8 +1207,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeString = { - io.appwrite.models.AttributeString.from(map = it as Map) - } + io.appwrite.models.AttributeString.from(map = it as Map) + } return client.call( "POST", path, @@ -834,6 +1219,51 @@ class Databases : Service { ) } + /** + * Update String Attribute + * + * Update a string attribute. Changing the `default` value will not update already existing documents. + * + * @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 key Attribute Key. + * @param required Is attribute required? + * @param default Default value for attribute when not provided. Cannot be set when attribute is required. + * @return [io.appwrite.models.AttributeString] + */ + @Throws(AppwriteException::class) + suspend fun updateStringAttribute( + databaseId: String, + collectionId: String, + key: String, + required: Boolean, + default: String? = null, + ): io.appwrite.models.AttributeString { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "required" to required, + "default" to default, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeString = { + io.appwrite.models.AttributeString.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeString::class.java, + converter, + ) + } + /** * Create URL Attribute * @@ -871,8 +1301,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.AttributeUrl = { - io.appwrite.models.AttributeUrl.from(map = it as Map) - } + io.appwrite.models.AttributeUrl.from(map = it as Map) + } return client.call( "POST", path, @@ -883,6 +1313,51 @@ class Databases : Service { ) } + /** + * Update URL Attribute + * + * Update an url attribute. Changing the `default` value will not update already existing documents. + * + * @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 key Attribute Key. + * @param required Is attribute required? + * @param default Default value for attribute when not provided. Cannot be set when attribute is required. + * @return [io.appwrite.models.AttributeUrl] + */ + @Throws(AppwriteException::class) + suspend fun updateUrlAttribute( + databaseId: String, + collectionId: String, + key: String, + required: Boolean, + default: String? = null, + ): io.appwrite.models.AttributeUrl { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "required" to required, + "default" to default, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeUrl = { + io.appwrite.models.AttributeUrl.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeUrl::class.java, + converter, + ) + } + /** * Get Attribute * @@ -953,6 +1428,49 @@ class Databases : Service { ) } + /** + * Update Relationship Attribute + * + * Update relationship attribute. [Learn more about relationship attributes](docs/databases-relationships#relationship-attributes). + * + * @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 key Attribute Key. + * @param onDelete Constraints option + * @return [io.appwrite.models.AttributeRelationship] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateRelationshipAttribute( + databaseId: String, + collectionId: String, + key: String, + onDelete: String? = null, + ): io.appwrite.models.AttributeRelationship { + val path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{key}", key) + + val params = mutableMapOf( + "onDelete" to onDelete, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AttributeRelationship = { + io.appwrite.models.AttributeRelationship.from(map = it as Map) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.AttributeRelationship::class.java, + converter, + ) + } + /** * List Documents * @@ -960,7 +1478,7 @@ class Databases : Service { * * @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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @@ -982,8 +1500,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { - io.appwrite.models.DocumentList.from(map = it as Map, nestedType) - } + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -1001,7 +1519,7 @@ class Databases : Service { * * @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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @@ -1010,7 +1528,7 @@ class Databases : Service { databaseId: String, collectionId: String, queries: List? = null, - ) = listDocuments( + ): io.appwrite.models.DocumentList> = listDocuments( databaseId, collectionId, queries, @@ -1024,9 +1542,9 @@ class Databases : Service { * * @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 documentId Document ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @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 the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -1052,8 +1570,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { - io.appwrite.models.Document.from(map = it as Map, nestedType) - } + io.appwrite.models.Document.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -1071,9 +1589,9 @@ class Databases : Service { * * @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 documentId Document ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @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 the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -1084,7 +1602,7 @@ class Databases : Service { documentId: String, data: Any, permissions: List? = null, - ) = createDocument( + ): io.appwrite.models.Document> = createDocument( databaseId, collectionId, documentId, @@ -1101,13 +1619,16 @@ class Databases : Service { * @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 queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only method allowed is select. * @return [io.appwrite.models.Document] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( databaseId: String, collectionId: String, documentId: String, + queries: List? = null, nestedType: Class, ): io.appwrite.models.Document { val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -1116,13 +1637,14 @@ class Databases : Service { .replace("{documentId}", documentId) val params = mutableMapOf( + "queries" to queries, ) val headers = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { - io.appwrite.models.Document.from(map = it as Map, nestedType) - } + io.appwrite.models.Document.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -1141,17 +1663,21 @@ class Databases : Service { * @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 queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only method allowed is select. * @return [io.appwrite.models.Document] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( databaseId: String, collectionId: String, documentId: String, - ) = getDocument( + queries: List? = null, + ): io.appwrite.models.Document> = getDocument( databaseId, collectionId, documentId, + queries, nestedType = classOf(), ) @@ -1164,7 +1690,7 @@ class Databases : Service { * @param collectionId Collection ID. * @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](/docs/permissions). + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -1190,8 +1716,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { - io.appwrite.models.Document.from(map = it as Map, nestedType) - } + io.appwrite.models.Document.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -1211,7 +1737,7 @@ class Databases : Service { * @param collectionId Collection ID. * @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](/docs/permissions). + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -1222,7 +1748,7 @@ class Databases : Service { documentId: String, data: Any? = null, permissions: List? = null, - ) = updateDocument( + ): io.appwrite.models.Document> = updateDocument( databaseId, collectionId, documentId, @@ -1290,8 +1816,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.IndexList = { - io.appwrite.models.IndexList.from(map = it as Map) - } + io.appwrite.models.IndexList.from(map = it as Map) + } return client.call( "GET", path, @@ -1339,8 +1865,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Index = { - io.appwrite.models.Index.from(map = it as Map) - } + io.appwrite.models.Index.from(map = it as Map) + } return client.call( "POST", path, @@ -1378,8 +1904,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Index = { - io.appwrite.models.Index.from(map = it as Map) - } + io.appwrite.models.Index.from(map = it as Map) + } return client.call( "GET", path, diff --git a/src/main/kotlin/io/appwrite/services/Functions.kt b/src/main/kotlin/io/appwrite/services/Functions.kt index cc00115..df2ddb8 100644 --- a/src/main/kotlin/io/appwrite/services/Functions.kt +++ b/src/main/kotlin/io/appwrite/services/Functions.kt @@ -19,7 +19,7 @@ class Functions : Service { * * Get a list of all the project's functions. You can use the query params to filter your results. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout + * @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. You may filter on the following attributes: name, enabled, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.FunctionList] */ @@ -39,8 +39,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FunctionList = { - io.appwrite.models.FunctionList.from(map = it as Map) - } + io.appwrite.models.FunctionList.from(map = it as Map) + } return client.call( "GET", path, @@ -56,10 +56,10 @@ class Functions : Service { * * Create a new function. You can pass a list of [permissions](/docs/permissions) to allow different project users or team with access to execute the function using the client API. * - * @param functionId Function ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param functionId Function 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 name Function name. Max length: 128 chars. - * @param execute An array of strings with execution roles. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 64 characters long. * @param runtime Execution runtime. + * @param execute An array of strings with execution roles. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 64 characters long. * @param events Events list. Maximum of 100 events are allowed. * @param schedule Schedule CRON syntax. * @param timeout Function maximum execution time in seconds. @@ -71,8 +71,8 @@ class Functions : Service { suspend fun create( functionId: String, name: String, - execute: List, runtime: String, + execute: List? = null, events: List? = null, schedule: String? = null, timeout: Long? = null, @@ -94,8 +94,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Function = { - io.appwrite.models.Function.from(map = it as Map) - } + io.appwrite.models.Function.from(map = it as Map) + } return client.call( "POST", path, @@ -124,8 +124,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.RuntimeList = { - io.appwrite.models.RuntimeList.from(map = it as Map) - } + io.appwrite.models.RuntimeList.from(map = it as Map) + } return client.call( "GET", path, @@ -157,8 +157,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Function = { - io.appwrite.models.Function.from(map = it as Map) - } + io.appwrite.models.Function.from(map = it as Map) + } return client.call( "GET", path, @@ -188,7 +188,7 @@ class Functions : Service { suspend fun update( functionId: String, name: String, - execute: List, + execute: List? = null, events: List? = null, schedule: String? = null, timeout: Long? = null, @@ -209,8 +209,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Function = { - io.appwrite.models.Function.from(map = it as Map) - } + io.appwrite.models.Function.from(map = it as Map) + } return client.call( "PUT", path, @@ -256,7 +256,7 @@ class Functions : Service { * Get a list of all the project's code deployments. You can use the query params to filter your results. * * @param functionId Function ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: entrypoint, size, buildId, activate + * @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. You may filter on the following attributes: entrypoint, size, buildId, activate * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.DeploymentList] */ @@ -278,8 +278,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DeploymentList = { - io.appwrite.models.DeploymentList.from(map = it as Map) - } + io.appwrite.models.DeploymentList.from(map = it as Map) + } return client.call( "GET", path, @@ -321,8 +321,8 @@ class Functions : Service { "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.Deployment = { - io.appwrite.models.Deployment.from(map = it as Map) - } + io.appwrite.models.Deployment.from(map = it as Map) + } val idParamName: String? = null val paramName = "code" return client.chunkedUpload( @@ -361,8 +361,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Deployment = { - io.appwrite.models.Deployment.from(map = it as Map) - } + io.appwrite.models.Deployment.from(map = it as Map) + } return client.call( "GET", path, @@ -397,8 +397,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Function = { - io.appwrite.models.Function.from(map = it as Map) - } + io.appwrite.models.Function.from(map = it as Map) + } return client.call( "PATCH", path, @@ -482,7 +482,7 @@ class Functions : Service { * Get a list of all the current user function execution logs. You can use the query params to filter your results. * * @param functionId Function ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, statusCode, duration + * @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. You may filter on the following attributes: trigger, status, statusCode, duration * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.ExecutionList] */ @@ -504,8 +504,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { - io.appwrite.models.ExecutionList.from(map = it as Map) - } + io.appwrite.models.ExecutionList.from(map = it as Map) + } return client.call( "GET", path, @@ -544,8 +544,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { - io.appwrite.models.Execution.from(map = it as Map) - } + io.appwrite.models.Execution.from(map = it as Map) + } return client.call( "POST", path, @@ -580,8 +580,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { - io.appwrite.models.Execution.from(map = it as Map) - } + io.appwrite.models.Execution.from(map = it as Map) + } return client.call( "GET", path, @@ -613,8 +613,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.VariableList = { - io.appwrite.models.VariableList.from(map = it as Map) - } + io.appwrite.models.VariableList.from(map = it as Map) + } return client.call( "GET", path, @@ -652,8 +652,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Variable = { - io.appwrite.models.Variable.from(map = it as Map) - } + io.appwrite.models.Variable.from(map = it as Map) + } return client.call( "POST", path, @@ -688,8 +688,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Variable = { - io.appwrite.models.Variable.from(map = it as Map) - } + io.appwrite.models.Variable.from(map = it as Map) + } return client.call( "GET", path, @@ -731,8 +731,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Variable = { - io.appwrite.models.Variable.from(map = it as Map) - } + io.appwrite.models.Variable.from(map = it as Map) + } return client.call( "PUT", path, diff --git a/src/main/kotlin/io/appwrite/services/Graphql.kt b/src/main/kotlin/io/appwrite/services/Graphql.kt index 3819084..0be1844 100644 --- a/src/main/kotlin/io/appwrite/services/Graphql.kt +++ b/src/main/kotlin/io/appwrite/services/Graphql.kt @@ -36,8 +36,8 @@ class Graphql : Service { "content-type" to "application/json", ) val converter: (Any) -> Any = { - it - } + it + } return client.call( "POST", path, @@ -70,8 +70,8 @@ class Graphql : Service { "content-type" to "application/json", ) val converter: (Any) -> Any = { - it - } + it + } return client.call( "POST", path, diff --git a/src/main/kotlin/io/appwrite/services/Health.kt b/src/main/kotlin/io/appwrite/services/Health.kt index 3a20e73..66f737c 100644 --- a/src/main/kotlin/io/appwrite/services/Health.kt +++ b/src/main/kotlin/io/appwrite/services/Health.kt @@ -32,8 +32,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthStatus = { - io.appwrite.models.HealthStatus.from(map = it as Map) - } + io.appwrite.models.HealthStatus.from(map = it as Map) + } return client.call( "GET", path, @@ -62,8 +62,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthAntivirus = { - io.appwrite.models.HealthAntivirus.from(map = it as Map) - } + io.appwrite.models.HealthAntivirus.from(map = it as Map) + } return client.call( "GET", path, @@ -92,8 +92,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthStatus = { - io.appwrite.models.HealthStatus.from(map = it as Map) - } + io.appwrite.models.HealthStatus.from(map = it as Map) + } return client.call( "GET", path, @@ -122,8 +122,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthStatus = { - io.appwrite.models.HealthStatus.from(map = it as Map) - } + io.appwrite.models.HealthStatus.from(map = it as Map) + } return client.call( "GET", path, @@ -152,8 +152,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthQueue = { - io.appwrite.models.HealthQueue.from(map = it as Map) - } + io.appwrite.models.HealthQueue.from(map = it as Map) + } return client.call( "GET", path, @@ -182,8 +182,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthQueue = { - io.appwrite.models.HealthQueue.from(map = it as Map) - } + io.appwrite.models.HealthQueue.from(map = it as Map) + } return client.call( "GET", path, @@ -212,8 +212,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthQueue = { - io.appwrite.models.HealthQueue.from(map = it as Map) - } + io.appwrite.models.HealthQueue.from(map = it as Map) + } return client.call( "GET", path, @@ -242,8 +242,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthQueue = { - io.appwrite.models.HealthQueue.from(map = it as Map) - } + io.appwrite.models.HealthQueue.from(map = it as Map) + } return client.call( "GET", path, @@ -272,8 +272,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthStatus = { - io.appwrite.models.HealthStatus.from(map = it as Map) - } + io.appwrite.models.HealthStatus.from(map = it as Map) + } return client.call( "GET", path, @@ -302,8 +302,8 @@ class Health : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.HealthTime = { - io.appwrite.models.HealthTime.from(map = it as Map) - } + io.appwrite.models.HealthTime.from(map = it as Map) + } return client.call( "GET", path, diff --git a/src/main/kotlin/io/appwrite/services/Locale.kt b/src/main/kotlin/io/appwrite/services/Locale.kt index 76d8173..85b3ee0 100644 --- a/src/main/kotlin/io/appwrite/services/Locale.kt +++ b/src/main/kotlin/io/appwrite/services/Locale.kt @@ -32,8 +32,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { - io.appwrite.models.Locale.from(map = it as Map) - } + io.appwrite.models.Locale.from(map = it as Map) + } return client.call( "GET", path, @@ -62,8 +62,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { - io.appwrite.models.ContinentList.from(map = it as Map) - } + io.appwrite.models.ContinentList.from(map = it as Map) + } return client.call( "GET", path, @@ -92,8 +92,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { - io.appwrite.models.CountryList.from(map = it as Map) - } + io.appwrite.models.CountryList.from(map = it as Map) + } return client.call( "GET", path, @@ -122,8 +122,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { - io.appwrite.models.CountryList.from(map = it as Map) - } + io.appwrite.models.CountryList.from(map = it as Map) + } return client.call( "GET", path, @@ -152,8 +152,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { - io.appwrite.models.PhoneList.from(map = it as Map) - } + io.appwrite.models.PhoneList.from(map = it as Map) + } return client.call( "GET", path, @@ -182,8 +182,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { - io.appwrite.models.CurrencyList.from(map = it as Map) - } + io.appwrite.models.CurrencyList.from(map = it as Map) + } return client.call( "GET", path, @@ -212,8 +212,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { - io.appwrite.models.LanguageList.from(map = it as Map) - } + io.appwrite.models.LanguageList.from(map = it as Map) + } return client.call( "GET", path, diff --git a/src/main/kotlin/io/appwrite/services/Storage.kt b/src/main/kotlin/io/appwrite/services/Storage.kt index f17d70b..b90b306 100644 --- a/src/main/kotlin/io/appwrite/services/Storage.kt +++ b/src/main/kotlin/io/appwrite/services/Storage.kt @@ -21,7 +21,7 @@ class Storage : Service { * * Get a list of all the storage buckets. You can use the query params to filter your results. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus + * @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. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.BucketList] */ @@ -41,8 +41,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.BucketList = { - io.appwrite.models.BucketList.from(map = it as Map) - } + io.appwrite.models.BucketList.from(map = it as Map) + } return client.call( "GET", path, @@ -58,9 +58,9 @@ class Storage : Service { * * Create a new storage bucket. * - * @param bucketId Unique Id. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param bucketId Unique 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 name Bucket name - * @param permissions An array of permission strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions). * @param fileSecurity Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions). * @param enabled Is bucket enabled? * @param maximumFileSize Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self-hosted setups you can change the max limit by changing the `_APP_STORAGE_LIMIT` environment variable. [Learn more about storage environment variables](docs/environment-variables#storage) @@ -102,8 +102,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Bucket = { - io.appwrite.models.Bucket.from(map = it as Map) - } + io.appwrite.models.Bucket.from(map = it as Map) + } return client.call( "POST", path, @@ -135,8 +135,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Bucket = { - io.appwrite.models.Bucket.from(map = it as Map) - } + io.appwrite.models.Bucket.from(map = it as Map) + } return client.call( "GET", path, @@ -154,7 +154,7 @@ class Storage : Service { * * @param bucketId Bucket unique ID. * @param name Bucket name - * @param permissions An array of permission strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions). * @param fileSecurity Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions). * @param enabled Is bucket enabled? * @param maximumFileSize Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](docs/environment-variables#storage) @@ -196,8 +196,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Bucket = { - io.appwrite.models.Bucket.from(map = it as Map) - } + io.appwrite.models.Bucket.from(map = it as Map) + } return client.call( "PUT", path, @@ -243,7 +243,7 @@ class Storage : Service { * Get a list of all the user files. You can use the query params to filter your results. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded + * @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. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.FileList] */ @@ -265,8 +265,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { - io.appwrite.models.FileList.from(map = it as Map) - } + io.appwrite.models.FileList.from(map = it as Map) + } return client.call( "GET", path, @@ -283,9 +283,9 @@ class Storage : Service { * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console.Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes.When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one.If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). - * @param fileId File ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param fileId File 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 file Binary file. - * @param permissions An array of permission strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.File] */ @JvmOverloads @@ -309,8 +309,8 @@ class Storage : Service { "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.File = { - io.appwrite.models.File.from(map = it as Map) - } + io.appwrite.models.File.from(map = it as Map) + } val idParamName: String? = "fileId" val paramName = "file" return client.chunkedUpload( @@ -349,8 +349,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { - io.appwrite.models.File.from(map = it as Map) - } + io.appwrite.models.File.from(map = it as Map) + } return client.call( "GET", path, @@ -368,7 +368,7 @@ class Storage : Service { * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param fileId File unique ID. - * @param permissions An array of permission string. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.File] */ @JvmOverloads @@ -389,8 +389,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { - io.appwrite.models.File.from(map = it as Map) - } + io.appwrite.models.File.from(map = it as Map) + } return client.call( "PUT", path, diff --git a/src/main/kotlin/io/appwrite/services/Teams.kt b/src/main/kotlin/io/appwrite/services/Teams.kt index 9580dce..e4214cd 100644 --- a/src/main/kotlin/io/appwrite/services/Teams.kt +++ b/src/main/kotlin/io/appwrite/services/Teams.kt @@ -19,16 +19,17 @@ class Teams : Service { * * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total + * @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. You may filter on the following attributes: name, total * @param search Search term to filter your list results. Max length: 256 chars. - * @return [io.appwrite.models.TeamList] + * @return [io.appwrite.models.TeamList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun list( + suspend fun list( queries: List? = null, search: String? = null, - ): io.appwrite.models.TeamList { + nestedType: Class, + ): io.appwrite.models.TeamList { val path = "/teams" val params = mutableMapOf( @@ -38,36 +39,57 @@ class Teams : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.TeamList = { - io.appwrite.models.TeamList.from(map = it as Map) - } + val converter: (Any) -> io.appwrite.models.TeamList = { + io.appwrite.models.TeamList.from(map = it as Map, nestedType) + } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.TeamList::class.java, + responseType = classOf(), converter, ) } + /** + * List Teams + * + * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. + * + * @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. You may filter on the following attributes: name, total + * @param search Search term to filter your list results. Max length: 256 chars. + * @return [io.appwrite.models.TeamList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun list( + queries: List? = null, + search: String? = null, + ): io.appwrite.models.TeamList> = list( + queries, + search, + nestedType = classOf(), + ) + /** * Create Team * * Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. * - * @param teamId Team ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param teamId Team 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 name Team name. Max length: 128 chars. * @param roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. - * @return [io.appwrite.models.Team] + * @return [io.appwrite.models.Team] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun create( + suspend fun create( teamId: String, name: String, roles: List? = null, - ): io.appwrite.models.Team { + nestedType: Class, + ): io.appwrite.models.Team { val path = "/teams" val params = mutableMapOf( @@ -78,15 +100,72 @@ class Teams : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it as Map) - } + val converter: (Any) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it as Map, nestedType) + } return client.call( "POST", path, headers, params, - responseType = io.appwrite.models.Team::class.java, + responseType = classOf(), + converter, + ) + } + + /** + * Create Team + * + * Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. + * + * @param teamId Team 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 name Team name. Max length: 128 chars. + * @param roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + * @return [io.appwrite.models.Team] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun create( + teamId: String, + name: String, + roles: List? = null, + ): io.appwrite.models.Team> = create( + teamId, + name, + roles, + nestedType = classOf(), + ) + + /** + * Get Team + * + * Get a team by its ID. All team members have read access for this resource. + * + * @param teamId Team ID. + * @return [io.appwrite.models.Team] + */ + @Throws(AppwriteException::class) + suspend fun get( + teamId: String, + nestedType: Class, + ): io.appwrite.models.Team { + val path = "/teams/{teamId}" + .replace("{teamId}", teamId) + + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it as Map, nestedType) + } + return client.call( + "GET", + path, + headers, + params, + responseType = classOf(), converter, ) } @@ -97,47 +176,31 @@ class Teams : Service { * Get a team by its ID. All team members have read access for this resource. * * @param teamId Team ID. - * @return [io.appwrite.models.Team] + * @return [io.appwrite.models.Team] */ @Throws(AppwriteException::class) suspend fun get( teamId: String, - ): io.appwrite.models.Team { - val path = "/teams/{teamId}" - .replace("{teamId}", teamId) - - val params = mutableMapOf( - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it as Map) - } - return client.call( - "GET", - path, - headers, - params, - responseType = io.appwrite.models.Team::class.java, - converter, - ) - } + ): io.appwrite.models.Team> = get( + teamId, + nestedType = classOf(), + ) /** - * Update Team + * Update Name * - * Update a team using its ID. Only members with the owner role can update the team. + * Update the team's name by its unique ID. * * @param teamId Team ID. * @param name New team name. Max length: 128 chars. - * @return [io.appwrite.models.Team] + * @return [io.appwrite.models.Team] */ @Throws(AppwriteException::class) - suspend fun update( + suspend fun updateName( teamId: String, name: String, - ): io.appwrite.models.Team { + nestedType: Class, + ): io.appwrite.models.Team { val path = "/teams/{teamId}" .replace("{teamId}", teamId) @@ -147,19 +210,38 @@ class Teams : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it as Map) - } + val converter: (Any) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it as Map, nestedType) + } return client.call( "PUT", path, headers, params, - responseType = io.appwrite.models.Team::class.java, + responseType = classOf(), converter, ) } + /** + * Update Name + * + * Update the team's name by its unique ID. + * + * @param teamId Team ID. + * @param name New team name. Max length: 128 chars. + * @return [io.appwrite.models.Team] + */ + @Throws(AppwriteException::class) + suspend fun updateName( + teamId: String, + name: String, + ): io.appwrite.models.Team> = updateName( + teamId, + name, + nestedType = classOf(), + ) + /** * Delete Team * @@ -195,7 +277,7 @@ class Teams : Service { * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. * * @param teamId Team ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm + * @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. You may filter on the following attributes: userId, teamId, invited, joined, confirm * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.MembershipList] */ @@ -217,8 +299,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { - io.appwrite.models.MembershipList.from(map = it as Map) - } + io.appwrite.models.MembershipList.from(map = it as Map) + } return client.call( "GET", path, @@ -232,12 +314,14 @@ class Teams : Service { /** * Create Team Membership * - * Invite a new member to join your team. If initiated from the client SDK, an email with a link to join the team will be sent to the member's email address and an account will be created for them should they not be signed up already. If initiated from server-side SDKs, the new member will automatically be added to the team.Use the 'url' parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the [Update Team Membership Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team. Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URL's are the once from domains you have set when adding your platforms in the console interface. + * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team.You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters.Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team. Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. * * @param teamId Team ID. - * @param email Email of the new team member. * @param roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @param url URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @param email Email of the new team member. + * @param userId ID of the user to be added to a team. + * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param name Name of the new team member. Max length: 128 chars. * @return [io.appwrite.models.Membership] */ @@ -245,9 +329,11 @@ class Teams : Service { @Throws(AppwriteException::class) suspend fun createMembership( teamId: String, - email: String, roles: List, url: String, + email: String? = null, + userId: String? = null, + phone: String? = null, name: String? = null, ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships" @@ -255,6 +341,8 @@ class Teams : Service { val params = mutableMapOf( "email" to email, + "userId" to userId, + "phone" to phone, "roles" to roles, "url" to url, "name" to name, @@ -263,8 +351,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it as Map) - } + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "POST", path, @@ -299,8 +387,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it as Map) - } + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "GET", path, @@ -338,8 +426,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it as Map) - } + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "PATCH", path, @@ -412,8 +500,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it as Map) - } + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "PATCH", path, @@ -424,4 +512,110 @@ class Teams : Service { ) } + /** + * Get Team Preferences + * + * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](/docs/client/account#accountGetPrefs). + * + * @param teamId Team ID. + * @return [io.appwrite.models.Preferences] + */ + @Throws(AppwriteException::class) + suspend fun getPrefs( + teamId: String, + nestedType: Class, + ): io.appwrite.models.Preferences { + val path = "/teams/{teamId}/prefs" + .replace("{teamId}", teamId) + + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Preferences = { + io.appwrite.models.Preferences.from(map = it as Map, nestedType) + } + return client.call( + "GET", + path, + headers, + params, + responseType = classOf(), + converter, + ) + } + + /** + * Get Team Preferences + * + * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](/docs/client/account#accountGetPrefs). + * + * @param teamId Team ID. + * @return [io.appwrite.models.Preferences] + */ + @Throws(AppwriteException::class) + suspend fun getPrefs( + teamId: String, + ): io.appwrite.models.Preferences> = getPrefs( + teamId, + nestedType = classOf(), + ) + + /** + * Update Preferences + * + * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. + * + * @param teamId Team ID. + * @param prefs Prefs key-value JSON object. + * @return [io.appwrite.models.Preferences] + */ + @Throws(AppwriteException::class) + suspend fun updatePrefs( + teamId: String, + prefs: Any, + nestedType: Class, + ): io.appwrite.models.Preferences { + val path = "/teams/{teamId}/prefs" + .replace("{teamId}", teamId) + + val params = mutableMapOf( + "prefs" to prefs, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Preferences = { + io.appwrite.models.Preferences.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = classOf(), + converter, + ) + } + + /** + * Update Preferences + * + * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. + * + * @param teamId Team ID. + * @param prefs Prefs key-value JSON object. + * @return [io.appwrite.models.Preferences] + */ + @Throws(AppwriteException::class) + suspend fun updatePrefs( + teamId: String, + prefs: Any, + ): io.appwrite.models.Preferences> = updatePrefs( + teamId, + prefs, + nestedType = classOf(), + ) + } \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/services/Users.kt b/src/main/kotlin/io/appwrite/services/Users.kt index 0cfcf6e..81082c2 100644 --- a/src/main/kotlin/io/appwrite/services/Users.kt +++ b/src/main/kotlin/io/appwrite/services/Users.kt @@ -19,7 +19,7 @@ class Users : Service { * * Get a list of all the project's users. You can use the query params to filter your results. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification + * @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. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.UserList] */ @@ -40,8 +40,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.UserList = { - io.appwrite.models.UserList.from(map = it as Map, nestedType) - } + io.appwrite.models.UserList.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -57,7 +57,7 @@ class Users : Service { * * Get a list of all the project's users. You can use the query params to filter your results. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification + * @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. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.UserList] */ @@ -66,7 +66,7 @@ class Users : Service { suspend fun list( queries: List? = null, search: String? = null, - ) = list( + ): io.appwrite.models.UserList> = list( queries, search, nestedType = classOf(), @@ -77,7 +77,7 @@ class Users : Service { * * Create a new user. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param password Plain text user password. Must be at least 8 chars. @@ -107,8 +107,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -124,7 +124,7 @@ class Users : Service { * * Create a new user. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param password Plain text user password. Must be at least 8 chars. @@ -139,7 +139,7 @@ class Users : Service { phone: String? = null, password: String? = null, name: String? = null, - ) = create( + ): io.appwrite.models.User> = create( userId, email, phone, @@ -153,7 +153,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using Argon2. * @param name User name. Max length: 128 chars. @@ -180,8 +180,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -197,7 +197,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using Argon2. * @param name User name. Max length: 128 chars. @@ -210,7 +210,7 @@ class Users : Service { email: String, password: String, name: String? = null, - ) = createArgon2User( + ): io.appwrite.models.User> = createArgon2User( userId, email, password, @@ -223,7 +223,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using Bcrypt. * @param name User name. Max length: 128 chars. @@ -250,8 +250,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -267,7 +267,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using Bcrypt. * @param name User name. Max length: 128 chars. @@ -280,7 +280,7 @@ class Users : Service { email: String, password: String, name: String? = null, - ) = createBcryptUser( + ): io.appwrite.models.User> = createBcryptUser( userId, email, password, @@ -293,7 +293,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using MD5. * @param name User name. Max length: 128 chars. @@ -320,8 +320,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -337,7 +337,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using MD5. * @param name User name. Max length: 128 chars. @@ -350,7 +350,7 @@ class Users : Service { email: String, password: String, name: String? = null, - ) = createMD5User( + ): io.appwrite.models.User> = createMD5User( userId, email, password, @@ -363,7 +363,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User ID. Choose a custom ID or pass the string `ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param email User email. * @param password User password hashed using PHPass. * @param name User name. Max length: 128 chars. @@ -390,8 +390,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -407,7 +407,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User ID. Choose a custom ID or pass the string `ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param email User email. * @param password User password hashed using PHPass. * @param name User name. Max length: 128 chars. @@ -420,7 +420,7 @@ class Users : Service { email: String, password: String, name: String? = null, - ) = createPHPassUser( + ): io.appwrite.models.User> = createPHPassUser( userId, email, password, @@ -433,7 +433,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using Scrypt. * @param passwordSalt Optional salt used to hash password. @@ -475,8 +475,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -492,7 +492,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using Scrypt. * @param passwordSalt Optional salt used to hash password. @@ -515,7 +515,7 @@ class Users : Service { passwordParallel: Long, passwordLength: Long, name: String? = null, - ) = createScryptUser( + ): io.appwrite.models.User> = createScryptUser( userId, email, password, @@ -533,7 +533,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using Scrypt Modified. * @param passwordSalt Salt used to hash password. @@ -569,8 +569,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -586,7 +586,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using Scrypt Modified. * @param passwordSalt Salt used to hash password. @@ -605,7 +605,7 @@ class Users : Service { passwordSaltSeparator: String, passwordSignerKey: String, name: String? = null, - ) = createScryptModifiedUser( + ): io.appwrite.models.User> = createScryptModifiedUser( userId, email, password, @@ -621,7 +621,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using SHA. * @param passwordVersion Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512' @@ -651,8 +651,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -668,7 +668,7 @@ class Users : Service { * * Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param userId User ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId User 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 email User email. * @param password User password hashed using SHA. * @param passwordVersion Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512' @@ -683,7 +683,7 @@ class Users : Service { password: String, passwordVersion: String? = null, name: String? = null, - ) = createSHAUser( + ): io.appwrite.models.User> = createSHAUser( userId, email, password, @@ -714,8 +714,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -737,7 +737,7 @@ class Users : Service { @Throws(AppwriteException::class) suspend fun get( userId: String, - ) = get( + ): io.appwrite.models.User> = get( userId, nestedType = classOf(), ) @@ -796,8 +796,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -821,7 +821,7 @@ class Users : Service { suspend fun updateEmail( userId: String, email: String, - ) = updateEmail( + ): io.appwrite.models.User> = updateEmail( userId, email, nestedType = classOf(), @@ -833,7 +833,7 @@ class Users : Service { * Get the user activity logs list by its unique ID. * * @param userId User ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only supported methods are limit and offset + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @return [io.appwrite.models.LogList] */ @JvmOverloads @@ -852,8 +852,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { - io.appwrite.models.LogList.from(map = it as Map) - } + io.appwrite.models.LogList.from(map = it as Map) + } return client.call( "GET", path, @@ -885,8 +885,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { - io.appwrite.models.MembershipList.from(map = it as Map) - } + io.appwrite.models.MembershipList.from(map = it as Map) + } return client.call( "GET", path, @@ -922,8 +922,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -947,7 +947,7 @@ class Users : Service { suspend fun updateName( userId: String, name: String, - ) = updateName( + ): io.appwrite.models.User> = updateName( userId, name, nestedType = classOf(), @@ -978,8 +978,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -1003,7 +1003,7 @@ class Users : Service { suspend fun updatePassword( userId: String, password: String, - ) = updatePassword( + ): io.appwrite.models.User> = updatePassword( userId, password, nestedType = classOf(), @@ -1034,8 +1034,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -1059,7 +1059,7 @@ class Users : Service { suspend fun updatePhone( userId: String, number: String, - ) = updatePhone( + ): io.appwrite.models.User> = updatePhone( userId, number, nestedType = classOf(), @@ -1087,8 +1087,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { - io.appwrite.models.Preferences.from(map = it as Map, nestedType) - } + io.appwrite.models.Preferences.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -1110,7 +1110,7 @@ class Users : Service { @Throws(AppwriteException::class) suspend fun getPrefs( userId: String, - ) = getPrefs( + ): io.appwrite.models.Preferences> = getPrefs( userId, nestedType = classOf(), ) @@ -1140,8 +1140,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { - io.appwrite.models.Preferences.from(map = it as Map, nestedType) - } + io.appwrite.models.Preferences.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -1165,7 +1165,7 @@ class Users : Service { suspend fun updatePrefs( userId: String, prefs: Any, - ) = updatePrefs( + ): io.appwrite.models.Preferences> = updatePrefs( userId, prefs, nestedType = classOf(), @@ -1192,8 +1192,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { - io.appwrite.models.SessionList.from(map = it as Map) - } + io.appwrite.models.SessionList.from(map = it as Map) + } return client.call( "GET", path, @@ -1290,8 +1290,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -1315,7 +1315,7 @@ class Users : Service { suspend fun updateStatus( userId: String, status: Boolean, - ) = updateStatus( + ): io.appwrite.models.User> = updateStatus( userId, status, nestedType = classOf(), @@ -1346,8 +1346,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -1371,7 +1371,7 @@ class Users : Service { suspend fun updateEmailVerification( userId: String, emailVerification: Boolean, - ) = updateEmailVerification( + ): io.appwrite.models.User> = updateEmailVerification( userId, emailVerification, nestedType = classOf(), @@ -1402,8 +1402,8 @@ class Users : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it as Map, nestedType) - } + io.appwrite.models.User.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -1427,7 +1427,7 @@ class Users : Service { suspend fun updatePhoneVerification( userId: String, phoneVerification: Boolean, - ) = updatePhoneVerification( + ): io.appwrite.models.User> = updatePhoneVerification( userId, phoneVerification, nestedType = classOf(),