Merge pull request #57 from appwrite/dev

This commit is contained in:
Jake Barnby
2026-03-26 06:07:11 +00:00
committed by GitHub
41 changed files with 1177 additions and 224 deletions
+21
View File
@@ -1,5 +1,26 @@
# Change Log
## 16.0.0
* [BREAKING] Changed `$sequence` type from `Int` to `String` for `Row` and `Document` models
* [BREAKING] Renamed `IndexType` enum: split into `DatabasesIndexType` (for Databases) and `TablesDBIndexType` (for TablesDB)
* [BREAKING] Replaced `specification` parameter with `buildSpecification` and `runtimeSpecification` in `Functions.create()`, `Functions.update()`, `Sites.create()`, `Sites.update()`
* Added new `Project` service with full CRUD for project-level environment variables
* Added new `Webhooks` service with full CRUD for project webhooks (including `updateSignature`)
* Added `Webhook` and `WebhookList` models
* Added `Users.updateImpersonator()` method for enabling/disabling user impersonation
* Added impersonation support: `setImpersonateUserId()`, `setImpersonateUserEmail()`, `setImpersonateUserPhone()` on `Client`
* Added `impersonator` and `impersonatorUserId` optional fields to `User` model
* Added `deploymentRetention` parameter to Functions and Sites create/update
* Added `startCommand` parameter to Sites create/update
* Added `Documentsdb`, `Vectorsdb` values to `BackupServices` and `DatabaseType` enums
* Added `WebhooksRead`, `WebhooksWrite`, `ProjectRead`, `ProjectWrite` scopes
* Fixed `NIOFoundationCompat` import to be conditional with `#if canImport` for platform compatibility
* Fixed `ByteBuffer` to `Data` conversion to use `readableBytesView` throughout
* Removed `getQueueBillingProjectAggregation`, `getQueueBillingTeamAggregation`, `getQueuePriorityBuilds`, `getQueueRegionManager`, `getQueueThreats` from `Health` service
* Updated `Log` model field descriptions to clarify impersonation behavior
* Updated `X-Appwrite-Response-Format` header to `1.9.0`
## 15.2.0
* Added `getConsolePausing` health endpoint
+3 -3
View File
@@ -2,12 +2,12 @@
![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.9.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.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
**This SDK is compatible with Appwrite server version 1.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
> 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)
@@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:
```swift
dependencies: [
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "15.2.0"),
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "16.0.0"),
],
```
+54 -7
View File
@@ -1,6 +1,8 @@
import NIO
import NIOCore
#if canImport(NIOFoundationCompat)
import NIOFoundationCompat
#endif
import NIOSSL
import Foundation
import AsyncHTTPClient
@@ -22,8 +24,8 @@ open class Client {
"x-sdk-name": "Swift",
"x-sdk-platform": "server",
"x-sdk-language": "swift",
"x-sdk-version": "15.2.0",
"x-appwrite-response-format": "1.8.0"
"x-sdk-version": "16.0.0",
"x-appwrite-response-format": "1.9.0"
]
internal var config: [String: String] = [:]
@@ -175,6 +177,51 @@ open class Client {
return self
}
///
/// Set ImpersonateUserId
///
/// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.
///
/// @param String value
///
/// @return Client
///
open func setImpersonateUserId(_ value: String) -> Client {
config["impersonateuserid"] = value
_ = addHeader(key: "X-Appwrite-Impersonate-User-Id", value: value)
return self
}
///
/// Set ImpersonateUserEmail
///
/// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.
///
/// @param String value
///
/// @return Client
///
open func setImpersonateUserEmail(_ value: String) -> Client {
config["impersonateuseremail"] = value
_ = addHeader(key: "X-Appwrite-Impersonate-User-Email", value: value)
return self
}
///
/// Set ImpersonateUserPhone
///
/// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.
///
/// @param String value
///
/// @return Client
///
open func setImpersonateUserPhone(_ value: String) -> Client {
config["impersonateuserphone"] = value
_ = addHeader(key: "X-Appwrite-Impersonate-User-Phone", value: value)
return self
}
///
/// Set self signed
@@ -344,7 +391,7 @@ open class Client {
var responseString = ""
do {
let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any]
let dict = try JSONSerialization.jsonObject(with: Data(data.readableBytesView)) as? [String: Any]
message = dict?["message"] as? String ?? response.status.reasonPhrase
type = dict?["type"] as? String ?? ""
@@ -434,7 +481,7 @@ open class Client {
if data.readableBytes == 0 {
return true as! T
}
let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any]
let dict = try JSONSerialization.jsonObject(with: Data(data.readableBytesView)) as? [String: Any]
return converter?(dict!) ?? dict! as! T
}
@@ -444,7 +491,7 @@ open class Client {
var responseString = ""
do {
let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any]
let dict = try JSONSerialization.jsonObject(with: Data(data.readableBytesView)) as? [String: Any]
message = dict?["message"] as? String ?? response.status.reasonPhrase
type = dict?["type"] as? String ?? ""
@@ -476,9 +523,9 @@ open class Client {
switch(input.sourceType) {
case "path":
input.data = ByteBuffer(data: try! Data(contentsOf: URL(fileURLWithPath: input.path)))
input.data = ByteBuffer(bytes: try! Data(contentsOf: URL(fileURLWithPath: input.path)))
case "data":
input.data = ByteBuffer(data: input.data as! Data)
input.data = ByteBuffer(bytes: input.data as! Data)
default:
break
}
+2 -2
View File
@@ -3528,7 +3528,7 @@ open class Databases: Service {
/// - databaseId: String
/// - collectionId: String
/// - key: String
/// - type: AppwriteEnums.IndexType
/// - type: AppwriteEnums.DatabasesIndexType
/// - attributes: [String]
/// - orders: [AppwriteEnums.OrderBy] (optional)
/// - lengths: [Int] (optional)
@@ -3540,7 +3540,7 @@ open class Databases: Service {
databaseId: String,
collectionId: String,
key: String,
type: AppwriteEnums.IndexType,
type: AppwriteEnums.DatabasesIndexType,
attributes: [String],
orders: [AppwriteEnums.OrderBy]? = nil,
lengths: [Int]? = nil
+18 -6
View File
@@ -71,7 +71,9 @@ open class Functions: Service {
/// - providerBranch: String (optional)
/// - providerSilentMode: Bool (optional)
/// - providerRootDirectory: String (optional)
/// - specification: String (optional)
/// - buildSpecification: String (optional)
/// - runtimeSpecification: String (optional)
/// - deploymentRetention: Int (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Function
///
@@ -93,7 +95,9 @@ open class Functions: Service {
providerBranch: String? = nil,
providerSilentMode: Bool? = nil,
providerRootDirectory: String? = nil,
specification: String? = nil
buildSpecification: String? = nil,
runtimeSpecification: String? = nil,
deploymentRetention: Int? = nil
) async throws -> AppwriteModels.Function {
let apiPath: String = "/functions"
@@ -115,7 +119,9 @@ open class Functions: Service {
"providerBranch": providerBranch,
"providerSilentMode": providerSilentMode,
"providerRootDirectory": providerRootDirectory,
"specification": specification
"buildSpecification": buildSpecification,
"runtimeSpecification": runtimeSpecification,
"deploymentRetention": deploymentRetention
]
let apiHeaders: [String: String] = [
@@ -241,7 +247,9 @@ open class Functions: Service {
/// - providerBranch: String (optional)
/// - providerSilentMode: Bool (optional)
/// - providerRootDirectory: String (optional)
/// - specification: String (optional)
/// - buildSpecification: String (optional)
/// - runtimeSpecification: String (optional)
/// - deploymentRetention: Int (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Function
///
@@ -263,7 +271,9 @@ open class Functions: Service {
providerBranch: String? = nil,
providerSilentMode: Bool? = nil,
providerRootDirectory: String? = nil,
specification: String? = nil
buildSpecification: String? = nil,
runtimeSpecification: String? = nil,
deploymentRetention: Int? = nil
) async throws -> AppwriteModels.Function {
let apiPath: String = "/functions/{functionId}"
.replacingOccurrences(of: "{functionId}", with: functionId)
@@ -285,7 +295,9 @@ open class Functions: Service {
"providerBranch": providerBranch,
"providerSilentMode": providerSilentMode,
"providerRootDirectory": providerRootDirectory,
"specification": specification
"buildSpecification": buildSpecification,
"runtimeSpecification": runtimeSpecification,
"deploymentRetention": deploymentRetention
]
let apiHeaders: [String: String] = [
-160
View File
@@ -246,70 +246,6 @@ open class Health: Service {
)
}
///
/// Get billing project aggregation queue.
///
/// - Parameters:
/// - threshold: Int (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.HealthQueue
///
open func getQueueBillingProjectAggregation(
threshold: Int? = nil
) async throws -> AppwriteModels.HealthQueue {
let apiPath: String = "/health/queue/billing-project-aggregation"
let apiParams: [String: Any?] = [
"threshold": threshold
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.HealthQueue = { response in
return AppwriteModels.HealthQueue.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get billing team aggregation queue.
///
/// - Parameters:
/// - threshold: Int (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.HealthQueue
///
open func getQueueBillingTeamAggregation(
threshold: Int? = nil
) async throws -> AppwriteModels.HealthQueue {
let apiPath: String = "/health/queue/billing-team-aggregation"
let apiParams: [String: Any?] = [
"threshold": threshold
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.HealthQueue = { response in
return AppwriteModels.HealthQueue.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get the number of builds that are waiting to be processed in the Appwrite
/// internal queue server.
@@ -343,38 +279,6 @@ open class Health: Service {
)
}
///
/// Get the priority builds queue size.
///
/// - Parameters:
/// - threshold: Int (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.HealthQueue
///
open func getQueuePriorityBuilds(
threshold: Int? = nil
) async throws -> AppwriteModels.HealthQueue {
let apiPath: String = "/health/queue/builds-priority"
let apiParams: [String: Any?] = [
"threshold": threshold
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.HealthQueue = { response in
return AppwriteModels.HealthQueue.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get the number of certificates that are waiting to be issued against
/// [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue
@@ -679,38 +583,6 @@ open class Health: Service {
)
}
///
/// Get region manager queue.
///
/// - Parameters:
/// - threshold: Int (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.HealthQueue
///
open func getQueueRegionManager(
threshold: Int? = nil
) async throws -> AppwriteModels.HealthQueue {
let apiPath: String = "/health/queue/region-manager"
let apiParams: [String: Any?] = [
"threshold": threshold
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.HealthQueue = { response in
return AppwriteModels.HealthQueue.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get the number of metrics that are waiting to be processed in the Appwrite
/// stats resources queue.
@@ -777,38 +649,6 @@ open class Health: Service {
)
}
///
/// Get threats queue.
///
/// - Parameters:
/// - threshold: Int (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.HealthQueue
///
open func getQueueThreats(
threshold: Int? = nil
) async throws -> AppwriteModels.HealthQueue {
let apiPath: String = "/health/queue/threats"
let apiParams: [String: Any?] = [
"threshold": threshold
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.HealthQueue = { response in
return AppwriteModels.HealthQueue.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get the number of webhooks that are waiting to be processed in the Appwrite
/// internal queue server.
+192
View File
@@ -0,0 +1,192 @@
import AsyncHTTPClient
import Foundation
import NIO
import JSONCodable
import AppwriteEnums
import AppwriteModels
/// The Project service allows you to manage all the projects in your Appwrite server.
open class Project: Service {
///
/// Get a list of all project environment variables.
///
/// - Parameters:
/// - queries: [String] (optional)
/// - total: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.VariableList
///
open func listVariables(
queries: [String]? = nil,
total: Bool? = nil
) async throws -> AppwriteModels.VariableList {
let apiPath: String = "/project/variables"
let apiParams: [String: Any?] = [
"queries": queries,
"total": total
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.VariableList = { response in
return AppwriteModels.VariableList.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Create a new project environment variable. These variables can be accessed
/// by all functions and sites in the project.
///
/// - Parameters:
/// - variableId: String
/// - key: String
/// - value: String
/// - secret: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Variable
///
open func createVariable(
variableId: String,
key: String,
value: String,
secret: Bool? = nil
) async throws -> AppwriteModels.Variable {
let apiPath: String = "/project/variables"
let apiParams: [String: Any?] = [
"variableId": variableId,
"key": key,
"value": value,
"secret": secret
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.Variable = { response in
return AppwriteModels.Variable.from(map: response as! [String: Any])
}
return try await client.call(
method: "POST",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get a variable by its unique ID.
///
/// - Parameters:
/// - variableId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Variable
///
open func getVariable(
variableId: String
) async throws -> AppwriteModels.Variable {
let apiPath: String = "/project/variables/{variableId}"
.replacingOccurrences(of: "{variableId}", with: variableId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.Variable = { response in
return AppwriteModels.Variable.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Update variable by its unique ID.
///
/// - Parameters:
/// - variableId: String
/// - key: String (optional)
/// - value: String (optional)
/// - secret: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Variable
///
open func updateVariable(
variableId: String,
key: String? = nil,
value: String? = nil,
secret: Bool? = nil
) async throws -> AppwriteModels.Variable {
let apiPath: String = "/project/variables/{variableId}"
.replacingOccurrences(of: "{variableId}", with: variableId)
let apiParams: [String: Any?] = [
"key": key,
"value": value,
"secret": secret
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.Variable = { response in
return AppwriteModels.Variable.from(map: response as! [String: Any])
}
return try await client.call(
method: "PUT",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Delete a variable by its unique ID.
///
/// - Parameters:
/// - variableId: String
/// - Throws: Exception if the request fails
/// - Returns: Any
///
open func deleteVariable(
variableId: String
) async throws -> Any {
let apiPath: String = "/project/variables/{variableId}"
.replacingOccurrences(of: "{variableId}", with: variableId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
return try await client.call(
method: "DELETE",
path: apiPath,
headers: apiHeaders,
params: apiParams )
}
}
+24 -6
View File
@@ -60,6 +60,7 @@ open class Sites: Service {
/// - timeout: Int (optional)
/// - installCommand: String (optional)
/// - buildCommand: String (optional)
/// - startCommand: String (optional)
/// - outputDirectory: String (optional)
/// - adapter: AppwriteEnums.Adapter (optional)
/// - installationId: String (optional)
@@ -68,7 +69,9 @@ open class Sites: Service {
/// - providerBranch: String (optional)
/// - providerSilentMode: Bool (optional)
/// - providerRootDirectory: String (optional)
/// - specification: String (optional)
/// - buildSpecification: String (optional)
/// - runtimeSpecification: String (optional)
/// - deploymentRetention: Int (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Site
///
@@ -82,6 +85,7 @@ open class Sites: Service {
timeout: Int? = nil,
installCommand: String? = nil,
buildCommand: String? = nil,
startCommand: String? = nil,
outputDirectory: String? = nil,
adapter: AppwriteEnums.Adapter? = nil,
installationId: String? = nil,
@@ -90,7 +94,9 @@ open class Sites: Service {
providerBranch: String? = nil,
providerSilentMode: Bool? = nil,
providerRootDirectory: String? = nil,
specification: String? = nil
buildSpecification: String? = nil,
runtimeSpecification: String? = nil,
deploymentRetention: Int? = nil
) async throws -> AppwriteModels.Site {
let apiPath: String = "/sites"
@@ -103,6 +109,7 @@ open class Sites: Service {
"timeout": timeout,
"installCommand": installCommand,
"buildCommand": buildCommand,
"startCommand": startCommand,
"outputDirectory": outputDirectory,
"buildRuntime": buildRuntime,
"adapter": adapter,
@@ -112,7 +119,9 @@ open class Sites: Service {
"providerBranch": providerBranch,
"providerSilentMode": providerSilentMode,
"providerRootDirectory": providerRootDirectory,
"specification": specification
"buildSpecification": buildSpecification,
"runtimeSpecification": runtimeSpecification,
"deploymentRetention": deploymentRetention
]
let apiHeaders: [String: String] = [
@@ -230,6 +239,7 @@ open class Sites: Service {
/// - timeout: Int (optional)
/// - installCommand: String (optional)
/// - buildCommand: String (optional)
/// - startCommand: String (optional)
/// - outputDirectory: String (optional)
/// - buildRuntime: AppwriteEnums.BuildRuntime (optional)
/// - adapter: AppwriteEnums.Adapter (optional)
@@ -239,7 +249,9 @@ open class Sites: Service {
/// - providerBranch: String (optional)
/// - providerSilentMode: Bool (optional)
/// - providerRootDirectory: String (optional)
/// - specification: String (optional)
/// - buildSpecification: String (optional)
/// - runtimeSpecification: String (optional)
/// - deploymentRetention: Int (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Site
///
@@ -252,6 +264,7 @@ open class Sites: Service {
timeout: Int? = nil,
installCommand: String? = nil,
buildCommand: String? = nil,
startCommand: String? = nil,
outputDirectory: String? = nil,
buildRuntime: AppwriteEnums.BuildRuntime? = nil,
adapter: AppwriteEnums.Adapter? = nil,
@@ -261,7 +274,9 @@ open class Sites: Service {
providerBranch: String? = nil,
providerSilentMode: Bool? = nil,
providerRootDirectory: String? = nil,
specification: String? = nil
buildSpecification: String? = nil,
runtimeSpecification: String? = nil,
deploymentRetention: Int? = nil
) async throws -> AppwriteModels.Site {
let apiPath: String = "/sites/{siteId}"
.replacingOccurrences(of: "{siteId}", with: siteId)
@@ -274,6 +289,7 @@ open class Sites: Service {
"timeout": timeout,
"installCommand": installCommand,
"buildCommand": buildCommand,
"startCommand": startCommand,
"outputDirectory": outputDirectory,
"buildRuntime": buildRuntime,
"adapter": adapter,
@@ -283,7 +299,9 @@ open class Sites: Service {
"providerBranch": providerBranch,
"providerSilentMode": providerSilentMode,
"providerRootDirectory": providerRootDirectory,
"specification": specification
"buildSpecification": buildSpecification,
"runtimeSpecification": runtimeSpecification,
"deploymentRetention": deploymentRetention
]
let apiHeaders: [String: String] = [
+2 -2
View File
@@ -2529,7 +2529,7 @@ open class TablesDB: Service {
/// - databaseId: String
/// - tableId: String
/// - key: String
/// - type: AppwriteEnums.IndexType
/// - type: AppwriteEnums.TablesDBIndexType
/// - columns: [String]
/// - orders: [AppwriteEnums.OrderBy] (optional)
/// - lengths: [Int] (optional)
@@ -2540,7 +2540,7 @@ open class TablesDB: Service {
databaseId: String,
tableId: String,
key: String,
type: AppwriteEnums.IndexType,
type: AppwriteEnums.TablesDBIndexType,
columns: [String],
orders: [AppwriteEnums.OrderBy]? = nil,
lengths: [Int]? = nil
+68
View File
@@ -940,6 +940,74 @@ open class Users: Service {
)
}
///
/// Enable or disable whether a user can impersonate other users. When
/// impersonation headers are used, the request runs as the target user for API
/// behavior, while internal audit logs still attribute the action to the
/// original impersonator and store the impersonated target details only in
/// internal audit payload data.
///
///
/// - Parameters:
/// - userId: String
/// - impersonator: Bool
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.User<T>
///
open func updateImpersonator<T>(
userId: String,
impersonator: Bool,
nestedType: T.Type
) async throws -> AppwriteModels.User<T> {
let apiPath: String = "/users/{userId}/impersonator"
.replacingOccurrences(of: "{userId}", with: userId)
let apiParams: [String: Any?] = [
"impersonator": impersonator
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.User<T> = { response in
return AppwriteModels.User.from(map: response as! [String: Any])
}
return try await client.call(
method: "PATCH",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Enable or disable whether a user can impersonate other users. When
/// impersonation headers are used, the request runs as the target user for API
/// behavior, while internal audit logs still attribute the action to the
/// original impersonator and store the impersonated target details only in
/// internal audit payload data.
///
///
/// - Parameters:
/// - userId: String
/// - impersonator: Bool
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.User<T>
///
open func updateImpersonator(
userId: String,
impersonator: Bool
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
return try await updateImpersonator(
userId: userId,
impersonator: impersonator,
nestedType: [String: AnyCodable].self
)
}
///
/// Use this endpoint to create a JSON Web Token for user by its unique ID. You
/// can use the resulting JWT to authenticate on behalf of the user. The JWT
+255
View File
@@ -0,0 +1,255 @@
import AsyncHTTPClient
import Foundation
import NIO
import JSONCodable
import AppwriteEnums
import AppwriteModels
///
open class Webhooks: Service {
///
/// Get a list of all webhooks belonging to the project. You can use the query
/// params to filter your results.
///
/// - Parameters:
/// - queries: [String] (optional)
/// - total: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.WebhookList
///
open func list(
queries: [String]? = nil,
total: Bool? = nil
) async throws -> AppwriteModels.WebhookList {
let apiPath: String = "/webhooks"
let apiParams: [String: Any?] = [
"queries": queries,
"total": total
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.WebhookList = { response in
return AppwriteModels.WebhookList.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Create a new webhook. Use this endpoint to configure a URL that will
/// receive events from Appwrite when specific events occur.
///
/// - Parameters:
/// - webhookId: String
/// - url: String
/// - name: String
/// - events: [String]
/// - enabled: Bool (optional)
/// - security: Bool (optional)
/// - httpUser: String (optional)
/// - httpPass: String (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Webhook
///
open func create(
webhookId: String,
url: String,
name: String,
events: [String],
enabled: Bool? = nil,
security: Bool? = nil,
httpUser: String? = nil,
httpPass: String? = nil
) async throws -> AppwriteModels.Webhook {
let apiPath: String = "/webhooks"
let apiParams: [String: Any?] = [
"webhookId": webhookId,
"url": url,
"name": name,
"events": events,
"enabled": enabled,
"security": security,
"httpUser": httpUser,
"httpPass": httpPass
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.Webhook = { response in
return AppwriteModels.Webhook.from(map: response as! [String: Any])
}
return try await client.call(
method: "POST",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get a webhook by its unique ID. This endpoint returns details about a
/// specific webhook configured for a project.
///
/// - Parameters:
/// - webhookId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Webhook
///
open func get(
webhookId: String
) async throws -> AppwriteModels.Webhook {
let apiPath: String = "/webhooks/{webhookId}"
.replacingOccurrences(of: "{webhookId}", with: webhookId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.Webhook = { response in
return AppwriteModels.Webhook.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Update a webhook by its unique ID. Use this endpoint to update the URL,
/// events, or status of an existing webhook.
///
/// - Parameters:
/// - webhookId: String
/// - name: String
/// - url: String
/// - events: [String]
/// - enabled: Bool (optional)
/// - security: Bool (optional)
/// - httpUser: String (optional)
/// - httpPass: String (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Webhook
///
open func update(
webhookId: String,
name: String,
url: String,
events: [String],
enabled: Bool? = nil,
security: Bool? = nil,
httpUser: String? = nil,
httpPass: String? = nil
) async throws -> AppwriteModels.Webhook {
let apiPath: String = "/webhooks/{webhookId}"
.replacingOccurrences(of: "{webhookId}", with: webhookId)
let apiParams: [String: Any?] = [
"name": name,
"url": url,
"events": events,
"enabled": enabled,
"security": security,
"httpUser": httpUser,
"httpPass": httpPass
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.Webhook = { response in
return AppwriteModels.Webhook.from(map: response as! [String: Any])
}
return try await client.call(
method: "PUT",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Delete a webhook by its unique ID. Once deleted, the webhook will no longer
/// receive project events.
///
/// - Parameters:
/// - webhookId: String
/// - Throws: Exception if the request fails
/// - Returns: Any
///
open func delete(
webhookId: String
) async throws -> Any {
let apiPath: String = "/webhooks/{webhookId}"
.replacingOccurrences(of: "{webhookId}", with: webhookId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
return try await client.call(
method: "DELETE",
path: apiPath,
headers: apiHeaders,
params: apiParams )
}
///
/// Update the webhook signature key. This endpoint can be used to regenerate
/// the signature key used to sign and validate payload deliveries for a
/// specific webhook.
///
/// - Parameters:
/// - webhookId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Webhook
///
open func updateSignature(
webhookId: String
) async throws -> AppwriteModels.Webhook {
let apiPath: String = "/webhooks/{webhookId}/signature"
.replacingOccurrences(of: "{webhookId}", with: webhookId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.Webhook = { response in
return AppwriteModels.Webhook.from(map: response as! [String: Any])
}
return try await client.call(
method: "PATCH",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
}
@@ -2,6 +2,9 @@ import Foundation
public enum BackupServices: String, CustomStringConvertible {
case databases = "databases"
case tablesdb = "tablesdb"
case documentsdb = "documentsdb"
case vectorsdb = "vectorsdb"
case functions = "functions"
case storage = "storage"
+2
View File
@@ -3,6 +3,8 @@ import Foundation
public enum DatabaseType: String, CustomStringConvertible {
case legacy = "legacy"
case tablesdb = "tablesdb"
case documentsdb = "documentsdb"
case vectorsdb = "vectorsdb"
public var description: String {
return rawValue
@@ -0,0 +1,12 @@
import Foundation
public enum DatabasesIndexType: String, CustomStringConvertible {
case key = "key"
case fulltext = "fulltext"
case unique = "unique"
case spatial = "spatial"
public var description: String {
return rawValue
}
}
+4
View File
@@ -58,6 +58,10 @@ public enum Scopes: String, CustomStringConvertible {
case assistantRead = "assistant.read"
case tokensRead = "tokens.read"
case tokensWrite = "tokens.write"
case webhooksRead = "webhooks.read"
case webhooksWrite = "webhooks.write"
case projectRead = "project.read"
case projectWrite = "project.write"
case policiesWrite = "policies.write"
case policiesRead = "policies.read"
case archivesRead = "archives.read"
@@ -1,6 +1,6 @@
import Foundation
public enum IndexType: String, CustomStringConvertible {
public enum TablesDBIndexType: String, CustomStringConvertible {
case key = "key"
case fulltext = "fulltext"
case unique = "unique"
@@ -1,8 +1,8 @@
import Foundation
public enum TemplateReferenceType: String, CustomStringConvertible {
case branch = "branch"
case commit = "commit"
case branch = "branch"
case tag = "tag"
public var description: String {
+4 -4
View File
@@ -18,7 +18,7 @@ open class Document<T : Codable>: Codable {
/// Document ID.
public let id: String
/// Document sequence ID.
public let sequence: Int
public let sequence: String
/// Collection ID.
public let collectionId: String
/// Database ID.
@@ -34,7 +34,7 @@ open class Document<T : Codable>: Codable {
init(
id: String,
sequence: Int,
sequence: String,
collectionId: String,
databaseId: String,
createdAt: String,
@@ -56,7 +56,7 @@ open class Document<T : Codable>: Codable {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decode(String.self, forKey: .id)
self.sequence = try container.decode(Int.self, forKey: .sequence)
self.sequence = try container.decode(String.self, forKey: .sequence)
self.collectionId = try container.decode(String.self, forKey: .collectionId)
self.databaseId = try container.decode(String.self, forKey: .databaseId)
self.createdAt = try container.decode(String.self, forKey: .createdAt)
@@ -94,7 +94,7 @@ open class Document<T : Codable>: Codable {
public static func from(map: [String: Any] ) -> Document {
return Document(
id: map["$id"] as? String ?? "",
sequence: map["$sequence"] as? Int ?? 0,
sequence: map["$sequence"] as? String ?? "",
collectionId: map["$collectionId"] as? String ?? "",
databaseId: map["$databaseId"] as? String ?? "",
createdAt: map["$createdAt"] as? String ?? "",
+27 -9
View File
@@ -14,6 +14,7 @@ open class Function: Codable {
case live = "live"
case logging = "logging"
case runtime = "runtime"
case deploymentRetention = "deploymentRetention"
case deploymentId = "deploymentId"
case deploymentCreatedAt = "deploymentCreatedAt"
case latestDeploymentId = "latestDeploymentId"
@@ -32,7 +33,8 @@ open class Function: Codable {
case providerBranch = "providerBranch"
case providerRootDirectory = "providerRootDirectory"
case providerSilentMode = "providerSilentMode"
case specification = "specification"
case buildSpecification = "buildSpecification"
case runtimeSpecification = "runtimeSpecification"
}
/// Function ID.
@@ -53,6 +55,8 @@ open class Function: Codable {
public let logging: Bool
/// Function execution and build runtime.
public let runtime: String
/// How many days to keep the non-active deployments before they will be automatically deleted.
public let deploymentRetention: Int
/// Function&#039;s active deployment ID.
public let deploymentId: String
/// Active deployment creation date in ISO 8601 format.
@@ -89,8 +93,10 @@ open class Function: Codable {
public let providerRootDirectory: String
/// Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests
public let providerSilentMode: Bool
/// Machine specification for builds and executions.
public let specification: String
/// Machine specification for deployment builds.
public let buildSpecification: String
/// Machine specification for executions.
public let runtimeSpecification: String
init(
id: String,
@@ -102,6 +108,7 @@ open class Function: Codable {
live: Bool,
logging: Bool,
runtime: String,
deploymentRetention: Int,
deploymentId: String,
deploymentCreatedAt: String,
latestDeploymentId: String,
@@ -120,7 +127,8 @@ open class Function: Codable {
providerBranch: String,
providerRootDirectory: String,
providerSilentMode: Bool,
specification: String
buildSpecification: String,
runtimeSpecification: String
) {
self.id = id
self.createdAt = createdAt
@@ -131,6 +139,7 @@ open class Function: Codable {
self.live = live
self.logging = logging
self.runtime = runtime
self.deploymentRetention = deploymentRetention
self.deploymentId = deploymentId
self.deploymentCreatedAt = deploymentCreatedAt
self.latestDeploymentId = latestDeploymentId
@@ -149,7 +158,8 @@ open class Function: Codable {
self.providerBranch = providerBranch
self.providerRootDirectory = providerRootDirectory
self.providerSilentMode = providerSilentMode
self.specification = specification
self.buildSpecification = buildSpecification
self.runtimeSpecification = runtimeSpecification
}
public required init(from decoder: Decoder) throws {
@@ -164,6 +174,7 @@ open class Function: Codable {
self.live = try container.decode(Bool.self, forKey: .live)
self.logging = try container.decode(Bool.self, forKey: .logging)
self.runtime = try container.decode(String.self, forKey: .runtime)
self.deploymentRetention = try container.decode(Int.self, forKey: .deploymentRetention)
self.deploymentId = try container.decode(String.self, forKey: .deploymentId)
self.deploymentCreatedAt = try container.decode(String.self, forKey: .deploymentCreatedAt)
self.latestDeploymentId = try container.decode(String.self, forKey: .latestDeploymentId)
@@ -182,7 +193,8 @@ open class Function: Codable {
self.providerBranch = try container.decode(String.self, forKey: .providerBranch)
self.providerRootDirectory = try container.decode(String.self, forKey: .providerRootDirectory)
self.providerSilentMode = try container.decode(Bool.self, forKey: .providerSilentMode)
self.specification = try container.decode(String.self, forKey: .specification)
self.buildSpecification = try container.decode(String.self, forKey: .buildSpecification)
self.runtimeSpecification = try container.decode(String.self, forKey: .runtimeSpecification)
}
public func encode(to encoder: Encoder) throws {
@@ -197,6 +209,7 @@ open class Function: Codable {
try container.encode(live, forKey: .live)
try container.encode(logging, forKey: .logging)
try container.encode(runtime, forKey: .runtime)
try container.encode(deploymentRetention, forKey: .deploymentRetention)
try container.encode(deploymentId, forKey: .deploymentId)
try container.encode(deploymentCreatedAt, forKey: .deploymentCreatedAt)
try container.encode(latestDeploymentId, forKey: .latestDeploymentId)
@@ -215,7 +228,8 @@ open class Function: Codable {
try container.encode(providerBranch, forKey: .providerBranch)
try container.encode(providerRootDirectory, forKey: .providerRootDirectory)
try container.encode(providerSilentMode, forKey: .providerSilentMode)
try container.encode(specification, forKey: .specification)
try container.encode(buildSpecification, forKey: .buildSpecification)
try container.encode(runtimeSpecification, forKey: .runtimeSpecification)
}
public func toMap() -> [String: Any] {
@@ -229,6 +243,7 @@ open class Function: Codable {
"live": live as Any,
"logging": logging as Any,
"runtime": runtime as Any,
"deploymentRetention": deploymentRetention as Any,
"deploymentId": deploymentId as Any,
"deploymentCreatedAt": deploymentCreatedAt as Any,
"latestDeploymentId": latestDeploymentId as Any,
@@ -247,7 +262,8 @@ open class Function: Codable {
"providerBranch": providerBranch as Any,
"providerRootDirectory": providerRootDirectory as Any,
"providerSilentMode": providerSilentMode as Any,
"specification": specification as Any
"buildSpecification": buildSpecification as Any,
"runtimeSpecification": runtimeSpecification as Any
]
}
@@ -262,6 +278,7 @@ open class Function: Codable {
live: map["live"] as! Bool,
logging: map["logging"] as! Bool,
runtime: map["runtime"] as! String,
deploymentRetention: map["deploymentRetention"] as! Int,
deploymentId: map["deploymentId"] as! String,
deploymentCreatedAt: map["deploymentCreatedAt"] as! String,
latestDeploymentId: map["latestDeploymentId"] as! String,
@@ -280,7 +297,8 @@ open class Function: Codable {
providerBranch: map["providerBranch"] as! String,
providerRootDirectory: map["providerRootDirectory"] as! String,
providerSilentMode: map["providerSilentMode"] as! Bool,
specification: map["specification"] as! String
buildSpecification: map["buildSpecification"] as! String,
runtimeSpecification: map["runtimeSpecification"] as! String
)
}
}
+3 -3
View File
@@ -30,11 +30,11 @@ open class Log: Codable {
/// Event name.
public let event: String
/// User ID.
/// User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user.
public let userId: String
/// User Email.
/// User email of the actor recorded for this log. During impersonation, this is the original impersonator.
public let userEmail: String
/// User Name.
/// User name of the actor recorded for this log. During impersonation, this is the original impersonator.
public let userName: String
/// API mode when event triggered.
public let mode: String
+4 -4
View File
@@ -18,7 +18,7 @@ open class Row<T : Codable>: Codable {
/// Row ID.
public let id: String
/// Row sequence ID.
public let sequence: Int
public let sequence: String
/// Table ID.
public let tableId: String
/// Database ID.
@@ -34,7 +34,7 @@ open class Row<T : Codable>: Codable {
init(
id: String,
sequence: Int,
sequence: String,
tableId: String,
databaseId: String,
createdAt: String,
@@ -56,7 +56,7 @@ open class Row<T : Codable>: Codable {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decode(String.self, forKey: .id)
self.sequence = try container.decode(Int.self, forKey: .sequence)
self.sequence = try container.decode(String.self, forKey: .sequence)
self.tableId = try container.decode(String.self, forKey: .tableId)
self.databaseId = try container.decode(String.self, forKey: .databaseId)
self.createdAt = try container.decode(String.self, forKey: .createdAt)
@@ -94,7 +94,7 @@ open class Row<T : Codable>: Codable {
public static func from(map: [String: Any] ) -> Row {
return Row(
id: map["$id"] as! String,
sequence: map["$sequence"] as! Int,
sequence: map["$sequence"] as! String,
tableId: map["$tableId"] as! String,
databaseId: map["$databaseId"] as! String,
createdAt: map["$createdAt"] as! String,
+36 -9
View File
@@ -13,6 +13,7 @@ open class Site: Codable {
case live = "live"
case logging = "logging"
case framework = "framework"
case deploymentRetention = "deploymentRetention"
case deploymentId = "deploymentId"
case deploymentCreatedAt = "deploymentCreatedAt"
case deploymentScreenshotLight = "deploymentScreenshotLight"
@@ -24,13 +25,15 @@ open class Site: Codable {
case timeout = "timeout"
case installCommand = "installCommand"
case buildCommand = "buildCommand"
case startCommand = "startCommand"
case outputDirectory = "outputDirectory"
case installationId = "installationId"
case providerRepositoryId = "providerRepositoryId"
case providerBranch = "providerBranch"
case providerRootDirectory = "providerRootDirectory"
case providerSilentMode = "providerSilentMode"
case specification = "specification"
case buildSpecification = "buildSpecification"
case runtimeSpecification = "runtimeSpecification"
case buildRuntime = "buildRuntime"
case adapter = "adapter"
case fallbackFile = "fallbackFile"
@@ -52,6 +55,8 @@ open class Site: Codable {
public let logging: Bool
/// Site framework.
public let framework: String
/// How many days to keep the non-active deployments before they will be automatically deleted.
public let deploymentRetention: Int
/// Site&#039;s active deployment ID.
public let deploymentId: String
/// Active deployment creation date in ISO 8601 format.
@@ -74,6 +79,8 @@ open class Site: Codable {
public let installCommand: String
/// The build command used to build the site.
public let buildCommand: String
/// Custom command to use when starting site runtime.
public let startCommand: String
/// The directory where the site build output is located.
public let outputDirectory: String
/// Site VCS (Version Control System) installation id.
@@ -86,8 +93,10 @@ open class Site: Codable {
public let providerRootDirectory: String
/// Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests
public let providerSilentMode: Bool
/// Machine specification for builds and executions.
public let specification: String
/// Machine specification for deployment builds.
public let buildSpecification: String
/// Machine specification for SSR executions.
public let runtimeSpecification: String
/// Site build runtime.
public let buildRuntime: String
/// Site framework adapter.
@@ -104,6 +113,7 @@ open class Site: Codable {
live: Bool,
logging: Bool,
framework: String,
deploymentRetention: Int,
deploymentId: String,
deploymentCreatedAt: String,
deploymentScreenshotLight: String,
@@ -115,13 +125,15 @@ open class Site: Codable {
timeout: Int,
installCommand: String,
buildCommand: String,
startCommand: String,
outputDirectory: String,
installationId: String,
providerRepositoryId: String,
providerBranch: String,
providerRootDirectory: String,
providerSilentMode: Bool,
specification: String,
buildSpecification: String,
runtimeSpecification: String,
buildRuntime: String,
adapter: String,
fallbackFile: String
@@ -134,6 +146,7 @@ open class Site: Codable {
self.live = live
self.logging = logging
self.framework = framework
self.deploymentRetention = deploymentRetention
self.deploymentId = deploymentId
self.deploymentCreatedAt = deploymentCreatedAt
self.deploymentScreenshotLight = deploymentScreenshotLight
@@ -145,13 +158,15 @@ open class Site: Codable {
self.timeout = timeout
self.installCommand = installCommand
self.buildCommand = buildCommand
self.startCommand = startCommand
self.outputDirectory = outputDirectory
self.installationId = installationId
self.providerRepositoryId = providerRepositoryId
self.providerBranch = providerBranch
self.providerRootDirectory = providerRootDirectory
self.providerSilentMode = providerSilentMode
self.specification = specification
self.buildSpecification = buildSpecification
self.runtimeSpecification = runtimeSpecification
self.buildRuntime = buildRuntime
self.adapter = adapter
self.fallbackFile = fallbackFile
@@ -168,6 +183,7 @@ open class Site: Codable {
self.live = try container.decode(Bool.self, forKey: .live)
self.logging = try container.decode(Bool.self, forKey: .logging)
self.framework = try container.decode(String.self, forKey: .framework)
self.deploymentRetention = try container.decode(Int.self, forKey: .deploymentRetention)
self.deploymentId = try container.decode(String.self, forKey: .deploymentId)
self.deploymentCreatedAt = try container.decode(String.self, forKey: .deploymentCreatedAt)
self.deploymentScreenshotLight = try container.decode(String.self, forKey: .deploymentScreenshotLight)
@@ -179,13 +195,15 @@ open class Site: Codable {
self.timeout = try container.decode(Int.self, forKey: .timeout)
self.installCommand = try container.decode(String.self, forKey: .installCommand)
self.buildCommand = try container.decode(String.self, forKey: .buildCommand)
self.startCommand = try container.decode(String.self, forKey: .startCommand)
self.outputDirectory = try container.decode(String.self, forKey: .outputDirectory)
self.installationId = try container.decode(String.self, forKey: .installationId)
self.providerRepositoryId = try container.decode(String.self, forKey: .providerRepositoryId)
self.providerBranch = try container.decode(String.self, forKey: .providerBranch)
self.providerRootDirectory = try container.decode(String.self, forKey: .providerRootDirectory)
self.providerSilentMode = try container.decode(Bool.self, forKey: .providerSilentMode)
self.specification = try container.decode(String.self, forKey: .specification)
self.buildSpecification = try container.decode(String.self, forKey: .buildSpecification)
self.runtimeSpecification = try container.decode(String.self, forKey: .runtimeSpecification)
self.buildRuntime = try container.decode(String.self, forKey: .buildRuntime)
self.adapter = try container.decode(String.self, forKey: .adapter)
self.fallbackFile = try container.decode(String.self, forKey: .fallbackFile)
@@ -202,6 +220,7 @@ open class Site: Codable {
try container.encode(live, forKey: .live)
try container.encode(logging, forKey: .logging)
try container.encode(framework, forKey: .framework)
try container.encode(deploymentRetention, forKey: .deploymentRetention)
try container.encode(deploymentId, forKey: .deploymentId)
try container.encode(deploymentCreatedAt, forKey: .deploymentCreatedAt)
try container.encode(deploymentScreenshotLight, forKey: .deploymentScreenshotLight)
@@ -213,13 +232,15 @@ open class Site: Codable {
try container.encode(timeout, forKey: .timeout)
try container.encode(installCommand, forKey: .installCommand)
try container.encode(buildCommand, forKey: .buildCommand)
try container.encode(startCommand, forKey: .startCommand)
try container.encode(outputDirectory, forKey: .outputDirectory)
try container.encode(installationId, forKey: .installationId)
try container.encode(providerRepositoryId, forKey: .providerRepositoryId)
try container.encode(providerBranch, forKey: .providerBranch)
try container.encode(providerRootDirectory, forKey: .providerRootDirectory)
try container.encode(providerSilentMode, forKey: .providerSilentMode)
try container.encode(specification, forKey: .specification)
try container.encode(buildSpecification, forKey: .buildSpecification)
try container.encode(runtimeSpecification, forKey: .runtimeSpecification)
try container.encode(buildRuntime, forKey: .buildRuntime)
try container.encode(adapter, forKey: .adapter)
try container.encode(fallbackFile, forKey: .fallbackFile)
@@ -235,6 +256,7 @@ open class Site: Codable {
"live": live as Any,
"logging": logging as Any,
"framework": framework as Any,
"deploymentRetention": deploymentRetention as Any,
"deploymentId": deploymentId as Any,
"deploymentCreatedAt": deploymentCreatedAt as Any,
"deploymentScreenshotLight": deploymentScreenshotLight as Any,
@@ -246,13 +268,15 @@ open class Site: Codable {
"timeout": timeout as Any,
"installCommand": installCommand as Any,
"buildCommand": buildCommand as Any,
"startCommand": startCommand as Any,
"outputDirectory": outputDirectory as Any,
"installationId": installationId as Any,
"providerRepositoryId": providerRepositoryId as Any,
"providerBranch": providerBranch as Any,
"providerRootDirectory": providerRootDirectory as Any,
"providerSilentMode": providerSilentMode as Any,
"specification": specification as Any,
"buildSpecification": buildSpecification as Any,
"runtimeSpecification": runtimeSpecification as Any,
"buildRuntime": buildRuntime as Any,
"adapter": adapter as Any,
"fallbackFile": fallbackFile as Any
@@ -269,6 +293,7 @@ open class Site: Codable {
live: map["live"] as! Bool,
logging: map["logging"] as! Bool,
framework: map["framework"] as! String,
deploymentRetention: map["deploymentRetention"] as! Int,
deploymentId: map["deploymentId"] as! String,
deploymentCreatedAt: map["deploymentCreatedAt"] as! String,
deploymentScreenshotLight: map["deploymentScreenshotLight"] as! String,
@@ -280,13 +305,15 @@ open class Site: Codable {
timeout: map["timeout"] as! Int,
installCommand: map["installCommand"] as! String,
buildCommand: map["buildCommand"] as! String,
startCommand: map["startCommand"] as! String,
outputDirectory: map["outputDirectory"] as! String,
installationId: map["installationId"] as! String,
providerRepositoryId: map["providerRepositoryId"] as! String,
providerBranch: map["providerBranch"] as! String,
providerRootDirectory: map["providerRootDirectory"] as! String,
providerSilentMode: map["providerSilentMode"] as! Bool,
specification: map["specification"] as! String,
buildSpecification: map["buildSpecification"] as! String,
runtimeSpecification: map["runtimeSpecification"] as! String,
buildRuntime: map["buildRuntime"] as! String,
adapter: map["adapter"] as! String,
fallbackFile: map["fallbackFile"] as! String
+21 -3
View File
@@ -24,6 +24,8 @@ open class User<T : Codable>: Codable {
case prefs = "prefs"
case targets = "targets"
case accessedAt = "accessedAt"
case impersonator = "impersonator"
case impersonatorUserId = "impersonatorUserId"
}
/// User ID.
@@ -64,6 +66,10 @@ open class User<T : Codable>: Codable {
public let targets: [Target]
/// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours.
public let accessedAt: String
/// Whether the user can impersonate other users.
public let impersonator: Bool?
/// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data.
public let impersonatorUserId: String?
init(
id: String,
@@ -84,7 +90,9 @@ open class User<T : Codable>: Codable {
mfa: Bool,
prefs: Preferences<T>,
targets: [Target],
accessedAt: String
accessedAt: String,
impersonator: Bool?,
impersonatorUserId: String?
) {
self.id = id
self.createdAt = createdAt
@@ -105,6 +113,8 @@ open class User<T : Codable>: Codable {
self.prefs = prefs
self.targets = targets
self.accessedAt = accessedAt
self.impersonator = impersonator
self.impersonatorUserId = impersonatorUserId
}
public required init(from decoder: Decoder) throws {
@@ -129,6 +139,8 @@ open class User<T : Codable>: Codable {
self.prefs = try container.decode(Preferences<T>.self, forKey: .prefs)
self.targets = try container.decode([Target].self, forKey: .targets)
self.accessedAt = try container.decode(String.self, forKey: .accessedAt)
self.impersonator = try container.decodeIfPresent(Bool.self, forKey: .impersonator)
self.impersonatorUserId = try container.decodeIfPresent(String.self, forKey: .impersonatorUserId)
}
public func encode(to encoder: Encoder) throws {
@@ -153,6 +165,8 @@ open class User<T : Codable>: Codable {
try container.encode(prefs, forKey: .prefs)
try container.encode(targets, forKey: .targets)
try container.encode(accessedAt, forKey: .accessedAt)
try container.encodeIfPresent(impersonator, forKey: .impersonator)
try container.encodeIfPresent(impersonatorUserId, forKey: .impersonatorUserId)
}
public func toMap() -> [String: Any] {
@@ -175,7 +189,9 @@ open class User<T : Codable>: Codable {
"mfa": mfa as Any,
"prefs": prefs.toMap() as Any,
"targets": targets.map { $0.toMap() } as Any,
"accessedAt": accessedAt as Any
"accessedAt": accessedAt as Any,
"impersonator": impersonator as Any,
"impersonatorUserId": impersonatorUserId as Any
]
}
@@ -199,7 +215,9 @@ open class User<T : Codable>: Codable {
mfa: map["mfa"] as! Bool,
prefs: Preferences.from(map: map["prefs"] as! [String: Any]),
targets: (map["targets"] as! [[String: Any]]).map { Target.from(map: $0) },
accessedAt: map["accessedAt"] as! String
accessedAt: map["accessedAt"] as! String,
impersonator: map["impersonator"] as? Bool,
impersonatorUserId: map["impersonatorUserId"] as? String
)
}
}
+151
View File
@@ -0,0 +1,151 @@
import Foundation
import JSONCodable
/// Webhook
open class Webhook: Codable {
enum CodingKeys: String, CodingKey {
case id = "$id"
case createdAt = "$createdAt"
case updatedAt = "$updatedAt"
case name = "name"
case url = "url"
case events = "events"
case security = "security"
case httpUser = "httpUser"
case httpPass = "httpPass"
case signatureKey = "signatureKey"
case enabled = "enabled"
case logs = "logs"
case attempts = "attempts"
}
/// Webhook ID.
public let id: String
/// Webhook creation date in ISO 8601 format.
public let createdAt: String
/// Webhook update date in ISO 8601 format.
public let updatedAt: String
/// Webhook name.
public let name: String
/// Webhook URL endpoint.
public let url: String
/// Webhook trigger events.
public let events: [String]
/// Indicated if SSL / TLS Certificate verification is enabled.
public let security: Bool
/// HTTP basic authentication username.
public let httpUser: String
/// HTTP basic authentication password.
public let httpPass: String
/// Signature key which can be used to validated incoming
public let signatureKey: String
/// Indicates if this webhook is enabled.
public let enabled: Bool
/// Webhook error logs from the most recent failure.
public let logs: String
/// Number of consecutive failed webhook attempts.
public let attempts: Int
init(
id: String,
createdAt: String,
updatedAt: String,
name: String,
url: String,
events: [String],
security: Bool,
httpUser: String,
httpPass: String,
signatureKey: String,
enabled: Bool,
logs: String,
attempts: Int
) {
self.id = id
self.createdAt = createdAt
self.updatedAt = updatedAt
self.name = name
self.url = url
self.events = events
self.security = security
self.httpUser = httpUser
self.httpPass = httpPass
self.signatureKey = signatureKey
self.enabled = enabled
self.logs = logs
self.attempts = attempts
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decode(String.self, forKey: .id)
self.createdAt = try container.decode(String.self, forKey: .createdAt)
self.updatedAt = try container.decode(String.self, forKey: .updatedAt)
self.name = try container.decode(String.self, forKey: .name)
self.url = try container.decode(String.self, forKey: .url)
self.events = try container.decode([String].self, forKey: .events)
self.security = try container.decode(Bool.self, forKey: .security)
self.httpUser = try container.decode(String.self, forKey: .httpUser)
self.httpPass = try container.decode(String.self, forKey: .httpPass)
self.signatureKey = try container.decode(String.self, forKey: .signatureKey)
self.enabled = try container.decode(Bool.self, forKey: .enabled)
self.logs = try container.decode(String.self, forKey: .logs)
self.attempts = try container.decode(Int.self, forKey: .attempts)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(createdAt, forKey: .createdAt)
try container.encode(updatedAt, forKey: .updatedAt)
try container.encode(name, forKey: .name)
try container.encode(url, forKey: .url)
try container.encode(events, forKey: .events)
try container.encode(security, forKey: .security)
try container.encode(httpUser, forKey: .httpUser)
try container.encode(httpPass, forKey: .httpPass)
try container.encode(signatureKey, forKey: .signatureKey)
try container.encode(enabled, forKey: .enabled)
try container.encode(logs, forKey: .logs)
try container.encode(attempts, forKey: .attempts)
}
public func toMap() -> [String: Any] {
return [
"$id": id as Any,
"$createdAt": createdAt as Any,
"$updatedAt": updatedAt as Any,
"name": name as Any,
"url": url as Any,
"events": events as Any,
"security": security as Any,
"httpUser": httpUser as Any,
"httpPass": httpPass as Any,
"signatureKey": signatureKey as Any,
"enabled": enabled as Any,
"logs": logs as Any,
"attempts": attempts as Any
]
}
public static func from(map: [String: Any] ) -> Webhook {
return Webhook(
id: map["$id"] as! String,
createdAt: map["$createdAt"] as! String,
updatedAt: map["$updatedAt"] as! String,
name: map["name"] as! String,
url: map["url"] as! String,
events: map["events"] as! [String],
security: map["security"] as! Bool,
httpUser: map["httpUser"] as! String,
httpPass: map["httpPass"] as! String,
signatureKey: map["signatureKey"] as! String,
enabled: map["enabled"] as! Bool,
logs: map["logs"] as! String,
attempts: map["attempts"] as! Int
)
}
}
+52
View File
@@ -0,0 +1,52 @@
import Foundation
import JSONCodable
/// Webhooks List
open class WebhookList: Codable {
enum CodingKeys: String, CodingKey {
case total = "total"
case webhooks = "webhooks"
}
/// Total number of webhooks that matched your query.
public let total: Int
/// List of webhooks.
public let webhooks: [Webhook]
init(
total: Int,
webhooks: [Webhook]
) {
self.total = total
self.webhooks = webhooks
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.total = try container.decode(Int.self, forKey: .total)
self.webhooks = try container.decode([Webhook].self, forKey: .webhooks)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(total, forKey: .total)
try container.encode(webhooks, forKey: .webhooks)
}
public func toMap() -> [String: Any] {
return [
"total": total as Any,
"webhooks": webhooks.map { $0.toMap() } as Any
]
}
public static func from(map: [String: Any] ) -> WebhookList {
return WebhookList(
total: map["total"] as! Int,
webhooks: (map["webhooks"] as! [[String: Any]]).map { Webhook.from(map: $0) }
)
}
}
+3 -1
View File
@@ -27,7 +27,9 @@ let function = try await functions.create(
providerBranch: "<PROVIDER_BRANCH>", // optional
providerSilentMode: false, // optional
providerRootDirectory: "<PROVIDER_ROOT_DIRECTORY>", // optional
specification: "" // optional
buildSpecification: "", // optional
runtimeSpecification: "", // optional
deploymentRetention: 0 // optional
)
```
+3 -1
View File
@@ -27,7 +27,9 @@ let function = try await functions.update(
providerBranch: "<PROVIDER_BRANCH>", // optional
providerSilentMode: false, // optional
providerRootDirectory: "<PROVIDER_ROOT_DIRECTORY>", // optional
specification: "" // optional
buildSpecification: "", // optional
runtimeSpecification: "", // optional
deploymentRetention: 0 // optional
)
```
+18
View File
@@ -0,0 +1,18 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let project = Project(client)
let variable = try await project.createVariable(
variableId: "<VARIABLE_ID>",
key: "<KEY>",
value: "<VALUE>",
secret: false // optional
)
```
+15
View File
@@ -0,0 +1,15 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let project = Project(client)
let result = try await project.deleteVariable(
variableId: "<VARIABLE_ID>"
)
```
+15
View File
@@ -0,0 +1,15 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let project = Project(client)
let variable = try await project.getVariable(
variableId: "<VARIABLE_ID>"
)
```
+16
View File
@@ -0,0 +1,16 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let project = Project(client)
let variableList = try await project.listVariables(
queries: [], // optional
total: false // optional
)
```
+18
View File
@@ -0,0 +1,18 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let project = Project(client)
let variable = try await project.updateVariable(
variableId: "<VARIABLE_ID>",
key: "<KEY>", // optional
value: "<VALUE>", // optional
secret: false // optional
)
```
+4 -1
View File
@@ -19,6 +19,7 @@ let site = try await sites.create(
timeout: 1, // optional
installCommand: "<INSTALL_COMMAND>", // optional
buildCommand: "<BUILD_COMMAND>", // optional
startCommand: "<START_COMMAND>", // optional
outputDirectory: "<OUTPUT_DIRECTORY>", // optional
adapter: .static, // optional
installationId: "<INSTALLATION_ID>", // optional
@@ -27,7 +28,9 @@ let site = try await sites.create(
providerBranch: "<PROVIDER_BRANCH>", // optional
providerSilentMode: false, // optional
providerRootDirectory: "<PROVIDER_ROOT_DIRECTORY>", // optional
specification: "" // optional
buildSpecification: "", // optional
runtimeSpecification: "", // optional
deploymentRetention: 0 // optional
)
```
+4 -1
View File
@@ -18,6 +18,7 @@ let site = try await sites.update(
timeout: 1, // optional
installCommand: "<INSTALL_COMMAND>", // optional
buildCommand: "<BUILD_COMMAND>", // optional
startCommand: "<START_COMMAND>", // optional
outputDirectory: "<OUTPUT_DIRECTORY>", // optional
buildRuntime: .node145, // optional
adapter: .static, // optional
@@ -27,7 +28,9 @@ let site = try await sites.update(
providerBranch: "<PROVIDER_BRANCH>", // optional
providerSilentMode: false, // optional
providerRootDirectory: "<PROVIDER_ROOT_DIRECTORY>", // optional
specification: "" // optional
buildSpecification: "", // optional
runtimeSpecification: "", // optional
deploymentRetention: 0 // optional
)
```
@@ -0,0 +1,16 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let users = Users(client)
let user = try await users.updateImpersonator(
userId: "<USER_ID>",
impersonator: false
)
```
+22
View File
@@ -0,0 +1,22 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let webhooks = Webhooks(client)
let webhook = try await webhooks.create(
webhookId: "<WEBHOOK_ID>",
url: "",
name: "<NAME>",
events: [],
enabled: false, // optional
security: false, // optional
httpUser: "<HTTP_USER>", // optional
httpPass: "<HTTP_PASS>" // optional
)
```
+15
View File
@@ -0,0 +1,15 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let webhooks = Webhooks(client)
let result = try await webhooks.delete(
webhookId: "<WEBHOOK_ID>"
)
```
+15
View File
@@ -0,0 +1,15 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let webhooks = Webhooks(client)
let webhook = try await webhooks.get(
webhookId: "<WEBHOOK_ID>"
)
```
+16
View File
@@ -0,0 +1,16 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let webhooks = Webhooks(client)
let webhookList = try await webhooks.list(
queries: [], // optional
total: false // optional
)
```
@@ -0,0 +1,15 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let webhooks = Webhooks(client)
let webhook = try await webhooks.updateSignature(
webhookId: "<WEBHOOK_ID>"
)
```
+22
View File
@@ -0,0 +1,22 @@
```swift
import Appwrite
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key
let webhooks = Webhooks(client)
let webhook = try await webhooks.update(
webhookId: "<WEBHOOK_ID>",
name: "<NAME>",
url: "",
events: [],
enabled: false, // optional
security: false, // optional
httpUser: "<HTTP_USER>", // optional
httpPass: "<HTTP_PASS>" // optional
)
```