diff --git a/CHANGELOG.md b/CHANGELOG.md index afd1c28..c2b36e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 15.0.0 + +* [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents +* Breaking: Renamed `IndexType` to `DatabasesIndexType` in docs. +* Breaking: Replaced `.setKey()` with `.setSession()` in docs examples. +* Updated: Updated docs to reflect new `DatabasesIndexType` examples. + ## 14.1.0 * Added getConsolePausing health status endpoint diff --git a/README.md b/README.md index fc72244..d60bd31 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.8.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.0-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.8.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.9.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:14.1.0") +implementation("io.appwrite:sdk-for-kotlin:15.0.0") ``` ### Maven @@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-kotlin - 14.1.0 + 15.0.0 ``` diff --git a/docs/examples/java/databases/create-index.md b/docs/examples/java/databases/create-index.md index 5dc2222..28a10ca 100644 --- a/docs/examples/java/databases/create-index.md +++ b/docs/examples/java/databases/create-index.md @@ -2,7 +2,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; -import io.appwrite.enums.IndexType; +import io.appwrite.enums.DatabasesIndexType; import io.appwrite.enums.OrderBy; Client client = new Client() @@ -16,7 +16,7 @@ databases.createIndex( "", // databaseId "", // collectionId "", // key - IndexType.KEY, // type + DatabasesIndexType.KEY, // type List.of(), // attributes List.of(OrderBy.ASC), // orders (optional) List.of(), // lengths (optional) diff --git a/docs/examples/java/functions/create.md b/docs/examples/java/functions/create.md index 47015f3..d423c66 100644 --- a/docs/examples/java/functions/create.md +++ b/docs/examples/java/functions/create.md @@ -30,7 +30,9 @@ functions.create( "", // providerBranch (optional) false, // providerSilentMode (optional) "", // providerRootDirectory (optional) - "", // specification (optional) + "", // buildSpecification (optional) + "", // runtimeSpecification (optional) + 0, // deploymentRetention (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/update.md b/docs/examples/java/functions/update.md index 7ab2402..5e7b5c8 100644 --- a/docs/examples/java/functions/update.md +++ b/docs/examples/java/functions/update.md @@ -30,7 +30,9 @@ functions.update( "", // providerBranch (optional) false, // providerSilentMode (optional) "", // providerRootDirectory (optional) - "", // specification (optional) + "", // buildSpecification (optional) + "", // runtimeSpecification (optional) + 0, // deploymentRetention (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/project/create-variable.md b/docs/examples/java/project/create-variable.md new file mode 100644 index 0000000..62d7a47 --- /dev/null +++ b/docs/examples/java/project/create-variable.md @@ -0,0 +1,28 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Project; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Project project = new Project(client); + +project.createVariable( + "", // variableId + "", // key + "", // value + false, // secret (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/project/delete-variable.md b/docs/examples/java/project/delete-variable.md new file mode 100644 index 0000000..98ff61d --- /dev/null +++ b/docs/examples/java/project/delete-variable.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Project; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Project project = new Project(client); + +project.deleteVariable( + "", // variableId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/project/get-variable.md b/docs/examples/java/project/get-variable.md new file mode 100644 index 0000000..f922e27 --- /dev/null +++ b/docs/examples/java/project/get-variable.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Project; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Project project = new Project(client); + +project.getVariable( + "", // variableId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/project/list-variables.md b/docs/examples/java/project/list-variables.md new file mode 100644 index 0000000..bfcfbd6 --- /dev/null +++ b/docs/examples/java/project/list-variables.md @@ -0,0 +1,26 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Project; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Project project = new Project(client); + +project.listVariables( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/project/update-variable.md b/docs/examples/java/project/update-variable.md new file mode 100644 index 0000000..19e7d88 --- /dev/null +++ b/docs/examples/java/project/update-variable.md @@ -0,0 +1,28 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Project; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Project project = new Project(client); + +project.updateVariable( + "", // variableId + "", // key (optional) + "", // value (optional) + false, // secret (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/sites/create.md b/docs/examples/java/sites/create.md index 328b395..1f1f8e3 100644 --- a/docs/examples/java/sites/create.md +++ b/docs/examples/java/sites/create.md @@ -23,6 +23,7 @@ sites.create( 1, // timeout (optional) "", // installCommand (optional) "", // buildCommand (optional) + "", // startCommand (optional) "", // outputDirectory (optional) Adapter.STATIC, // adapter (optional) "", // installationId (optional) @@ -31,7 +32,9 @@ sites.create( "", // providerBranch (optional) false, // providerSilentMode (optional) "", // providerRootDirectory (optional) - "", // specification (optional) + "", // buildSpecification (optional) + "", // runtimeSpecification (optional) + 0, // deploymentRetention (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/sites/update.md b/docs/examples/java/sites/update.md index 6f34a38..5086605 100644 --- a/docs/examples/java/sites/update.md +++ b/docs/examples/java/sites/update.md @@ -22,6 +22,7 @@ sites.update( 1, // timeout (optional) "", // installCommand (optional) "", // buildCommand (optional) + "", // startCommand (optional) "", // outputDirectory (optional) BuildRuntime.NODE_14_5, // buildRuntime (optional) Adapter.STATIC, // adapter (optional) @@ -31,7 +32,9 @@ sites.update( "", // providerBranch (optional) false, // providerSilentMode (optional) "", // providerRootDirectory (optional) - "", // specification (optional) + "", // buildSpecification (optional) + "", // runtimeSpecification (optional) + 0, // deploymentRetention (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/create-index.md b/docs/examples/java/tablesdb/create-index.md index 0ad4055..17b6e1d 100644 --- a/docs/examples/java/tablesdb/create-index.md +++ b/docs/examples/java/tablesdb/create-index.md @@ -2,7 +2,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.TablesDB; -import io.appwrite.enums.IndexType; +import io.appwrite.enums.TablesDBIndexType; import io.appwrite.enums.OrderBy; Client client = new Client() @@ -16,7 +16,7 @@ tablesDB.createIndex( "", // databaseId "", // tableId "", // key - IndexType.KEY, // type + TablesDBIndexType.KEY, // type List.of(), // columns List.of(OrderBy.ASC), // orders (optional) List.of(), // lengths (optional) diff --git a/docs/examples/java/users/update-impersonator.md b/docs/examples/java/users/update-impersonator.md new file mode 100644 index 0000000..879e436 --- /dev/null +++ b/docs/examples/java/users/update-impersonator.md @@ -0,0 +1,26 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Users; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Users users = new Users(client); + +users.updateImpersonator( + "", // userId + false, // impersonator + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/webhooks/create.md b/docs/examples/java/webhooks/create.md new file mode 100644 index 0000000..22a856e --- /dev/null +++ b/docs/examples/java/webhooks/create.md @@ -0,0 +1,32 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Webhooks; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Webhooks webhooks = new Webhooks(client); + +webhooks.create( + "", // webhookId + "", // url + "", // name + List.of(), // events + false, // enabled (optional) + false, // security (optional) + "", // httpUser (optional) + "", // httpPass (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/webhooks/delete.md b/docs/examples/java/webhooks/delete.md new file mode 100644 index 0000000..21c5304 --- /dev/null +++ b/docs/examples/java/webhooks/delete.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Webhooks; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Webhooks webhooks = new Webhooks(client); + +webhooks.delete( + "", // webhookId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/webhooks/get.md b/docs/examples/java/webhooks/get.md new file mode 100644 index 0000000..07ed771 --- /dev/null +++ b/docs/examples/java/webhooks/get.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Webhooks; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Webhooks webhooks = new Webhooks(client); + +webhooks.get( + "", // webhookId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/webhooks/list.md b/docs/examples/java/webhooks/list.md new file mode 100644 index 0000000..22e3d32 --- /dev/null +++ b/docs/examples/java/webhooks/list.md @@ -0,0 +1,26 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Webhooks; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Webhooks webhooks = new Webhooks(client); + +webhooks.list( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/webhooks/update-signature.md b/docs/examples/java/webhooks/update-signature.md new file mode 100644 index 0000000..2526dd5 --- /dev/null +++ b/docs/examples/java/webhooks/update-signature.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Webhooks; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Webhooks webhooks = new Webhooks(client); + +webhooks.updateSignature( + "", // webhookId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/java/webhooks/update.md b/docs/examples/java/webhooks/update.md new file mode 100644 index 0000000..cb7cf9b --- /dev/null +++ b/docs/examples/java/webhooks/update.md @@ -0,0 +1,32 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Webhooks; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Webhooks webhooks = new Webhooks(client); + +webhooks.update( + "", // webhookId + "", // name + "", // url + List.of(), // events + false, // enabled (optional) + false, // security (optional) + "", // httpUser (optional) + "", // httpPass (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + +``` diff --git a/docs/examples/kotlin/databases/create-index.md b/docs/examples/kotlin/databases/create-index.md index 85d3729..aae520e 100644 --- a/docs/examples/kotlin/databases/create-index.md +++ b/docs/examples/kotlin/databases/create-index.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases -import io.appwrite.enums.IndexType +import io.appwrite.enums.DatabasesIndexType import io.appwrite.enums.OrderBy val client = Client() @@ -16,7 +16,7 @@ val response = databases.createIndex( databaseId = "", collectionId = "", key = "", - type = IndexType.KEY, + type = DatabasesIndexType.KEY, attributes = listOf(), orders = listOf(OrderBy.ASC), // optional lengths = listOf() // optional diff --git a/docs/examples/kotlin/functions/create.md b/docs/examples/kotlin/functions/create.md index 0ad7f97..ce62e40 100644 --- a/docs/examples/kotlin/functions/create.md +++ b/docs/examples/kotlin/functions/create.md @@ -30,6 +30,8 @@ val response = functions.create( providerBranch = "", // optional providerSilentMode = false, // optional providerRootDirectory = "", // optional - specification = "" // optional + buildSpecification = "", // optional + runtimeSpecification = "", // optional + deploymentRetention = 0 // optional ) ``` diff --git a/docs/examples/kotlin/functions/update.md b/docs/examples/kotlin/functions/update.md index c04a3c9..a686091 100644 --- a/docs/examples/kotlin/functions/update.md +++ b/docs/examples/kotlin/functions/update.md @@ -30,6 +30,8 @@ val response = functions.update( providerBranch = "", // optional providerSilentMode = false, // optional providerRootDirectory = "", // optional - specification = "" // optional + buildSpecification = "", // optional + runtimeSpecification = "", // optional + deploymentRetention = 0 // optional ) ``` diff --git a/docs/examples/kotlin/project/create-variable.md b/docs/examples/kotlin/project/create-variable.md new file mode 100644 index 0000000..e61e1ba --- /dev/null +++ b/docs/examples/kotlin/project/create-variable.md @@ -0,0 +1,19 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Project + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val project = Project(client) + +val response = project.createVariable( + variableId = "", + key = "", + value = "", + secret = false // optional +) +``` diff --git a/docs/examples/kotlin/project/delete-variable.md b/docs/examples/kotlin/project/delete-variable.md new file mode 100644 index 0000000..674d805 --- /dev/null +++ b/docs/examples/kotlin/project/delete-variable.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Project + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val project = Project(client) + +val response = project.deleteVariable( + variableId = "" +) +``` diff --git a/docs/examples/kotlin/project/get-variable.md b/docs/examples/kotlin/project/get-variable.md new file mode 100644 index 0000000..59dea64 --- /dev/null +++ b/docs/examples/kotlin/project/get-variable.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Project + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val project = Project(client) + +val response = project.getVariable( + variableId = "" +) +``` diff --git a/docs/examples/kotlin/project/list-variables.md b/docs/examples/kotlin/project/list-variables.md new file mode 100644 index 0000000..d455a15 --- /dev/null +++ b/docs/examples/kotlin/project/list-variables.md @@ -0,0 +1,17 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Project + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val project = Project(client) + +val response = project.listVariables( + queries = listOf(), // optional + total = false // optional +) +``` diff --git a/docs/examples/kotlin/project/update-variable.md b/docs/examples/kotlin/project/update-variable.md new file mode 100644 index 0000000..cc6b22e --- /dev/null +++ b/docs/examples/kotlin/project/update-variable.md @@ -0,0 +1,19 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Project + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val project = Project(client) + +val response = project.updateVariable( + variableId = "", + key = "", // optional + value = "", // optional + secret = false // optional +) +``` diff --git a/docs/examples/kotlin/sites/create.md b/docs/examples/kotlin/sites/create.md index a0a0205..9bc8982 100644 --- a/docs/examples/kotlin/sites/create.md +++ b/docs/examples/kotlin/sites/create.md @@ -23,6 +23,7 @@ val response = sites.create( timeout = 1, // optional installCommand = "", // optional buildCommand = "", // optional + startCommand = "", // optional outputDirectory = "", // optional adapter = Adapter.STATIC, // optional installationId = "", // optional @@ -31,6 +32,8 @@ val response = sites.create( providerBranch = "", // optional providerSilentMode = false, // optional providerRootDirectory = "", // optional - specification = "" // optional + buildSpecification = "", // optional + runtimeSpecification = "", // optional + deploymentRetention = 0 // optional ) ``` diff --git a/docs/examples/kotlin/sites/update.md b/docs/examples/kotlin/sites/update.md index e3b1ecb..63ff5b0 100644 --- a/docs/examples/kotlin/sites/update.md +++ b/docs/examples/kotlin/sites/update.md @@ -22,6 +22,7 @@ val response = sites.update( timeout = 1, // optional installCommand = "", // optional buildCommand = "", // optional + startCommand = "", // optional outputDirectory = "", // optional buildRuntime = BuildRuntime.NODE_14_5, // optional adapter = Adapter.STATIC, // optional @@ -31,6 +32,8 @@ val response = sites.update( providerBranch = "", // optional providerSilentMode = false, // optional providerRootDirectory = "", // optional - specification = "" // optional + buildSpecification = "", // optional + runtimeSpecification = "", // optional + deploymentRetention = 0 // optional ) ``` diff --git a/docs/examples/kotlin/tablesdb/create-index.md b/docs/examples/kotlin/tablesdb/create-index.md index b3c09ee..021290d 100644 --- a/docs/examples/kotlin/tablesdb/create-index.md +++ b/docs/examples/kotlin/tablesdb/create-index.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.TablesDB -import io.appwrite.enums.IndexType +import io.appwrite.enums.TablesDBIndexType import io.appwrite.enums.OrderBy val client = Client() @@ -16,7 +16,7 @@ val response = tablesDB.createIndex( databaseId = "", tableId = "", key = "", - type = IndexType.KEY, + type = TablesDBIndexType.KEY, columns = listOf(), orders = listOf(OrderBy.ASC), // optional lengths = listOf() // optional diff --git a/docs/examples/kotlin/users/update-impersonator.md b/docs/examples/kotlin/users/update-impersonator.md new file mode 100644 index 0000000..58a8e6e --- /dev/null +++ b/docs/examples/kotlin/users/update-impersonator.md @@ -0,0 +1,17 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Users + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val users = Users(client) + +val response = users.updateImpersonator( + userId = "", + impersonator = false +) +``` diff --git a/docs/examples/kotlin/webhooks/create.md b/docs/examples/kotlin/webhooks/create.md new file mode 100644 index 0000000..d5eaedd --- /dev/null +++ b/docs/examples/kotlin/webhooks/create.md @@ -0,0 +1,23 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Webhooks + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val webhooks = Webhooks(client) + +val response = webhooks.create( + webhookId = "", + url = "", + name = "", + events = listOf(), + enabled = false, // optional + security = false, // optional + httpUser = "", // optional + httpPass = "" // optional +) +``` diff --git a/docs/examples/kotlin/webhooks/delete.md b/docs/examples/kotlin/webhooks/delete.md new file mode 100644 index 0000000..6f381c2 --- /dev/null +++ b/docs/examples/kotlin/webhooks/delete.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Webhooks + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val webhooks = Webhooks(client) + +val response = webhooks.delete( + webhookId = "" +) +``` diff --git a/docs/examples/kotlin/webhooks/get.md b/docs/examples/kotlin/webhooks/get.md new file mode 100644 index 0000000..1f82c0b --- /dev/null +++ b/docs/examples/kotlin/webhooks/get.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Webhooks + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val webhooks = Webhooks(client) + +val response = webhooks.get( + webhookId = "" +) +``` diff --git a/docs/examples/kotlin/webhooks/list.md b/docs/examples/kotlin/webhooks/list.md new file mode 100644 index 0000000..f3f9f23 --- /dev/null +++ b/docs/examples/kotlin/webhooks/list.md @@ -0,0 +1,17 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Webhooks + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val webhooks = Webhooks(client) + +val response = webhooks.list( + queries = listOf(), // optional + total = false // optional +) +``` diff --git a/docs/examples/kotlin/webhooks/update-signature.md b/docs/examples/kotlin/webhooks/update-signature.md new file mode 100644 index 0000000..d58f9ef --- /dev/null +++ b/docs/examples/kotlin/webhooks/update-signature.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Webhooks + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val webhooks = Webhooks(client) + +val response = webhooks.updateSignature( + webhookId = "" +) +``` diff --git a/docs/examples/kotlin/webhooks/update.md b/docs/examples/kotlin/webhooks/update.md new file mode 100644 index 0000000..06e7d31 --- /dev/null +++ b/docs/examples/kotlin/webhooks/update.md @@ -0,0 +1,23 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Webhooks + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val webhooks = Webhooks(client) + +val response = webhooks.update( + webhookId = "", + name = "", + url = "", + events = listOf(), + enabled = false, // optional + security = false, // optional + httpUser = "", // optional + httpPass = "" // optional +) +``` diff --git a/src/main/kotlin/io/appwrite/Client.kt b/src/main/kotlin/io/appwrite/Client.kt index 18232f2..0fd7889 100644 --- a/src/main/kotlin/io/appwrite/Client.kt +++ b/src/main/kotlin/io/appwrite/Client.kt @@ -57,12 +57,12 @@ class Client @JvmOverloads constructor( init { headers = mutableMapOf( "content-type" to "application/json", - "user-agent" to "AppwriteKotlinSDK/14.1.0 ${System.getProperty("http.agent")}", + "user-agent" to "AppwriteKotlinSDK/15.0.0 ${System.getProperty("http.agent")}", "x-sdk-name" to "Kotlin", "x-sdk-platform" to "server", "x-sdk-language" to "kotlin", - "x-sdk-version" to "14.1.0", - "x-appwrite-response-format" to "1.8.0", + "x-sdk-version" to "15.0.0", + "x-appwrite-response-format" to "1.9.0", ) config = mutableMapOf() @@ -158,6 +158,51 @@ class Client @JvmOverloads constructor( return this } + /** + * Set ImpersonateUserId + * + * Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * + * @param {string} impersonateuserid + * + * @return this + */ + fun setImpersonateUserId(value: String): Client { + config["impersonateUserId"] = value + addHeader("x-appwrite-impersonate-user-id", value) + return this + } + + /** + * Set ImpersonateUserEmail + * + * Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * + * @param {string} impersonateuseremail + * + * @return this + */ + fun setImpersonateUserEmail(value: String): Client { + config["impersonateUserEmail"] = value + addHeader("x-appwrite-impersonate-user-email", value) + return this + } + + /** + * Set ImpersonateUserPhone + * + * Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * + * @param {string} impersonateuserphone + * + * @return this + */ + fun setImpersonateUserPhone(value: String): Client { + config["impersonateUserPhone"] = value + addHeader("x-appwrite-impersonate-user-phone", value) + return this + } + /** * Set self Signed * diff --git a/src/main/kotlin/io/appwrite/enums/BackupServices.kt b/src/main/kotlin/io/appwrite/enums/BackupServices.kt index e82c017..3cadb7e 100644 --- a/src/main/kotlin/io/appwrite/enums/BackupServices.kt +++ b/src/main/kotlin/io/appwrite/enums/BackupServices.kt @@ -5,6 +5,12 @@ import com.google.gson.annotations.SerializedName enum class BackupServices(val value: String) { @SerializedName("databases") DATABASES("databases"), + @SerializedName("tablesdb") + TABLESDB("tablesdb"), + @SerializedName("documentsdb") + DOCUMENTSDB("documentsdb"), + @SerializedName("vectorsdb") + VECTORSDB("vectorsdb"), @SerializedName("functions") FUNCTIONS("functions"), @SerializedName("storage") diff --git a/src/main/kotlin/io/appwrite/enums/DatabaseType.kt b/src/main/kotlin/io/appwrite/enums/DatabaseType.kt index 8aeb0f4..f2dfc31 100644 --- a/src/main/kotlin/io/appwrite/enums/DatabaseType.kt +++ b/src/main/kotlin/io/appwrite/enums/DatabaseType.kt @@ -6,7 +6,11 @@ enum class DatabaseType(val value: String) { @SerializedName("legacy") LEGACY("legacy"), @SerializedName("tablesdb") - TABLESDB("tablesdb"); + TABLESDB("tablesdb"), + @SerializedName("documentsdb") + DOCUMENTSDB("documentsdb"), + @SerializedName("vectorsdb") + VECTORSDB("vectorsdb"); override fun toString() = value } \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/enums/DatabasesIndexType.kt b/src/main/kotlin/io/appwrite/enums/DatabasesIndexType.kt new file mode 100644 index 0000000..491eec4 --- /dev/null +++ b/src/main/kotlin/io/appwrite/enums/DatabasesIndexType.kt @@ -0,0 +1,16 @@ +package io.appwrite.enums + +import com.google.gson.annotations.SerializedName + +enum class DatabasesIndexType(val value: String) { + @SerializedName("key") + KEY("key"), + @SerializedName("fulltext") + FULLTEXT("fulltext"), + @SerializedName("unique") + UNIQUE("unique"), + @SerializedName("spatial") + SPATIAL("spatial"); + + override fun toString() = value +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/enums/Scopes.kt b/src/main/kotlin/io/appwrite/enums/Scopes.kt index 1b77212..0dcf844 100644 --- a/src/main/kotlin/io/appwrite/enums/Scopes.kt +++ b/src/main/kotlin/io/appwrite/enums/Scopes.kt @@ -117,6 +117,14 @@ enum class Scopes(val value: String) { TOKENS_READ("tokens.read"), @SerializedName("tokens.write") TOKENS_WRITE("tokens.write"), + @SerializedName("webhooks.read") + WEBHOOKS_READ("webhooks.read"), + @SerializedName("webhooks.write") + WEBHOOKS_WRITE("webhooks.write"), + @SerializedName("project.read") + PROJECT_READ("project.read"), + @SerializedName("project.write") + PROJECT_WRITE("project.write"), @SerializedName("policies.write") POLICIES_WRITE("policies.write"), @SerializedName("policies.read") diff --git a/src/main/kotlin/io/appwrite/enums/IndexType.kt b/src/main/kotlin/io/appwrite/enums/TablesDBIndexType.kt similarity index 86% rename from src/main/kotlin/io/appwrite/enums/IndexType.kt rename to src/main/kotlin/io/appwrite/enums/TablesDBIndexType.kt index eeebc06..452fe9d 100644 --- a/src/main/kotlin/io/appwrite/enums/IndexType.kt +++ b/src/main/kotlin/io/appwrite/enums/TablesDBIndexType.kt @@ -2,7 +2,7 @@ package io.appwrite.enums import com.google.gson.annotations.SerializedName -enum class IndexType(val value: String) { +enum class TablesDBIndexType(val value: String) { @SerializedName("key") KEY("key"), @SerializedName("fulltext") diff --git a/src/main/kotlin/io/appwrite/enums/TemplateReferenceType.kt b/src/main/kotlin/io/appwrite/enums/TemplateReferenceType.kt index 1f258b7..2997c18 100644 --- a/src/main/kotlin/io/appwrite/enums/TemplateReferenceType.kt +++ b/src/main/kotlin/io/appwrite/enums/TemplateReferenceType.kt @@ -3,10 +3,10 @@ package io.appwrite.enums import com.google.gson.annotations.SerializedName enum class TemplateReferenceType(val value: String) { - @SerializedName("branch") - BRANCH("branch"), @SerializedName("commit") COMMIT("commit"), + @SerializedName("branch") + BRANCH("branch"), @SerializedName("tag") TAG("tag"); diff --git a/src/main/kotlin/io/appwrite/models/Document.kt b/src/main/kotlin/io/appwrite/models/Document.kt index 830fe38..c55e6d2 100644 --- a/src/main/kotlin/io/appwrite/models/Document.kt +++ b/src/main/kotlin/io/appwrite/models/Document.kt @@ -17,7 +17,7 @@ data class Document( * Document sequence ID. */ @SerializedName("\$sequence") - val sequence: Long, + val sequence: String, /** * Collection ID. @@ -69,7 +69,7 @@ data class Document( companion object { operator fun invoke( id: String, - sequence: Long, + sequence: String, collectionId: String, databaseId: String, createdAt: String, @@ -93,7 +93,7 @@ data class Document( nestedType: Class ) = Document( id = map["\$id"] as String, - sequence = (map["\$sequence"] as Number).toLong(), + sequence = map["\$sequence"] as String, collectionId = map["\$collectionId"] as String, databaseId = map["\$databaseId"] as String, createdAt = map["\$createdAt"] as String, diff --git a/src/main/kotlin/io/appwrite/models/Function.kt b/src/main/kotlin/io/appwrite/models/Function.kt index 6cc111f..566c58d 100644 --- a/src/main/kotlin/io/appwrite/models/Function.kt +++ b/src/main/kotlin/io/appwrite/models/Function.kt @@ -61,6 +61,12 @@ data class Function( @SerializedName("runtime") val runtime: String, + /** + * How many days to keep the non-active deployments before they will be automatically deleted. + */ + @SerializedName("deploymentRetention") + val deploymentRetention: Long, + /** * Function's active deployment ID. */ @@ -170,10 +176,16 @@ data class Function( val providerSilentMode: Boolean, /** - * Machine specification for builds and executions. + * Machine specification for deployment builds. */ - @SerializedName("specification") - val specification: String, + @SerializedName("buildSpecification") + val buildSpecification: String, + + /** + * Machine specification for executions. + */ + @SerializedName("runtimeSpecification") + val runtimeSpecification: String, ) { fun toMap(): Map = mapOf( @@ -186,6 +198,7 @@ data class Function( "live" to live as Any, "logging" to logging as Any, "runtime" to runtime as Any, + "deploymentRetention" to deploymentRetention as Any, "deploymentId" to deploymentId as Any, "deploymentCreatedAt" to deploymentCreatedAt as Any, "latestDeploymentId" to latestDeploymentId as Any, @@ -204,7 +217,8 @@ data class Function( "providerBranch" to providerBranch as Any, "providerRootDirectory" to providerRootDirectory as Any, "providerSilentMode" to providerSilentMode as Any, - "specification" to specification as Any, + "buildSpecification" to buildSpecification as Any, + "runtimeSpecification" to runtimeSpecification as Any, ) companion object { @@ -222,6 +236,7 @@ data class Function( live = map["live"] as Boolean, logging = map["logging"] as Boolean, runtime = map["runtime"] as String, + deploymentRetention = (map["deploymentRetention"] as Number).toLong(), deploymentId = map["deploymentId"] as String, deploymentCreatedAt = map["deploymentCreatedAt"] as String, latestDeploymentId = map["latestDeploymentId"] as String, @@ -240,7 +255,8 @@ data class Function( providerBranch = map["providerBranch"] as String, providerRootDirectory = map["providerRootDirectory"] as String, providerSilentMode = map["providerSilentMode"] as Boolean, - specification = map["specification"] as String, + buildSpecification = map["buildSpecification"] as String, + runtimeSpecification = map["runtimeSpecification"] as String, ) } } \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/Log.kt b/src/main/kotlin/io/appwrite/models/Log.kt index c2df960..fe8c60b 100644 --- a/src/main/kotlin/io/appwrite/models/Log.kt +++ b/src/main/kotlin/io/appwrite/models/Log.kt @@ -14,19 +14,19 @@ data class Log( val event: String, /** - * User ID. + * User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. */ @SerializedName("userId") val userId: String, /** - * User Email. + * User email of the actor recorded for this log. During impersonation, this is the original impersonator. */ @SerializedName("userEmail") val userEmail: String, /** - * User Name. + * User name of the actor recorded for this log. During impersonation, this is the original impersonator. */ @SerializedName("userName") val userName: String, diff --git a/src/main/kotlin/io/appwrite/models/Row.kt b/src/main/kotlin/io/appwrite/models/Row.kt index 793d278..488ec7b 100644 --- a/src/main/kotlin/io/appwrite/models/Row.kt +++ b/src/main/kotlin/io/appwrite/models/Row.kt @@ -17,7 +17,7 @@ data class Row( * Row sequence ID. */ @SerializedName("\$sequence") - val sequence: Long, + val sequence: String, /** * Table ID. @@ -69,7 +69,7 @@ data class Row( companion object { operator fun invoke( id: String, - sequence: Long, + sequence: String, tableId: String, databaseId: String, createdAt: String, @@ -93,7 +93,7 @@ data class Row( nestedType: Class ) = Row( id = map["\$id"] as String, - sequence = (map["\$sequence"] as Number).toLong(), + sequence = map["\$sequence"] as String, tableId = map["\$tableId"] as String, databaseId = map["\$databaseId"] as String, createdAt = map["\$createdAt"] as String, diff --git a/src/main/kotlin/io/appwrite/models/Site.kt b/src/main/kotlin/io/appwrite/models/Site.kt index c246ac1..0359543 100644 --- a/src/main/kotlin/io/appwrite/models/Site.kt +++ b/src/main/kotlin/io/appwrite/models/Site.kt @@ -55,6 +55,12 @@ data class Site( @SerializedName("framework") val framework: String, + /** + * How many days to keep the non-active deployments before they will be automatically deleted. + */ + @SerializedName("deploymentRetention") + val deploymentRetention: Long, + /** * Site's active deployment ID. */ @@ -121,6 +127,12 @@ data class Site( @SerializedName("buildCommand") val buildCommand: String, + /** + * Custom command to use when starting site runtime. + */ + @SerializedName("startCommand") + val startCommand: String, + /** * The directory where the site build output is located. */ @@ -158,10 +170,16 @@ data class Site( val providerSilentMode: Boolean, /** - * Machine specification for builds and executions. + * Machine specification for deployment builds. */ - @SerializedName("specification") - val specification: String, + @SerializedName("buildSpecification") + val buildSpecification: String, + + /** + * Machine specification for SSR executions. + */ + @SerializedName("runtimeSpecification") + val runtimeSpecification: String, /** * Site build runtime. @@ -191,6 +209,7 @@ data class Site( "live" to live as Any, "logging" to logging as Any, "framework" to framework as Any, + "deploymentRetention" to deploymentRetention as Any, "deploymentId" to deploymentId as Any, "deploymentCreatedAt" to deploymentCreatedAt as Any, "deploymentScreenshotLight" to deploymentScreenshotLight as Any, @@ -202,13 +221,15 @@ data class Site( "timeout" to timeout as Any, "installCommand" to installCommand as Any, "buildCommand" to buildCommand as Any, + "startCommand" to startCommand as Any, "outputDirectory" to outputDirectory as Any, "installationId" to installationId as Any, "providerRepositoryId" to providerRepositoryId as Any, "providerBranch" to providerBranch as Any, "providerRootDirectory" to providerRootDirectory as Any, "providerSilentMode" to providerSilentMode as Any, - "specification" to specification as Any, + "buildSpecification" to buildSpecification as Any, + "runtimeSpecification" to runtimeSpecification as Any, "buildRuntime" to buildRuntime as Any, "adapter" to adapter as Any, "fallbackFile" to fallbackFile as Any, @@ -228,6 +249,7 @@ data class Site( live = map["live"] as Boolean, logging = map["logging"] as Boolean, framework = map["framework"] as String, + deploymentRetention = (map["deploymentRetention"] as Number).toLong(), deploymentId = map["deploymentId"] as String, deploymentCreatedAt = map["deploymentCreatedAt"] as String, deploymentScreenshotLight = map["deploymentScreenshotLight"] as String, @@ -239,13 +261,15 @@ data class Site( timeout = (map["timeout"] as Number).toLong(), installCommand = map["installCommand"] as String, buildCommand = map["buildCommand"] as String, + startCommand = map["startCommand"] as String, outputDirectory = map["outputDirectory"] as String, installationId = map["installationId"] as String, providerRepositoryId = map["providerRepositoryId"] as String, providerBranch = map["providerBranch"] as String, providerRootDirectory = map["providerRootDirectory"] as String, providerSilentMode = map["providerSilentMode"] as Boolean, - specification = map["specification"] as String, + buildSpecification = map["buildSpecification"] as String, + runtimeSpecification = map["runtimeSpecification"] as String, buildRuntime = map["buildRuntime"] as String, adapter = map["adapter"] as String, fallbackFile = map["fallbackFile"] as String, diff --git a/src/main/kotlin/io/appwrite/models/User.kt b/src/main/kotlin/io/appwrite/models/User.kt index e9a1144..a76d61f 100644 --- a/src/main/kotlin/io/appwrite/models/User.kt +++ b/src/main/kotlin/io/appwrite/models/User.kt @@ -121,6 +121,18 @@ data class User( @SerializedName("accessedAt") val accessedAt: String, + /** + * Whether the user can impersonate other users. + */ + @SerializedName("impersonator") + var impersonator: Boolean?, + + /** + * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + */ + @SerializedName("impersonatorUserId") + var impersonatorUserId: String?, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -142,6 +154,8 @@ data class User( "prefs" to prefs.toMap() as Any, "targets" to targets.map { it.toMap() } as Any, "accessedAt" to accessedAt as Any, + "impersonator" to impersonator as Any, + "impersonatorUserId" to impersonatorUserId as Any, ) companion object { @@ -165,6 +179,8 @@ data class User( prefs: Preferences>, targets: List, accessedAt: String, + impersonator: Boolean?, + impersonatorUserId: String?, ) = User>( id, createdAt, @@ -185,6 +201,8 @@ data class User( prefs, targets, accessedAt, + impersonator, + impersonatorUserId, ) @Suppress("UNCHECKED_CAST") @@ -211,6 +229,8 @@ data class User( prefs = Preferences.from(map = map["prefs"] as Map, nestedType), targets = (map["targets"] as List>).map { Target.from(map = it) }, accessedAt = map["accessedAt"] as String, + impersonator = map["impersonator"] as? Boolean, + impersonatorUserId = map["impersonatorUserId"] as? String, ) } } \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/Webhook.kt b/src/main/kotlin/io/appwrite/models/Webhook.kt new file mode 100644 index 0000000..23b1bf7 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/Webhook.kt @@ -0,0 +1,126 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Webhook + */ +data class Webhook( + /** + * Webhook ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Webhook creation date in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Webhook update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Webhook name. + */ + @SerializedName("name") + val name: String, + + /** + * Webhook URL endpoint. + */ + @SerializedName("url") + val url: String, + + /** + * Webhook trigger events. + */ + @SerializedName("events") + val events: List, + + /** + * Indicated if SSL / TLS Certificate verification is enabled. + */ + @SerializedName("security") + val security: Boolean, + + /** + * HTTP basic authentication username. + */ + @SerializedName("httpUser") + val httpUser: String, + + /** + * HTTP basic authentication password. + */ + @SerializedName("httpPass") + val httpPass: String, + + /** + * Signature key which can be used to validated incoming + */ + @SerializedName("signatureKey") + val signatureKey: String, + + /** + * Indicates if this webhook is enabled. + */ + @SerializedName("enabled") + val enabled: Boolean, + + /** + * Webhook error logs from the most recent failure. + */ + @SerializedName("logs") + val logs: String, + + /** + * Number of consecutive failed webhook attempts. + */ + @SerializedName("attempts") + val attempts: Long, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "name" to name as Any, + "url" to url as Any, + "events" to events as Any, + "security" to security as Any, + "httpUser" to httpUser as Any, + "httpPass" to httpPass as Any, + "signatureKey" to signatureKey as Any, + "enabled" to enabled as Any, + "logs" to logs as Any, + "attempts" to attempts as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Webhook( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + name = map["name"] as String, + url = map["url"] as String, + events = map["events"] as List, + security = map["security"] as Boolean, + httpUser = map["httpUser"] as String, + httpPass = map["httpPass"] as String, + signatureKey = map["signatureKey"] as String, + enabled = map["enabled"] as Boolean, + logs = map["logs"] as String, + attempts = (map["attempts"] as Number).toLong(), + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/WebhookList.kt b/src/main/kotlin/io/appwrite/models/WebhookList.kt new file mode 100644 index 0000000..887ad05 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/WebhookList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Webhooks List + */ +data class WebhookList( + /** + * Total number of webhooks that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of webhooks. + */ + @SerializedName("webhooks") + val webhooks: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "webhooks" to webhooks.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = WebhookList( + total = (map["total"] as Number).toLong(), + webhooks = (map["webhooks"] as List>).map { Webhook.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/services/Databases.kt b/src/main/kotlin/io/appwrite/services/Databases.kt index ef4f371..d483f23 100644 --- a/src/main/kotlin/io/appwrite/services/Databases.kt +++ b/src/main/kotlin/io/appwrite/services/Databases.kt @@ -3537,7 +3537,7 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, key: String, - type: io.appwrite.enums.IndexType, + type: io.appwrite.enums.DatabasesIndexType, attributes: List, orders: List? = null, lengths: List? = null, diff --git a/src/main/kotlin/io/appwrite/services/Functions.kt b/src/main/kotlin/io/appwrite/services/Functions.kt index 33bb88b..5019863 100644 --- a/src/main/kotlin/io/appwrite/services/Functions.kt +++ b/src/main/kotlin/io/appwrite/services/Functions.kt @@ -72,7 +72,9 @@ class Functions(client: Client) : Service(client) { * @param providerBranch Production branch for the repo linked to the function. * @param providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param providerRootDirectory Path to function code in the linked repo. - * @param specification Runtime specification for the function and builds. + * @param buildSpecification Build specification for the function deployments. + * @param runtimeSpecification Runtime specification for the function executions. + * @param deploymentRetention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @return [io.appwrite.models.Function] */ @JvmOverloads @@ -95,7 +97,9 @@ class Functions(client: Client) : Service(client) { providerBranch: String? = null, providerSilentMode: Boolean? = null, providerRootDirectory: String? = null, - specification: String? = null, + buildSpecification: String? = null, + runtimeSpecification: String? = null, + deploymentRetention: Long? = null, ): io.appwrite.models.Function { val apiPath = "/functions" @@ -117,7 +121,9 @@ class Functions(client: Client) : Service(client) { "providerBranch" to providerBranch, "providerSilentMode" to providerSilentMode, "providerRootDirectory" to providerRootDirectory, - "specification" to specification, + "buildSpecification" to buildSpecification, + "runtimeSpecification" to runtimeSpecification, + "deploymentRetention" to deploymentRetention, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -239,7 +245,9 @@ class Functions(client: Client) : Service(client) { * @param providerBranch Production branch for the repo linked to the function * @param providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param providerRootDirectory Path to function code in the linked repo. - * @param specification Runtime specification for the function and builds. + * @param buildSpecification Build specification for the function deployments. + * @param runtimeSpecification Runtime specification for the function executions. + * @param deploymentRetention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @return [io.appwrite.models.Function] */ @JvmOverloads @@ -262,7 +270,9 @@ class Functions(client: Client) : Service(client) { providerBranch: String? = null, providerSilentMode: Boolean? = null, providerRootDirectory: String? = null, - specification: String? = null, + buildSpecification: String? = null, + runtimeSpecification: String? = null, + deploymentRetention: Long? = null, ): io.appwrite.models.Function { val apiPath = "/functions/{functionId}" .replace("{functionId}", functionId) @@ -284,7 +294,9 @@ class Functions(client: Client) : Service(client) { "providerBranch" to providerBranch, "providerSilentMode" to providerSilentMode, "providerRootDirectory" to providerRootDirectory, - "specification" to specification, + "buildSpecification" to buildSpecification, + "runtimeSpecification" to runtimeSpecification, + "deploymentRetention" to deploymentRetention, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", diff --git a/src/main/kotlin/io/appwrite/services/Health.kt b/src/main/kotlin/io/appwrite/services/Health.kt index 53231f6..dfee698 100644 --- a/src/main/kotlin/io/appwrite/services/Health.kt +++ b/src/main/kotlin/io/appwrite/services/Health.kt @@ -245,68 +245,6 @@ class Health(client: Client) : Service(client) { ) } - /** - * Get billing project aggregation queue. - * - * @param threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - * @return [io.appwrite.models.HealthQueue] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueBillingProjectAggregation( - threshold: Long? = null, - ): io.appwrite.models.HealthQueue { - val apiPath = "/health/queue/billing-project-aggregation" - - val apiParams = mutableMapOf( - "threshold" to threshold, - ) - val apiHeaders = mutableMapOf( - ) - val converter: (Any) -> io.appwrite.models.HealthQueue = { - io.appwrite.models.HealthQueue.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.HealthQueue::class.java, - converter, - ) - } - - /** - * Get billing team aggregation queue. - * - * @param threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - * @return [io.appwrite.models.HealthQueue] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueBillingTeamAggregation( - threshold: Long? = null, - ): io.appwrite.models.HealthQueue { - val apiPath = "/health/queue/billing-team-aggregation" - - val apiParams = mutableMapOf( - "threshold" to threshold, - ) - val apiHeaders = mutableMapOf( - ) - val converter: (Any) -> io.appwrite.models.HealthQueue = { - io.appwrite.models.HealthQueue.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.HealthQueue::class.java, - converter, - ) - } - /** * Get the number of builds that are waiting to be processed in the Appwrite internal queue server. * @@ -338,37 +276,6 @@ class Health(client: Client) : Service(client) { ) } - /** - * Get the priority builds queue size. - * - * @param threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 500. - * @return [io.appwrite.models.HealthQueue] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueuePriorityBuilds( - threshold: Long? = null, - ): io.appwrite.models.HealthQueue { - val apiPath = "/health/queue/builds-priority" - - val apiParams = mutableMapOf( - "threshold" to threshold, - ) - val apiHeaders = mutableMapOf( - ) - val converter: (Any) -> io.appwrite.models.HealthQueue = { - io.appwrite.models.HealthQueue.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.HealthQueue::class.java, - converter, - ) - } - /** * Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. * @@ -655,37 +562,6 @@ class Health(client: Client) : Service(client) { ) } - /** - * Get region manager queue. - * - * @param threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - * @return [io.appwrite.models.HealthQueue] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueRegionManager( - threshold: Long? = null, - ): io.appwrite.models.HealthQueue { - val apiPath = "/health/queue/region-manager" - - val apiParams = mutableMapOf( - "threshold" to threshold, - ) - val apiHeaders = mutableMapOf( - ) - val converter: (Any) -> io.appwrite.models.HealthQueue = { - io.appwrite.models.HealthQueue.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.HealthQueue::class.java, - converter, - ) - } - /** * Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. * @@ -748,37 +624,6 @@ class Health(client: Client) : Service(client) { ) } - /** - * Get threats queue. - * - * @param threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - * @return [io.appwrite.models.HealthQueue] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueThreats( - threshold: Long? = null, - ): io.appwrite.models.HealthQueue { - val apiPath = "/health/queue/threats" - - val apiParams = mutableMapOf( - "threshold" to threshold, - ) - val apiHeaders = mutableMapOf( - ) - val converter: (Any) -> io.appwrite.models.HealthQueue = { - io.appwrite.models.HealthQueue.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.HealthQueue::class.java, - converter, - ) - } - /** * Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. * diff --git a/src/main/kotlin/io/appwrite/services/Project.kt b/src/main/kotlin/io/appwrite/services/Project.kt new file mode 100644 index 0000000..52c0b30 --- /dev/null +++ b/src/main/kotlin/io/appwrite/services/Project.kt @@ -0,0 +1,189 @@ +package io.appwrite.services + +import io.appwrite.Client +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * The Project service allows you to manage all the projects in your Appwrite server. +**/ +class Project(client: Client) : Service(client) { + + /** + * Get a list of all project environment variables. + * + * @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: key, resourceType, resourceId, secret + * @param total When set to false, the total count returned will be 0 and will not be calculated. + * @return [io.appwrite.models.VariableList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listVariables( + queries: List? = null, + total: Boolean? = null, + ): io.appwrite.models.VariableList { + val apiPath = "/project/variables" + + val apiParams = mutableMapOf( + "queries" to queries, + "total" to total, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.VariableList = { + io.appwrite.models.VariableList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.VariableList::class.java, + converter, + ) + } + + /** + * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. + * + * @param variableId Variable 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 key Variable key. Max length: 255 chars. + * @param value Variable value. Max length: 8192 chars. + * @param secret Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @return [io.appwrite.models.Variable] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createVariable( + variableId: String, + key: String, + value: String, + secret: Boolean? = null, + ): io.appwrite.models.Variable { + val apiPath = "/project/variables" + + val apiParams = mutableMapOf( + "variableId" to variableId, + "key" to key, + "value" to value, + "secret" to secret, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Variable = { + io.appwrite.models.Variable.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Variable::class.java, + converter, + ) + } + + /** + * Get a variable by its unique ID. + * + * @param variableId Variable ID. + * @return [io.appwrite.models.Variable] + */ + @Throws(AppwriteException::class) + suspend fun getVariable( + variableId: String, + ): io.appwrite.models.Variable { + val apiPath = "/project/variables/{variableId}" + .replace("{variableId}", variableId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Variable = { + io.appwrite.models.Variable.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Variable::class.java, + converter, + ) + } + + /** + * Update variable by its unique ID. + * + * @param variableId Variable ID. + * @param key Variable key. Max length: 255 chars. + * @param value Variable value. Max length: 8192 chars. + * @param secret Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @return [io.appwrite.models.Variable] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateVariable( + variableId: String, + key: String? = null, + value: String? = null, + secret: Boolean? = null, + ): io.appwrite.models.Variable { + val apiPath = "/project/variables/{variableId}" + .replace("{variableId}", variableId) + + val apiParams = mutableMapOf( + "key" to key, + "value" to value, + "secret" to secret, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Variable = { + io.appwrite.models.Variable.from(map = it as Map) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Variable::class.java, + converter, + ) + } + + /** + * Delete a variable by its unique ID. + * + * @param variableId Variable ID. + * @return [Any] + */ + @Throws(AppwriteException::class) + suspend fun deleteVariable( + variableId: String, + ): Any { + val apiPath = "/project/variables/{variableId}" + .replace("{variableId}", variableId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/services/Sites.kt b/src/main/kotlin/io/appwrite/services/Sites.kt index 2b638ea..e1823cc 100644 --- a/src/main/kotlin/io/appwrite/services/Sites.kt +++ b/src/main/kotlin/io/appwrite/services/Sites.kt @@ -64,6 +64,7 @@ class Sites(client: Client) : Service(client) { * @param timeout Maximum request time in seconds. * @param installCommand Install Command. * @param buildCommand Build Command. + * @param startCommand Custom start command. Leave empty to use default. * @param outputDirectory Output Directory for site. * @param adapter Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param installationId Appwrite Installation ID for VCS (Version Control System) deployment. @@ -72,7 +73,9 @@ class Sites(client: Client) : Service(client) { * @param providerBranch Production branch for the repo linked to the site. * @param providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param providerRootDirectory Path to site code in the linked repo. - * @param specification Framework specification for the site and builds. + * @param buildSpecification Build specification for the site deployments. + * @param runtimeSpecification Runtime specification for the SSR executions. + * @param deploymentRetention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @return [io.appwrite.models.Site] */ @JvmOverloads @@ -87,6 +90,7 @@ class Sites(client: Client) : Service(client) { timeout: Long? = null, installCommand: String? = null, buildCommand: String? = null, + startCommand: String? = null, outputDirectory: String? = null, adapter: io.appwrite.enums.Adapter? = null, installationId: String? = null, @@ -95,7 +99,9 @@ class Sites(client: Client) : Service(client) { providerBranch: String? = null, providerSilentMode: Boolean? = null, providerRootDirectory: String? = null, - specification: String? = null, + buildSpecification: String? = null, + runtimeSpecification: String? = null, + deploymentRetention: Long? = null, ): io.appwrite.models.Site { val apiPath = "/sites" @@ -108,6 +114,7 @@ class Sites(client: Client) : Service(client) { "timeout" to timeout, "installCommand" to installCommand, "buildCommand" to buildCommand, + "startCommand" to startCommand, "outputDirectory" to outputDirectory, "buildRuntime" to buildRuntime, "adapter" to adapter, @@ -117,7 +124,9 @@ class Sites(client: Client) : Service(client) { "providerBranch" to providerBranch, "providerSilentMode" to providerSilentMode, "providerRootDirectory" to providerRootDirectory, - "specification" to specification, + "buildSpecification" to buildSpecification, + "runtimeSpecification" to runtimeSpecification, + "deploymentRetention" to deploymentRetention, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -230,6 +239,7 @@ class Sites(client: Client) : Service(client) { * @param timeout Maximum request time in seconds. * @param installCommand Install Command. * @param buildCommand Build Command. + * @param startCommand Custom start command. Leave empty to use default. * @param outputDirectory Output Directory for site. * @param buildRuntime Runtime to use during build step. * @param adapter Framework adapter defining rendering strategy. Allowed values are: static, ssr @@ -239,7 +249,9 @@ class Sites(client: Client) : Service(client) { * @param providerBranch Production branch for the repo linked to the site. * @param providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param providerRootDirectory Path to site code in the linked repo. - * @param specification Framework specification for the site and builds. + * @param buildSpecification Build specification for the site deployments. + * @param runtimeSpecification Runtime specification for the SSR executions. + * @param deploymentRetention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @return [io.appwrite.models.Site] */ @JvmOverloads @@ -253,6 +265,7 @@ class Sites(client: Client) : Service(client) { timeout: Long? = null, installCommand: String? = null, buildCommand: String? = null, + startCommand: String? = null, outputDirectory: String? = null, buildRuntime: io.appwrite.enums.BuildRuntime? = null, adapter: io.appwrite.enums.Adapter? = null, @@ -262,7 +275,9 @@ class Sites(client: Client) : Service(client) { providerBranch: String? = null, providerSilentMode: Boolean? = null, providerRootDirectory: String? = null, - specification: String? = null, + buildSpecification: String? = null, + runtimeSpecification: String? = null, + deploymentRetention: Long? = null, ): io.appwrite.models.Site { val apiPath = "/sites/{siteId}" .replace("{siteId}", siteId) @@ -275,6 +290,7 @@ class Sites(client: Client) : Service(client) { "timeout" to timeout, "installCommand" to installCommand, "buildCommand" to buildCommand, + "startCommand" to startCommand, "outputDirectory" to outputDirectory, "buildRuntime" to buildRuntime, "adapter" to adapter, @@ -284,7 +300,9 @@ class Sites(client: Client) : Service(client) { "providerBranch" to providerBranch, "providerSilentMode" to providerSilentMode, "providerRootDirectory" to providerRootDirectory, - "specification" to specification, + "buildSpecification" to buildSpecification, + "runtimeSpecification" to runtimeSpecification, + "deploymentRetention" to deploymentRetention, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", diff --git a/src/main/kotlin/io/appwrite/services/TablesDB.kt b/src/main/kotlin/io/appwrite/services/TablesDB.kt index 83287e4..e100d06 100644 --- a/src/main/kotlin/io/appwrite/services/TablesDB.kt +++ b/src/main/kotlin/io/appwrite/services/TablesDB.kt @@ -2429,7 +2429,7 @@ class TablesDB(client: Client) : Service(client) { databaseId: String, tableId: String, key: String, - type: io.appwrite.enums.IndexType, + type: io.appwrite.enums.TablesDBIndexType, columns: List, orders: List? = null, lengths: List? = null, diff --git a/src/main/kotlin/io/appwrite/services/Users.kt b/src/main/kotlin/io/appwrite/services/Users.kt index 748a0ad..5c7ef35 100644 --- a/src/main/kotlin/io/appwrite/services/Users.kt +++ b/src/main/kotlin/io/appwrite/services/Users.kt @@ -16,7 +16,7 @@ class Users(client: Client) : Service(client) { /** * 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/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, labels + * @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, labels, impersonator * @param search Search term to filter your list results. Max length: 256 chars. * @param total When set to false, the total count returned will be 0 and will not be calculated. * @return [io.appwrite.models.UserList] @@ -54,7 +54,7 @@ class Users(client: Client) : Service(client) { /** * 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/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, labels + * @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, labels, impersonator * @param search Search term to filter your list results. Max length: 256 chars. * @param total When set to false, the total count returned will be 0 and will not be calculated. * @return [io.appwrite.models.UserList] @@ -848,6 +848,60 @@ class Users(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. + * + * + * @param userId User ID. + * @param impersonator Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun updateImpersonator( + userId: String, + impersonator: Boolean, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/users/{userId}/impersonator" + .replace("{userId}", userId) + + val apiParams = mutableMapOf( + "impersonator" to impersonator, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. + * + * + * @param userId User ID. + * @param impersonator Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun updateImpersonator( + userId: String, + impersonator: Boolean, + ): io.appwrite.models.User> = updateImpersonator( + userId, + impersonator, + nestedType = classOf(), + ) + /** * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. * diff --git a/src/main/kotlin/io/appwrite/services/Webhooks.kt b/src/main/kotlin/io/appwrite/services/Webhooks.kt new file mode 100644 index 0000000..846a401 --- /dev/null +++ b/src/main/kotlin/io/appwrite/services/Webhooks.kt @@ -0,0 +1,244 @@ +package io.appwrite.services + +import io.appwrite.Client +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * +**/ +class Webhooks(client: Client) : Service(client) { + + /** + * Get a list of all webhooks belonging to the project. 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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, httpUser, security, events, enabled, logs, attempts + * @param total When set to false, the total count returned will be 0 and will not be calculated. + * @return [io.appwrite.models.WebhookList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun list( + queries: List? = null, + total: Boolean? = null, + ): io.appwrite.models.WebhookList { + val apiPath = "/webhooks" + + val apiParams = mutableMapOf( + "queries" to queries, + "total" to total, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.WebhookList = { + io.appwrite.models.WebhookList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.WebhookList::class.java, + converter, + ) + } + + /** + * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. + * + * @param webhookId Webhook 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 url Webhook URL. + * @param name Webhook name. Max length: 128 chars. + * @param events Events list. Maximum of 100 events are allowed. + * @param enabled Enable or disable a webhook. + * @param security Certificate verification, false for disabled or true for enabled. + * @param httpUser Webhook HTTP user. Max length: 256 chars. + * @param httpPass Webhook HTTP password. Max length: 256 chars. + * @return [io.appwrite.models.Webhook] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun create( + webhookId: String, + url: String, + name: String, + events: List, + enabled: Boolean? = null, + security: Boolean? = null, + httpUser: String? = null, + httpPass: String? = null, + ): io.appwrite.models.Webhook { + val apiPath = "/webhooks" + + val apiParams = mutableMapOf( + "webhookId" to webhookId, + "url" to url, + "name" to name, + "events" to events, + "enabled" to enabled, + "security" to security, + "httpUser" to httpUser, + "httpPass" to httpPass, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Webhook = { + io.appwrite.models.Webhook.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Webhook::class.java, + converter, + ) + } + + /** + * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + * + * @param webhookId Webhook ID. + * @return [io.appwrite.models.Webhook] + */ + @Throws(AppwriteException::class) + suspend fun get( + webhookId: String, + ): io.appwrite.models.Webhook { + val apiPath = "/webhooks/{webhookId}" + .replace("{webhookId}", webhookId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Webhook = { + io.appwrite.models.Webhook.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Webhook::class.java, + converter, + ) + } + + /** + * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. + * + * @param webhookId Webhook ID. + * @param name Webhook name. Max length: 128 chars. + * @param url Webhook URL. + * @param events Events list. Maximum of 100 events are allowed. + * @param enabled Enable or disable a webhook. + * @param security Certificate verification, false for disabled or true for enabled. + * @param httpUser Webhook HTTP user. Max length: 256 chars. + * @param httpPass Webhook HTTP password. Max length: 256 chars. + * @return [io.appwrite.models.Webhook] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun update( + webhookId: String, + name: String, + url: String, + events: List, + enabled: Boolean? = null, + security: Boolean? = null, + httpUser: String? = null, + httpPass: String? = null, + ): io.appwrite.models.Webhook { + val apiPath = "/webhooks/{webhookId}" + .replace("{webhookId}", webhookId) + + val apiParams = mutableMapOf( + "name" to name, + "url" to url, + "events" to events, + "enabled" to enabled, + "security" to security, + "httpUser" to httpUser, + "httpPass" to httpPass, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Webhook = { + io.appwrite.models.Webhook.from(map = it as Map) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Webhook::class.java, + converter, + ) + } + + /** + * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + * + * @param webhookId Webhook ID. + * @return [Any] + */ + @Throws(AppwriteException::class) + suspend fun delete( + webhookId: String, + ): Any { + val apiPath = "/webhooks/{webhookId}" + .replace("{webhookId}", webhookId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + /** + * Update the webhook signature key. This endpoint can be used to regenerate the signature key used to sign and validate payload deliveries for a specific webhook. + * + * @param webhookId Webhook ID. + * @return [io.appwrite.models.Webhook] + */ + @Throws(AppwriteException::class) + suspend fun updateSignature( + webhookId: String, + ): io.appwrite.models.Webhook { + val apiPath = "/webhooks/{webhookId}/signature" + .replace("{webhookId}", webhookId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Webhook = { + io.appwrite.models.Webhook.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Webhook::class.java, + converter, + ) + } + +} \ No newline at end of file