diff --git a/README.md b/README.md
index 66da83e..fd4990d 100644
--- a/README.md
+++ b/README.md
@@ -2,16 +2,16 @@


-
+
[](https://travis-ci.com/appwrite/sdk-generator)
[](https://twitter.com/appwrite_io)
[](https://appwrite.io/discord)
-**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).**
+**This SDK is compatible with Appwrite server version 0.10.x. For older versions, please check previous releases.**
-Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
+Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs
-
+
## Installation
@@ -38,7 +38,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:
```groovy
-implementation("io.appwrite:sdk-for-android:0.0.1")
+implementation("io.appwrite:sdk-for-android:0.2.0-SNAPSHOT")
```
### Maven
@@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
io.appwrite
sdk-for-android
- 0.0.1
+ 0.2.0-SNAPSHOT
```
diff --git a/build.gradle b/build.gradle
index ee004cf..6e75fcc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,7 @@ apply plugin: 'io.github.gradle-nexus.publish-plugin'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.31"
- version '0.0.1'
+ version '0.2.0-SNAPSHOT'
repositories {
maven { url "https://plugins.gradle.org/m2/" }
google()
diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md
deleted file mode 100644
index 8d4c95a..0000000
--- a/docs/examples/java/account/get-session.md
+++ /dev/null
@@ -1,48 +0,0 @@
-import androidx.appcompat.app.AppCompatActivity
-import android.os.Bundle
-import kotlinx.coroutines.GlobalScope
-import kotlinx.coroutines.launch
-import io.appwrite.Client
-import io.appwrite.services.Account
-
-public class MainActivity extends AppCompatActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- Client client = new Client(getApplicationContext())
- .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
- .setProject("5df5acd0d48c2"); // Your project ID
-
- Account account = new Account(client);
-
- account.getSession(
- "[SESSION_ID]"
- new Continuation() {
- @NotNull
- @Override
- public CoroutineContext getContext() {
- return EmptyCoroutineContext.INSTANCE;
- }
-
- @Override
- public void resumeWith(@NotNull Object o) {
- String json = "";
- try {
- if (o instanceof Result.Failure) {
- Result.Failure failure = (Result.Failure) o;
- throw failure.exception;
- } else {
- Response response = (Response) o;
- json = response.body().string();
- }
- } catch (Throwable th) {
- Log.e("ERROR", th.toString());
- }
- }
- }
- );
- }
-}
\ No newline at end of file
diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md
deleted file mode 100644
index 45f00b6..0000000
--- a/docs/examples/kotlin/account/get-session.md
+++ /dev/null
@@ -1,26 +0,0 @@
-import androidx.appcompat.app.AppCompatActivity
-import android.os.Bundle
-import kotlinx.coroutines.GlobalScope
-import kotlinx.coroutines.launch
-import io.appwrite.Client
-import io.appwrite.services.Account
-
-class MainActivity : AppCompatActivity() {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_main)
-
- val client = Client(applicationContext)
- .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
- .setProject("5df5acd0d48c2") // Your project ID
-
- val account = Account(client)
-
- GlobalScope.launch {
- val response = account.getSession(
- sessionId = "[SESSION_ID]"
- )
- val json = response.body?.string()
- }
- }
-}
\ No newline at end of file
diff --git a/library/build.gradle b/library/build.gradle
index d5e9a7c..87899c6 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -7,11 +7,11 @@ plugins {
ext {
PUBLISH_GROUP_ID = 'io.appwrite'
PUBLISH_ARTIFACT_ID = 'sdk-for-android'
- PUBLISH_VERSION = '0.0.1'
+ PUBLISH_VERSION = '0.2.0-SNAPSHOT'
POM_URL = 'https://github.com/appwrite/sdk-for-android'
POM_SCM_URL = 'https://github.com/appwrite/sdk-for-android'
POM_ISSUE_URL = 'https://github.com/appwrite/sdk-for-android/issues'
- POM_DESCRIPTION = 'Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)'
+ POM_DESCRIPTION = 'Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs'
POM_LICENSE_URL = 'https://opensource.org/licenses/GPL-3.0'
POM_LICENSE_NAME = "GPL-3.0"
POM_DEVELOPER_ID = 'appwrite'
@@ -53,8 +53,8 @@ android {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${KotlinCompilerVersion.VERSION}")
- api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3")
- api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3")
+ api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1")
+ api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0")
api(platform("com.squareup.okhttp3:okhttp-bom:4.9.0"))
api("com.squareup.okhttp3:okhttp")
@@ -65,15 +65,16 @@ dependencies {
implementation("net.gotev:cookie-store:1.3.5")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-common-java8:2.3.1")
- implementation("androidx.appcompat:appcompat:1.2.0")
- implementation("androidx.fragment:fragment-ktx:1.3.2")
- implementation("androidx.activity:activity-ktx:1.2.2")
+ implementation("androidx.appcompat:appcompat:1.3.1")
+ implementation("androidx.fragment:fragment-ktx:1.3.6")
+ implementation("androidx.activity:activity-ktx:1.3.1")
implementation("androidx.browser:browser:1.3.0")
testImplementation 'junit:junit:4.+'
- testImplementation "androidx.test.ext:junit-ktx:1.1.2"
- testImplementation "androidx.test:core-ktx:1.3.0"
+ testImplementation "androidx.test.ext:junit-ktx:1.1.3"
+ testImplementation "androidx.test:core-ktx:1.4.0"
testImplementation "org.robolectric:robolectric:4.5.1"
+ testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1")
}
apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
\ No newline at end of file
diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt
index e15f2a5..be66506 100644
--- a/library/src/main/java/io/appwrite/Client.kt
+++ b/library/src/main/java/io/appwrite/Client.kt
@@ -5,8 +5,7 @@ import android.content.pm.PackageManager
import com.google.gson.Gson
import io.appwrite.appwrite.BuildConfig
import io.appwrite.exceptions.AppwriteException
-import io.appwrite.extensions.JsonExtensions.fromJson
-import io.appwrite.models.Error
+import io.appwrite.extensions.fromJson
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@@ -36,6 +35,7 @@ import kotlin.coroutines.resume
class Client @JvmOverloads constructor(
context: Context,
var endPoint: String = "https://appwrite.io/v1",
+ var endPointRealtime: String? = null,
private var selfSigned: Boolean = false
) : CoroutineScope {
@@ -71,7 +71,7 @@ class Client @JvmOverloads constructor(
"origin" to "appwrite-android://${context.packageName}",
"user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}",
"x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}",
- "x-appwrite-response-format" to "0.9.0"
+ "x-appwrite-response-format" to "0.10.0"
)
config = mutableMapOf()
@@ -93,6 +93,21 @@ class Client @JvmOverloads constructor(
return this
}
+ /**
+ * Set Key
+ *
+ * Your secret API key
+ *
+ * @param {string} key
+ *
+ * @return this
+ */
+ fun setKey(value: String): Client {
+ config["key"] = value
+ addHeader("x-appwrite-key", value)
+ return this
+ }
+
/**
* Set JWT
*
@@ -121,6 +136,19 @@ class Client @JvmOverloads constructor(
return this
}
+ /**
+ * Set Mode
+ *
+ * @param {string} mode
+ *
+ * @return this
+ */
+ fun setMode(value: String): Client {
+ config["mode"] = value
+ addHeader("x-appwrite-mode", value)
+ return this
+ }
+
/**
* Set self Signed
*
@@ -171,7 +199,7 @@ class Client @JvmOverloads constructor(
}
/**
- * Set endpoint
+ * Set endpoint and realtime endpoint.
*
* @param endpoint
*
@@ -179,6 +207,23 @@ class Client @JvmOverloads constructor(
*/
fun setEndpoint(endPoint: String): Client {
this.endPoint = endPoint
+
+ if (this.endPointRealtime == null && endPoint.startsWith("http")) {
+ this.endPointRealtime = endPoint.replaceFirst("http", "ws")
+ }
+
+ return this
+ }
+
+ /**
+ * Set realtime endpoint
+ *
+ * @param endpoint
+ *
+ * @return this
+ */
+ fun setEndpointRealtime(endPoint: String): Client {
+ this.endPointRealtime = endPoint
return this
}
@@ -317,9 +362,9 @@ class Client @JvmOverloads constructor(
val contentType: String = response.headers["content-type"] ?: ""
val error = if (contentType.contains("application/json", ignoreCase = true)) {
- bodyString.fromJson(Error::class.java)
+ bodyString.fromJson()
} else {
- Error(bodyString, response.code)
+ AppwriteException(bodyString, response.code)
}
it.cancel(AppwriteException(
diff --git a/library/src/main/java/io/appwrite/extensions/CollectionExtensions.kt b/library/src/main/java/io/appwrite/extensions/CollectionExtensions.kt
new file mode 100644
index 0000000..a92704f
--- /dev/null
+++ b/library/src/main/java/io/appwrite/extensions/CollectionExtensions.kt
@@ -0,0 +1,12 @@
+package io.appwrite.extensions
+
+import kotlinx.coroutines.Dispatchers.IO
+import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
+import kotlinx.coroutines.withContext
+
+suspend fun Collection.forEachAsync(
+ callback: suspend (T) -> Unit
+) = withContext(IO) {
+ map { async { callback.invoke(it) } }.awaitAll()
+}
\ No newline at end of file
diff --git a/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt b/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt
index 4cf0f4f..444a77d 100644
--- a/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt
+++ b/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt
@@ -2,11 +2,33 @@ package io.appwrite.extensions
import com.google.gson.Gson
-object JsonExtensions {
+val gson = Gson()
- fun Any.toJson(): String =
- Gson().toJson(this)
+fun Any.toJson(): String =
+ gson.toJson(this)
- fun String.fromJson(clazz: Class): T =
- Gson().fromJson(this, clazz)
-}
\ No newline at end of file
+fun String.fromJson(clazz: Class): T =
+ gson.fromJson(this, clazz)
+
+inline fun String.fromJson(): T =
+ gson.fromJson(this, T::class.java)
+
+fun Any.jsonCast(to: Class): T =
+ toJson().fromJson(to)
+
+inline fun Any.jsonCast(): T =
+ toJson().fromJson(T::class.java)
+
+fun Any.tryJsonCast(to: Class): T? = try {
+ toJson().fromJson(to)
+} catch (ex: Exception) {
+ ex.printStackTrace()
+ null
+}
+
+inline fun Any.tryJsonCast(): T? = try {
+ toJson().fromJson(T::class.java)
+} catch (ex: Exception) {
+ ex.printStackTrace()
+ null
+}
diff --git a/library/src/main/java/io/appwrite/models/RealtimeModels.kt b/library/src/main/java/io/appwrite/models/RealtimeModels.kt
new file mode 100644
index 0000000..b4990c8
--- /dev/null
+++ b/library/src/main/java/io/appwrite/models/RealtimeModels.kt
@@ -0,0 +1,31 @@
+package io.appwrite.models
+
+import java.io.Closeable
+
+data class RealtimeSubscription(
+ private val close: () -> Unit
+) : Closeable {
+ override fun close() = close.invoke()
+}
+
+data class RealtimeCallback(
+ val payloadClass: Class<*>,
+ val callback: (RealtimeResponseEvent<*>) -> Unit
+)
+
+open class RealtimeResponse(
+ val type: String,
+ val data: Any
+)
+
+data class RealtimeResponseEvent(
+ val event: String,
+ val channels: Collection,
+ val timestamp: Long,
+ var payload: T
+)
+
+enum class RealtimeCode(val value: Int) {
+ POLICY_VIOLATION(1008),
+ UNKNOWN_ERROR(-1)
+}
\ No newline at end of file
diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt
index bad36e5..4cd0504 100644
--- a/library/src/main/java/io/appwrite/services/Account.kt
+++ b/library/src/main/java/io/appwrite/services/Account.kt
@@ -11,7 +11,7 @@ import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import java.io.File
-class Account(private val client: Client) : BaseService(client) {
+class Account(client: Client) : Service(client) {
/**
* Get Account
@@ -134,8 +134,7 @@ class Account(private val client: Client) : BaseService(client) {
* Use this endpoint to create a JSON Web Token. You can use the resulting JWT
* to authenticate on behalf of the current user when working with the
* Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
- * from its creation and will be invalid if the user will logout in that time
- * frame.
+ * from its creation and will be invalid if the user will logout.
*
* @return [Response]
*/
@@ -432,10 +431,9 @@ class Account(private val client: Client) : BaseService(client) {
*
* Use this endpoint to allow a new user to register an anonymous account in
* your project. This route will also create a new session for the user. To
- * allow the new user to convert an anonymous account to a normal account, you
- * need to update its [email and
- * password](/docs/client/account#accountUpdateEmail) or create an [OAuth2
- * session](/docs/client/account#accountCreateOAuth2Session).
+ * allow the new user to convert an anonymous account to a normal account
+ * account, you need to update its [email and
+ * password](/docs/client/account#accountUpdateEmail).
*
* @return [Response]
*/
@@ -529,31 +527,6 @@ class Account(private val client: Client) : BaseService(client) {
}
- /**
- * Get Session By ID
- *
- * Use this endpoint to get a logged in user's session using a Session ID.
- * Inputting 'current' will return the current session being used.
- *
- * @param sessionId
- * @return [Response]
- */
- @JvmOverloads
- @Throws(AppwriteException::class)
- suspend fun getSession(
- sessionId: String
- ): Response {
- val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId)
- val params = mapOf(
- )
-
- val headers = mapOf(
- "content-type" to "application/json"
- )
-
- return client.call("GET", path, headers, params)
- }
-
/**
* Delete Account Session
*
diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt
index b828eb0..3e0432f 100644
--- a/library/src/main/java/io/appwrite/services/Avatars.kt
+++ b/library/src/main/java/io/appwrite/services/Avatars.kt
@@ -9,7 +9,7 @@ import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import java.io.File
-class Avatars(private val client: Client) : BaseService(client) {
+class Avatars(client: Client) : Service(client) {
/**
* Get Browser Icon
diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt
index 81bf0c6..fc7fc9b 100644
--- a/library/src/main/java/io/appwrite/services/Database.kt
+++ b/library/src/main/java/io/appwrite/services/Database.kt
@@ -7,8 +7,165 @@ import okhttp3.Cookie
import okhttp3.Response
import java.io.File
-class Database(private val client: Client) : BaseService(client) {
+class Database(client: Client) : Service(client) {
+ /**
+ * List Collections
+ *
+ * Get a list of all the user collections. You can use the query params to
+ * filter your results. On admin mode, this endpoint will return a list of all
+ * of the project's collections. [Learn more about different API
+ * modes](/docs/admin).
+ *
+ * @param search
+ * @param limit
+ * @param offset
+ * @param orderType
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun listCollections(
+ search: String? = null,
+ limit: Int? = null,
+ offset: Int? = null,
+ orderType: String? = null
+ ): Response {
+ val path = "/database/collections"
+ val params = mapOf(
+ "search" to search,
+ "limit" to limit,
+ "offset" to offset,
+ "orderType" to orderType
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create Collection
+ *
+ * Create a new Collection.
+ *
+ * @param name
+ * @param read
+ * @param write
+ * @param rules
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun createCollection(
+ name: String,
+ read: List,
+ write: List,
+ rules: List
+ ): Response {
+ val path = "/database/collections"
+ val params = mapOf(
+ "name" to name,
+ "read" to read,
+ "write" to write,
+ "rules" to rules
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get Collection
+ *
+ * Get a collection by its unique ID. This endpoint response returns a JSON
+ * object with the collection metadata.
+ *
+ * @param collectionId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getCollection(
+ collectionId: String
+ ): Response {
+ val path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Update Collection
+ *
+ * Update a collection by its unique ID.
+ *
+ * @param collectionId
+ * @param name
+ * @param read
+ * @param write
+ * @param rules
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateCollection(
+ collectionId: String,
+ name: String,
+ read: List? = null,
+ write: List? = null,
+ rules: List? = null
+ ): Response {
+ val path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId)
+ val params = mapOf(
+ "name" to name,
+ "read" to read,
+ "write" to write,
+ "rules" to rules
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PUT", path, headers, params)
+ }
+
+ /**
+ * Delete Collection
+ *
+ * Delete a collection by its unique ID. Only users with write permissions
+ * have access to delete this resource.
+ *
+ * @param collectionId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun deleteCollection(
+ collectionId: String
+ ): Response {
+ val path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
/**
* List Documents
*
diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt
index 95c203c..fba3eba 100644
--- a/library/src/main/java/io/appwrite/services/Functions.kt
+++ b/library/src/main/java/io/appwrite/services/Functions.kt
@@ -7,8 +7,178 @@ import okhttp3.Cookie
import okhttp3.Response
import java.io.File
-class Functions(private val client: Client) : BaseService(client) {
+class Functions(client: Client) : Service(client) {
+ /**
+ * List Functions
+ *
+ * Get a list of all the project's functions. You can use the query params to
+ * filter your results.
+ *
+ * @param search
+ * @param limit
+ * @param offset
+ * @param orderType
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun list(
+ search: String? = null,
+ limit: Int? = null,
+ offset: Int? = null,
+ orderType: String? = null
+ ): Response {
+ val path = "/functions"
+ val params = mapOf(
+ "search" to search,
+ "limit" to limit,
+ "offset" to offset,
+ "orderType" to orderType
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create Function
+ *
+ * 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 name
+ * @param execute
+ * @param env
+ * @param vars
+ * @param events
+ * @param schedule
+ * @param timeout
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun create(
+ name: String,
+ execute: List,
+ env: String,
+ vars: Any? = null,
+ events: List? = null,
+ schedule: String? = null,
+ timeout: Int? = null
+ ): Response {
+ val path = "/functions"
+ val params = mapOf(
+ "name" to name,
+ "execute" to execute,
+ "env" to env,
+ "vars" to vars,
+ "events" to events,
+ "schedule" to schedule,
+ "timeout" to timeout
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get Function
+ *
+ * Get a function by its unique ID.
+ *
+ * @param functionId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun get(
+ functionId: String
+ ): Response {
+ val path = "/functions/{functionId}".replace("{functionId}", functionId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Update Function
+ *
+ * Update function by its unique ID.
+ *
+ * @param functionId
+ * @param name
+ * @param execute
+ * @param vars
+ * @param events
+ * @param schedule
+ * @param timeout
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun update(
+ functionId: String,
+ name: String,
+ execute: List,
+ vars: Any? = null,
+ events: List? = null,
+ schedule: String? = null,
+ timeout: Int? = null
+ ): Response {
+ val path = "/functions/{functionId}".replace("{functionId}", functionId)
+ val params = mapOf(
+ "name" to name,
+ "execute" to execute,
+ "vars" to vars,
+ "events" to events,
+ "schedule" to schedule,
+ "timeout" to timeout
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PUT", path, headers, params)
+ }
+
+ /**
+ * Delete Function
+ *
+ * Delete a function by its unique ID.
+ *
+ * @param functionId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun delete(
+ functionId: String
+ ): Response {
+ val path = "/functions/{functionId}".replace("{functionId}", functionId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
/**
* List Executions
*
@@ -104,4 +274,186 @@ class Functions(private val client: Client) : BaseService(client) {
return client.call("GET", path, headers, params)
}
+ /**
+ * Update Function Tag
+ *
+ * Update the function code tag ID using the unique function ID. Use this
+ * endpoint to switch the code tag that should be executed by the execution
+ * endpoint.
+ *
+ * @param functionId
+ * @param tag
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateTag(
+ functionId: String,
+ tag: String
+ ): Response {
+ val path = "/functions/{functionId}/tag".replace("{functionId}", functionId)
+ val params = mapOf(
+ "tag" to tag
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PATCH", path, headers, params)
+ }
+
+ /**
+ * List Tags
+ *
+ * Get a list of all the project's code tags. You can use the query params to
+ * filter your results.
+ *
+ * @param functionId
+ * @param search
+ * @param limit
+ * @param offset
+ * @param orderType
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun listTags(
+ functionId: String,
+ search: String? = null,
+ limit: Int? = null,
+ offset: Int? = null,
+ orderType: String? = null
+ ): Response {
+ val path = "/functions/{functionId}/tags".replace("{functionId}", functionId)
+ val params = mapOf(
+ "search" to search,
+ "limit" to limit,
+ "offset" to offset,
+ "orderType" to orderType
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create Tag
+ *
+ * Create a new function code tag. Use this endpoint to upload a new version
+ * of your code function. To execute your newly uploaded code, you'll need to
+ * update the function's tag to use your new tag UID.
+ *
+ * This endpoint accepts a tar.gz file compressed with your code. Make sure to
+ * include any dependencies your code has within the compressed file. You can
+ * learn more about code packaging in the [Appwrite Cloud Functions
+ * tutorial](/docs/functions).
+ *
+ * Use the "command" param to set the entry point used to execute your code.
+ *
+ * @param functionId
+ * @param command
+ * @param code
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun createTag(
+ functionId: String,
+ command: String,
+ code: File
+ ): Response {
+ val path = "/functions/{functionId}/tags".replace("{functionId}", functionId)
+ val params = mapOf(
+ "command" to command,
+ "code" to code
+ )
+
+ val headers = mapOf(
+ "content-type" to "multipart/form-data"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get Tag
+ *
+ * Get a code tag by its unique ID.
+ *
+ * @param functionId
+ * @param tagId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getTag(
+ functionId: String,
+ tagId: String
+ ): Response {
+ val path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Delete Tag
+ *
+ * Delete a code tag by its unique ID.
+ *
+ * @param functionId
+ * @param tagId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun deleteTag(
+ functionId: String,
+ tagId: String
+ ): Response {
+ val path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+ /**
+ * Get Function Usage
+ *
+ * @param functionId
+ * @param range
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getUsage(
+ functionId: String,
+ range: String? = null
+ ): Response {
+ val path = "/functions/{functionId}/usage".replace("{functionId}", functionId)
+ val params = mapOf(
+ "range" to range
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
}
\ No newline at end of file
diff --git a/library/src/main/java/io/appwrite/services/Health.kt b/library/src/main/java/io/appwrite/services/Health.kt
new file mode 100644
index 0000000..cada8d5
--- /dev/null
+++ b/library/src/main/java/io/appwrite/services/Health.kt
@@ -0,0 +1,275 @@
+package io.appwrite.services
+
+import android.net.Uri
+import io.appwrite.Client
+import io.appwrite.exceptions.AppwriteException
+import okhttp3.Cookie
+import okhttp3.Response
+import java.io.File
+
+class Health(client: Client) : Service(client) {
+
+ /**
+ * Get HTTP
+ *
+ * Check the Appwrite HTTP server is up and responsive.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun get(): Response {
+ val path = "/health"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Anti virus
+ *
+ * Check the Appwrite Anti Virus server is up and connection is successful.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getAntiVirus(): Response {
+ val path = "/health/anti-virus"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Cache
+ *
+ * Check the Appwrite in-memory cache server is up and connection is
+ * successful.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getCache(): Response {
+ val path = "/health/cache"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get DB
+ *
+ * Check the Appwrite database server is up and connection is successful.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getDB(): Response {
+ val path = "/health/db"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Certificate Queue
+ *
+ * Get the number of certificates that are waiting to be issued against
+ * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue
+ * server.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getQueueCertificates(): Response {
+ val path = "/health/queue/certificates"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Functions Queue
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getQueueFunctions(): Response {
+ val path = "/health/queue/functions"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Logs Queue
+ *
+ * Get the number of logs that are waiting to be processed in the Appwrite
+ * internal queue server.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getQueueLogs(): Response {
+ val path = "/health/queue/logs"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Tasks Queue
+ *
+ * Get the number of tasks that are waiting to be processed in the Appwrite
+ * internal queue server.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getQueueTasks(): Response {
+ val path = "/health/queue/tasks"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Usage Queue
+ *
+ * Get the number of usage stats that are waiting to be processed in the
+ * Appwrite internal queue server.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getQueueUsage(): Response {
+ val path = "/health/queue/usage"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Webhooks Queue
+ *
+ * Get the number of webhooks that are waiting to be processed in the Appwrite
+ * internal queue server.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getQueueWebhooks(): Response {
+ val path = "/health/queue/webhooks"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Local Storage
+ *
+ * Check the Appwrite local storage device is up and connection is successful.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getStorageLocal(): Response {
+ val path = "/health/storage/local"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get Time
+ *
+ * Check the Appwrite server time is synced with Google remote NTP server. We
+ * use this technology to smoothly handle leap seconds with no disruptive
+ * events. The [Network Time
+ * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is
+ * used by hundreds of millions of computers and devices to synchronize their
+ * clocks over the Internet. If your computer sets its own clock, it likely
+ * uses NTP.
+ *
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getTime(): Response {
+ val path = "/health/time"
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+}
\ No newline at end of file
diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt
index 36a3fce..415df78 100644
--- a/library/src/main/java/io/appwrite/services/Locale.kt
+++ b/library/src/main/java/io/appwrite/services/Locale.kt
@@ -7,7 +7,7 @@ import okhttp3.Cookie
import okhttp3.Response
import java.io.File
-class Locale(private val client: Client) : BaseService(client) {
+class Locale(client: Client) : Service(client) {
/**
* Get User Locale
diff --git a/library/src/main/java/io/appwrite/services/Projects.kt b/library/src/main/java/io/appwrite/services/Projects.kt
new file mode 100644
index 0000000..e019a4e
--- /dev/null
+++ b/library/src/main/java/io/appwrite/services/Projects.kt
@@ -0,0 +1,1016 @@
+package io.appwrite.services
+
+import android.net.Uri
+import io.appwrite.Client
+import io.appwrite.exceptions.AppwriteException
+import okhttp3.Cookie
+import okhttp3.Response
+import java.io.File
+
+class Projects(client: Client) : Service(client) {
+
+ /**
+ * List Projects
+ *
+ * @param search
+ * @param limit
+ * @param offset
+ * @param orderType
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun list(
+ search: String? = null,
+ limit: Int? = null,
+ offset: Int? = null,
+ orderType: String? = null
+ ): Response {
+ val path = "/projects"
+ val params = mapOf(
+ "search" to search,
+ "limit" to limit,
+ "offset" to offset,
+ "orderType" to orderType
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create Project
+ *
+ * @param name
+ * @param teamId
+ * @param description
+ * @param logo
+ * @param url
+ * @param legalName
+ * @param legalCountry
+ * @param legalState
+ * @param legalCity
+ * @param legalAddress
+ * @param legalTaxId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun create(
+ name: String,
+ teamId: String,
+ description: String? = null,
+ logo: String? = null,
+ url: String? = null,
+ legalName: String? = null,
+ legalCountry: String? = null,
+ legalState: String? = null,
+ legalCity: String? = null,
+ legalAddress: String? = null,
+ legalTaxId: String? = null
+ ): Response {
+ val path = "/projects"
+ val params = mapOf(
+ "name" to name,
+ "teamId" to teamId,
+ "description" to description,
+ "logo" to logo,
+ "url" to url,
+ "legalName" to legalName,
+ "legalCountry" to legalCountry,
+ "legalState" to legalState,
+ "legalCity" to legalCity,
+ "legalAddress" to legalAddress,
+ "legalTaxId" to legalTaxId
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get Project
+ *
+ * @param projectId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun get(
+ projectId: String
+ ): Response {
+ val path = "/projects/{projectId}".replace("{projectId}", projectId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Update Project
+ *
+ * @param projectId
+ * @param name
+ * @param description
+ * @param logo
+ * @param url
+ * @param legalName
+ * @param legalCountry
+ * @param legalState
+ * @param legalCity
+ * @param legalAddress
+ * @param legalTaxId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun update(
+ projectId: String,
+ name: String,
+ description: String? = null,
+ logo: String? = null,
+ url: String? = null,
+ legalName: String? = null,
+ legalCountry: String? = null,
+ legalState: String? = null,
+ legalCity: String? = null,
+ legalAddress: String? = null,
+ legalTaxId: String? = null
+ ): Response {
+ val path = "/projects/{projectId}".replace("{projectId}", projectId)
+ val params = mapOf(
+ "name" to name,
+ "description" to description,
+ "logo" to logo,
+ "url" to url,
+ "legalName" to legalName,
+ "legalCountry" to legalCountry,
+ "legalState" to legalState,
+ "legalCity" to legalCity,
+ "legalAddress" to legalAddress,
+ "legalTaxId" to legalTaxId
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PATCH", path, headers, params)
+ }
+
+ /**
+ * Delete Project
+ *
+ * @param projectId
+ * @param password
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun delete(
+ projectId: String,
+ password: String
+ ): Response {
+ val path = "/projects/{projectId}".replace("{projectId}", projectId)
+ val params = mapOf(
+ "password" to password
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+ /**
+ * Update Project users limit
+ *
+ * @param projectId
+ * @param limit
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateAuthLimit(
+ projectId: String,
+ limit: String
+ ): Response {
+ val path = "/projects/{projectId}/auth/limit".replace("{projectId}", projectId)
+ val params = mapOf(
+ "limit" to limit
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PATCH", path, headers, params)
+ }
+
+ /**
+ * Update Project auth method status. Use this endpoint to enable or disable a given auth method for this project.
+ *
+ * @param projectId
+ * @param method
+ * @param status
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateAuthStatus(
+ projectId: String,
+ method: String,
+ status: Boolean
+ ): Response {
+ val path = "/projects/{projectId}/auth/{method}".replace("{projectId}", projectId).replace("{method}", method)
+ val params = mapOf(
+ "status" to status
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PATCH", path, headers, params)
+ }
+
+ /**
+ * List Domains
+ *
+ * @param projectId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun listDomains(
+ projectId: String
+ ): Response {
+ val path = "/projects/{projectId}/domains".replace("{projectId}", projectId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create Domain
+ *
+ * @param projectId
+ * @param domain
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun createDomain(
+ projectId: String,
+ domain: String
+ ): Response {
+ val path = "/projects/{projectId}/domains".replace("{projectId}", projectId)
+ val params = mapOf(
+ "domain" to domain
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get Domain
+ *
+ * @param projectId
+ * @param domainId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getDomain(
+ projectId: String,
+ domainId: String
+ ): Response {
+ val path = "/projects/{projectId}/domains/{domainId}".replace("{projectId}", projectId).replace("{domainId}", domainId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Delete Domain
+ *
+ * @param projectId
+ * @param domainId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun deleteDomain(
+ projectId: String,
+ domainId: String
+ ): Response {
+ val path = "/projects/{projectId}/domains/{domainId}".replace("{projectId}", projectId).replace("{domainId}", domainId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+ /**
+ * Update Domain Verification Status
+ *
+ * @param projectId
+ * @param domainId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateDomainVerification(
+ projectId: String,
+ domainId: String
+ ): Response {
+ val path = "/projects/{projectId}/domains/{domainId}/verification".replace("{projectId}", projectId).replace("{domainId}", domainId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PATCH", path, headers, params)
+ }
+
+ /**
+ * List Keys
+ *
+ * @param projectId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun listKeys(
+ projectId: String
+ ): Response {
+ val path = "/projects/{projectId}/keys".replace("{projectId}", projectId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create Key
+ *
+ * @param projectId
+ * @param name
+ * @param scopes
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun createKey(
+ projectId: String,
+ name: String,
+ scopes: List
+ ): Response {
+ val path = "/projects/{projectId}/keys".replace("{projectId}", projectId)
+ val params = mapOf(
+ "name" to name,
+ "scopes" to scopes
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get Key
+ *
+ * @param projectId
+ * @param keyId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getKey(
+ projectId: String,
+ keyId: String
+ ): Response {
+ val path = "/projects/{projectId}/keys/{keyId}".replace("{projectId}", projectId).replace("{keyId}", keyId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Update Key
+ *
+ * @param projectId
+ * @param keyId
+ * @param name
+ * @param scopes
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateKey(
+ projectId: String,
+ keyId: String,
+ name: String,
+ scopes: List
+ ): Response {
+ val path = "/projects/{projectId}/keys/{keyId}".replace("{projectId}", projectId).replace("{keyId}", keyId)
+ val params = mapOf(
+ "name" to name,
+ "scopes" to scopes
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PUT", path, headers, params)
+ }
+
+ /**
+ * Delete Key
+ *
+ * @param projectId
+ * @param keyId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun deleteKey(
+ projectId: String,
+ keyId: String
+ ): Response {
+ val path = "/projects/{projectId}/keys/{keyId}".replace("{projectId}", projectId).replace("{keyId}", keyId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+ /**
+ * Update Project OAuth2
+ *
+ * @param projectId
+ * @param provider
+ * @param appId
+ * @param secret
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateOAuth2(
+ projectId: String,
+ provider: String,
+ appId: String? = null,
+ secret: String? = null
+ ): Response {
+ val path = "/projects/{projectId}/oauth2".replace("{projectId}", projectId)
+ val params = mapOf(
+ "provider" to provider,
+ "appId" to appId,
+ "secret" to secret
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PATCH", path, headers, params)
+ }
+
+ /**
+ * List Platforms
+ *
+ * @param projectId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun listPlatforms(
+ projectId: String
+ ): Response {
+ val path = "/projects/{projectId}/platforms".replace("{projectId}", projectId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create Platform
+ *
+ * @param projectId
+ * @param type
+ * @param name
+ * @param key
+ * @param store
+ * @param hostname
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun createPlatform(
+ projectId: String,
+ type: String,
+ name: String,
+ key: String? = null,
+ store: String? = null,
+ hostname: String? = null
+ ): Response {
+ val path = "/projects/{projectId}/platforms".replace("{projectId}", projectId)
+ val params = mapOf(
+ "type" to type,
+ "name" to name,
+ "key" to key,
+ "store" to store,
+ "hostname" to hostname
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get Platform
+ *
+ * @param projectId
+ * @param platformId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getPlatform(
+ projectId: String,
+ platformId: String
+ ): Response {
+ val path = "/projects/{projectId}/platforms/{platformId}".replace("{projectId}", projectId).replace("{platformId}", platformId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Update Platform
+ *
+ * @param projectId
+ * @param platformId
+ * @param name
+ * @param key
+ * @param store
+ * @param hostname
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updatePlatform(
+ projectId: String,
+ platformId: String,
+ name: String,
+ key: String? = null,
+ store: String? = null,
+ hostname: String? = null
+ ): Response {
+ val path = "/projects/{projectId}/platforms/{platformId}".replace("{projectId}", projectId).replace("{platformId}", platformId)
+ val params = mapOf(
+ "name" to name,
+ "key" to key,
+ "store" to store,
+ "hostname" to hostname
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PUT", path, headers, params)
+ }
+
+ /**
+ * Delete Platform
+ *
+ * @param projectId
+ * @param platformId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun deletePlatform(
+ projectId: String,
+ platformId: String
+ ): Response {
+ val path = "/projects/{projectId}/platforms/{platformId}".replace("{projectId}", projectId).replace("{platformId}", platformId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+ /**
+ * List Tasks
+ *
+ * @param projectId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun listTasks(
+ projectId: String
+ ): Response {
+ val path = "/projects/{projectId}/tasks".replace("{projectId}", projectId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create Task
+ *
+ * @param projectId
+ * @param name
+ * @param status
+ * @param schedule
+ * @param security
+ * @param httpMethod
+ * @param httpUrl
+ * @param httpHeaders
+ * @param httpUser
+ * @param httpPass
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun createTask(
+ projectId: String,
+ name: String,
+ status: String,
+ schedule: String,
+ security: Boolean,
+ httpMethod: String,
+ httpUrl: String,
+ httpHeaders: List? = null,
+ httpUser: String? = null,
+ httpPass: String? = null
+ ): Response {
+ val path = "/projects/{projectId}/tasks".replace("{projectId}", projectId)
+ val params = mapOf(
+ "name" to name,
+ "status" to status,
+ "schedule" to schedule,
+ "security" to security,
+ "httpMethod" to httpMethod,
+ "httpUrl" to httpUrl,
+ "httpHeaders" to httpHeaders,
+ "httpUser" to httpUser,
+ "httpPass" to httpPass
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get Task
+ *
+ * @param projectId
+ * @param taskId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getTask(
+ projectId: String,
+ taskId: String
+ ): Response {
+ val path = "/projects/{projectId}/tasks/{taskId}".replace("{projectId}", projectId).replace("{taskId}", taskId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Update Task
+ *
+ * @param projectId
+ * @param taskId
+ * @param name
+ * @param status
+ * @param schedule
+ * @param security
+ * @param httpMethod
+ * @param httpUrl
+ * @param httpHeaders
+ * @param httpUser
+ * @param httpPass
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateTask(
+ projectId: String,
+ taskId: String,
+ name: String,
+ status: String,
+ schedule: String,
+ security: Boolean,
+ httpMethod: String,
+ httpUrl: String,
+ httpHeaders: List? = null,
+ httpUser: String? = null,
+ httpPass: String? = null
+ ): Response {
+ val path = "/projects/{projectId}/tasks/{taskId}".replace("{projectId}", projectId).replace("{taskId}", taskId)
+ val params = mapOf(
+ "name" to name,
+ "status" to status,
+ "schedule" to schedule,
+ "security" to security,
+ "httpMethod" to httpMethod,
+ "httpUrl" to httpUrl,
+ "httpHeaders" to httpHeaders,
+ "httpUser" to httpUser,
+ "httpPass" to httpPass
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PUT", path, headers, params)
+ }
+
+ /**
+ * Delete Task
+ *
+ * @param projectId
+ * @param taskId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun deleteTask(
+ projectId: String,
+ taskId: String
+ ): Response {
+ val path = "/projects/{projectId}/tasks/{taskId}".replace("{projectId}", projectId).replace("{taskId}", taskId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+ /**
+ * Get Project
+ *
+ * @param projectId
+ * @param range
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getUsage(
+ projectId: String,
+ range: String? = null
+ ): Response {
+ val path = "/projects/{projectId}/usage".replace("{projectId}", projectId)
+ val params = mapOf(
+ "range" to range
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * List Webhooks
+ *
+ * @param projectId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun listWebhooks(
+ projectId: String
+ ): Response {
+ val path = "/projects/{projectId}/webhooks".replace("{projectId}", projectId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create Webhook
+ *
+ * @param projectId
+ * @param name
+ * @param events
+ * @param url
+ * @param security
+ * @param httpUser
+ * @param httpPass
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun createWebhook(
+ projectId: String,
+ name: String,
+ events: List,
+ url: String,
+ security: Boolean,
+ httpUser: String? = null,
+ httpPass: String? = null
+ ): Response {
+ val path = "/projects/{projectId}/webhooks".replace("{projectId}", projectId)
+ val params = mapOf(
+ "name" to name,
+ "events" to events,
+ "url" to url,
+ "security" to security,
+ "httpUser" to httpUser,
+ "httpPass" to httpPass
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get Webhook
+ *
+ * @param projectId
+ * @param webhookId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getWebhook(
+ projectId: String,
+ webhookId: String
+ ): Response {
+ val path = "/projects/{projectId}/webhooks/{webhookId}".replace("{projectId}", projectId).replace("{webhookId}", webhookId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Update Webhook
+ *
+ * @param projectId
+ * @param webhookId
+ * @param name
+ * @param events
+ * @param url
+ * @param security
+ * @param httpUser
+ * @param httpPass
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateWebhook(
+ projectId: String,
+ webhookId: String,
+ name: String,
+ events: List,
+ url: String,
+ security: Boolean,
+ httpUser: String? = null,
+ httpPass: String? = null
+ ): Response {
+ val path = "/projects/{projectId}/webhooks/{webhookId}".replace("{projectId}", projectId).replace("{webhookId}", webhookId)
+ val params = mapOf(
+ "name" to name,
+ "events" to events,
+ "url" to url,
+ "security" to security,
+ "httpUser" to httpUser,
+ "httpPass" to httpPass
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PUT", path, headers, params)
+ }
+
+ /**
+ * Delete Webhook
+ *
+ * @param projectId
+ * @param webhookId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun deleteWebhook(
+ projectId: String,
+ webhookId: String
+ ): Response {
+ val path = "/projects/{projectId}/webhooks/{webhookId}".replace("{projectId}", projectId).replace("{webhookId}", webhookId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+}
\ No newline at end of file
diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt
new file mode 100644
index 0000000..cec1dad
--- /dev/null
+++ b/library/src/main/java/io/appwrite/services/Realtime.kt
@@ -0,0 +1,174 @@
+package io.appwrite.services
+
+import io.appwrite.Client
+import io.appwrite.exceptions.AppwriteException
+import io.appwrite.extensions.forEachAsync
+import io.appwrite.extensions.fromJson
+import io.appwrite.extensions.jsonCast
+import io.appwrite.models.*
+import kotlinx.coroutines.*
+import kotlinx.coroutines.Dispatchers.IO
+import okhttp3.Request
+import okhttp3.Response
+import okhttp3.WebSocket
+import okhttp3.WebSocketListener
+import okhttp3.internal.concurrent.TaskRunner
+import okhttp3.internal.ws.RealWebSocket
+import java.util.*
+import kotlin.coroutines.CoroutineContext
+
+class Realtime(client: Client) : Service(client), CoroutineScope {
+
+ private val job = Job()
+
+ override val coroutineContext: CoroutineContext
+ get() = Dispatchers.Main + job
+
+ private companion object {
+ private const val TYPE_ERROR = "error"
+ private const val TYPE_EVENT = "event"
+
+ private const val DEBOUNCE_MILLIS = 1L
+
+ private var socket: RealWebSocket? = null
+ private var channelCallbacks = mutableMapOf>()
+ private var errorCallbacks = mutableSetOf<(AppwriteException) -> Unit>()
+
+ private var subCallDepth = 0
+ }
+
+ private fun createSocket() {
+ val queryParamBuilder = StringBuilder()
+ .append("project=${client.config["project"]}")
+
+ channelCallbacks.keys.forEach {
+ queryParamBuilder
+ .append("&channels[]=$it")
+ }
+
+ val request = Request.Builder()
+ .url("${client.endPointRealtime}/realtime?$queryParamBuilder")
+ .build()
+
+ if (socket != null) {
+ closeSocket()
+ }
+
+ socket = RealWebSocket(
+ taskRunner = TaskRunner.INSTANCE,
+ originalRequest = request,
+ listener = AppwriteWebSocketListener(),
+ random = Random(),
+ pingIntervalMillis = client.http.pingIntervalMillis.toLong(),
+ extensions = null,
+ minimumDeflateSize = client.http.minWebSocketMessageToCompress
+ )
+
+ socket!!.connect(client.http)
+ }
+
+ private fun closeSocket() {
+ socket?.close(RealtimeCode.POLICY_VIOLATION.value, null)
+ }
+
+ fun subscribe(
+ vararg channels: String,
+ callback: (RealtimeResponseEvent) -> Unit,
+ ) = subscribe(
+ channels = channels,
+ Any::class.java,
+ callback
+ )
+
+ fun subscribe(
+ vararg channels: String,
+ payloadType: Class,
+ callback: (RealtimeResponseEvent) -> Unit,
+ ): RealtimeSubscription {
+ channels.forEach {
+ if (!channelCallbacks.containsKey(it)) {
+ channelCallbacks[it] = mutableListOf(
+ RealtimeCallback(
+ payloadType,
+ callback as (RealtimeResponseEvent<*>) -> Unit
+ )
+ )
+ return@forEach
+ }
+ channelCallbacks[it]?.add(
+ RealtimeCallback(payloadType, callback as (RealtimeResponseEvent<*>) -> Unit)
+ )
+ }
+
+ launch {
+ subCallDepth++
+ delay(DEBOUNCE_MILLIS)
+ if (subCallDepth == 1) {
+ createSocket()
+ }
+ subCallDepth--
+ }
+
+ return RealtimeSubscription { unsubscribe(*channels) }
+ }
+
+ fun unsubscribe(vararg channels: String) {
+ channels.forEach {
+ channelCallbacks[it] = mutableListOf()
+ }
+ if (channelCallbacks.all { it.value.isEmpty() }) {
+ errorCallbacks = mutableSetOf()
+ closeSocket()
+ }
+ }
+
+ fun doOnError(callback: (AppwriteException) -> Unit) {
+ errorCallbacks.add(callback)
+ }
+
+ private inner class AppwriteWebSocketListener : WebSocketListener() {
+
+ override fun onMessage(webSocket: WebSocket, text: String) {
+ super.onMessage(webSocket, text)
+
+ launch(IO) {
+ val message = text.fromJson()
+ when (message.type) {
+ TYPE_ERROR -> handleResponseError(message)
+ TYPE_EVENT -> handleResponseEvent(message)
+ }
+ }
+ }
+
+ private fun handleResponseError(message: RealtimeResponse) {
+ val error = message.data.jsonCast()
+ errorCallbacks.forEach { it.invoke(error) }
+ }
+
+ private suspend fun handleResponseEvent(message: RealtimeResponse) {
+ val event = message.data.jsonCast>()
+ event.channels.forEachAsync { channel ->
+ channelCallbacks[channel]?.forEachAsync { callbackWrapper ->
+ event.payload = event.payload.jsonCast(callbackWrapper.payloadClass)
+ callbackWrapper.callback.invoke(event)
+ }
+ }
+ }
+
+ override fun onClosing(webSocket: WebSocket, code: Int, reason: String) {
+ super.onClosing(webSocket, code, reason)
+ if (code == RealtimeCode.POLICY_VIOLATION.value) {
+ return
+ }
+ launch {
+ delay(1000)
+ createSocket()
+ }
+ }
+
+ override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {
+ super.onFailure(webSocket, t, response)
+ t.printStackTrace()
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/io/appwrite/services/BaseService.kt b/library/src/main/java/io/appwrite/services/Service.kt
similarity index 50%
rename from library/src/main/java/io/appwrite/services/BaseService.kt
rename to library/src/main/java/io/appwrite/services/Service.kt
index 1d6df97..6a00fb1 100644
--- a/library/src/main/java/io/appwrite/services/BaseService.kt
+++ b/library/src/main/java/io/appwrite/services/Service.kt
@@ -2,4 +2,4 @@ package io.appwrite.services
import io.appwrite.Client
-abstract class BaseService(private val client: Client)
+abstract class Service(val client: Client)
diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt
index 6b053d0..c13a0a3 100644
--- a/library/src/main/java/io/appwrite/services/Storage.kt
+++ b/library/src/main/java/io/appwrite/services/Storage.kt
@@ -9,7 +9,7 @@ import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import java.io.File
-class Storage(private val client: Client) : BaseService(client) {
+class Storage(client: Client) : Service(client) {
/**
* List Files
@@ -195,7 +195,6 @@ class Storage(private val client: Client) : BaseService(client) {
* @param fileId
* @param width
* @param height
- * @param gravity
* @param quality
* @param borderWidth
* @param borderColor
@@ -212,7 +211,6 @@ class Storage(private val client: Client) : BaseService(client) {
fileId: String,
width: Int? = null,
height: Int? = null,
- gravity: String? = null,
quality: Int? = null,
borderWidth: Int? = null,
borderColor: String? = null,
@@ -226,7 +224,6 @@ class Storage(private val client: Client) : BaseService(client) {
val params = mapOf(
"width" to width,
"height" to height,
- "gravity" to gravity,
"quality" to quality,
"borderWidth" to borderWidth,
"borderColor" to borderColor,
diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt
index 8e14663..873de7d 100644
--- a/library/src/main/java/io/appwrite/services/Teams.kt
+++ b/library/src/main/java/io/appwrite/services/Teams.kt
@@ -7,7 +7,7 @@ import okhttp3.Cookie
import okhttp3.Response
import java.io.File
-class Teams(private val client: Client) : BaseService(client) {
+class Teams(client: Client) : Service(client) {
/**
* List Teams
diff --git a/library/src/main/java/io/appwrite/services/Users.kt b/library/src/main/java/io/appwrite/services/Users.kt
new file mode 100644
index 0000000..0241d2d
--- /dev/null
+++ b/library/src/main/java/io/appwrite/services/Users.kt
@@ -0,0 +1,303 @@
+package io.appwrite.services
+
+import android.net.Uri
+import io.appwrite.Client
+import io.appwrite.exceptions.AppwriteException
+import okhttp3.Cookie
+import okhttp3.Response
+import java.io.File
+
+class Users(client: Client) : Service(client) {
+
+ /**
+ * List Users
+ *
+ * Get a list of all the project's users. You can use the query params to
+ * filter your results.
+ *
+ * @param search
+ * @param limit
+ * @param offset
+ * @param orderType
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun list(
+ search: String? = null,
+ limit: Int? = null,
+ offset: Int? = null,
+ orderType: String? = null
+ ): Response {
+ val path = "/users"
+ val params = mapOf(
+ "search" to search,
+ "limit" to limit,
+ "offset" to offset,
+ "orderType" to orderType
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Create User
+ *
+ * Create a new user.
+ *
+ * @param email
+ * @param password
+ * @param name
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun create(
+ email: String,
+ password: String,
+ name: String? = null
+ ): Response {
+ val path = "/users"
+ val params = mapOf(
+ "email" to email,
+ "password" to password,
+ "name" to name
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("POST", path, headers, params)
+ }
+
+ /**
+ * Get User
+ *
+ * Get a user by its unique ID.
+ *
+ * @param userId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun get(
+ userId: String
+ ): Response {
+ val path = "/users/{userId}".replace("{userId}", userId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Delete User
+ *
+ * Delete a user by its unique ID.
+ *
+ * @param userId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun delete(
+ userId: String
+ ): Response {
+ val path = "/users/{userId}".replace("{userId}", userId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+ /**
+ * Get User Logs
+ *
+ * Get a user activity logs list by its unique ID.
+ *
+ * @param userId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getLogs(
+ userId: String
+ ): Response {
+ val path = "/users/{userId}/logs".replace("{userId}", userId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Get User Preferences
+ *
+ * Get the user preferences by its unique ID.
+ *
+ * @param userId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getPrefs(
+ userId: String
+ ): Response {
+ val path = "/users/{userId}/prefs".replace("{userId}", userId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Update User Preferences
+ *
+ * Update the user preferences by its unique ID. You can pass only the
+ * specific settings you wish to update.
+ *
+ * @param userId
+ * @param prefs
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updatePrefs(
+ userId: String,
+ prefs: Any
+ ): Response {
+ val path = "/users/{userId}/prefs".replace("{userId}", userId)
+ val params = mapOf(
+ "prefs" to prefs
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PATCH", path, headers, params)
+ }
+
+ /**
+ * Get User Sessions
+ *
+ * Get the user sessions list by its unique ID.
+ *
+ * @param userId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun getSessions(
+ userId: String
+ ): Response {
+ val path = "/users/{userId}/sessions".replace("{userId}", userId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("GET", path, headers, params)
+ }
+
+ /**
+ * Delete User Sessions
+ *
+ * Delete all user's sessions by using the user's unique ID.
+ *
+ * @param userId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun deleteSessions(
+ userId: String
+ ): Response {
+ val path = "/users/{userId}/sessions".replace("{userId}", userId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+ /**
+ * Delete User Session
+ *
+ * Delete a user sessions by its unique ID.
+ *
+ * @param userId
+ * @param sessionId
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun deleteSession(
+ userId: String,
+ sessionId: String
+ ): Response {
+ val path = "/users/{userId}/sessions/{sessionId}".replace("{userId}", userId).replace("{sessionId}", sessionId)
+ val params = mapOf(
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("DELETE", path, headers, params)
+ }
+
+ /**
+ * Update User Status
+ *
+ * Update the user status by its unique ID.
+ *
+ * @param userId
+ * @param status
+ * @return [Response]
+ */
+ @JvmOverloads
+ @Throws(AppwriteException::class)
+ suspend fun updateStatus(
+ userId: String,
+ status: Int
+ ): Response {
+ val path = "/users/{userId}/status".replace("{userId}", userId)
+ val params = mapOf(
+ "status" to status
+ )
+
+ val headers = mapOf(
+ "content-type" to "application/json"
+ )
+
+ return client.call("PATCH", path, headers, params)
+ }
+
+}
\ No newline at end of file