Skip to content

Commit 0ad70d0

Browse files
feat: 1.6.x
1 parent 49059ea commit 0ad70d0

File tree

271 files changed

+710
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+710
-449
lines changed

README.md

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

33
![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.5.6-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.5.7-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
99

10-
**This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
10+
**This SDK is compatible with Appwrite server version 1.6.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
1111

1212
> This is the Swift SDK for integrating with Appwrite from your Swift server-side code. If you're looking for the Apple SDK you should check [appwrite/sdk-for-apple](https://github.com/appwrite/sdk-for-apple)
1313

Sources/Appwrite/Client.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ open class Client {
386386
timeout: .seconds(30)
387387
)
388388

389+
if let warning = response.headers["x-appwrite-warning"].first {
390+
warning.split(separator: ";").forEach { warning in
391+
print("Warning: \(warning)")
392+
}
393+
}
394+
389395
switch response.status.code {
390396
case 0..<400:
391397
switch T.self {

Sources/Appwrite/Services/Account.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ open class Account: Service {
290290
///
291291
open func createJWT(
292292
) async throws -> AppwriteModels.Jwt {
293-
let apiPath: String = "/account/jwt"
293+
let apiPath: String = "/account/jwts"
294294

295295
let apiParams: [String: Any] = [:]
296296

@@ -443,7 +443,7 @@ open class Account: Service {
443443
///
444444
/// Verify an authenticator app after adding it using the [add
445445
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
446-
/// method. add
446+
/// method.
447447
///
448448
/// @param AppwriteEnums.AuthenticatorType type
449449
/// @param String otp
@@ -484,7 +484,7 @@ open class Account: Service {
484484
///
485485
/// Verify an authenticator app after adding it using the [add
486486
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
487-
/// method. add
487+
/// method.
488488
///
489489
/// @param AppwriteEnums.AuthenticatorType type
490490
/// @param String otp

Sources/Appwrite/Services/Functions.swift

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ open class Functions: Service {
6666
/// @param Bool logging
6767
/// @param String entrypoint
6868
/// @param String commands
69+
/// @param [String] scopes
6970
/// @param String installationId
7071
/// @param String providerRepositoryId
7172
/// @param String providerBranch
@@ -90,6 +91,7 @@ open class Functions: Service {
9091
logging: Bool? = nil,
9192
entrypoint: String? = nil,
9293
commands: String? = nil,
94+
scopes: [String]? = nil,
9395
installationId: String? = nil,
9496
providerRepositoryId: String? = nil,
9597
providerBranch: String? = nil,
@@ -114,6 +116,7 @@ open class Functions: Service {
114116
"logging": logging,
115117
"entrypoint": entrypoint,
116118
"commands": commands,
119+
"scopes": scopes,
117120
"installationId": installationId,
118121
"providerRepositoryId": providerRepositoryId,
119122
"providerBranch": providerBranch,
@@ -223,6 +226,7 @@ open class Functions: Service {
223226
/// @param Bool logging
224227
/// @param String entrypoint
225228
/// @param String commands
229+
/// @param [String] scopes
226230
/// @param String installationId
227231
/// @param String providerRepositoryId
228232
/// @param String providerBranch
@@ -243,6 +247,7 @@ open class Functions: Service {
243247
logging: Bool? = nil,
244248
entrypoint: String? = nil,
245249
commands: String? = nil,
250+
scopes: [String]? = nil,
246251
installationId: String? = nil,
247252
providerRepositoryId: String? = nil,
248253
providerBranch: String? = nil,
@@ -263,6 +268,7 @@ open class Functions: Service {
263268
"logging": logging,
264269
"entrypoint": entrypoint,
265270
"commands": commands,
271+
"scopes": scopes,
266272
"installationId": installationId,
267273
"providerRepositoryId": providerRepositoryId,
268274
"providerBranch": providerBranch,
@@ -526,10 +532,7 @@ open class Functions: Service {
526532
}
527533

528534
///
529-
/// Create build
530-
///
531-
/// Create a new build for an Appwrite Function deployment. This endpoint can
532-
/// be used to retry a failed build.
535+
/// Rebuild deployment
533536
///
534537
/// @param String functionId
535538
/// @param String deploymentId
@@ -540,14 +543,15 @@ open class Functions: Service {
540543
open func createBuild(
541544
functionId: String,
542545
deploymentId: String,
543-
buildId: String
546+
buildId: String? = nil
544547
) async throws -> Any {
545-
let apiPath: String = "/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}"
548+
let apiPath: String = "/functions/{functionId}/deployments/{deploymentId}/build"
546549
.replacingOccurrences(of: "{functionId}", with: functionId)
547550
.replacingOccurrences(of: "{deploymentId}", with: deploymentId)
548-
.replacingOccurrences(of: "{buildId}", with: buildId)
549551

550-
let apiParams: [String: Any] = [:]
552+
let apiParams: [String: Any?] = [
553+
"buildId": buildId
554+
]
551555

552556
let apiHeaders: [String: String] = [
553557
"content-type": "application/json"
@@ -560,6 +564,41 @@ open class Functions: Service {
560564
params: apiParams )
561565
}
562566

567+
///
568+
/// Cancel deployment
569+
///
570+
/// @param String functionId
571+
/// @param String deploymentId
572+
/// @throws Exception
573+
/// @return array
574+
///
575+
open func updateDeploymentBuild(
576+
functionId: String,
577+
deploymentId: String
578+
) async throws -> AppwriteModels.Build {
579+
let apiPath: String = "/functions/{functionId}/deployments/{deploymentId}/build"
580+
.replacingOccurrences(of: "{functionId}", with: functionId)
581+
.replacingOccurrences(of: "{deploymentId}", with: deploymentId)
582+
583+
let apiParams: [String: Any] = [:]
584+
585+
let apiHeaders: [String: String] = [
586+
"content-type": "application/json"
587+
]
588+
589+
let converter: (Any) -> AppwriteModels.Build = { response in
590+
return AppwriteModels.Build.from(map: response as! [String: Any])
591+
}
592+
593+
return try await client.call(
594+
method: "PATCH",
595+
path: apiPath,
596+
headers: apiHeaders,
597+
params: apiParams,
598+
converter: converter
599+
)
600+
}
601+
563602
///
564603
/// Download Deployment
565604
///
@@ -648,6 +687,7 @@ open class Functions: Service {
648687
/// @param String path
649688
/// @param AppwriteEnums.ExecutionMethod method
650689
/// @param Any headers
690+
/// @param String scheduledAt
651691
/// @throws Exception
652692
/// @return array
653693
///
@@ -657,7 +697,8 @@ open class Functions: Service {
657697
async: Bool? = nil,
658698
path: String? = nil,
659699
method: AppwriteEnums.ExecutionMethod? = nil,
660-
headers: Any? = nil
700+
headers: Any? = nil,
701+
scheduledAt: String? = nil
661702
) async throws -> AppwriteModels.Execution {
662703
let apiPath: String = "/functions/{functionId}/executions"
663704
.replacingOccurrences(of: "{functionId}", with: functionId)
@@ -667,7 +708,8 @@ open class Functions: Service {
667708
"async": async,
668709
"path": path,
669710
"method": method,
670-
"headers": headers
711+
"headers": headers,
712+
"scheduledAt": scheduledAt
671713
]
672714

673715
let apiHeaders: [String: String] = [
@@ -724,6 +766,38 @@ open class Functions: Service {
724766
)
725767
}
726768

769+
///
770+
/// Delete execution
771+
///
772+
/// Delete a function execution by its unique ID.
773+
///
774+
///
775+
/// @param String functionId
776+
/// @param String executionId
777+
/// @throws Exception
778+
/// @return array
779+
///
780+
open func deleteExecution(
781+
functionId: String,
782+
executionId: String
783+
) async throws -> Any {
784+
let apiPath: String = "/functions/{functionId}/executions/{executionId}"
785+
.replacingOccurrences(of: "{functionId}", with: functionId)
786+
.replacingOccurrences(of: "{executionId}", with: executionId)
787+
788+
let apiParams: [String: Any] = [:]
789+
790+
let apiHeaders: [String: String] = [
791+
"content-type": "application/json"
792+
]
793+
794+
return try await client.call(
795+
method: "DELETE",
796+
path: apiPath,
797+
headers: apiHeaders,
798+
params: apiParams )
799+
}
800+
727801
///
728802
/// List variables
729803
///

Sources/Appwrite/Services/Users.swift

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,49 @@ open class Users: Service {
962962
)
963963
}
964964

965+
///
966+
/// Create user JWT
967+
///
968+
/// Use this endpoint to create a JSON Web Token for user by its unique ID. You
969+
/// can use the resulting JWT to authenticate on behalf of the user. The JWT
970+
/// secret will become invalid if the session it uses gets deleted.
971+
///
972+
/// @param String userId
973+
/// @param String sessionId
974+
/// @param Int duration
975+
/// @throws Exception
976+
/// @return array
977+
///
978+
open func createJWT(
979+
userId: String,
980+
sessionId: String? = nil,
981+
duration: Int? = nil
982+
) async throws -> AppwriteModels.Jwt {
983+
let apiPath: String = "/users/{userId}/jwts"
984+
.replacingOccurrences(of: "{userId}", with: userId)
985+
986+
let apiParams: [String: Any?] = [
987+
"sessionId": sessionId,
988+
"duration": duration
989+
]
990+
991+
let apiHeaders: [String: String] = [
992+
"content-type": "application/json"
993+
]
994+
995+
let converter: (Any) -> AppwriteModels.Jwt = { response in
996+
return AppwriteModels.Jwt.from(map: response as! [String: Any])
997+
}
998+
999+
return try await client.call(
1000+
method: "POST",
1001+
path: apiPath,
1002+
headers: apiHeaders,
1003+
params: apiParams,
1004+
converter: converter
1005+
)
1006+
}
1007+
9651008
///
9661009
/// Update user labels
9671010
///

Sources/AppwriteEnums/Name.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public enum Name: String, Codable {
88
case v1Functions = "v1-functions"
99
case v1Usage = "v1-usage"
1010
case v1UsageDump = "v1-usage-dump"
11-
case webhooksv1 = "webhooksv1"
11+
case v1Webhooks = "v1-webhooks"
1212
case v1Certificates = "v1-certificates"
1313
case v1Builds = "v1-builds"
1414
case v1Messaging = "v1-messaging"

Sources/AppwriteEnums/Runtime.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public enum Runtime: String, Codable {
4646
case cpp17 = "cpp-17"
4747
case cpp20 = "cpp-20"
4848
case bun10 = "bun-1.0"
49+
case go122 = "go-1.22"
4950

5051
public func encode(to encoder: Encoder) throws {
5152
var container = encoder.singleValueContainer()

Sources/AppwriteModels/Build.swift

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import Foundation
2+
import JSONCodable
3+
4+
/// Build
5+
public class Build {
6+
7+
/// Build ID.
8+
public let id: String
9+
10+
/// The deployment that created this build.
11+
public let deploymentId: String
12+
13+
/// The build status. There are a few different types and each one means something different. \nFailed - The deployment build has failed. More details can usually be found in buildStderr\nReady - The deployment build was successful and the deployment is ready to be deployed\nProcessing - The deployment is currently waiting to have a build triggered\nBuilding - The deployment is currently being built
14+
public let status: String
15+
16+
/// The stdout of the build.
17+
public let stdout: String
18+
19+
/// The stderr of the build.
20+
public let stderr: String
21+
22+
/// The deployment creation date in ISO 8601 format.
23+
public let startTime: String
24+
25+
/// The time the build was finished in ISO 8601 format.
26+
public let endTime: String
27+
28+
/// The build duration in seconds.
29+
public let duration: Int
30+
31+
/// The code size in bytes.
32+
public let size: Int
33+
34+
35+
init(
36+
id: String,
37+
deploymentId: String,
38+
status: String,
39+
stdout: String,
40+
stderr: String,
41+
startTime: String,
42+
endTime: String,
43+
duration: Int,
44+
size: Int
45+
) {
46+
self.id = id
47+
self.deploymentId = deploymentId
48+
self.status = status
49+
self.stdout = stdout
50+
self.stderr = stderr
51+
self.startTime = startTime
52+
self.endTime = endTime
53+
self.duration = duration
54+
self.size = size
55+
}
56+
57+
public func toMap() -> [String: Any] {
58+
return [
59+
"$id": id as Any,
60+
"deploymentId": deploymentId as Any,
61+
"status": status as Any,
62+
"stdout": stdout as Any,
63+
"stderr": stderr as Any,
64+
"startTime": startTime as Any,
65+
"endTime": endTime as Any,
66+
"duration": duration as Any,
67+
"size": size as Any
68+
]
69+
}
70+
71+
public static func from(map: [String: Any] ) -> Build {
72+
return Build(
73+
id: map["$id"] as! String,
74+
deploymentId: map["deploymentId"] as! String,
75+
status: map["status"] as! String,
76+
stdout: map["stdout"] as! String,
77+
stderr: map["stderr"] as! String,
78+
startTime: map["startTime"] as! String,
79+
endTime: map["endTime"] as! String,
80+
duration: map["duration"] as! Int,
81+
size: map["size"] as! Int
82+
)
83+
}
84+
}

0 commit comments

Comments
 (0)