Merge pull request #24 from appwrite/dev

update to support 1.0.0-RC1
This commit is contained in:
Christy Jacob
2022-09-05 21:30:48 +04:00
committed by GitHub
37 changed files with 351 additions and 340 deletions
+1 -1
View File
@@ -51,4 +51,4 @@ jobs:
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SDK_VERSION: ${{ github.event.release.tag_name }}
SDK_VERSION: ${{ github.event.release.tag_name }}
+1 -1
View File
@@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification,
3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+4 -4
View File
@@ -2,12 +2,12 @@
![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.15.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![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 0.15.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).**
**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-android/releases).**
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
@@ -38,7 +38,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:
```groovy
implementation("io.appwrite:sdk-for-android:0.7.0")
implementation("io.appwrite:sdk-for-android:1.0.0-SNAPSHOT")
```
### Maven
@@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-android</artifactId>
<version>0.7.0</version>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
```
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Databases databases = new Databases(client, "[DATABASE_ID]");
Databases databases = new Databases(client);
databases.createDocument(
"[DATABASE_ID]",
"[COLLECTION_ID]",
"[DOCUMENT_ID]",
mapOf( "a" to "b" ),
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Databases databases = new Databases(client, "[DATABASE_ID]");
Databases databases = new Databases(client);
databases.deleteDocument(
"[DATABASE_ID]",
"[COLLECTION_ID]",
"[DOCUMENT_ID]"
new Continuation<Object>() {
+2 -1
View File
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Databases databases = new Databases(client, "[DATABASE_ID]");
Databases databases = new Databases(client);
databases.getDocument(
"[DATABASE_ID]",
"[COLLECTION_ID]",
"[DOCUMENT_ID]"
new Continuation<Object>() {
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Databases databases = new Databases(client, "[DATABASE_ID]");
Databases databases = new Databases(client);
databases.listDocuments(
"[DATABASE_ID]",
"[COLLECTION_ID]",
new Continuation<Object>() {
@NotNull
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Databases databases = new Databases(client, "[DATABASE_ID]");
Databases databases = new Databases(client);
databases.updateDocument(
"[DATABASE_ID]",
"[COLLECTION_ID]",
"[DOCUMENT_ID]",
new Continuation<Object>() {
@@ -3,6 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.models.InputFile
import io.appwrite.services.Storage
public class MainActivity extends AppCompatActivity {
@@ -19,7 +19,7 @@ class MainActivity : AppCompatActivity() {
GlobalScope.launch {
val response = account.createPhoneSession(
userId = "[USER_ID]",
number = ""
phone = ""
)
val json = response.body?.string()
}
+1 -1
View File
@@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() {
GlobalScope.launch {
val response = account.updatePhone(
number = "",
phone = "",
password = "password"
)
val json = response.body?.string()
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val databases = Databases(client, "[DATABASE_ID]")
val databases = Databases(client)
GlobalScope.launch {
val response = databases.createDocument(
databaseId = "[DATABASE_ID]",
collectionId = "[COLLECTION_ID]",
documentId = "[DOCUMENT_ID]",
data = mapOf( "a" to "b" ),
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val databases = Databases(client, "[DATABASE_ID]")
val databases = Databases(client)
GlobalScope.launch {
val response = databases.deleteDocument(
databaseId = "[DATABASE_ID]",
collectionId = "[COLLECTION_ID]",
documentId = "[DOCUMENT_ID]"
)
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val databases = Databases(client, "[DATABASE_ID]")
val databases = Databases(client)
GlobalScope.launch {
val response = databases.getDocument(
databaseId = "[DATABASE_ID]",
collectionId = "[COLLECTION_ID]",
documentId = "[DOCUMENT_ID]"
)
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val databases = Databases(client, "[DATABASE_ID]")
val databases = Databases(client)
GlobalScope.launch {
val response = databases.listDocuments(
databaseId = "[DATABASE_ID]",
collectionId = "[COLLECTION_ID]",
)
val json = response.body?.string()
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val databases = Databases(client, "[DATABASE_ID]")
val databases = Databases(client)
GlobalScope.launch {
val response = databases.updateDocument(
databaseId = "[DATABASE_ID]",
collectionId = "[COLLECTION_ID]",
documentId = "[DOCUMENT_ID]",
)
@@ -3,6 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.models.InputFile
import io.appwrite.services.Storage
class MainActivity : AppCompatActivity() {
+6 -3
View File
@@ -40,7 +40,7 @@ import kotlin.coroutines.resume
class Client @JvmOverloads constructor(
context: Context,
var endPoint: String = "https://appwrite.io/v1",
var endPoint: String = "https://HOSTNAME/v1",
var endPointRealtime: String? = null,
private var selfSigned: Boolean = false
) : CoroutineScope {
@@ -85,8 +85,11 @@ class Client @JvmOverloads constructor(
"content-type" to "application/json",
"origin" to "appwrite-android://${context.packageName}",
"user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}",
"x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}",
"x-appwrite-response-format" to "0.15.0"
"x-sdk-name" to "Android",
"x-sdk-platform" to "client",
"x-sdk-language" to "android",
"x-sdk-version" to "1.0.0-SNAPSHOT",
"x-appwrite-response-format" to "1.0.0-RC1"
)
config = mutableMapOf()
+10
View File
@@ -0,0 +1,10 @@
package io.appwrite
class ID {
companion object {
fun custom(id: String): String
= id
fun unique(): String
= "unique()"
}
}
@@ -0,0 +1,21 @@
package io.appwrite
class Permission {
companion object {
fun read(role: String): String {
return "read(\"${role}\")"
}
fun write(role: String): String {
return "write(\"${role}\")"
}
fun create(role: String): String {
return "create(\"${role}\")"
}
fun update(role: String): String {
return "update(\"${role}\")"
}
fun delete(role: String): String {
return "delete(\"${role}\")"
}
}
}
+19 -7
View File
@@ -6,20 +6,32 @@ class Query {
fun notEqual(attribute: String, value: Any) = Query.addQuery(attribute, "notEqual", value)
fun lesser(attribute: String, value: Any) = Query.addQuery(attribute, "lesser", value)
fun lessThan(attribute: String, value: Any) = Query.addQuery(attribute, "lessThan", value)
fun lesserEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lesserEqual", value)
fun lessThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lessThanEqual", value)
fun greater(attribute: String, value: Any) = Query.addQuery(attribute, "greater", value)
fun greaterThan(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThan", value)
fun greaterEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterEqual", value)
fun greaterThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThanEqual", value)
fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value)
private fun addQuery(attribute: String, oper: String, value: Any): String {
fun orderAsc(attribute: String) = "orderAsc(\"${attribute}\")"
fun orderDesc(attribute: String) = "orderDesc(\"${attribute}\")"
fun cursorBefore(documentId: String) = "cursorBefore(\"${documentId}\")"
fun cursorAfter(documentId: String) = "cursorAfter(\"${documentId}\")"
fun limit(limit: Int) = "limit(${limit})"
fun offset(offset: Int) = "offset(${offset})"
private fun addQuery(attribute: String, method: String, value: Any): String {
return when (value) {
is List<*> -> "${attribute}.${oper}(${value.map{it -> parseValues(it!!)}.joinToString(",")})"
else -> "${attribute}.${oper}(${Query.parseValues(value)})"
is List<*> -> "${method}(\"${attribute}\", [${value.map{it -> parseValues(it!!)}.joinToString(",")}])"
else -> "${method}(\"${attribute}\", [${Query.parseValues(value)}])"
}
}
private fun parseValues(value: Any): String {
+22
View File
@@ -0,0 +1,22 @@
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"
}
}
@@ -3,9 +3,9 @@ package io.appwrite.models
import com.google.gson.annotations.SerializedName
/**
* User
* Account
*/
data class User(
data class Account(
/**
* User ID.
*
@@ -14,18 +14,18 @@ data class User(
val id: String,
/**
* User creation date in Unix timestamp.
* User creation date in ISO 8601 format.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
val createdAt: String,
/**
* User update date in Unix timestamp.
* User update date in ISO 8601 format.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
val updatedAt: String,
/**
* User name.
@@ -35,11 +35,11 @@ data class User(
val name: String,
/**
* User registration date in Unix timestamp.
* User registration date in ISO 8601 format.
*
*/
@SerializedName("registration")
val registration: Long,
val registration: String,
/**
* User status. Pass `true` for enabled and `false` for disabled.
@@ -49,11 +49,11 @@ data class User(
val status: Boolean,
/**
* Unix timestamp of the most recent password update
* Password update time in ISO 8601 format.
*
*/
@SerializedName("passwordUpdate")
val passwordUpdate: Long,
val passwordUpdate: String,
/**
* User email address.
@@ -92,14 +92,14 @@ data class User(
) {
companion object {
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = User(
fun from(map: Map<String, Any>) = Account(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
name = map["name"] as String,
registration = (map["registration"] as Number).toLong(),
registration = map["registration"] as String,
status = map["status"] as Boolean,
passwordUpdate = (map["passwordUpdate"] as Number).toLong(),
passwordUpdate = map["passwordUpdate"] as String,
email = map["email"] as String,
phone = map["phone"] as String,
emailVerification = map["emailVerification"] as Boolean,
@@ -21,32 +21,25 @@ data class Document(
val collection: String,
/**
* Document creation date in Unix timestamp.
* Document creation date in ISO 8601 format.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
val createdAt: String,
/**
* Document update date in Unix timestamp.
* Document update date in ISO 8601 format.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
val updatedAt: String,
/**
* Document read permissions.
* Document permissions. [Learn more about permissions](/docs/permissions).
*
*/
@SerializedName("\$read")
val read: List<Any>,
/**
* Document write permissions.
*
*/
@SerializedName("\$write")
val write: List<Any>,
@SerializedName("\$permissions")
val permissions: List<Any>,
val data: Map<String, Any>
) {
@@ -55,10 +48,9 @@ data class Document(
fun from(map: Map<String, Any>) = Document(
id = map["\$id"] as String,
collection = map["\$collection"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
read = map["\$read"] as List<Any>,
write = map["\$write"] as List<Any>,
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
permissions = map["\$permissions"] as List<Any>,
data = map
)
}
@@ -68,8 +60,7 @@ data class Document(
"\$collection" to collection as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"\$read" to read as Any,
"\$write" to write as Any,
"\$permissions" to permissions as Any,
"data" to data
)
@@ -14,25 +14,25 @@ data class Execution(
val id: String,
/**
* Execution creation date in Unix timestamp.
* Execution creation date in ISO 8601 format.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
val createdAt: String,
/**
* Execution update date in Unix timestamp.
* Execution upate date in ISO 8601 format.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
val updatedAt: String,
/**
* Execution read permissions.
* Execution roles.
*
*/
@SerializedName("\$read")
val read: List<Any>,
@SerializedName("\$permissions")
val permissions: List<Any>,
/**
* Function ID.
@@ -70,7 +70,14 @@ data class Execution(
val response: String,
/**
* The script stderr output string. Logs the last 4,000 characters of the execution stderr output
* The script stdout output string. Logs the last 4,000 characters of the execution stdout output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.
*
*/
@SerializedName("stdout")
val stdout: String,
/**
* The script stderr output string. Logs the last 4,000 characters of the execution stderr output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.
*
*/
@SerializedName("stderr")
@@ -87,14 +94,15 @@ data class Execution(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Execution(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
read = map["\$read"] as List<Any>,
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
permissions = map["\$permissions"] as List<Any>,
functionId = map["functionId"] as String,
trigger = map["trigger"] as String,
status = map["status"] as String,
statusCode = (map["statusCode"] as Number).toLong(),
response = map["response"] as String,
stdout = map["stdout"] as String,
stderr = map["stderr"] as String,
time = (map["time"] as Number).toDouble()
)
@@ -104,12 +112,13 @@ data class Execution(
"\$id" to id as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"\$read" to read as Any,
"\$permissions" to permissions as Any,
"functionId" to functionId as Any,
"trigger" to trigger as Any,
"status" to status as Any,
"statusCode" to statusCode as Any,
"response" to response as Any,
"stdout" to stdout as Any,
"stderr" to stderr as Any,
"time" to time as Any
)
@@ -21,32 +21,25 @@ data class File(
val bucketId: String,
/**
* File creation date in Unix timestamp.
* File creation date in ISO 8601 format.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
val createdAt: String,
/**
* File update date in Unix timestamp.
* File update date in ISO 8601 format.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
val updatedAt: String,
/**
* File read permissions.
* File permissions. [Learn more about permissions](/docs/permissions).
*
*/
@SerializedName("\$read")
val read: List<Any>,
/**
* File write permissions.
*
*/
@SerializedName("\$write")
val write: List<Any>,
@SerializedName("\$permissions")
val permissions: List<Any>,
/**
* File name.
@@ -95,10 +88,9 @@ data class File(
fun from(map: Map<String, Any>) = File(
id = map["\$id"] as String,
bucketId = map["bucketId"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
read = map["\$read"] as List<Any>,
write = map["\$write"] as List<Any>,
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
permissions = map["\$permissions"] as List<Any>,
name = map["name"] as String,
signature = map["signature"] as String,
mimeType = map["mimeType"] as String,
@@ -113,8 +105,7 @@ data class File(
"bucketId" to bucketId as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"\$read" to read as Any,
"\$write" to write as Any,
"\$permissions" to permissions as Any,
"name" to name as Any,
"signature" to signature as Any,
"mimeType" to mimeType as Any,
@@ -49,11 +49,11 @@ data class Log(
val ip: String,
/**
* Log creation time in Unix timestamp.
* Log creation date in ISO 8601 format.
*
*/
@SerializedName("time")
val time: Long,
val time: String,
/**
* Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).
@@ -162,7 +162,7 @@ data class Log(
userName = map["userName"] as String,
mode = map["mode"] as String,
ip = map["ip"] as String,
time = (map["time"] as Number).toLong(),
time = map["time"] as String,
osCode = map["osCode"] as String,
osName = map["osName"] as String,
osVersion = map["osVersion"] as String,
@@ -14,18 +14,18 @@ data class Membership(
val id: String,
/**
* Membership creation date in Unix timestamp.
* Membership creation date in ISO 8601 format.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
val createdAt: String,
/**
* Membership update date in Unix timestamp.
* Membership update date in ISO 8601 format.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
val updatedAt: String,
/**
* User ID.
@@ -63,18 +63,18 @@ data class Membership(
val teamName: String,
/**
* Date, the user has been invited to join the team in Unix timestamp.
* Date, the user has been invited to join the team in ISO 8601 format.
*
*/
@SerializedName("invited")
val invited: Long,
val invited: String,
/**
* Date, the user has accepted the invitation to join the team in Unix timestamp.
* Date, the user has accepted the invitation to join the team in ISO 8601 format.
*
*/
@SerializedName("joined")
val joined: Long,
val joined: String,
/**
* User confirmation status, true if the user has joined the team or false otherwise.
@@ -94,15 +94,15 @@ data class Membership(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Membership(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
userId = map["userId"] as String,
userName = map["userName"] as String,
userEmail = map["userEmail"] as String,
teamId = map["teamId"] as String,
teamName = map["teamName"] as String,
invited = (map["invited"] as Number).toLong(),
joined = (map["joined"] as Number).toLong(),
invited = map["invited"] as String,
joined = map["joined"] as String,
confirm = map["confirm"] as Boolean,
roles = map["roles"] as List<Any>
)
@@ -14,11 +14,11 @@ data class Session(
val id: String,
/**
* Session creation date in Unix timestamp.
* Session creation date in ISO 8601 format.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
val createdAt: String,
/**
* User ID.
@@ -28,11 +28,11 @@ data class Session(
val userId: String,
/**
* Session expiration date in Unix timestamp.
* Session expiration date in ISO 8601 format.
*
*/
@SerializedName("expire")
val expire: Long,
val expire: String,
/**
* Session Provider.
@@ -56,11 +56,11 @@ data class Session(
val providerAccessToken: String,
/**
* Date, the Unix timestamp of when the access token expires.
* The date of when the access token expires in ISO 8601 format.
*
*/
@SerializedName("providerAccessTokenExpiry")
val providerAccessTokenExpiry: Long,
val providerAccessTokenExpiry: String,
/**
* Session Provider Refresh Token.
@@ -185,13 +185,13 @@ data class Session(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Session(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
createdAt = map["\$createdAt"] as String,
userId = map["userId"] as String,
expire = (map["expire"] as Number).toLong(),
expire = map["expire"] as String,
provider = map["provider"] as String,
providerUid = map["providerUid"] as String,
providerAccessToken = map["providerAccessToken"] as String,
providerAccessTokenExpiry = (map["providerAccessTokenExpiry"] as Number).toLong(),
providerAccessTokenExpiry = map["providerAccessTokenExpiry"] as String,
providerRefreshToken = map["providerRefreshToken"] as String,
ip = map["ip"] as String,
osCode = map["osCode"] as String,
@@ -14,18 +14,18 @@ data class Team(
val id: String,
/**
* Team creation date in Unix timestamp.
* Team creation date in ISO 8601 format.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
val createdAt: String,
/**
* Team update date in Unix timestamp.
* Team update date in ISO 8601 format.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
val updatedAt: String,
/**
* Team name.
@@ -45,8 +45,8 @@ data class Team(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Team(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
name = map["name"] as String,
total = (map["total"] as Number).toLong()
)
@@ -14,11 +14,11 @@ data class Token(
val id: String,
/**
* Token creation date in Unix timestamp.
* Token creation date in ISO 8601 format.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
val createdAt: String,
/**
* User ID.
@@ -35,20 +35,20 @@ data class Token(
val secret: String,
/**
* Token expiration date in Unix timestamp.
* Token expiration date in ISO 8601 format.
*
*/
@SerializedName("expire")
val expire: Long
val expire: String
) {
companion object {
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Token(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
createdAt = map["\$createdAt"] as String,
userId = map["userId"] as String,
secret = map["secret"] as String,
expire = (map["expire"] as Number).toLong()
expire = map["expire"] as String
)
}
@@ -21,26 +21,26 @@ class Account : Service {
*
* Get currently logged in user data as JSON object.
*
* @return [io.appwrite.models.User]
* @return [io.appwrite.models.Account]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun get(): io.appwrite.models.User {
suspend fun get(): io.appwrite.models.Account {
val path = "/account"
val params = mutableMapOf<String, Any?>(
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
io.appwrite.models.User.from(map = it)
val converter: (Map<String, Any>) -> io.appwrite.models.Account = {
io.appwrite.models.Account.from(map = it)
}
return client.call(
"GET",
path,
headers,
params,
responseType = io.appwrite.models.User::class.java,
responseType = io.appwrite.models.Account::class.java,
converter,
)
}
@@ -59,7 +59,7 @@ class Account : Service {
* @param email User email.
* @param password User password. Must be at least 8 chars.
* @param name User name. Max length: 128 chars.
* @return [io.appwrite.models.User]
* @return [io.appwrite.models.Account]
*/
@JvmOverloads
@Throws(AppwriteException::class)
@@ -68,7 +68,7 @@ class Account : Service {
email: String,
password: String,
name: String? = null
): io.appwrite.models.User {
): io.appwrite.models.Account {
val path = "/account"
val params = mutableMapOf<String, Any?>(
"userId" to userId,
@@ -79,15 +79,15 @@ class Account : Service {
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
io.appwrite.models.User.from(map = it)
val converter: (Map<String, Any>) -> io.appwrite.models.Account = {
io.appwrite.models.Account.from(map = it)
}
return client.call(
"POST",
path,
headers,
params,
responseType = io.appwrite.models.User::class.java,
responseType = io.appwrite.models.Account::class.java,
converter,
)
}
@@ -106,14 +106,14 @@ class Account : Service {
*
* @param email User email.
* @param password User password. Must be at least 8 chars.
* @return [io.appwrite.models.User]
* @return [io.appwrite.models.Account]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateEmail(
email: String,
password: String
): io.appwrite.models.User {
): io.appwrite.models.Account {
val path = "/account/email"
val params = mutableMapOf<String, Any?>(
"email" to email,
@@ -122,15 +122,15 @@ class Account : Service {
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
io.appwrite.models.User.from(map = it)
val converter: (Map<String, Any>) -> io.appwrite.models.Account = {
io.appwrite.models.Account.from(map = it)
}
return client.call(
"PATCH",
path,
headers,
params,
responseType = io.appwrite.models.User::class.java,
responseType = io.appwrite.models.Account::class.java,
converter,
)
}
@@ -174,20 +174,17 @@ class Account : Service {
* Get currently logged in user list of latest security activity logs. Each
* log returns user IP address, location and date and time of log.
*
* @param limit Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only supported methods are limit and offset
* @return [io.appwrite.models.LogList]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getLogs(
limit: Long? = null,
offset: Long? = null
queries: List<String>? = null
): io.appwrite.models.LogList {
val path = "/account/logs"
val params = mutableMapOf<String, Any?>(
"limit" to limit,
"offset" to offset
"queries" to queries
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -211,13 +208,13 @@ class Account : Service {
* Update currently logged in user account name.
*
* @param name User name. Max length: 128 chars.
* @return [io.appwrite.models.User]
* @return [io.appwrite.models.Account]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateName(
name: String
): io.appwrite.models.User {
): io.appwrite.models.Account {
val path = "/account/name"
val params = mutableMapOf<String, Any?>(
"name" to name
@@ -225,15 +222,15 @@ class Account : Service {
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
io.appwrite.models.User.from(map = it)
val converter: (Map<String, Any>) -> io.appwrite.models.Account = {
io.appwrite.models.Account.from(map = it)
}
return client.call(
"PATCH",
path,
headers,
params,
responseType = io.appwrite.models.User::class.java,
responseType = io.appwrite.models.Account::class.java,
converter,
)
}
@@ -247,14 +244,14 @@ class Account : Service {
*
* @param password New user password. Must be at least 8 chars.
* @param oldPassword Current user password. Must be at least 8 chars.
* @return [io.appwrite.models.User]
* @return [io.appwrite.models.Account]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updatePassword(
password: String,
oldPassword: String? = null
): io.appwrite.models.User {
): io.appwrite.models.Account {
val path = "/account/password"
val params = mutableMapOf<String, Any?>(
"password" to password,
@@ -263,15 +260,15 @@ class Account : Service {
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
io.appwrite.models.User.from(map = it)
val converter: (Map<String, Any>) -> io.appwrite.models.Account = {
io.appwrite.models.Account.from(map = it)
}
return client.call(
"PATCH",
path,
headers,
params,
responseType = io.appwrite.models.User::class.java,
responseType = io.appwrite.models.Account::class.java,
converter,
)
}
@@ -279,38 +276,39 @@ class Account : Service {
/**
* Update Account Phone
*
* Update currently logged in user account phone number. After changing phone
* number, the user confirmation status will get reset. A new confirmation SMS
* is not sent automatically however you can use the phone confirmation
* endpoint again to send the confirmation SMS.
* Update the currently logged in user's phone number. After updating the
* phone number, the phone verification status will be reset. A confirmation
* SMS is not sent automatically, however you can use the [POST
* /account/verification/phone](/docs/client/account#accountCreatePhoneVerification)
* endpoint to send a confirmation SMS.
*
* @param number Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
* @param phone Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
* @param password User password. Must be at least 8 chars.
* @return [io.appwrite.models.User]
* @return [io.appwrite.models.Account]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updatePhone(
number: String,
phone: String,
password: String
): io.appwrite.models.User {
): io.appwrite.models.Account {
val path = "/account/phone"
val params = mutableMapOf<String, Any?>(
"number" to number,
"phone" to phone,
"password" to password
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
io.appwrite.models.User.from(map = it)
val converter: (Map<String, Any>) -> io.appwrite.models.Account = {
io.appwrite.models.Account.from(map = it)
}
return client.call(
"PATCH",
path,
headers,
params,
responseType = io.appwrite.models.User::class.java,
responseType = io.appwrite.models.Account::class.java,
converter,
)
}
@@ -352,13 +350,13 @@ class Account : Service {
* size is 64kB and throws error if exceeded.
*
* @param prefs Prefs key-value JSON object.
* @return [io.appwrite.models.User]
* @return [io.appwrite.models.Account]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updatePrefs(
prefs: Any
): io.appwrite.models.User {
): io.appwrite.models.Account {
val path = "/account/prefs"
val params = mutableMapOf<String, Any?>(
"prefs" to prefs
@@ -366,15 +364,15 @@ class Account : Service {
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
io.appwrite.models.User.from(map = it)
val converter: (Map<String, Any>) -> io.appwrite.models.Account = {
io.appwrite.models.Account.from(map = it)
}
return client.call(
"PATCH",
path,
headers,
params,
responseType = io.appwrite.models.User::class.java,
responseType = io.appwrite.models.Account::class.java,
converter,
)
}
@@ -602,9 +600,10 @@ class Account : Service {
/**
* Create Magic URL session
*
* Sends the user an email with a secret key for creating a session. When the
* user clicks the link in the email, the user is redirected back to the URL
* you provided with the secret key and userId values attached to the URL
* Sends the user an email with a secret key for creating a session. If the
* provided user ID has not be registered, a new user will be created. When
* the user clicks the link in the email, the user is redirected back to the
* URL you provided with the secret key and userId values attached to the URL
* query string. Use the query string parameters to submit a request to the
* [PUT
* /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession)
@@ -709,7 +708,7 @@ class Account : Service {
* user..
*
*
* @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, dailymotion, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom.
* @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom.
* @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -722,7 +721,7 @@ class Account : Service {
provider: String,
success: String? = null,
failure: String? = null,
scopes: List<Any>? = null
scopes: List<String>? = null
) {
val path = "/account/sessions/oauth2/{provider}".replace("{provider}", provider)
val params = mutableMapOf<String, Any?>(
@@ -778,26 +777,27 @@ class Account : Service {
/**
* Create Phone session
*
* Sends the user a SMS with a secret key for creating a session. Use the
* returned user ID and the secret to submit a request to the [PUT
* Sends the user an SMS with a secret key for creating a session. If the
* provided user ID has not be registered, a new user will be created. Use the
* returned user ID and secret and submit a request to the [PUT
* /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession)
* endpoint to complete the login process. The secret sent to the user's phone
* is valid for 15 minutes.
*
* @param userId Unique Id. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
* @param number Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
* @param phone Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
* @return [io.appwrite.models.Token]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun createPhoneSession(
userId: String,
number: String
phone: String
): io.appwrite.models.Token {
val path = "/account/sessions/phone"
val params = mutableMapOf<String, Any?>(
"userId" to userId,
"number" to number
"phone" to phone
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -816,19 +816,13 @@ class Account : Service {
}
/**
* Create Phone session (confirmation)
* Create Phone Session (confirmation)
*
* Use this endpoint to complete creating the session with the Magic URL. Both
* the **userId** and **secret** arguments will be passed as query parameters
* to the redirect URL you have provided when sending your request to the
* [POST
* /account/sessions/magic-url](/docs/client/account#accountCreateMagicURLSession)
* endpoint.
*
* Please note that in order to avoid a [Redirect
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
* the only valid redirect URLs are the ones from domains you have set when
* adding your platforms in the console interface.
* Use this endpoint to complete creating a session with SMS. Use the
* **userId** from the
* [createPhoneSession](/docs/client/account#accountCreatePhoneSession)
* endpoint and the **secret** received via SMS to successfully update and
* confirm the phone session.
*
* @param userId User ID.
* @param secret Valid verification token.
@@ -966,26 +960,26 @@ class Account : Service {
* record is not deleted but permanently blocked from any access. To
* completely delete a user, use the Users API instead.
*
* @return [io.appwrite.models.User]
* @return [io.appwrite.models.Account]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateStatus(): io.appwrite.models.User {
suspend fun updateStatus(): io.appwrite.models.Account {
val path = "/account/status"
val params = mutableMapOf<String, Any?>(
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
io.appwrite.models.User.from(map = it)
val converter: (Map<String, Any>) -> io.appwrite.models.Account = {
io.appwrite.models.Account.from(map = it)
}
return client.call(
"PATCH",
path,
headers,
params,
responseType = io.appwrite.models.User::class.java,
responseType = io.appwrite.models.Account::class.java,
converter,
)
}
@@ -1079,13 +1073,12 @@ class Account : Service {
/**
* Create Phone Verification
*
* Use this endpoint to send a verification message to your user's phone
* number to confirm they are the valid owners of that address. The provided
* secret should allow you to complete the verification process by verifying
* both the **userId** and **secret** parameters. Learn more about how to
* [complete the verification
* Use this endpoint to send a verification SMS to the currently logged in
* user. This endpoint is meant for use after updating a user's phone number
* using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone)
* endpoint. Learn more about how to [complete the verification
* process](/docs/client/account#accountUpdatePhoneVerification). The
* verification link sent to the user's phone number is valid for 15 minutes.
* verification code sent to the user's phone number is valid for 15 minutes.
*
* @return [io.appwrite.models.Token]
*/
@@ -131,7 +131,8 @@ class Avatars : Service {
*
* You can use this endpoint to show different country flags icons to your
* users. The code argument receives the 2 letter country code. Use width,
* height and quality arguments to change the output settings.
* height and quality arguments to change the output settings. Country codes
* follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard.
*
* When one dimension is specified and the other is 0, the image is scaled
* with preserved aspect ratio. If both dimensions are 0, the API provides an
@@ -232,7 +233,6 @@ class Avatars : Service {
* @param name Full Name. When empty, current user name or email will be used. Max length: 128 chars.
* @param width Image width. Pass an integer between 0 to 2000. Defaults to 100.
* @param height Image height. Pass an integer between 0 to 2000. Defaults to 100.
* @param color Changes text color. By default a random color will be picked and stay will persistent to the given name.
* @param background Changes background color. By default a random color will be picked and stay will persistent to the given name.
* @return [ByteArray]
*/
@@ -242,7 +242,6 @@ class Avatars : Service {
name: String? = null,
width: Long? = null,
height: Long? = null,
color: String? = null,
background: String? = null
): ByteArray {
val path = "/avatars/initials"
@@ -250,7 +249,6 @@ class Avatars : Service {
"name" to name,
"width" to width,
"height" to height,
"color" to color,
"background" to background,
"project" to client.config["project"]
)
@@ -10,46 +10,31 @@ import java.io.File
class Databases : Service {
val databaseId: String
public constructor(client: Client, databaseId: String) : super(client) {
this.databaseId = databaseId
}
public constructor (client: Client) : super(client) { }
/**
* List Documents
*
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long.
* @param limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 4096 characters long.
* @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed.
* Get a list of all the user's documents in a given collection. You can use
* the query params to filter your results. On admin mode, this endpoint will
* return a list of all of documents belonging to the provided collectionId.
* [Learn more about different API modes](/docs/admin).
*
* @param databaseId Database ID.
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long.
* @return [io.appwrite.models.DocumentList]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun listDocuments(
databaseId: String,
collectionId: String,
queries: List<Any>? = null,
limit: Long? = null,
offset: Long? = null,
cursor: String? = null,
cursorDirection: String? = null,
orderAttributes: List<Any>? = null,
orderTypes: List<Any>? = null
queries: List<String>? = null
): io.appwrite.models.DocumentList {
val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId)
val params = mutableMapOf<String, Any?>(
"queries" to queries,
"limit" to limit,
"offset" to offset,
"cursor" to cursor,
"cursorDirection" to cursorDirection,
"orderAttributes" to orderAttributes,
"orderTypes" to orderTypes
"queries" to queries
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -70,28 +55,32 @@ class Databases : Service {
/**
* Create Document
*
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). Make sure to define attributes before creating documents.
* Create a new Document. Before using this route, you should create a new
* collection resource using either a [server
* integration](/docs/server/databases#databasesCreateCollection) API or
* directly from your database console.
*
* @param databaseId Database ID.
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.
* @param documentId Document ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
* @param data Document data as JSON object.
* @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
* @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
* @param permissions An array of permissions strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions).
* @return [io.appwrite.models.Document]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun createDocument(
databaseId: String,
collectionId: String,
documentId: String,
data: Any,
read: List<Any>? = null,
write: List<Any>? = null
permissions: List<String>? = null
): io.appwrite.models.Document {
val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId)
val params = mutableMapOf<String, Any?>(
"documentId" to documentId,
"data" to data,
"read" to read,
"write" to write
"permissions" to permissions
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -112,13 +101,18 @@ class Databases : Service {
/**
* Get Document
*
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
* Get a document by its unique ID. This endpoint response returns a JSON
* object with the document data.
*
* @param databaseId Database ID.
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
* @param documentId Document ID.
* @return [io.appwrite.models.Document]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getDocument(
databaseId: String,
collectionId: String,
documentId: String
): io.appwrite.models.Document {
@@ -144,27 +138,29 @@ class Databases : Service {
/**
* Update Document
*
* Update a document by its unique ID. Using the patch method you can pass
* only specific fields that will get updated.
*
* @param databaseId Database ID.
* @param collectionId Collection ID.
* @param documentId Document ID.
* @param data Document data as JSON object. Include only attribute and value pairs to be updated.
* @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
* @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
* @param permissions An array of permissions strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).
* @return [io.appwrite.models.Document]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateDocument(
databaseId: String,
collectionId: String,
documentId: String,
data: Any? = null,
read: List<Any>? = null,
write: List<Any>? = null
permissions: List<String>? = null
): io.appwrite.models.Document {
val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId)
val params = mutableMapOf<String, Any?>(
"data" to data,
"read" to read,
"write" to write
"permissions" to permissions
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -185,13 +181,17 @@ class Databases : Service {
/**
* Delete Document
*
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
* Delete a document by its unique ID.
*
* @param databaseId Database ID.
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
* @param documentId Document ID.
* @return [Any]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun deleteDocument(
databaseId: String,
collectionId: String,
documentId: String
): Any {
@@ -51,30 +51,21 @@ class Functions : Service {
* different API modes](/docs/admin).
*
* @param functionId Function ID.
* @param limit Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @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 search Search term to filter your list results. Max length: 256 chars.
* @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @return [io.appwrite.models.ExecutionList]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun listExecutions(
functionId: String,
limit: Long? = null,
offset: Long? = null,
search: String? = null,
cursor: String? = null,
cursorDirection: String? = null
queries: List<String>? = null,
search: String? = null
): io.appwrite.models.ExecutionList {
val path = "/functions/{functionId}/executions".replace("{functionId}", functionId)
val params = mutableMapOf<String, Any?>(
"limit" to limit,
"offset" to offset,
"search" to search,
"cursor" to cursor,
"cursorDirection" to cursorDirection
"queries" to queries,
"search" to search
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -22,33 +22,21 @@ class Storage : Service {
* project's files. [Learn more about different API modes](/docs/admin).
*
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded
* @param search Search term to filter your list results. Max length: 256 chars.
* @param limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @param orderType Order result by ASC or DESC order.
* @return [io.appwrite.models.FileList]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun listFiles(
bucketId: String,
search: String? = null,
limit: Long? = null,
offset: Long? = null,
cursor: String? = null,
cursorDirection: String? = null,
orderType: String? = null
queries: List<String>? = null,
search: String? = null
): io.appwrite.models.FileList {
val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId)
val params = mutableMapOf<String, Any?>(
"search" to search,
"limit" to limit,
"offset" to offset,
"cursor" to cursor,
"cursorDirection" to cursorDirection,
"orderType" to orderType
"queries" to queries,
"search" to search
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -71,8 +59,8 @@ class Storage : Service {
*
* Create a new file. Before using this route, you should create a new bucket
* resource using either a [server
* integration](/docs/server/database#storageCreateBucket) API or directly
* from your Appwrite console.
* integration](/docs/server/storage#storageCreateBucket) API or directly from
* your Appwrite console.
*
* Larger files should be uploaded using multiple requests with the
* [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
@@ -91,8 +79,7 @@ class Storage : Service {
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
* @param fileId File ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
* @param file Binary file.
* @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
* @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
* @param permissions An array of permission strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions).
* @return [io.appwrite.models.File]
*/
@JvmOverloads
@@ -101,15 +88,13 @@ class Storage : Service {
bucketId: String,
fileId: String,
file: InputFile,
read: List<Any>? = null,
write: List<Any>? = null, onProgress: ((UploadProgress) -> Unit)? = null
permissions: List<String>? = null, onProgress: ((UploadProgress) -> Unit)? = null
): io.appwrite.models.File {
val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId)
val params = mutableMapOf<String, Any?>(
"fileId" to fileId,
"file" to file,
"read" to read,
"write" to write
"permissions" to permissions
)
val headers = mutableMapOf(
"content-type" to "multipart/form-data"
@@ -174,8 +159,7 @@ class Storage : Service {
*
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
* @param fileId File unique ID.
* @param read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
* @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
* @param permissions An array of permission string. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).
* @return [io.appwrite.models.File]
*/
@JvmOverloads
@@ -183,13 +167,11 @@ class Storage : Service {
suspend fun updateFile(
bucketId: String,
fileId: String,
read: List<Any>? = null,
write: List<Any>? = null
permissions: List<String>? = null
): io.appwrite.models.File {
val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId)
val params = mutableMapOf<String, Any?>(
"read" to read,
"write" to write
"permissions" to permissions
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -21,32 +21,20 @@ class Teams : Service {
* In admin mode, this endpoint returns a list of all the teams in the current
* project. [Learn more about different API modes](/docs/admin).
*
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total
* @param search Search term to filter your list results. Max length: 256 chars.
* @param limit Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @param orderType Order result by ASC or DESC order.
* @return [io.appwrite.models.TeamList]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun list(
search: String? = null,
limit: Long? = null,
offset: Long? = null,
cursor: String? = null,
cursorDirection: String? = null,
orderType: String? = null
queries: List<String>? = null,
search: String? = null
): io.appwrite.models.TeamList {
val path = "/teams"
val params = mutableMapOf<String, Any?>(
"search" to search,
"limit" to limit,
"offset" to offset,
"cursor" to cursor,
"cursorDirection" to cursorDirection,
"orderType" to orderType
"queries" to queries,
"search" to search
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -81,7 +69,7 @@ class Teams : Service {
suspend fun create(
teamId: String,
name: String,
roles: List<Any>? = null
roles: List<String>? = null
): io.appwrite.models.Team {
val path = "/teams"
val params = mutableMapOf<String, Any?>(
@@ -209,33 +197,21 @@ class Teams : Service {
* members have read access to this endpoint.
*
* @param teamId Team ID.
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm
* @param search Search term to filter your list results. Max length: 256 chars.
* @param limit Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @param orderType Order result by ASC or DESC order.
* @return [io.appwrite.models.MembershipList]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getMemberships(
teamId: String,
search: String? = null,
limit: Long? = null,
offset: Long? = null,
cursor: String? = null,
cursorDirection: String? = null,
orderType: String? = null
queries: List<String>? = null,
search: String? = null
): io.appwrite.models.MembershipList {
val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId)
val params = mutableMapOf<String, Any?>(
"search" to search,
"limit" to limit,
"offset" to offset,
"cursor" to cursor,
"cursorDirection" to cursorDirection,
"orderType" to orderType
"queries" to queries,
"search" to search
)
val headers = mutableMapOf(
"content-type" to "application/json"
@@ -284,7 +260,7 @@ class Teams : Service {
suspend fun createMembership(
teamId: String,
email: String,
roles: List<Any>,
roles: List<String>,
url: String,
name: String? = null
): io.appwrite.models.Membership {
@@ -363,7 +339,7 @@ class Teams : Service {
suspend fun updateMembershipRoles(
teamId: String,
membershipId: String,
roles: List<Any>
roles: List<String>
): io.appwrite.models.Membership {
val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId)
val params = mutableMapOf<String, Any?>(