Update for 1.0.0

This commit is contained in:
Jake Barnby
2022-09-14 22:47:26 +12:00
parent 5764714cd1
commit c8c24fa74c
40 changed files with 692 additions and 84 deletions
+13 -15
View File
@@ -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.0.0-RC1-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.0.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.0.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-kotlin/releases).**
**This SDK is compatible with Appwrite server version 1.0.0. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-kotlin/releases).**
> This is the Kotlin SDK for integrating with Appwrite from your Kotlin server-side code. If you're looking for the Android SDK you should check [appwrite/sdk-for-android](https://github.com/appwrite/sdk-for-android)
@@ -39,7 +39,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:
```groovy
implementation("io.appwrite:sdk-for-kotlin:1.0.0-SNAPSHOT")
implementation("io.appwrite:sdk-for-kotlin:1.0.0")
```
### Maven
@@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-kotlin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
</dependency>
</dependencies>
```
@@ -81,12 +81,11 @@ Once your SDK object is set, create any of the Appwrite service objects and choo
```kotlin
val users = Users(client)
val response = users.create(
user = "[USER_ID]",
val user = users.create(
user = ID.unique(),
email = "email@example.com",
password = "password",
)
val json = response.body?.string()
```
### Full Example
@@ -94,6 +93,7 @@ val json = response.body?.string()
```kotlin
import io.appwrite.Client
import io.appwrite.services.Users
import io.appwrite.ID
suspend fun main() {
val client = Client(context)
@@ -103,12 +103,11 @@ suspend fun main() {
.setSelfSigned(true) // Use only on dev mode with a self-signed SSL cert
val users = Users(client)
val response = users.create(
user = "[USER_ID]",
val user = users.create(
user = ID.unique(),
email = "email@example.com",
password = "password",
)
val json = response.body?.string()
}
```
@@ -118,20 +117,19 @@ The Appwrite Kotlin SDK raises `AppwriteException` object with `message`, `code`
```kotlin
import io.appwrite.Client
import io.appwrite.ID
import io.appwrite.services.Users
suspend fun main() {
val users = Users(client)
try {
val response = users.create(
user = "[USER_ID]",
val user = users.create(
user = ID.unique(),
email = "email@example.com",
password = "password",
)
var jsonString = response.body?.string() ?: ""
} catch (e: AppwriteException) {
println(e)
e.printStackTrace()
}
}
```
+35
View File
@@ -0,0 +1,35 @@
import io.appwrite.Client
import io.appwrite.services.Account
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token
Account account = new Account(client);
account.listLogs(
new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
}
@@ -0,0 +1,33 @@
import io.appwrite.Client
import io.appwrite.services.Account
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token
Account account = new Account(client);
account.listSessions(new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
});
}
@@ -9,7 +9,7 @@ public void main() {
Functions functions = new Functions(client);
functions.listVariables(
functionId = "[FUNCTION_ID]",
functionId = "[FUNCTION_ID]"
new Continuation<Response>() {
@NotNull
@Override
@@ -0,0 +1,33 @@
import io.appwrite.Client
import io.appwrite.services.Locale
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Locale locale = new Locale(client);
locale.listContinents(new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
});
}
@@ -0,0 +1,33 @@
import io.appwrite.Client
import io.appwrite.services.Locale
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Locale locale = new Locale(client);
locale.listCountriesEU(new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
});
}
@@ -0,0 +1,33 @@
import io.appwrite.Client
import io.appwrite.services.Locale
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Locale locale = new Locale(client);
locale.listCountriesPhones(new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
});
}
@@ -0,0 +1,33 @@
import io.appwrite.Client
import io.appwrite.services.Locale
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Locale locale = new Locale(client);
locale.listCountries(new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
});
}
@@ -0,0 +1,33 @@
import io.appwrite.Client
import io.appwrite.services.Locale
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Locale locale = new Locale(client);
locale.listCurrencies(new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
});
}
@@ -0,0 +1,33 @@
import io.appwrite.Client
import io.appwrite.services.Locale
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Locale locale = new Locale(client);
locale.listLanguages(new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
});
}
@@ -0,0 +1,36 @@
import io.appwrite.Client
import io.appwrite.services.Teams
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Teams teams = new Teams(client);
teams.listMemberships(
teamId = "[TEAM_ID]",
new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
}
+36
View File
@@ -0,0 +1,36 @@
import io.appwrite.Client
import io.appwrite.services.Users
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Users users = new Users(client);
users.listLogs(
userId = "[USER_ID]",
new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
}
@@ -0,0 +1,36 @@
import io.appwrite.Client
import io.appwrite.services.Users
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Users users = new Users(client);
users.listMemberships(
userId = "[USER_ID]"
new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
}
+36
View File
@@ -0,0 +1,36 @@
import io.appwrite.Client
import io.appwrite.services.Users
public void main() {
Client client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
Users users = new Users(client);
users.listSessions(
userId = "[USER_ID]"
new Continuation<Response>() {
@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;
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
}
+14
View File
@@ -0,0 +1,14 @@
import io.appwrite.Client
import io.appwrite.services.Account
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
val account = Account(client)
val response = account.listLogs(
)
val json = response.body?.string()
}
@@ -0,0 +1,13 @@
import io.appwrite.Client
import io.appwrite.services.Account
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
val account = Account(client)
val response = account.listSessions()
val json = response.body?.string()
}
@@ -9,7 +9,7 @@ suspend fun main() {
val functions = Functions(client)
val response = functions.listVariables(
functionId = "[FUNCTION_ID]",
functionId = "[FUNCTION_ID]"
)
val json = response.body?.string()
}
@@ -0,0 +1,13 @@
import io.appwrite.Client
import io.appwrite.services.Locale
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val locale = Locale(client)
val response = locale.listContinents()
val json = response.body?.string()
}
@@ -0,0 +1,13 @@
import io.appwrite.Client
import io.appwrite.services.Locale
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val locale = Locale(client)
val response = locale.listCountriesEU()
val json = response.body?.string()
}
@@ -0,0 +1,13 @@
import io.appwrite.Client
import io.appwrite.services.Locale
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val locale = Locale(client)
val response = locale.listCountriesPhones()
val json = response.body?.string()
}
@@ -0,0 +1,13 @@
import io.appwrite.Client
import io.appwrite.services.Locale
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val locale = Locale(client)
val response = locale.listCountries()
val json = response.body?.string()
}
@@ -0,0 +1,13 @@
import io.appwrite.Client
import io.appwrite.services.Locale
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val locale = Locale(client)
val response = locale.listCurrencies()
val json = response.body?.string()
}
@@ -0,0 +1,13 @@
import io.appwrite.Client
import io.appwrite.services.Locale
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val locale = Locale(client)
val response = locale.listLanguages()
val json = response.body?.string()
}
@@ -0,0 +1,15 @@
import io.appwrite.Client
import io.appwrite.services.Teams
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val teams = Teams(client)
val response = teams.listMemberships(
teamId = "[TEAM_ID]",
)
val json = response.body?.string()
}
+15
View File
@@ -0,0 +1,15 @@
import io.appwrite.Client
import io.appwrite.services.Users
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val users = Users(client)
val response = users.listLogs(
userId = "[USER_ID]",
)
val json = response.body?.string()
}
@@ -0,0 +1,15 @@
import io.appwrite.Client
import io.appwrite.services.Users
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val users = Users(client)
val response = users.listMemberships(
userId = "[USER_ID]"
)
val json = response.body?.string()
}
@@ -0,0 +1,15 @@
import io.appwrite.Client
import io.appwrite.services.Users
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
val users = Users(client)
val response = users.listSessions(
userId = "[USER_ID]"
)
val json = response.body?.string()
}
Vendored Regular → Executable
View File
+2 -2
View File
@@ -65,8 +65,8 @@ class Client @JvmOverloads constructor(
"x-sdk-name" to "Kotlin",
"x-sdk-platform" to "server",
"x-sdk-language" to "kotlin",
"x-sdk-version" to "1.0.0-SNAPSHOT",
"x-appwrite-response-format" to "1.0.0-RC1"
"x-sdk-version" to "1.0.0",
"x-appwrite-response-format" to "1.0.0"
)
config = mutableMapOf()
+25 -16
View File
@@ -2,21 +2,30 @@ package io.appwrite
class Role {
companion object {
fun any(): String
= "any"
fun user(id: String): String
= "user:$id"
fun users(): String
= "users"
fun guests(): String
= "guests"
fun team(id: String, role: String = ""): String
= if(role.isEmpty()) {
"team:$id"
} else {
"team:$id/$role"
}
fun status(status: String): String
= "status:$status"
fun any(): String = "any"
fun user(id: String, status: String = ""): String = if(status.isEmpty()) {
"user:$id"
} else {
"user:$id/$status"
}
fun users(status: String = ""): String = if(status.isEmpty()) {
"users"
} else {
"users/$status"
}
fun guests(): String = "guests"
fun team(id: String, role: String = ""): String = if(role.isEmpty()) {
"team:$id"
} else {
"team:$id/$role"
}
fun member(id: String): String = "member:$id"
fun status(status: String): String = "status:$status"
}
}
+2 -2
View File
@@ -39,7 +39,7 @@ data class Bucket(
*
*/
@SerializedName("fileSecurity")
val fileSecurity: String,
val fileSecurity: Boolean,
/**
* Bucket name.
@@ -97,7 +97,7 @@ data class Bucket(
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
permissions = map["\$permissions"] as List<Any>,
fileSecurity = map["fileSecurity"] as String,
fileSecurity = map["fileSecurity"] as Boolean,
name = map["name"] as String,
enabled = map["enabled"] as Boolean,
maximumFileSize = (map["maximumFileSize"] as Number).toLong(),
+13 -4
View File
@@ -17,8 +17,15 @@ data class Document(
* Collection ID.
*
*/
@SerializedName("\$collection")
val collection: String,
@SerializedName("\$collectionId")
val collectionId: String,
/**
* Database ID.
*
*/
@SerializedName("\$databaseId")
val databaseId: String,
/**
* Document creation date in ISO 8601 format.
@@ -47,7 +54,8 @@ data class Document(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Document(
id = map["\$id"] as String,
collection = map["\$collection"] as String,
collectionId = map["\$collectionId"] as String,
databaseId = map["\$databaseId"] as String,
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
permissions = map["\$permissions"] as List<Any>,
@@ -57,7 +65,8 @@ data class Document(
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"\$collection" to collection as Any,
"\$collectionId" to collectionId as Any,
"\$databaseId" to databaseId as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"\$permissions" to permissions as Any,
@@ -84,11 +84,11 @@ data class Execution(
val stderr: String,
/**
* The script execution time in seconds.
* The script execution duration in seconds.
*
*/
@SerializedName("time")
val time: Double
@SerializedName("duration")
val duration: Double
) {
companion object {
@Suppress("UNCHECKED_CAST")
@@ -104,7 +104,7 @@ data class Execution(
response = map["response"] as String,
stdout = map["stdout"] as String,
stderr = map["stderr"] as String,
time = (map["time"] as Number).toDouble()
duration = (map["duration"] as Number).toDouble()
)
}
@@ -120,6 +120,6 @@ data class Execution(
"response" to response as Any,
"stdout" to stdout as Any,
"stderr" to stderr as Any,
"time" to time as Any
"duration" to duration as Any
)
}
@@ -42,11 +42,11 @@ data class Function(
val name: String,
/**
* Function status. Possible values: `disabled`, `enabled`
* Function enabled.
*
*/
@SerializedName("status")
val status: String,
@SerializedName("enabled")
val enabled: Boolean,
/**
* Function execution runtime.
@@ -112,7 +112,7 @@ data class Function(
updatedAt = map["\$updatedAt"] as String,
execute = map["execute"] as List<Any>,
name = map["name"] as String,
status = map["status"] as String,
enabled = map["enabled"] as Boolean,
runtime = map["runtime"] as String,
deployment = map["deployment"] as String,
vars = (map["vars"] as List<Map<String, Any>>).map { Variable.from(map = it) },
@@ -130,7 +130,7 @@ data class Function(
"\$updatedAt" to updatedAt as Any,
"execute" to execute as Any,
"name" to name as Any,
"status" to status as Any,
"enabled" to enabled as Any,
"runtime" to runtime as Any,
"deployment" to deployment as Any,
"vars" to vars.map { it.toMap() } as Any,
@@ -5,4 +5,21 @@ import com.google.gson.annotations.SerializedName
/**
* Preferences
*/
class Preferences {}
data class Preferences(
val data: Map<String, Any>
) {
companion object {
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Preferences(
data = map
)
}
fun toMap(): Map<String, Any> = mapOf(
"data" to data
)
fun <T> convertTo(fromJson: (Map<String, Any>) -> T): T {
return fromJson(data)
}
}
@@ -83,7 +83,7 @@ class Account : Service {
}
/**
* Get Account Logs
* List Account Logs
*
* Get currently logged in user list of latest security activity logs. Each
* log returns user IP address, location and date and time of log.
@@ -93,7 +93,7 @@ class Account : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getLogs(
suspend fun listLogs(
queries: List<String>? = null
): io.appwrite.models.LogList {
val path = "/account/logs"
@@ -385,7 +385,7 @@ class Account : Service {
}
/**
* Get Account Sessions
* List Account Sessions
*
* Get currently logged in user list of active sessions across different
* devices.
@@ -394,7 +394,7 @@ class Account : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getSessions(): io.appwrite.models.SessionList {
suspend fun listSessions(): io.appwrite.models.SessionList {
val path = "/account/sessions"
val params = mutableMapOf<String, Any?>(
)
@@ -16,7 +16,7 @@ class Functions : Service {
* Get a list of all the project's functions. You can use the query params to
* filter your results.
*
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, status, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout
* @param search Search term to filter your list results. Max length: 256 chars.
* @return [io.appwrite.models.FunctionList]
*/
@@ -61,6 +61,7 @@ class Functions : Service {
* @param events Events list. Maximum of 100 events are allowed.
* @param schedule Schedule CRON syntax.
* @param timeout Function maximum execution time in seconds.
* @param enabled Is function enabled?
* @return [io.appwrite.models.Function]
*/
@JvmOverloads
@@ -72,7 +73,8 @@ class Functions : Service {
runtime: String,
events: List<String>? = null,
schedule: String? = null,
timeout: Long? = null
timeout: Long? = null,
enabled: Boolean? = null
): io.appwrite.models.Function {
val path = "/functions"
val params = mutableMapOf<String, Any?>(
@@ -82,7 +84,8 @@ class Functions : Service {
"runtime" to runtime,
"events" to events,
"schedule" to schedule,
"timeout" to timeout
"timeout" to timeout,
"enabled" to enabled
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -172,6 +175,7 @@ class Functions : Service {
* @param events Events list. Maximum of 100 events are allowed.
* @param schedule Schedule CRON syntax.
* @param timeout Maximum execution time in seconds.
* @param enabled Is function enabled?
* @return [io.appwrite.models.Function]
*/
@JvmOverloads
@@ -182,7 +186,8 @@ class Functions : Service {
execute: List<String>,
events: List<String>? = null,
schedule: String? = null,
timeout: Long? = null
timeout: Long? = null,
enabled: Boolean? = null
): io.appwrite.models.Function {
val path = "/functions/{functionId}".replace("{functionId}", functionId)
val params = mutableMapOf<String, Any?>(
@@ -190,7 +195,8 @@ class Functions : Service {
"execute" to execute,
"events" to events,
"schedule" to schedule,
"timeout" to timeout
"timeout" to timeout,
"enabled" to enabled
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -468,7 +474,7 @@ class Functions : Service {
* different API modes](/docs/admin).
*
* @param functionId Function ID.
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, statusCode, time
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, statusCode, duration
* @param search Search term to filter your list results. Max length: 256 chars.
* @return [io.appwrite.models.ExecutionList]
*/
@@ -510,7 +516,7 @@ class Functions : Service {
*
* @param functionId Function ID.
* @param data String of custom data to send to function.
* @param async Execute code asynchronously. Default value is true.
* @param async Execute code in the background. Default value is false.
* @return [io.appwrite.models.Execution]
*/
@JvmOverloads
@@ -581,21 +587,15 @@ class Functions : Service {
* Get a list of all variables of a specific function.
*
* @param functionId Function unique ID.
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key
* @param search Search term to filter your list results. Max length: 256 chars.
* @return [io.appwrite.models.VariableList]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun listVariables(
functionId: String,
queries: List<String>? = null,
search: String? = null
functionId: String
): io.appwrite.models.VariableList {
val path = "/functions/{functionId}/variables".replace("{functionId}", functionId)
val params = mutableMapOf<String, Any?>(
"queries" to queries,
"search" to search
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -54,7 +54,7 @@ class Locale : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getContinents(): io.appwrite.models.ContinentList {
suspend fun listContinents(): io.appwrite.models.ContinentList {
val path = "/locale/continents"
val params = mutableMapOf<String, Any?>(
)
@@ -84,7 +84,7 @@ class Locale : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getCountries(): io.appwrite.models.CountryList {
suspend fun listCountries(): io.appwrite.models.CountryList {
val path = "/locale/countries"
val params = mutableMapOf<String, Any?>(
)
@@ -114,7 +114,7 @@ class Locale : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getCountriesEU(): io.appwrite.models.CountryList {
suspend fun listCountriesEU(): io.appwrite.models.CountryList {
val path = "/locale/countries/eu"
val params = mutableMapOf<String, Any?>(
)
@@ -144,7 +144,7 @@ class Locale : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getCountriesPhones(): io.appwrite.models.PhoneList {
suspend fun listCountriesPhones(): io.appwrite.models.PhoneList {
val path = "/locale/countries/phones"
val params = mutableMapOf<String, Any?>(
)
@@ -175,7 +175,7 @@ class Locale : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getCurrencies(): io.appwrite.models.CurrencyList {
suspend fun listCurrencies(): io.appwrite.models.CurrencyList {
val path = "/locale/currencies"
val params = mutableMapOf<String, Any?>(
)
@@ -205,7 +205,7 @@ class Locale : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getLanguages(): io.appwrite.models.LanguageList {
suspend fun listLanguages(): io.appwrite.models.LanguageList {
val path = "/locale/languages"
val params = mutableMapOf<String, Any?>(
)
@@ -189,7 +189,7 @@ class Teams : Service {
}
/**
* Get Team Memberships
* List Team Memberships
*
* Use this endpoint to list a team's members using the team's ID. All team
* members have read access to this endpoint.
@@ -201,7 +201,7 @@ class Teams : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getMemberships(
suspend fun listMemberships(
teamId: String,
queries: List<String>? = null,
search: String? = null
@@ -534,7 +534,7 @@ class Users : Service {
}
/**
* Get User Logs
* List User Logs
*
* Get the user activity logs list by its unique ID.
*
@@ -544,7 +544,7 @@ class Users : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getLogs(
suspend fun listLogs(
userId: String,
queries: List<String>? = null
): io.appwrite.models.LogList {
@@ -569,7 +569,7 @@ class Users : Service {
}
/**
* Get User Memberships
* List User Memberships
*
* Get the user membership list by its unique ID.
*
@@ -578,7 +578,7 @@ class Users : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getMemberships(
suspend fun listMemberships(
userId: String
): io.appwrite.models.MembershipList {
val path = "/users/{userId}/memberships".replace("{userId}", userId)
@@ -775,7 +775,7 @@ class Users : Service {
}
/**
* Get User Sessions
* List User Sessions
*
* Get the user sessions list by its unique ID.
*
@@ -784,7 +784,7 @@ class Users : Service {
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getSessions(
suspend fun listSessions(
userId: String
): io.appwrite.models.SessionList {
val path = "/users/{userId}/sessions".replace("{userId}", userId)