From 2774e024d54da2be2fff44db562f04a23066f699 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Aug 2024 11:15:44 +0000 Subject: [PATCH] chore: updates for appwrite 1.6.x --- .../java/functions/get-deployment-download.md | 23 --- docs/examples/java/functions/get-template.md | 22 --- .../functions/get-deployment-download.md | 14 -- .../examples/kotlin/functions/get-template.md | 13 -- .../io/appwrite/models/TemplateFunction.kt | 158 ------------------ .../io/appwrite/models/TemplateRuntime.kt | 54 ------ .../io/appwrite/models/TemplateVariable.kt | 70 -------- .../java/io/appwrite/services/Functions.kt | 65 ------- 8 files changed, 419 deletions(-) delete mode 100644 docs/examples/java/functions/get-deployment-download.md delete mode 100644 docs/examples/java/functions/get-template.md delete mode 100644 docs/examples/kotlin/functions/get-deployment-download.md delete mode 100644 docs/examples/kotlin/functions/get-template.md delete mode 100644 library/src/main/java/io/appwrite/models/TemplateFunction.kt delete mode 100644 library/src/main/java/io/appwrite/models/TemplateRuntime.kt delete mode 100644 library/src/main/java/io/appwrite/models/TemplateVariable.kt diff --git a/docs/examples/java/functions/get-deployment-download.md b/docs/examples/java/functions/get-deployment-download.md deleted file mode 100644 index 200cdf2..0000000 --- a/docs/examples/java/functions/get-deployment-download.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Functions; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Functions functions = new Functions(client); - -functions.getDeploymentDownload( - "", // functionId - "", // deploymentId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/functions/get-template.md b/docs/examples/java/functions/get-template.md deleted file mode 100644 index af9efc7..0000000 --- a/docs/examples/java/functions/get-template.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Functions; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Functions functions = new Functions(client); - -functions.getTemplate( - "", // templateId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/kotlin/functions/get-deployment-download.md b/docs/examples/kotlin/functions/get-deployment-download.md deleted file mode 100644 index 21e99cb..0000000 --- a/docs/examples/kotlin/functions/get-deployment-download.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Functions - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val functions = Functions(client) - -val result = functions.getDeploymentDownload( - functionId = "", - deploymentId = "", -) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-template.md b/docs/examples/kotlin/functions/get-template.md deleted file mode 100644 index 4af83bd..0000000 --- a/docs/examples/kotlin/functions/get-template.md +++ /dev/null @@ -1,13 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Functions - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val functions = Functions(client) - -val result = functions.getTemplate( - templateId = "", -) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateFunction.kt b/library/src/main/java/io/appwrite/models/TemplateFunction.kt deleted file mode 100644 index 3da1135..0000000 --- a/library/src/main/java/io/appwrite/models/TemplateFunction.kt +++ /dev/null @@ -1,158 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Template Function - */ -data class TemplateFunction( - /** - * Function Template Icon. - */ - @SerializedName("icon") - val icon: String, - - /** - * Function Template ID. - */ - @SerializedName("id") - val id: String, - - /** - * Function Template Name. - */ - @SerializedName("name") - val name: String, - - /** - * Function Template Tagline. - */ - @SerializedName("tagline") - val tagline: String, - - /** - * Execution permissions. - */ - @SerializedName("permissions") - val permissions: List, - - /** - * Function trigger events. - */ - @SerializedName("events") - val events: List, - - /** - * Function execution schedult in CRON format. - */ - @SerializedName("cron") - val cron: String, - - /** - * Function execution timeout in seconds. - */ - @SerializedName("timeout") - val timeout: Long, - - /** - * Function use cases. - */ - @SerializedName("useCases") - val useCases: List, - - /** - * List of runtimes that can be used with this template. - */ - @SerializedName("runtimes") - val runtimes: List, - - /** - * Function Template Instructions. - */ - @SerializedName("instructions") - val instructions: String, - - /** - * VCS (Version Control System) Provider. - */ - @SerializedName("vcsProvider") - val vcsProvider: String, - - /** - * VCS (Version Control System) Repository ID - */ - @SerializedName("providerRepositoryId") - val providerRepositoryId: String, - - /** - * VCS (Version Control System) Owner. - */ - @SerializedName("providerOwner") - val providerOwner: String, - - /** - * VCS (Version Control System) branch version (tag). - */ - @SerializedName("providerVersion") - val providerVersion: String, - - /** - * Function variables. - */ - @SerializedName("variables") - val variables: List, - - /** - * Function scopes. - */ - @SerializedName("scopes") - val scopes: List, - -) { - fun toMap(): Map = mapOf( - "icon" to icon as Any, - "id" to id as Any, - "name" to name as Any, - "tagline" to tagline as Any, - "permissions" to permissions as Any, - "events" to events as Any, - "cron" to cron as Any, - "timeout" to timeout as Any, - "useCases" to useCases as Any, - "runtimes" to runtimes.map { it.toMap() } as Any, - "instructions" to instructions as Any, - "vcsProvider" to vcsProvider as Any, - "providerRepositoryId" to providerRepositoryId as Any, - "providerOwner" to providerOwner as Any, - "providerVersion" to providerVersion as Any, - "variables" to variables.map { it.toMap() } as Any, - "scopes" to scopes as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = TemplateFunction( - icon = map["icon"] as String, - id = map["id"] as String, - name = map["name"] as String, - tagline = map["tagline"] as String, - permissions = map["permissions"] as List, - events = map["events"] as List, - cron = map["cron"] as String, - timeout = (map["timeout"] as Number).toLong(), - useCases = map["useCases"] as List, - runtimes = (map["runtimes"] as List>).map { TemplateRuntime.from(map = it) }, - instructions = map["instructions"] as String, - vcsProvider = map["vcsProvider"] as String, - providerRepositoryId = map["providerRepositoryId"] as String, - providerOwner = map["providerOwner"] as String, - providerVersion = map["providerVersion"] as String, - variables = (map["variables"] as List>).map { TemplateVariable.from(map = it) }, - scopes = map["scopes"] as List, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateRuntime.kt b/library/src/main/java/io/appwrite/models/TemplateRuntime.kt deleted file mode 100644 index d354239..0000000 --- a/library/src/main/java/io/appwrite/models/TemplateRuntime.kt +++ /dev/null @@ -1,54 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Template Runtime - */ -data class TemplateRuntime( - /** - * Runtime Name. - */ - @SerializedName("name") - val name: String, - - /** - * The build command used to build the deployment. - */ - @SerializedName("commands") - val commands: String, - - /** - * The entrypoint file used to execute the deployment. - */ - @SerializedName("entrypoint") - val entrypoint: String, - - /** - * Path to function in VCS (Version Control System) repository - */ - @SerializedName("providerRootDirectory") - val providerRootDirectory: String, - -) { - fun toMap(): Map = mapOf( - "name" to name as Any, - "commands" to commands as Any, - "entrypoint" to entrypoint as Any, - "providerRootDirectory" to providerRootDirectory as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = TemplateRuntime( - name = map["name"] as String, - commands = map["commands"] as String, - entrypoint = map["entrypoint"] as String, - providerRootDirectory = map["providerRootDirectory"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateVariable.kt b/library/src/main/java/io/appwrite/models/TemplateVariable.kt deleted file mode 100644 index 96d6607..0000000 --- a/library/src/main/java/io/appwrite/models/TemplateVariable.kt +++ /dev/null @@ -1,70 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Template Variable - */ -data class TemplateVariable( - /** - * Variable Name. - */ - @SerializedName("name") - val name: String, - - /** - * Variable Description. - */ - @SerializedName("description") - val description: String, - - /** - * Variable Value. - */ - @SerializedName("value") - val value: String, - - /** - * Variable Placeholder. - */ - @SerializedName("placeholder") - val placeholder: String, - - /** - * Is the variable required? - */ - @SerializedName("required") - val required: Boolean, - - /** - * Variable Type. - */ - @SerializedName("type") - val type: String, - -) { - fun toMap(): Map = mapOf( - "name" to name as Any, - "description" to description as Any, - "value" to value as Any, - "placeholder" to placeholder as Any, - "required" to required as Any, - "type" to type as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = TemplateVariable( - name = map["name"] as String, - description = map["description"] as String, - value = map["value"] as String, - placeholder = map["placeholder"] as String, - required = map["required"] as Boolean, - type = map["type"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index c3c6120..d31e853 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -8,8 +8,6 @@ import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie -import okhttp3.HttpUrl -import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File /** @@ -17,69 +15,6 @@ import java.io.File **/ class Functions(client: Client) : Service(client) { - /** - * Get function template - * - * Get a function template using ID. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method. - * - * @param templateId Template ID. - * @return [io.appwrite.models.TemplateFunction] - */ - suspend fun getTemplate( - templateId: String, - ): io.appwrite.models.TemplateFunction { - val apiPath = "/functions/templates/{templateId}" - .replace("{templateId}", templateId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.TemplateFunction = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.TemplateFunction.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.TemplateFunction::class.java, - converter, - ) - } - - - /** - * Download deployment - * - * Get a Deployment's contents by its unique ID. This endpoint supports range requests for partial or streaming file download. - * - * @param functionId Function ID. - * @param deploymentId Deployment ID. - * @return [ByteArray] - */ - suspend fun getDeploymentDownload( - functionId: String, - deploymentId: String, - ): ByteArray { - val apiPath = "/functions/{functionId}/deployments/{deploymentId}/download" - .replace("{functionId}", functionId) - .replace("{deploymentId}", deploymentId) - - val apiParams = mutableMapOf( - "project" to client.config["project"], - ) - return client.call( - "GET", - apiPath, - params = apiParams, - responseType = ByteArray::class.java - ) - } - - /** * List executions *