From 2216ab25d6840d239f4fced4bfb3a7064d47f146 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Aug 2024 11:18:09 +0000 Subject: [PATCH] chore: updates for appwrite 1.6.x --- .../java/functions/get-deployment-download.md | 2 +- docs/examples/java/functions/get-template.md | 22 --- .../functions/get-deployment-download.md | 2 +- .../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 -------- .../kotlin/io/appwrite/services/Functions.kt | 33 ---- 8 files changed, 2 insertions(+), 352 deletions(-) delete mode 100644 docs/examples/java/functions/get-template.md delete mode 100644 docs/examples/kotlin/functions/get-template.md delete mode 100644 src/main/kotlin/io/appwrite/models/TemplateFunction.kt delete mode 100644 src/main/kotlin/io/appwrite/models/TemplateRuntime.kt delete mode 100644 src/main/kotlin/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 index 405ca50..719d662 100644 --- a/docs/examples/java/functions/get-deployment-download.md +++ b/docs/examples/java/functions/get-deployment-download.md @@ -5,7 +5,7 @@ import io.appwrite.services.Functions; Client client = new Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID - .setSession(""); // The user session to authenticate with + .setKey(""); // Your secret API key Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/get-template.md b/docs/examples/java/functions/get-template.md deleted file mode 100644 index 1521fa4..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() - .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; - } - - System.out.println(result); - }) -); - diff --git a/docs/examples/kotlin/functions/get-deployment-download.md b/docs/examples/kotlin/functions/get-deployment-download.md index 229ccce..13dec6a 100644 --- a/docs/examples/kotlin/functions/get-deployment-download.md +++ b/docs/examples/kotlin/functions/get-deployment-download.md @@ -5,7 +5,7 @@ import io.appwrite.services.Functions val client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID - .setSession("") // The user session to authenticate with + .setKey("") // Your secret API key val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/get-template.md b/docs/examples/kotlin/functions/get-template.md deleted file mode 100644 index 53d838f..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() - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val functions = Functions(client) - -val response = functions.getTemplate( - templateId = "" -) diff --git a/src/main/kotlin/io/appwrite/models/TemplateFunction.kt b/src/main/kotlin/io/appwrite/models/TemplateFunction.kt deleted file mode 100644 index 3da1135..0000000 --- a/src/main/kotlin/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/src/main/kotlin/io/appwrite/models/TemplateRuntime.kt b/src/main/kotlin/io/appwrite/models/TemplateRuntime.kt deleted file mode 100644 index d354239..0000000 --- a/src/main/kotlin/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/src/main/kotlin/io/appwrite/models/TemplateVariable.kt b/src/main/kotlin/io/appwrite/models/TemplateVariable.kt deleted file mode 100644 index 96d6607..0000000 --- a/src/main/kotlin/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/src/main/kotlin/io/appwrite/services/Functions.kt b/src/main/kotlin/io/appwrite/services/Functions.kt index ec7d7e7..d0a98f5 100644 --- a/src/main/kotlin/io/appwrite/services/Functions.kt +++ b/src/main/kotlin/io/appwrite/services/Functions.kt @@ -209,39 +209,6 @@ 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] - */ - @Throws(AppwriteException::class) - 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 = { - io.appwrite.models.TemplateFunction.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.TemplateFunction::class.java, - converter, - ) - } - /** * Get function *