Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b1b2ad4

Browse files
committedAug 17, 2024·
chore: release rc
1 parent 945e31c commit b1b2ad4

22 files changed

+522
-35
lines changed
 

‎README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-kotlin.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-kotlin.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.5.7-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
88

@@ -39,7 +39,7 @@ repositories {
3939
Next, add the dependency to your project's `build.gradle(.kts)` file:
4040

4141
```groovy
42-
implementation("io.appwrite:sdk-for-kotlin:5.0.2")
42+
implementation("io.appwrite:sdk-for-kotlin:6.0.0-rc.1")
4343
```
4444

4545
### Maven
@@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file:
5050
<dependency>
5151
<groupId>io.appwrite</groupId>
5252
<artifactId>sdk-for-kotlin</artifactId>
53-
<version>5.0.2</version>
53+
<version>6.0.0-rc.1</version>
5454
</dependency>
5555
</dependencies>
5656
```

‎build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ext {
1818
POM_LICENSE_NAME = "GPL-3.0"
1919
POM_DEVELOPER_ID = 'appwrite'
2020
POM_DEVELOPER_NAME = 'Appwrite Team'
21-
POM_DEVELOPER_EMAIL = 'team@appwrite.io'
21+
POM_DEVELOPER_EMAIL = 'team@localhost.test'
2222
GITHUB_SCM_CONNECTION = 'scm:git:git://github.com/appwrite/sdk-for-kotlin.git'
2323
}
2424

‎docs/examples/java/account/delete-mfa-authenticator.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Account account = new Account(client);
1212

1313
account.deleteMfaAuthenticator(
1414
AuthenticatorType.TOTP, // type
15-
"<OTP>", // otp
1615
new CoroutineCallback<>((result, error) -> {
1716
if (error != null) {
1817
error.printStackTrace();

‎docs/examples/java/functions/create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ functions.create(
3131
"<TEMPLATE_REPOSITORY>", // templateRepository (optional)
3232
"<TEMPLATE_OWNER>", // templateOwner (optional)
3333
"<TEMPLATE_ROOT_DIRECTORY>", // templateRootDirectory (optional)
34-
"<TEMPLATE_BRANCH>", // templateBranch (optional)
34+
"<TEMPLATE_VERSION>", // templateVersion (optional)
3535
new CoroutineCallback<>((result, error) -> {
3636
if (error != null) {
3737
error.printStackTrace();

‎docs/examples/java/functions/download-deployment.md renamed to ‎docs/examples/java/functions/get-deployment-download.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import io.appwrite.services.Functions;
55
Client client = new Client()
66
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
77
.setProject("&lt;YOUR_PROJECT_ID&gt;") // Your project ID
8-
.setKey("&lt;YOUR_API_KEY&gt;"); // Your secret API key
8+
.setSession(""); // The user session to authenticate with
99

1010
Functions functions = new Functions(client);
1111

12-
functions.downloadDeployment(
12+
functions.getDeploymentDownload(
1313
"<FUNCTION_ID>", // functionId
1414
"<DEPLOYMENT_ID>", // deploymentId
1515
new CoroutineCallback<>((result, error) -> {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Functions;
4+
5+
Client client = new Client()
6+
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("&lt;YOUR_PROJECT_ID&gt;"); // Your project ID
8+
9+
Functions functions = new Functions(client);
10+
11+
functions.getTemplate(
12+
"<TEMPLATE_ID>", // templateId
13+
new CoroutineCallback<>((result, error) -> {
14+
if (error != null) {
15+
error.printStackTrace();
16+
return;
17+
}
18+
19+
System.out.println(result);
20+
})
21+
);
22+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Functions;
4+
5+
Client client = new Client()
6+
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("&lt;YOUR_PROJECT_ID&gt;"); // Your project ID
8+
9+
Functions functions = new Functions(client);
10+
11+
functions.listTemplates(
12+
listOf(), // runtimes (optional)
13+
listOf(), // useCases (optional)
14+
1, // limit (optional)
15+
0, // offset (optional)
16+
new CoroutineCallback<>((result, error) -> {
17+
if (error != null) {
18+
error.printStackTrace();
19+
return;
20+
}
21+
22+
System.out.println(result);
23+
})
24+
);
25+

‎docs/examples/kotlin/account/delete-mfa-authenticator.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ val client = Client()
1111
val account = Account(client)
1212

1313
val response = account.deleteMfaAuthenticator(
14-
type = AuthenticatorType.TOTP,
15-
otp = "<OTP>"
14+
type = AuthenticatorType.TOTP
1615
)

‎docs/examples/kotlin/functions/create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ val response = functions.create(
3131
templateRepository = "<TEMPLATE_REPOSITORY>", // optional
3232
templateOwner = "<TEMPLATE_OWNER>", // optional
3333
templateRootDirectory = "<TEMPLATE_ROOT_DIRECTORY>", // optional
34-
templateBranch = "<TEMPLATE_BRANCH>" // optional
34+
templateVersion = "<TEMPLATE_VERSION>" // optional
3535
)

‎docs/examples/kotlin/functions/download-deployment.md renamed to ‎docs/examples/kotlin/functions/get-deployment-download.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import io.appwrite.services.Functions
55
val client = Client()
66
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
77
.setProject("&lt;YOUR_PROJECT_ID&gt;") // Your project ID
8-
.setKey("&lt;YOUR_API_KEY&gt;") // Your secret API key
8+
.setSession("") // The user session to authenticate with
99

1010
val functions = Functions(client)
1111

12-
val result = functions.downloadDeployment(
12+
val result = functions.getDeploymentDownload(
1313
functionId = "<FUNCTION_ID>",
1414
deploymentId = "<DEPLOYMENT_ID>"
1515
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Functions
4+
5+
val client = Client()
6+
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("&lt;YOUR_PROJECT_ID&gt;") // Your project ID
8+
9+
val functions = Functions(client)
10+
11+
val response = functions.getTemplate(
12+
templateId = "<TEMPLATE_ID>"
13+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Functions
4+
5+
val client = Client()
6+
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("&lt;YOUR_PROJECT_ID&gt;") // Your project ID
8+
9+
val functions = Functions(client)
10+
11+
val response = functions.listTemplates(
12+
runtimes = listOf(), // optional
13+
useCases = listOf(), // optional
14+
limit = 1, // optional
15+
offset = 0 // optional
16+
)

‎src/main/kotlin/io/appwrite/Client.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ class Client @JvmOverloads constructor(
5757
init {
5858
headers = mutableMapOf(
5959
"content-type" to "application/json",
60-
"user-agent" to "AppwriteKotlinSDK/5.0.2 ${System.getProperty("http.agent")}",
60+
"user-agent" to "AppwriteKotlinSDK/6.0.0-rc.1 ${System.getProperty("http.agent")}",
6161
"x-sdk-name" to "Kotlin",
6262
"x-sdk-platform" to "server",
6363
"x-sdk-language" to "kotlin",
64-
"x-sdk-version" to "5.0.2",
65-
"x-appwrite-response-format" to "1.5.0",
64+
"x-sdk-version" to "6.0.0-rc.1",
65+
"x-appwrite-response-format" to "1.6.0",
6666
)
6767

6868
config = mutableMapOf()

‎src/main/kotlin/io/appwrite/models/Execution.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ data class Execution(
103103
@SerializedName("duration")
104104
val duration: Double,
105105

106+
/**
107+
* The scheduled time for execution. If left empty, execution will be queued immediately.
108+
*/
109+
@SerializedName("scheduledAt")
110+
var scheduledAt: String?,
111+
106112
) {
107113
fun toMap(): Map<String, Any> = mapOf(
108114
"\$id" to id as Any,
@@ -121,6 +127,7 @@ data class Execution(
121127
"logs" to logs as Any,
122128
"errors" to errors as Any,
123129
"duration" to duration as Any,
130+
"scheduledAt" to scheduledAt as Any,
124131
)
125132

126133
companion object {
@@ -145,6 +152,7 @@ data class Execution(
145152
logs = map["logs"] as String,
146153
errors = map["errors"] as String,
147154
duration = (map["duration"] as Number).toDouble(),
155+
scheduledAt = map["scheduledAt"] as? String?,
148156
)
149157
}
150158
}

‎src/main/kotlin/io/appwrite/models/Runtime.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ data class Runtime(
1313
@SerializedName("\$id")
1414
val id: String,
1515

16+
/**
17+
* Parent runtime key.
18+
*/
19+
@SerializedName("key")
20+
val key: String,
21+
1622
/**
1723
* Runtime Name.
1824
*/
@@ -52,6 +58,7 @@ data class Runtime(
5258
) {
5359
fun toMap(): Map<String, Any> = mapOf(
5460
"\$id" to id as Any,
61+
"key" to key as Any,
5562
"name" to name as Any,
5663
"version" to version as Any,
5764
"base" to base as Any,
@@ -67,6 +74,7 @@ data class Runtime(
6774
map: Map<String, Any>,
6875
) = Runtime(
6976
id = map["\$id"] as String,
77+
key = map["key"] as String,
7078
name = map["name"] as String,
7179
version = map["version"] as String,
7280
base = map["base"] as String,
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
package io.appwrite.models
2+
3+
import com.google.gson.annotations.SerializedName
4+
import io.appwrite.extensions.jsonCast
5+
6+
/**
7+
* Template Function
8+
*/
9+
data class TemplateFunction(
10+
/**
11+
* Function Template Icon.
12+
*/
13+
@SerializedName("icon")
14+
val icon: String,
15+
16+
/**
17+
* Function Template ID.
18+
*/
19+
@SerializedName("id")
20+
val id: String,
21+
22+
/**
23+
* Function Template Name.
24+
*/
25+
@SerializedName("name")
26+
val name: String,
27+
28+
/**
29+
* Function Template Tagline.
30+
*/
31+
@SerializedName("tagline")
32+
val tagline: String,
33+
34+
/**
35+
* Execution permissions.
36+
*/
37+
@SerializedName("permissions")
38+
val permissions: List<Any>,
39+
40+
/**
41+
* Function trigger events.
42+
*/
43+
@SerializedName("events")
44+
val events: List<Any>,
45+
46+
/**
47+
* Function execution schedult in CRON format.
48+
*/
49+
@SerializedName("cron")
50+
val cron: String,
51+
52+
/**
53+
* Function execution timeout in seconds.
54+
*/
55+
@SerializedName("timeout")
56+
val timeout: Long,
57+
58+
/**
59+
* Function use cases.
60+
*/
61+
@SerializedName("useCases")
62+
val useCases: List<Any>,
63+
64+
/**
65+
* List of runtimes that can be used with this template.
66+
*/
67+
@SerializedName("runtimes")
68+
val runtimes: List<TemplateRuntime>,
69+
70+
/**
71+
* Function Template Instructions.
72+
*/
73+
@SerializedName("instructions")
74+
val instructions: String,
75+
76+
/**
77+
* VCS (Version Control System) Provider.
78+
*/
79+
@SerializedName("vcsProvider")
80+
val vcsProvider: String,
81+
82+
/**
83+
* VCS (Version Control System) Repository ID
84+
*/
85+
@SerializedName("providerRepositoryId")
86+
val providerRepositoryId: String,
87+
88+
/**
89+
* VCS (Version Control System) Owner.
90+
*/
91+
@SerializedName("providerOwner")
92+
val providerOwner: String,
93+
94+
/**
95+
* VCS (Version Control System) branch version (tag).
96+
*/
97+
@SerializedName("providerVersion")
98+
val providerVersion: String,
99+
100+
/**
101+
* Function variables.
102+
*/
103+
@SerializedName("variables")
104+
val variables: List<TemplateVariable>,
105+
106+
/**
107+
* Function scopes.
108+
*/
109+
@SerializedName("scopes")
110+
val scopes: List<Any>,
111+
112+
) {
113+
fun toMap(): Map<String, Any> = mapOf(
114+
"icon" to icon as Any,
115+
"id" to id as Any,
116+
"name" to name as Any,
117+
"tagline" to tagline as Any,
118+
"permissions" to permissions as Any,
119+
"events" to events as Any,
120+
"cron" to cron as Any,
121+
"timeout" to timeout as Any,
122+
"useCases" to useCases as Any,
123+
"runtimes" to runtimes.map { it.toMap() } as Any,
124+
"instructions" to instructions as Any,
125+
"vcsProvider" to vcsProvider as Any,
126+
"providerRepositoryId" to providerRepositoryId as Any,
127+
"providerOwner" to providerOwner as Any,
128+
"providerVersion" to providerVersion as Any,
129+
"variables" to variables.map { it.toMap() } as Any,
130+
"scopes" to scopes as Any,
131+
)
132+
133+
companion object {
134+
135+
@Suppress("UNCHECKED_CAST")
136+
fun from(
137+
map: Map<String, Any>,
138+
) = TemplateFunction(
139+
icon = map["icon"] as String,
140+
id = map["id"] as String,
141+
name = map["name"] as String,
142+
tagline = map["tagline"] as String,
143+
permissions = map["permissions"] as List<Any>,
144+
events = map["events"] as List<Any>,
145+
cron = map["cron"] as String,
146+
timeout = (map["timeout"] as Number).toLong(),
147+
useCases = map["useCases"] as List<Any>,
148+
runtimes = (map["runtimes"] as List<Map<String, Any>>).map { TemplateRuntime.from(map = it) },
149+
instructions = map["instructions"] as String,
150+
vcsProvider = map["vcsProvider"] as String,
151+
providerRepositoryId = map["providerRepositoryId"] as String,
152+
providerOwner = map["providerOwner"] as String,
153+
providerVersion = map["providerVersion"] as String,
154+
variables = (map["variables"] as List<Map<String, Any>>).map { TemplateVariable.from(map = it) },
155+
scopes = map["scopes"] as List<Any>,
156+
)
157+
}
158+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.appwrite.models
2+
3+
import com.google.gson.annotations.SerializedName
4+
import io.appwrite.extensions.jsonCast
5+
6+
/**
7+
* Function Templates List
8+
*/
9+
data class TemplateFunctionList(
10+
/**
11+
* Total number of templates documents that matched your query.
12+
*/
13+
@SerializedName("total")
14+
val total: Long,
15+
16+
/**
17+
* List of templates.
18+
*/
19+
@SerializedName("templates")
20+
val templates: List<TemplateFunction>,
21+
22+
) {
23+
fun toMap(): Map<String, Any> = mapOf(
24+
"total" to total as Any,
25+
"templates" to templates.map { it.toMap() } as Any,
26+
)
27+
28+
companion object {
29+
30+
@Suppress("UNCHECKED_CAST")
31+
fun from(
32+
map: Map<String, Any>,
33+
) = TemplateFunctionList(
34+
total = (map["total"] as Number).toLong(),
35+
templates = (map["templates"] as List<Map<String, Any>>).map { TemplateFunction.from(map = it) },
36+
)
37+
}
38+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package io.appwrite.models
2+
3+
import com.google.gson.annotations.SerializedName
4+
import io.appwrite.extensions.jsonCast
5+
6+
/**
7+
* Template Runtime
8+
*/
9+
data class TemplateRuntime(
10+
/**
11+
* Runtime Name.
12+
*/
13+
@SerializedName("name")
14+
val name: String,
15+
16+
/**
17+
* The build command used to build the deployment.
18+
*/
19+
@SerializedName("commands")
20+
val commands: String,
21+
22+
/**
23+
* The entrypoint file used to execute the deployment.
24+
*/
25+
@SerializedName("entrypoint")
26+
val entrypoint: String,
27+
28+
/**
29+
* Path to function in VCS (Version Control System) repository
30+
*/
31+
@SerializedName("providerRootDirectory")
32+
val providerRootDirectory: String,
33+
34+
) {
35+
fun toMap(): Map<String, Any> = mapOf(
36+
"name" to name as Any,
37+
"commands" to commands as Any,
38+
"entrypoint" to entrypoint as Any,
39+
"providerRootDirectory" to providerRootDirectory as Any,
40+
)
41+
42+
companion object {
43+
44+
@Suppress("UNCHECKED_CAST")
45+
fun from(
46+
map: Map<String, Any>,
47+
) = TemplateRuntime(
48+
name = map["name"] as String,
49+
commands = map["commands"] as String,
50+
entrypoint = map["entrypoint"] as String,
51+
providerRootDirectory = map["providerRootDirectory"] as String,
52+
)
53+
}
54+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package io.appwrite.models
2+
3+
import com.google.gson.annotations.SerializedName
4+
import io.appwrite.extensions.jsonCast
5+
6+
/**
7+
* Template Variable
8+
*/
9+
data class TemplateVariable(
10+
/**
11+
* Variable Name.
12+
*/
13+
@SerializedName("name")
14+
val name: String,
15+
16+
/**
17+
* Variable Description.
18+
*/
19+
@SerializedName("description")
20+
val description: String,
21+
22+
/**
23+
* Variable Value.
24+
*/
25+
@SerializedName("value")
26+
val value: String,
27+
28+
/**
29+
* Variable Placeholder.
30+
*/
31+
@SerializedName("placeholder")
32+
val placeholder: String,
33+
34+
/**
35+
* Is the variable required?
36+
*/
37+
@SerializedName("required")
38+
val required: Boolean,
39+
40+
/**
41+
* Variable Type.
42+
*/
43+
@SerializedName("type")
44+
val type: String,
45+
46+
) {
47+
fun toMap(): Map<String, Any> = mapOf(
48+
"name" to name as Any,
49+
"description" to description as Any,
50+
"value" to value as Any,
51+
"placeholder" to placeholder as Any,
52+
"required" to required as Any,
53+
"type" to type as Any,
54+
)
55+
56+
companion object {
57+
58+
@Suppress("UNCHECKED_CAST")
59+
fun from(
60+
map: Map<String, Any>,
61+
) = TemplateVariable(
62+
name = map["name"] as String,
63+
description = map["description"] as String,
64+
value = map["value"] as String,
65+
placeholder = map["placeholder"] as String,
66+
required = map["required"] as Boolean,
67+
type = map["type"] as String,
68+
)
69+
}
70+
}

‎src/main/kotlin/io/appwrite/services/Account.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ class Account(client: Client) : Service(client) {
361361
)
362362

363363
/**
364-
* Add Authenticator
364+
* Create Authenticator
365365
*
366366
* Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method.
367367
*
@@ -455,19 +455,16 @@ class Account(client: Client) : Service(client) {
455455
* Delete an authenticator for a user by ID.
456456
*
457457
* @param type Type of authenticator.
458-
* @param otp Valid verification token.
459458
* @return [Any]
460459
*/
461460
@Throws(AppwriteException::class)
462461
suspend fun deleteMfaAuthenticator(
463462
type: io.appwrite.enums.AuthenticatorType,
464-
otp: String,
465463
): Any {
466464
val apiPath = "/account/mfa/authenticators/{type}"
467465
.replace("{type}", type.value)
468466

469467
val apiParams = mutableMapOf<String, Any?>(
470-
"otp" to otp,
471468
)
472469
val apiHeaders = mutableMapOf(
473470
"content-type" to "application/json",
@@ -482,7 +479,7 @@ class Account(client: Client) : Service(client) {
482479
}
483480

484481
/**
485-
* Create 2FA Challenge
482+
* Create MFA Challenge
486483
*
487484
* Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method.
488485
*
@@ -1625,7 +1622,7 @@ class Account(client: Client) : Service(client) {
16251622
}
16261623

16271624
/**
1628-
* Create phone verification (confirmation)
1625+
* Update phone verification (confirmation)
16291626
*
16301627
* Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user&#039;s phone number to verify the user email ownership. If confirmed this route will return a 200 status code.
16311628
*

‎src/main/kotlin/io/appwrite/services/Avatars.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class Avatars(client: Client) : Service(client) {
9494
/**
9595
* Get favicon
9696
*
97-
* Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL.
97+
* Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL.This endpoint does not follow HTTP redirects.
9898
*
9999
* @param url Website URL which you want to fetch the favicon from.
100100
* @return [ByteArray]
@@ -160,7 +160,7 @@ class Avatars(client: Client) : Service(client) {
160160
/**
161161
* Get image from URL
162162
*
163-
* Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol.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 image at source quality. If dimensions are not specified, the default size of image returned is 400x400px.
163+
* Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol.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 image at source quality. If dimensions are not specified, the default size of image returned is 400x400px.This endpoint does not follow HTTP redirects.
164164
*
165165
* @param url Image URL which you want to crop.
166166
* @param width Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400.

‎src/main/kotlin/io/appwrite/services/Functions.kt

Lines changed: 91 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Functions(client: Client) : Service(client) {
7777
* @param templateRepository Repository name of the template.
7878
* @param templateOwner The name of the owner of the template.
7979
* @param templateRootDirectory Path to function code in the template repo.
80-
* @param templateBranch Production branch for the repo linked to the function template.
80+
* @param templateVersion Version (tag) for the repo linked to the function template.
8181
* @return [io.appwrite.models.Function]
8282
*/
8383
@JvmOverloads
@@ -103,7 +103,7 @@ class Functions(client: Client) : Service(client) {
103103
templateRepository: String? = null,
104104
templateOwner: String? = null,
105105
templateRootDirectory: String? = null,
106-
templateBranch: String? = null,
106+
templateVersion: String? = null,
107107
): io.appwrite.models.Function {
108108
val apiPath = "/functions"
109109

@@ -128,7 +128,7 @@ class Functions(client: Client) : Service(client) {
128128
"templateRepository" to templateRepository,
129129
"templateOwner" to templateOwner,
130130
"templateRootDirectory" to templateRootDirectory,
131-
"templateBranch" to templateBranch,
131+
"templateVersion" to templateVersion,
132132
)
133133
val apiHeaders = mutableMapOf(
134134
"content-type" to "application/json",
@@ -176,6 +176,82 @@ class Functions(client: Client) : Service(client) {
176176
)
177177
}
178178

179+
/**
180+
* List function templates
181+
*
182+
* List available function templates. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method.
183+
*
184+
* @param runtimes List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed.
185+
* @param useCases List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed.
186+
* @param limit Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.
187+
* @param offset Offset the list of returned templates. Maximum offset is 5000.
188+
* @return [io.appwrite.models.TemplateFunctionList]
189+
*/
190+
@JvmOverloads
191+
@Throws(AppwriteException::class)
192+
suspend fun listTemplates(
193+
runtimes: List<String>? = null,
194+
useCases: List<String>? = null,
195+
limit: Long? = null,
196+
offset: Long? = null,
197+
): io.appwrite.models.TemplateFunctionList {
198+
val apiPath = "/functions/templates"
199+
200+
val apiParams = mutableMapOf<String, Any?>(
201+
"runtimes" to runtimes,
202+
"useCases" to useCases,
203+
"limit" to limit,
204+
"offset" to offset,
205+
)
206+
val apiHeaders = mutableMapOf(
207+
"content-type" to "application/json",
208+
)
209+
val converter: (Any) -> io.appwrite.models.TemplateFunctionList = {
210+
io.appwrite.models.TemplateFunctionList.from(map = it as Map<String, Any>)
211+
}
212+
return client.call(
213+
"GET",
214+
apiPath,
215+
apiHeaders,
216+
apiParams,
217+
responseType = io.appwrite.models.TemplateFunctionList::class.java,
218+
converter,
219+
)
220+
}
221+
222+
/**
223+
* Get function template
224+
*
225+
* Get a function template using ID. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method.
226+
*
227+
* @param templateId Template ID.
228+
* @return [io.appwrite.models.TemplateFunction]
229+
*/
230+
@Throws(AppwriteException::class)
231+
suspend fun getTemplate(
232+
templateId: String,
233+
): io.appwrite.models.TemplateFunction {
234+
val apiPath = "/functions/templates/{templateId}"
235+
.replace("{templateId}", templateId)
236+
237+
val apiParams = mutableMapOf<String, Any?>(
238+
)
239+
val apiHeaders = mutableMapOf(
240+
"content-type" to "application/json",
241+
)
242+
val converter: (Any) -> io.appwrite.models.TemplateFunction = {
243+
io.appwrite.models.TemplateFunction.from(map = it as Map<String, Any>)
244+
}
245+
return client.call(
246+
"GET",
247+
apiPath,
248+
apiHeaders,
249+
apiParams,
250+
responseType = io.appwrite.models.TemplateFunction::class.java,
251+
converter,
252+
)
253+
}
254+
179255
/**
180256
* Get function
181257
*
@@ -326,7 +402,7 @@ class Functions(client: Client) : Service(client) {
326402
* Get a list of all the project&#039;s code deployments. You can use the query params to filter your results.
327403
*
328404
* @param functionId Function ID.
329-
* @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: size, buildId, activate, entrypoint, commands
405+
* @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: size, buildId, activate, entrypoint, commands, type, size
330406
* @param search Search term to filter your list results. Max length: 256 chars.
331407
* @return [io.appwrite.models.DeploymentList]
332408
*/
@@ -448,7 +524,7 @@ class Functions(client: Client) : Service(client) {
448524
}
449525

450526
/**
451-
* Update function deployment
527+
* Update deployment
452528
*
453529
* Update the function code deployment ID using the unique function ID. Use this endpoint to switch the code deployment that should be executed by the execution endpoint.
454530
*
@@ -588,7 +664,7 @@ class Functions(client: Client) : Service(client) {
588664
}
589665

590666
/**
591-
* Download Deployment
667+
* Download deployment
592668
*
593669
* Get a Deployment&#039;s contents by its unique ID. This endpoint supports range requests for partial or streaming file download.
594670
*
@@ -597,7 +673,7 @@ class Functions(client: Client) : Service(client) {
597673
* @return [ByteArray]
598674
*/
599675
@Throws(AppwriteException::class)
600-
suspend fun downloadDeployment(
676+
suspend fun getDeploymentDownload(
601677
functionId: String,
602678
deploymentId: String,
603679
): ByteArray {
@@ -669,7 +745,7 @@ class Functions(client: Client) : Service(client) {
669745
* @param path HTTP path of execution. Path can include query params. Default value is /
670746
* @param method HTTP method of execution. Default value is GET.
671747
* @param headers HTTP headers of execution. Defaults to empty.
672-
* @param scheduledAt Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.
748+
* @param scheduledAt Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes.
673749
* @return [io.appwrite.models.Execution]
674750
*/
675751
@JvmOverloads
@@ -682,6 +758,7 @@ class Functions(client: Client) : Service(client) {
682758
method: io.appwrite.enums.ExecutionMethod? = null,
683759
headers: Any? = null,
684760
scheduledAt: String? = null,
761+
onProgress: ((UploadProgress) -> Unit)? = null
685762
): io.appwrite.models.Execution {
686763
val apiPath = "/functions/{functionId}/executions"
687764
.replace("{functionId}", functionId)
@@ -695,18 +772,21 @@ class Functions(client: Client) : Service(client) {
695772
"scheduledAt" to scheduledAt,
696773
)
697774
val apiHeaders = mutableMapOf(
698-
"content-type" to "application/json",
775+
"content-type" to "multipart/form-data",
699776
)
700777
val converter: (Any) -> io.appwrite.models.Execution = {
701778
io.appwrite.models.Execution.from(map = it as Map<String, Any>)
702779
}
703-
return client.call(
704-
"POST",
780+
val idParamName: String? = null
781+
return client.chunkedUpload(
705782
apiPath,
706783
apiHeaders,
707784
apiParams,
708785
responseType = io.appwrite.models.Execution::class.java,
709786
converter,
787+
paramName,
788+
idParamName,
789+
onProgress,
710790
)
711791
}
712792

0 commit comments

Comments
 (0)
Please sign in to comment.