From 4d7524d625173c1c0d0f0d30e3fa1a70dfbc2a73 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sun, 18 May 2025 00:02:51 +1200 Subject: [PATCH 1/3] Add support for 1.7 --- README.md | 8 +-- docs/examples/java/avatars/get-browser.md | 2 +- docs/examples/java/avatars/get-credit-card.md | 2 +- docs/examples/java/avatars/get-flag.md | 2 +- .../java/databases/create-document.md | 4 +- .../java/databases/create-documents.md | 24 ++++++++ .../java/functions/list-executions.md | 1 - .../java/storage/get-file-download.md | 1 + .../examples/java/storage/get-file-preview.md | 3 +- docs/examples/java/storage/get-file-view.md | 1 + docs/examples/kotlin/avatars/get-browser.md | 2 +- .../kotlin/avatars/get-credit-card.md | 2 +- docs/examples/kotlin/avatars/get-flag.md | 2 +- .../kotlin/databases/create-document.md | 4 +- .../kotlin/databases/create-documents.md | 15 +++++ .../kotlin/functions/list-executions.md | 1 - .../kotlin/storage/get-file-download.md | 1 + .../kotlin/storage/get-file-preview.md | 3 +- docs/examples/kotlin/storage/get-file-view.md | 1 + library/src/main/java/io/appwrite/Client.kt | 4 +- .../java/io/appwrite/enums/ImageFormat.kt | 2 - .../main/java/io/appwrite/models/Execution.kt | 2 +- .../main/java/io/appwrite/services/Avatars.kt | 6 +- .../java/io/appwrite/services/Databases.kt | 58 +++++++++++++++++++ .../java/io/appwrite/services/Functions.kt | 3 - .../main/java/io/appwrite/services/Storage.kt | 13 ++++- .../main/java/io/appwrite/services/Teams.kt | 2 +- 27 files changed, 140 insertions(+), 29 deletions(-) create mode 100644 docs/examples/java/databases/create-documents.md create mode 100644 docs/examples/kotlin/databases/create-documents.md diff --git a/README.md b/README.md index 9edac18..4abf758 100644 --- a/README.md +++ b/README.md @@ -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-1.6.2-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.0-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 1.6.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.7.x. 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:7.0.1") +implementation("io.appwrite:sdk-for-android:7.1.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 7.0.1 + 7.1.0 ``` diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index 4c85796..1b6632f 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -13,7 +13,7 @@ avatars.getBrowser( Browser.AVANT_BROWSER, // code 0, // width (optional) 0, // height (optional) - 0, // quality (optional) + -1, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index a8bc303..e2ac2c2 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -13,7 +13,7 @@ avatars.getCreditCard( CreditCard.AMERICAN_EXPRESS, // code 0, // width (optional) 0, // height (optional) - 0, // quality (optional) + -1, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index 61ced3b..689e27f 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -13,7 +13,7 @@ avatars.getFlag( Flag.AFGHANISTAN, // code 0, // width (optional) 0, // height (optional) - 0, // quality (optional) + -1, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 4804d75..7fb129b 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,7 +4,9 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT(""); // Your secret JSON Web Token Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/create-documents.md b/docs/examples/java/databases/create-documents.md new file mode 100644 index 0000000..dbdc64f --- /dev/null +++ b/docs/examples/java/databases/create-documents.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey(""); // + +Databases databases = new Databases(client); + +databases.createDocuments( + "", // databaseId + "", // collectionId + listOf(), // documents + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index f23e5fb..0270cf0 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -11,7 +11,6 @@ Functions functions = new Functions(client); functions.listExecutions( "", // functionId listOf(), // queries (optional) - "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index ce2b846..73a8617 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -11,6 +11,7 @@ Storage storage = new Storage(client); storage.getFileDownload( "", // bucketId "", // fileId + "", // token (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 1f5e365..67b92eb 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -14,7 +14,7 @@ storage.getFilePreview( 0, // width (optional) 0, // height (optional) ImageGravity.CENTER, // gravity (optional) - 0, // quality (optional) + -1, // quality (optional) 0, // borderWidth (optional) "", // borderColor (optional) 0, // borderRadius (optional) @@ -22,6 +22,7 @@ storage.getFilePreview( -360, // rotation (optional) "", // background (optional) ImageFormat.JPG, // output (optional) + "", // token (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index cda3545..b042b1f 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -11,6 +11,7 @@ Storage storage = new Storage(client); storage.getFileView( "", // bucketId "", // fileId + "", // token (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index 4e2f5e0..d04adfb 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -13,5 +13,5 @@ val result = avatars.getBrowser( code = Browser.AVANT_BROWSER, width = 0, // (optional) height = 0, // (optional) - quality = 0, // (optional) + quality = -1, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 91aae45..91c88da 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -13,5 +13,5 @@ val result = avatars.getCreditCard( code = CreditCard.AMERICAN_EXPRESS, width = 0, // (optional) height = 0, // (optional) - quality = 0, // (optional) + quality = -1, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index 1d8f5f6..1dbc1cd 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -13,5 +13,5 @@ val result = avatars.getFlag( code = Flag.AFGHANISTAN, width = 0, // (optional) height = 0, // (optional) - quality = 0, // (optional) + quality = -1, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 849a636..0bafb31 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,7 +4,9 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT("") // Your secret JSON Web Token val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/create-documents.md b/docs/examples/kotlin/databases/create-documents.md new file mode 100644 index 0000000..33635b4 --- /dev/null +++ b/docs/examples/kotlin/databases/create-documents.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey("") // + +val databases = Databases(client) + +val result = databases.createDocuments( + databaseId = "", + collectionId = "", + documents = listOf(), +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index a56993f..37ea8b8 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -11,5 +11,4 @@ val functions = Functions(client) val result = functions.listExecutions( functionId = "", queries = listOf(), // (optional) - search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index b4d3386..89c6e8a 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -11,4 +11,5 @@ val storage = Storage(client) val result = storage.getFileDownload( bucketId = "", fileId = "", + token = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 31aa6e2..d766dc7 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -14,7 +14,7 @@ val result = storage.getFilePreview( width = 0, // (optional) height = 0, // (optional) gravity = ImageGravity.CENTER, // (optional) - quality = 0, // (optional) + quality = -1, // (optional) borderWidth = 0, // (optional) borderColor = "", // (optional) borderRadius = 0, // (optional) @@ -22,4 +22,5 @@ val result = storage.getFilePreview( rotation = -360, // (optional) background = "", // (optional) output = ImageFormat.JPG, // (optional) + token = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 7a5b31d..513e1f9 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -11,4 +11,5 @@ val storage = Storage(client) val result = storage.getFileView( bucketId = "", fileId = "", + token = "", // (optional) ) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 909e62f..67400ea 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,8 +87,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "7.0.1", - "x-appwrite-response-format" to "1.6.0" + "x-sdk-version" to "7.1.0", + "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt index 7249f2a..c3dea06 100644 --- a/library/src/main/java/io/appwrite/enums/ImageFormat.kt +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -7,8 +7,6 @@ enum class ImageFormat(val value: String) { JPG("jpg"), @SerializedName("jpeg") JPEG("jpeg"), - @SerializedName("gif") - GIF("gif"), @SerializedName("png") PNG("png"), @SerializedName("webp") diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 1b6226a..216e146 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -98,7 +98,7 @@ data class Execution( val errors: String, /** - * Function execution duration in seconds. + * Resource(function/site) execution duration in seconds. */ @SerializedName("duration") val duration: Double, diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 2900bf4..55406cc 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -23,7 +23,7 @@ class Avatars(client: Client) : Service(client) { * @param code Browser Code. * @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 quality Image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @return [ByteArray] */ @JvmOverloads @@ -57,7 +57,7 @@ class Avatars(client: Client) : Service(client) { * @param code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. * @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 quality Image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @return [ByteArray] */ @JvmOverloads @@ -115,7 +115,7 @@ class Avatars(client: Client) : Service(client) { * @param code Country Code. ISO Alpha-2 country code format. * @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 quality Image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @return [ByteArray] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index b6559a9..73384a1 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -146,6 +146,64 @@ class Databases(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + nestedType: Class, + ): io.appwrite.models.DocumentList { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + + val apiParams = mutableMapOf( + "documents" to documents, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + @Throws(AppwriteException::class) + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + ): io.appwrite.models.DocumentList> = createDocuments( + databaseId, + collectionId, + documents, + nestedType = classOf(), + ) + /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index a3644f2..b370448 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -20,21 +20,18 @@ class Functions(client: Client) : Service(client) { * * @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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId - * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads suspend fun listExecutions( functionId: String, queries: List? = null, - search: String? = null, ): io.appwrite.models.ExecutionList { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val apiParams = mutableMapOf( "queries" to queries, - "search" to search, ) val apiHeaders = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 391dedb..3b0323a 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -213,17 +213,21 @@ class Storage(client: Client) : Service(client) { * * @param bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. + * @param token File token for accessing this file. * @return [ByteArray] */ + @JvmOverloads suspend fun getFileDownload( bucketId: String, fileId: String, + token: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/download" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( + "token" to token, "project" to client.config["project"], ) return client.call( @@ -243,7 +247,7 @@ class Storage(client: Client) : Service(client) { * @param width Resize preview image width, Pass an integer between 0 to 4000. * @param height Resize preview image height, Pass an integer between 0 to 4000. * @param gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right - * @param quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param quality Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @param borderWidth Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. * @param borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix. * @param borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000. @@ -251,6 +255,7 @@ class Storage(client: Client) : Service(client) { * @param rotation Preview image rotation in degrees. Pass an integer between -360 and 360. * @param background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. * @param output Output format type (jpeg, jpg, png, gif and webp). + * @param token File token for accessing this file. * @return [ByteArray] */ @JvmOverloads @@ -268,6 +273,7 @@ class Storage(client: Client) : Service(client) { rotation: Long? = null, background: String? = null, output: io.appwrite.enums.ImageFormat? = null, + token: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) @@ -285,6 +291,7 @@ class Storage(client: Client) : Service(client) { "rotation" to rotation, "background" to background, "output" to output, + "token" to token, "project" to client.config["project"], ) return client.call( @@ -301,17 +308,21 @@ class Storage(client: Client) : Service(client) { * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. + * @param token File token for accessing this file. * @return [ByteArray] */ + @JvmOverloads suspend fun getFileView( bucketId: String, fileId: String, + token: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/view" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( + "token" to token, "project" to client.config["project"], ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 6810ce1..2756a5a 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -256,7 +256,7 @@ class Teams(client: Client) : Service(client) { * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.MembershipList] */ From 32f43932b4685330f7b47ad0963ff53d5a51443e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sun, 18 May 2025 02:03:51 +1200 Subject: [PATCH 2/3] Add 1.7 support --- .../java/databases/create-documents.md | 24 -------- .../kotlin/databases/create-documents.md | 15 ----- .../java/io/appwrite/services/Databases.kt | 58 ------------------- 3 files changed, 97 deletions(-) delete mode 100644 docs/examples/java/databases/create-documents.md delete mode 100644 docs/examples/kotlin/databases/create-documents.md diff --git a/docs/examples/java/databases/create-documents.md b/docs/examples/java/databases/create-documents.md deleted file mode 100644 index dbdc64f..0000000 --- a/docs/examples/java/databases/create-documents.md +++ /dev/null @@ -1,24 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Databases; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setKey(""); // - -Databases databases = new Databases(client); - -databases.createDocuments( - "", // databaseId - "", // collectionId - listOf(), // documents - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/kotlin/databases/create-documents.md b/docs/examples/kotlin/databases/create-documents.md deleted file mode 100644 index 33635b4..0000000 --- a/docs/examples/kotlin/databases/create-documents.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Databases - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setKey("") // - -val databases = Databases(client) - -val result = databases.createDocuments( - databaseId = "", - collectionId = "", - documents = listOf(), -) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 73384a1..b6559a9 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -146,64 +146,6 @@ class Databases(client: Client) : Service(client) { nestedType = classOf(), ) - /** - * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. - * @return [io.appwrite.models.DocumentList] - */ - suspend fun createDocuments( - databaseId: String, - collectionId: String, - documents: List, - nestedType: Class, - ): io.appwrite.models.DocumentList { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" - .replace("{databaseId}", databaseId) - .replace("{collectionId}", collectionId) - - val apiParams = mutableMapOf( - "documents" to documents, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.DocumentList = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.DocumentList.from(map = it as Map, nestedType) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. - * @return [io.appwrite.models.DocumentList] - */ - @Throws(AppwriteException::class) - suspend fun createDocuments( - databaseId: String, - collectionId: String, - documents: List, - ): io.appwrite.models.DocumentList> = createDocuments( - databaseId, - collectionId, - documents, - nestedType = classOf(), - ) - /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * From c6f6d9676997788acb80eecb9f902bfe6a4fb073 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 18 May 2025 07:48:42 +0000 Subject: [PATCH 3/3] chore: bump to next major versions --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4abf758..f00352f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:7.1.0") +implementation("io.appwrite:sdk-for-android:8.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 7.1.0 + 8.0.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 67400ea..7905e40 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "7.1.0", + "x-sdk-version" to "8.0.0", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf()