add backups service

This commit is contained in:
root
2026-02-12 08:31:12 +00:00
parent 7f367055cc
commit 5c79ff1f97
46 changed files with 2362 additions and 10 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
[![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 latest. 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)
+176
View File
@@ -303,6 +303,182 @@ open class Account: Service {
)
}
///
/// Get a list of all API keys from the current account.
///
/// - Parameters:
/// - total: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.KeyList
///
open func listKeys(
total: Bool? = nil
) async throws -> AppwriteModels.KeyList {
let apiPath: String = "/account/keys"
let apiParams: [String: Any?] = [
"total": total
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.KeyList = { response in
return AppwriteModels.KeyList.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Create a new account API key.
///
/// - Parameters:
/// - name: String
/// - scopes: [AppwriteEnums.Scopes]
/// - expire: String (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Key
///
open func createKey(
name: String,
scopes: [AppwriteEnums.Scopes],
expire: String? = nil
) async throws -> AppwriteModels.Key {
let apiPath: String = "/account/keys"
let apiParams: [String: Any?] = [
"name": name,
"scopes": scopes,
"expire": expire
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.Key = { response in
return AppwriteModels.Key.from(map: response as! [String: Any])
}
return try await client.call(
method: "POST",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get a key by its unique ID. This endpoint returns details about a specific
/// API key in your account including it's scopes.
///
/// - Parameters:
/// - keyId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Key
///
open func getKey(
keyId: String
) async throws -> AppwriteModels.Key {
let apiPath: String = "/account/keys/{keyId}"
.replacingOccurrences(of: "{keyId}", with: keyId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.Key = { response in
return AppwriteModels.Key.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Update a key by its unique ID. Use this endpoint to update the name,
/// scopes, or expiration time of an API key.
///
/// - Parameters:
/// - keyId: String
/// - name: String
/// - scopes: [AppwriteEnums.Scopes]
/// - expire: String (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Key
///
open func updateKey(
keyId: String,
name: String,
scopes: [AppwriteEnums.Scopes],
expire: String? = nil
) async throws -> AppwriteModels.Key {
let apiPath: String = "/account/keys/{keyId}"
.replacingOccurrences(of: "{keyId}", with: keyId)
let apiParams: [String: Any?] = [
"name": name,
"scopes": scopes,
"expire": expire
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.Key = { response in
return AppwriteModels.Key.from(map: response as! [String: Any])
}
return try await client.call(
method: "PUT",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Delete a key by its unique ID. Once deleted, the key can no longer be used
/// to authenticate API calls.
///
/// - Parameters:
/// - keyId: String
/// - Throws: Exception if the request fails
/// - Returns: Any
///
open func deleteKey(
keyId: String
) async throws -> Any {
let apiPath: String = "/account/keys/{keyId}"
.replacingOccurrences(of: "{keyId}", with: keyId)
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 )
}
///
/// Get the list of latest security activity logs for the currently logged in
/// user. Each log returns user IP address, location and date and time of log.
+433
View File
@@ -0,0 +1,433 @@
import AsyncHTTPClient
import Foundation
import NIO
import JSONCodable
import AppwriteEnums
import AppwriteModels
///
open class Backups: Service {
///
/// List all archives for a project.
///
/// - Parameters:
/// - queries: [String] (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupArchiveList
///
open func listArchives(
queries: [String]? = nil
) async throws -> AppwriteModels.BackupArchiveList {
let apiPath: String = "/backups/archives"
let apiParams: [String: Any?] = [
"queries": queries
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.BackupArchiveList = { response in
return AppwriteModels.BackupArchiveList.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Create a new archive asynchronously for a project.
///
/// - Parameters:
/// - services: [AppwriteEnums.BackupServices]
/// - resourceId: String (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupArchive
///
open func createArchive(
services: [AppwriteEnums.BackupServices],
resourceId: String? = nil
) async throws -> AppwriteModels.BackupArchive {
let apiPath: String = "/backups/archives"
let apiParams: [String: Any?] = [
"services": services,
"resourceId": resourceId
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.BackupArchive = { response in
return AppwriteModels.BackupArchive.from(map: response as! [String: Any])
}
return try await client.call(
method: "POST",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get a backup archive using it's ID.
///
/// - Parameters:
/// - archiveId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupArchive
///
open func getArchive(
archiveId: String
) async throws -> AppwriteModels.BackupArchive {
let apiPath: String = "/backups/archives/{archiveId}"
.replacingOccurrences(of: "{archiveId}", with: archiveId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.BackupArchive = { response in
return AppwriteModels.BackupArchive.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Delete an existing archive for a project.
///
/// - Parameters:
/// - archiveId: String
/// - Throws: Exception if the request fails
/// - Returns: Any
///
open func deleteArchive(
archiveId: String
) async throws -> Any {
let apiPath: String = "/backups/archives/{archiveId}"
.replacingOccurrences(of: "{archiveId}", with: archiveId)
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 )
}
///
/// List all policies for a project.
///
/// - Parameters:
/// - queries: [String] (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupPolicyList
///
open func listPolicies(
queries: [String]? = nil
) async throws -> AppwriteModels.BackupPolicyList {
let apiPath: String = "/backups/policies"
let apiParams: [String: Any?] = [
"queries": queries
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.BackupPolicyList = { response in
return AppwriteModels.BackupPolicyList.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Create a new backup policy.
///
/// - Parameters:
/// - policyId: String
/// - services: [AppwriteEnums.BackupServices]
/// - retention: Int
/// - schedule: String
/// - name: String (optional)
/// - resourceId: String (optional)
/// - enabled: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupPolicy
///
open func createPolicy(
policyId: String,
services: [AppwriteEnums.BackupServices],
retention: Int,
schedule: String,
name: String? = nil,
resourceId: String? = nil,
enabled: Bool? = nil
) async throws -> AppwriteModels.BackupPolicy {
let apiPath: String = "/backups/policies"
let apiParams: [String: Any?] = [
"policyId": policyId,
"name": name,
"services": services,
"resourceId": resourceId,
"enabled": enabled,
"retention": retention,
"schedule": schedule
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.BackupPolicy = { response in
return AppwriteModels.BackupPolicy.from(map: response as! [String: Any])
}
return try await client.call(
method: "POST",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get a backup policy using it's ID.
///
/// - Parameters:
/// - policyId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupPolicy
///
open func getPolicy(
policyId: String
) async throws -> AppwriteModels.BackupPolicy {
let apiPath: String = "/backups/policies/{policyId}"
.replacingOccurrences(of: "{policyId}", with: policyId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.BackupPolicy = { response in
return AppwriteModels.BackupPolicy.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Update an existing policy using it's ID.
///
/// - Parameters:
/// - policyId: String
/// - name: String (optional)
/// - retention: Int (optional)
/// - schedule: String (optional)
/// - enabled: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupPolicy
///
open func updatePolicy(
policyId: String,
name: String? = nil,
retention: Int? = nil,
schedule: String? = nil,
enabled: Bool? = nil
) async throws -> AppwriteModels.BackupPolicy {
let apiPath: String = "/backups/policies/{policyId}"
.replacingOccurrences(of: "{policyId}", with: policyId)
let apiParams: [String: Any?] = [
"name": name,
"retention": retention,
"schedule": schedule,
"enabled": enabled
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.BackupPolicy = { response in
return AppwriteModels.BackupPolicy.from(map: response as! [String: Any])
}
return try await client.call(
method: "PATCH",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Delete a policy using it's ID.
///
/// - Parameters:
/// - policyId: String
/// - Throws: Exception if the request fails
/// - Returns: Any
///
open func deletePolicy(
policyId: String
) async throws -> Any {
let apiPath: String = "/backups/policies/{policyId}"
.replacingOccurrences(of: "{policyId}", with: policyId)
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 )
}
///
/// Create and trigger a new restoration for a backup on a project.
///
/// - Parameters:
/// - archiveId: String
/// - services: [AppwriteEnums.BackupServices]
/// - newResourceId: String (optional)
/// - newResourceName: String (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupRestoration
///
open func createRestoration(
archiveId: String,
services: [AppwriteEnums.BackupServices],
newResourceId: String? = nil,
newResourceName: String? = nil
) async throws -> AppwriteModels.BackupRestoration {
let apiPath: String = "/backups/restoration"
let apiParams: [String: Any?] = [
"archiveId": archiveId,
"services": services,
"newResourceId": newResourceId,
"newResourceName": newResourceName
]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.BackupRestoration = { response in
return AppwriteModels.BackupRestoration.from(map: response as! [String: Any])
}
return try await client.call(
method: "POST",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// List all backup restorations for a project.
///
/// - Parameters:
/// - queries: [String] (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupRestorationList
///
open func listRestorations(
queries: [String]? = nil
) async throws -> AppwriteModels.BackupRestorationList {
let apiPath: String = "/backups/restorations"
let apiParams: [String: Any?] = [
"queries": queries
]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.BackupRestorationList = { response in
return AppwriteModels.BackupRestorationList.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
///
/// Get the current status of a backup restoration.
///
/// - Parameters:
/// - restorationId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.BackupRestoration
///
open func getRestoration(
restorationId: String
) async throws -> AppwriteModels.BackupRestoration {
let apiPath: String = "/backups/restorations/{restorationId}"
.replacingOccurrences(of: "{restorationId}", with: restorationId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [:]
let converter: (Any) -> AppwriteModels.BackupRestoration = { response in
return AppwriteModels.BackupRestoration.from(map: response as! [String: Any])
}
return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
}
+160
View File
@@ -209,6 +209,70 @@ 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.
@@ -242,6 +306,38 @@ 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
@@ -546,6 +642,38 @@ 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.
@@ -612,6 +740,38 @@ 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.
@@ -0,0 +1,72 @@
import AsyncHTTPClient
import Foundation
import NIO
import JSONCodable
import AppwriteEnums
import AppwriteModels
///
open class Organizations: Service {
///
/// Delete an organization.
///
/// - Parameters:
/// - organizationId: String
/// - Throws: Exception if the request fails
/// - Returns: Any
///
open func delete(
organizationId: String
) async throws -> Any {
let apiPath: String = "/organizations/{organizationId}"
.replacingOccurrences(of: "{organizationId}", with: organizationId)
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 )
}
///
/// Get estimation for deleting an organization.
///
/// - Parameters:
/// - organizationId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.EstimationDeleteOrganization
///
open func estimationDeleteOrganization(
organizationId: String
) async throws -> AppwriteModels.EstimationDeleteOrganization {
let apiPath: String = "/organizations/{organizationId}/estimations/delete-organization"
.replacingOccurrences(of: "{organizationId}", with: organizationId)
let apiParams: [String: Any] = [:]
let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let converter: (Any) -> AppwriteModels.EstimationDeleteOrganization = { response in
return AppwriteModels.EstimationDeleteOrganization.from(map: response as! [String: Any])
}
return try await client.call(
method: "PATCH",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}
}
@@ -0,0 +1,11 @@
import Foundation
public enum BackupServices: String, CustomStringConvertible {
case databases = "databases"
case functions = "functions"
case storage = "storage"
public var description: String {
return rawValue
}
}
-3
View File
@@ -23,9 +23,6 @@ public enum BuildRuntime: String, CustomStringConvertible {
case python312 = "python-3.12"
case pythonMl311 = "python-ml-3.11"
case pythonMl312 = "python-ml-3.12"
case deno121 = "deno-1.21"
case deno124 = "deno-1.24"
case deno135 = "deno-1.35"
case deno140 = "deno-1.40"
case deno146 = "deno-1.46"
case deno20 = "deno-2.0"
@@ -40,6 +40,8 @@ public enum OAuthProvider: String, CustomStringConvertible {
case yandex = "yandex"
case zoho = "zoho"
case zoom = "zoom"
case githubImagine = "githubImagine"
case googleImagine = "googleImagine"
public var description: String {
return rawValue
-3
View File
@@ -23,9 +23,6 @@ public enum Runtime: String, CustomStringConvertible {
case python312 = "python-3.12"
case pythonMl311 = "python-ml-3.11"
case pythonMl312 = "python-ml-3.12"
case deno121 = "deno-1.21"
case deno124 = "deno-1.24"
case deno135 = "deno-1.35"
case deno140 = "deno-1.40"
case deno146 = "deno-1.46"
case deno20 = "deno-2.0"
+8
View File
@@ -56,6 +56,14 @@ public enum Scopes: String, CustomStringConvertible {
case assistantRead = "assistant.read"
case tokensRead = "tokens.read"
case tokensWrite = "tokens.write"
case policiesWrite = "policies.write"
case policiesRead = "policies.read"
case archivesRead = "archives.read"
case archivesWrite = "archives.write"
case restorationsRead = "restorations.read"
case restorationsWrite = "restorations.write"
case domainsRead = "domains.read"
case domainsWrite = "domains.write"
public var description: String {
return rawValue
+142
View File
@@ -0,0 +1,142 @@
import Foundation
import JSONCodable
/// Archive
open class BackupArchive: Codable {
enum CodingKeys: String, CodingKey {
case id = "$id"
case createdAt = "$createdAt"
case updatedAt = "$updatedAt"
case policyId = "policyId"
case size = "size"
case status = "status"
case startedAt = "startedAt"
case migrationId = "migrationId"
case services = "services"
case resources = "resources"
case resourceId = "resourceId"
case resourceType = "resourceType"
}
/// Archive ID.
public let id: String
/// Archive creation time in ISO 8601 format.
public let createdAt: String
/// Archive update date in ISO 8601 format.
public let updatedAt: String
/// Archive policy ID.
public let policyId: String
/// Archive size in bytes.
public let size: Int
/// The status of the archive creation. Possible values: pending, processing, uploading, completed, failed.
public let status: String
/// The backup start time.
public let startedAt: String
/// Migration ID.
public let migrationId: String
/// The services that are backed up by this archive.
public let services: [String]
/// The resources that are backed up by this archive.
public let resources: [String]
/// The resource ID to backup. Set only if this archive should backup a single resource.
public let resourceId: String?
/// The resource type to backup. Set only if this archive should backup a single resource.
public let resourceType: String?
init(
id: String,
createdAt: String,
updatedAt: String,
policyId: String,
size: Int,
status: String,
startedAt: String,
migrationId: String,
services: [String],
resources: [String],
resourceId: String?,
resourceType: String?
) {
self.id = id
self.createdAt = createdAt
self.updatedAt = updatedAt
self.policyId = policyId
self.size = size
self.status = status
self.startedAt = startedAt
self.migrationId = migrationId
self.services = services
self.resources = resources
self.resourceId = resourceId
self.resourceType = resourceType
}
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.policyId = try container.decode(String.self, forKey: .policyId)
self.size = try container.decode(Int.self, forKey: .size)
self.status = try container.decode(String.self, forKey: .status)
self.startedAt = try container.decode(String.self, forKey: .startedAt)
self.migrationId = try container.decode(String.self, forKey: .migrationId)
self.services = try container.decode([String].self, forKey: .services)
self.resources = try container.decode([String].self, forKey: .resources)
self.resourceId = try container.decodeIfPresent(String.self, forKey: .resourceId)
self.resourceType = try container.decodeIfPresent(String.self, forKey: .resourceType)
}
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(policyId, forKey: .policyId)
try container.encode(size, forKey: .size)
try container.encode(status, forKey: .status)
try container.encode(startedAt, forKey: .startedAt)
try container.encode(migrationId, forKey: .migrationId)
try container.encode(services, forKey: .services)
try container.encode(resources, forKey: .resources)
try container.encodeIfPresent(resourceId, forKey: .resourceId)
try container.encodeIfPresent(resourceType, forKey: .resourceType)
}
public func toMap() -> [String: Any] {
return [
"$id": id as Any,
"$createdAt": createdAt as Any,
"$updatedAt": updatedAt as Any,
"policyId": policyId as Any,
"size": size as Any,
"status": status as Any,
"startedAt": startedAt as Any,
"migrationId": migrationId as Any,
"services": services as Any,
"resources": resources as Any,
"resourceId": resourceId as Any,
"resourceType": resourceType as Any
]
}
public static func from(map: [String: Any] ) -> BackupArchive {
return BackupArchive(
id: map["$id"] as! String,
createdAt: map["$createdAt"] as! String,
updatedAt: map["$updatedAt"] as! String,
policyId: map["policyId"] as! String,
size: map["size"] as! Int,
status: map["status"] as! String,
startedAt: map["startedAt"] as! String,
migrationId: map["migrationId"] as! String,
services: map["services"] as! [String],
resources: map["resources"] as! [String],
resourceId: map["resourceId"] as? String,
resourceType: map["resourceType"] as? String
)
}
}
@@ -0,0 +1,52 @@
import Foundation
import JSONCodable
/// Backup archive list
open class BackupArchiveList: Codable {
enum CodingKeys: String, CodingKey {
case total = "total"
case archives = "archives"
}
/// Total number of archives that matched your query.
public let total: Int
/// List of archives.
public let archives: [BackupArchive]
init(
total: Int,
archives: [BackupArchive]
) {
self.total = total
self.archives = archives
}
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.archives = try container.decode([BackupArchive].self, forKey: .archives)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(total, forKey: .total)
try container.encode(archives, forKey: .archives)
}
public func toMap() -> [String: Any] {
return [
"total": total as Any,
"archives": archives.map { $0.toMap() } as Any
]
}
public static func from(map: [String: Any] ) -> BackupArchiveList {
return BackupArchiveList(
total: map["total"] as! Int,
archives: (map["archives"] as! [[String: Any]]).map { BackupArchive.from(map: $0) }
)
}
}
+133
View File
@@ -0,0 +1,133 @@
import Foundation
import JSONCodable
/// backup
open class BackupPolicy: Codable {
enum CodingKeys: String, CodingKey {
case id = "$id"
case name = "name"
case createdAt = "$createdAt"
case updatedAt = "$updatedAt"
case services = "services"
case resources = "resources"
case resourceId = "resourceId"
case resourceType = "resourceType"
case retention = "retention"
case schedule = "schedule"
case enabled = "enabled"
}
/// Backup policy ID.
public let id: String
/// Backup policy name.
public let name: String
/// Policy creation date in ISO 8601 format.
public let createdAt: String
/// Policy update date in ISO 8601 format.
public let updatedAt: String
/// The services that are backed up by this policy.
public let services: [String]
/// The resources that are backed up by this policy.
public let resources: [String]
/// The resource ID to backup. Set only if this policy should backup a single resource.
public let resourceId: String?
/// The resource type to backup. Set only if this policy should backup a single resource.
public let resourceType: String?
/// How many days to keep the backup before it will be automatically deleted.
public let retention: Int
/// Policy backup schedule in CRON format.
public let schedule: String
/// Is this policy enabled.
public let enabled: Bool
init(
id: String,
name: String,
createdAt: String,
updatedAt: String,
services: [String],
resources: [String],
resourceId: String?,
resourceType: String?,
retention: Int,
schedule: String,
enabled: Bool
) {
self.id = id
self.name = name
self.createdAt = createdAt
self.updatedAt = updatedAt
self.services = services
self.resources = resources
self.resourceId = resourceId
self.resourceType = resourceType
self.retention = retention
self.schedule = schedule
self.enabled = enabled
}
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.name = try container.decode(String.self, forKey: .name)
self.createdAt = try container.decode(String.self, forKey: .createdAt)
self.updatedAt = try container.decode(String.self, forKey: .updatedAt)
self.services = try container.decode([String].self, forKey: .services)
self.resources = try container.decode([String].self, forKey: .resources)
self.resourceId = try container.decodeIfPresent(String.self, forKey: .resourceId)
self.resourceType = try container.decodeIfPresent(String.self, forKey: .resourceType)
self.retention = try container.decode(Int.self, forKey: .retention)
self.schedule = try container.decode(String.self, forKey: .schedule)
self.enabled = try container.decode(Bool.self, forKey: .enabled)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
try container.encode(createdAt, forKey: .createdAt)
try container.encode(updatedAt, forKey: .updatedAt)
try container.encode(services, forKey: .services)
try container.encode(resources, forKey: .resources)
try container.encodeIfPresent(resourceId, forKey: .resourceId)
try container.encodeIfPresent(resourceType, forKey: .resourceType)
try container.encode(retention, forKey: .retention)
try container.encode(schedule, forKey: .schedule)
try container.encode(enabled, forKey: .enabled)
}
public func toMap() -> [String: Any] {
return [
"$id": id as Any,
"name": name as Any,
"$createdAt": createdAt as Any,
"$updatedAt": updatedAt as Any,
"services": services as Any,
"resources": resources as Any,
"resourceId": resourceId as Any,
"resourceType": resourceType as Any,
"retention": retention as Any,
"schedule": schedule as Any,
"enabled": enabled as Any
]
}
public static func from(map: [String: Any] ) -> BackupPolicy {
return BackupPolicy(
id: map["$id"] as! String,
name: map["name"] as! String,
createdAt: map["$createdAt"] as! String,
updatedAt: map["$updatedAt"] as! String,
services: map["services"] as! [String],
resources: map["resources"] as! [String],
resourceId: map["resourceId"] as? String,
resourceType: map["resourceType"] as? String,
retention: map["retention"] as! Int,
schedule: map["schedule"] as! String,
enabled: map["enabled"] as! Bool
)
}
}
@@ -0,0 +1,52 @@
import Foundation
import JSONCodable
/// Backup policy list
open class BackupPolicyList: Codable {
enum CodingKeys: String, CodingKey {
case total = "total"
case policies = "policies"
}
/// Total number of policies that matched your query.
public let total: Int
/// List of policies.
public let policies: [BackupPolicy]
init(
total: Int,
policies: [BackupPolicy]
) {
self.total = total
self.policies = policies
}
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.policies = try container.decode([BackupPolicy].self, forKey: .policies)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(total, forKey: .total)
try container.encode(policies, forKey: .policies)
}
public func toMap() -> [String: Any] {
return [
"total": total as Any,
"policies": policies.map { $0.toMap() } as Any
]
}
public static func from(map: [String: Any] ) -> BackupPolicyList {
return BackupPolicyList(
total: map["total"] as! Int,
policies: (map["policies"] as! [[String: Any]]).map { BackupPolicy.from(map: $0) }
)
}
}
@@ -0,0 +1,133 @@
import Foundation
import JSONCodable
/// Restoration
open class BackupRestoration: Codable {
enum CodingKeys: String, CodingKey {
case id = "$id"
case createdAt = "$createdAt"
case updatedAt = "$updatedAt"
case archiveId = "archiveId"
case policyId = "policyId"
case status = "status"
case startedAt = "startedAt"
case migrationId = "migrationId"
case services = "services"
case resources = "resources"
case options = "options"
}
/// Restoration ID.
public let id: String
/// Restoration creation time in ISO 8601 format.
public let createdAt: String
/// Restoration update date in ISO 8601 format.
public let updatedAt: String
/// Backup archive ID.
public let archiveId: String
/// Backup policy ID.
public let policyId: String
/// The status of the restoration. Possible values: pending, downloading, processing, completed, failed.
public let status: String
/// The backup start time.
public let startedAt: String
/// Migration ID.
public let migrationId: String
/// The services that are backed up by this policy.
public let services: [String]
/// The resources that are backed up by this policy.
public let resources: [String]
/// Optional data in key-value object.
public let options: String
init(
id: String,
createdAt: String,
updatedAt: String,
archiveId: String,
policyId: String,
status: String,
startedAt: String,
migrationId: String,
services: [String],
resources: [String],
options: String
) {
self.id = id
self.createdAt = createdAt
self.updatedAt = updatedAt
self.archiveId = archiveId
self.policyId = policyId
self.status = status
self.startedAt = startedAt
self.migrationId = migrationId
self.services = services
self.resources = resources
self.options = options
}
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.archiveId = try container.decode(String.self, forKey: .archiveId)
self.policyId = try container.decode(String.self, forKey: .policyId)
self.status = try container.decode(String.self, forKey: .status)
self.startedAt = try container.decode(String.self, forKey: .startedAt)
self.migrationId = try container.decode(String.self, forKey: .migrationId)
self.services = try container.decode([String].self, forKey: .services)
self.resources = try container.decode([String].self, forKey: .resources)
self.options = try container.decode(String.self, forKey: .options)
}
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(archiveId, forKey: .archiveId)
try container.encode(policyId, forKey: .policyId)
try container.encode(status, forKey: .status)
try container.encode(startedAt, forKey: .startedAt)
try container.encode(migrationId, forKey: .migrationId)
try container.encode(services, forKey: .services)
try container.encode(resources, forKey: .resources)
try container.encode(options, forKey: .options)
}
public func toMap() -> [String: Any] {
return [
"$id": id as Any,
"$createdAt": createdAt as Any,
"$updatedAt": updatedAt as Any,
"archiveId": archiveId as Any,
"policyId": policyId as Any,
"status": status as Any,
"startedAt": startedAt as Any,
"migrationId": migrationId as Any,
"services": services as Any,
"resources": resources as Any,
"options": options as Any
]
}
public static func from(map: [String: Any] ) -> BackupRestoration {
return BackupRestoration(
id: map["$id"] as! String,
createdAt: map["$createdAt"] as! String,
updatedAt: map["$updatedAt"] as! String,
archiveId: map["archiveId"] as! String,
policyId: map["policyId"] as! String,
status: map["status"] as! String,
startedAt: map["startedAt"] as! String,
migrationId: map["migrationId"] as! String,
services: map["services"] as! [String],
resources: map["resources"] as! [String],
options: map["options"] as! String
)
}
}
@@ -0,0 +1,52 @@
import Foundation
import JSONCodable
/// Backup restoration list
open class BackupRestorationList: Codable {
enum CodingKeys: String, CodingKey {
case total = "total"
case restorations = "restorations"
}
/// Total number of restorations that matched your query.
public let total: Int
/// List of restorations.
public let restorations: [BackupRestoration]
init(
total: Int,
restorations: [BackupRestoration]
) {
self.total = total
self.restorations = restorations
}
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.restorations = try container.decode([BackupRestoration].self, forKey: .restorations)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(total, forKey: .total)
try container.encode(restorations, forKey: .restorations)
}
public func toMap() -> [String: Any] {
return [
"total": total as Any,
"restorations": restorations.map { $0.toMap() } as Any
]
}
public static func from(map: [String: Any] ) -> BackupRestorationList {
return BackupRestorationList(
total: map["total"] as! Int,
restorations: (map["restorations"] as! [[String: Any]]).map { BackupRestoration.from(map: $0) }
)
}
}
+21 -3
View File
@@ -12,6 +12,8 @@ open class Database: Codable {
case updatedAt = "$updatedAt"
case enabled = "enabled"
case type = "type"
case policies = "policies"
case archives = "archives"
}
/// Database ID.
@@ -26,6 +28,10 @@ open class Database: Codable {
public let enabled: Bool
/// Database type.
public let type: AppwriteEnums.DatabaseType
/// Database backup policies.
public let policies: [Index]
/// Database backup archives.
public let archives: [Collection]
init(
id: String,
@@ -33,7 +39,9 @@ open class Database: Codable {
createdAt: String,
updatedAt: String,
enabled: Bool,
type: AppwriteEnums.DatabaseType
type: AppwriteEnums.DatabaseType,
policies: [Index],
archives: [Collection]
) {
self.id = id
self.name = name
@@ -41,6 +49,8 @@ open class Database: Codable {
self.updatedAt = updatedAt
self.enabled = enabled
self.type = type
self.policies = policies
self.archives = archives
}
public required init(from decoder: Decoder) throws {
@@ -52,6 +62,8 @@ open class Database: Codable {
self.updatedAt = try container.decode(String.self, forKey: .updatedAt)
self.enabled = try container.decode(Bool.self, forKey: .enabled)
self.type = AppwriteEnums.DatabaseType(rawValue: try container.decode(String.self, forKey: .type))!
self.policies = try container.decode([Index].self, forKey: .policies)
self.archives = try container.decode([Collection].self, forKey: .archives)
}
public func encode(to encoder: Encoder) throws {
@@ -63,6 +75,8 @@ open class Database: Codable {
try container.encode(updatedAt, forKey: .updatedAt)
try container.encode(enabled, forKey: .enabled)
try container.encode(type.rawValue, forKey: .type)
try container.encode(policies, forKey: .policies)
try container.encode(archives, forKey: .archives)
}
public func toMap() -> [String: Any] {
@@ -72,7 +86,9 @@ open class Database: Codable {
"$createdAt": createdAt as Any,
"$updatedAt": updatedAt as Any,
"enabled": enabled as Any,
"type": type.rawValue as Any
"type": type.rawValue as Any,
"policies": policies.map { $0.toMap() } as Any,
"archives": archives.map { $0.toMap() } as Any
]
}
@@ -83,7 +99,9 @@ open class Database: Codable {
createdAt: map["$createdAt"] as! String,
updatedAt: map["$updatedAt"] as! String,
enabled: map["enabled"] as! Bool,
type: DatabaseType(rawValue: map["type"] as! String)!
type: DatabaseType(rawValue: map["type"] as! String)!,
policies: (map["policies"] as! [[String: Any]]).map { Index.from(map: $0) },
archives: (map["archives"] as! [[String: Any]]).map { Collection.from(map: $0) }
)
}
}
@@ -0,0 +1,43 @@
import Foundation
import JSONCodable
/// EstimationDeleteOrganization
open class EstimationDeleteOrganization: Codable {
enum CodingKeys: String, CodingKey {
case unpaidInvoices = "unpaidInvoices"
}
/// List of unpaid invoices
public let unpaidInvoices: [Invoice]
init(
unpaidInvoices: [Invoice]
) {
self.unpaidInvoices = unpaidInvoices
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.unpaidInvoices = try container.decode([Invoice].self, forKey: .unpaidInvoices)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(unpaidInvoices, forKey: .unpaidInvoices)
}
public func toMap() -> [String: Any] {
return [
"unpaidInvoices": unpaidInvoices.map { $0.toMap() } as Any
]
}
public static func from(map: [String: Any] ) -> EstimationDeleteOrganization {
return EstimationDeleteOrganization(
unpaidInvoices: (map["unpaidInvoices"] as! [[String: Any]]).map { Invoice.from(map: $0) }
)
}
}
+232
View File
@@ -0,0 +1,232 @@
import Foundation
import JSONCodable
/// Invoice
open class Invoice: Codable {
enum CodingKeys: String, CodingKey {
case id = "$id"
case createdAt = "$createdAt"
case updatedAt = "$updatedAt"
case permissions = "$permissions"
case teamId = "teamId"
case aggregationId = "aggregationId"
case plan = "plan"
case usage = "usage"
case amount = "amount"
case tax = "tax"
case taxAmount = "taxAmount"
case vat = "vat"
case vatAmount = "vatAmount"
case grossAmount = "grossAmount"
case creditsUsed = "creditsUsed"
case currency = "currency"
case clientSecret = "clientSecret"
case status = "status"
case lastError = "lastError"
case dueAt = "dueAt"
case from = "from"
case to = "to"
}
/// Invoice ID.
public let id: String
/// Invoice creation time in ISO 8601 format.
public let createdAt: String
/// Invoice update date in ISO 8601 format.
public let updatedAt: String
/// Invoice permissions. [Learn more about permissions](/docs/permissions).
public let permissions: [String]
/// Project ID
public let teamId: String
/// Aggregation ID
public let aggregationId: String
/// Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`.
public let plan: String
/// Usage breakdown per resource
public let usage: [UsageResources]
/// Invoice Amount
public let amount: Double
/// Tax percentage
public let tax: Double
/// Tax amount
public let taxAmount: Double
/// VAT percentage
public let vat: Double
/// VAT amount
public let vatAmount: Double
/// Gross amount after vat, tax, and discounts applied.
public let grossAmount: Double
/// Credits used.
public let creditsUsed: Double
/// Currency the invoice is in
public let currency: String
/// Client secret for processing failed payments in front-end
public let clientSecret: String
/// Invoice status
public let status: String
/// Last payment error associated with the invoice
public let lastError: String
/// Invoice due date.
public let dueAt: String
/// Beginning date of the invoice
public let from: String
/// End date of the invoice
public let to: String
init(
id: String,
createdAt: String,
updatedAt: String,
permissions: [String],
teamId: String,
aggregationId: String,
plan: String,
usage: [UsageResources],
amount: Double,
tax: Double,
taxAmount: Double,
vat: Double,
vatAmount: Double,
grossAmount: Double,
creditsUsed: Double,
currency: String,
clientSecret: String,
status: String,
lastError: String,
dueAt: String,
from: String,
to: String
) {
self.id = id
self.createdAt = createdAt
self.updatedAt = updatedAt
self.permissions = permissions
self.teamId = teamId
self.aggregationId = aggregationId
self.plan = plan
self.usage = usage
self.amount = amount
self.tax = tax
self.taxAmount = taxAmount
self.vat = vat
self.vatAmount = vatAmount
self.grossAmount = grossAmount
self.creditsUsed = creditsUsed
self.currency = currency
self.clientSecret = clientSecret
self.status = status
self.lastError = lastError
self.dueAt = dueAt
self.from = from
self.to = to
}
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.permissions = try container.decode([String].self, forKey: .permissions)
self.teamId = try container.decode(String.self, forKey: .teamId)
self.aggregationId = try container.decode(String.self, forKey: .aggregationId)
self.plan = try container.decode(String.self, forKey: .plan)
self.usage = try container.decode([UsageResources].self, forKey: .usage)
self.amount = try container.decode(Double.self, forKey: .amount)
self.tax = try container.decode(Double.self, forKey: .tax)
self.taxAmount = try container.decode(Double.self, forKey: .taxAmount)
self.vat = try container.decode(Double.self, forKey: .vat)
self.vatAmount = try container.decode(Double.self, forKey: .vatAmount)
self.grossAmount = try container.decode(Double.self, forKey: .grossAmount)
self.creditsUsed = try container.decode(Double.self, forKey: .creditsUsed)
self.currency = try container.decode(String.self, forKey: .currency)
self.clientSecret = try container.decode(String.self, forKey: .clientSecret)
self.status = try container.decode(String.self, forKey: .status)
self.lastError = try container.decode(String.self, forKey: .lastError)
self.dueAt = try container.decode(String.self, forKey: .dueAt)
self.from = try container.decode(String.self, forKey: .from)
self.to = try container.decode(String.self, forKey: .to)
}
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(permissions, forKey: .permissions)
try container.encode(teamId, forKey: .teamId)
try container.encode(aggregationId, forKey: .aggregationId)
try container.encode(plan, forKey: .plan)
try container.encode(usage, forKey: .usage)
try container.encode(amount, forKey: .amount)
try container.encode(tax, forKey: .tax)
try container.encode(taxAmount, forKey: .taxAmount)
try container.encode(vat, forKey: .vat)
try container.encode(vatAmount, forKey: .vatAmount)
try container.encode(grossAmount, forKey: .grossAmount)
try container.encode(creditsUsed, forKey: .creditsUsed)
try container.encode(currency, forKey: .currency)
try container.encode(clientSecret, forKey: .clientSecret)
try container.encode(status, forKey: .status)
try container.encode(lastError, forKey: .lastError)
try container.encode(dueAt, forKey: .dueAt)
try container.encode(from, forKey: .from)
try container.encode(to, forKey: .to)
}
public func toMap() -> [String: Any] {
return [
"$id": id as Any,
"$createdAt": createdAt as Any,
"$updatedAt": updatedAt as Any,
"$permissions": permissions as Any,
"teamId": teamId as Any,
"aggregationId": aggregationId as Any,
"plan": plan as Any,
"usage": usage.map { $0.toMap() } as Any,
"amount": amount as Any,
"tax": tax as Any,
"taxAmount": taxAmount as Any,
"vat": vat as Any,
"vatAmount": vatAmount as Any,
"grossAmount": grossAmount as Any,
"creditsUsed": creditsUsed as Any,
"currency": currency as Any,
"clientSecret": clientSecret as Any,
"status": status as Any,
"lastError": lastError as Any,
"dueAt": dueAt as Any,
"from": from as Any,
"to": to as Any
]
}
public static func from(map: [String: Any] ) -> Invoice {
return Invoice(
id: map["$id"] as! String,
createdAt: map["$createdAt"] as! String,
updatedAt: map["$updatedAt"] as! String,
permissions: map["$permissions"] as! [String],
teamId: map["teamId"] as! String,
aggregationId: map["aggregationId"] as! String,
plan: map["plan"] as! String,
usage: (map["usage"] as! [[String: Any]]).map { UsageResources.from(map: $0) },
amount: map["amount"] as! Double,
tax: map["tax"] as! Double,
taxAmount: map["taxAmount"] as! Double,
vat: map["vat"] as! Double,
vatAmount: map["vatAmount"] as! Double,
grossAmount: map["grossAmount"] as! Double,
creditsUsed: map["creditsUsed"] as! Double,
currency: map["currency"] as! String,
clientSecret: map["clientSecret"] as! String,
status: map["status"] as! String,
lastError: map["lastError"] as! String,
dueAt: map["dueAt"] as! String,
from: map["from"] as! String,
to: map["to"] as! String
)
}
}
+115
View File
@@ -0,0 +1,115 @@
import Foundation
import JSONCodable
/// Key
open class Key: Codable {
enum CodingKeys: String, CodingKey {
case id = "$id"
case createdAt = "$createdAt"
case updatedAt = "$updatedAt"
case name = "name"
case expire = "expire"
case scopes = "scopes"
case secret = "secret"
case accessedAt = "accessedAt"
case sdks = "sdks"
}
/// Key ID.
public let id: String
/// Key creation date in ISO 8601 format.
public let createdAt: String
/// Key update date in ISO 8601 format.
public let updatedAt: String
/// Key name.
public let name: String
/// Key expiration date in ISO 8601 format.
public let expire: String
/// Allowed permission scopes.
public let scopes: [String]
/// Secret key.
public let secret: String
/// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours.
public let accessedAt: String
/// List of SDK user agents that used this key.
public let sdks: [String]
init(
id: String,
createdAt: String,
updatedAt: String,
name: String,
expire: String,
scopes: [String],
secret: String,
accessedAt: String,
sdks: [String]
) {
self.id = id
self.createdAt = createdAt
self.updatedAt = updatedAt
self.name = name
self.expire = expire
self.scopes = scopes
self.secret = secret
self.accessedAt = accessedAt
self.sdks = sdks
}
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.expire = try container.decode(String.self, forKey: .expire)
self.scopes = try container.decode([String].self, forKey: .scopes)
self.secret = try container.decode(String.self, forKey: .secret)
self.accessedAt = try container.decode(String.self, forKey: .accessedAt)
self.sdks = try container.decode([String].self, forKey: .sdks)
}
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(expire, forKey: .expire)
try container.encode(scopes, forKey: .scopes)
try container.encode(secret, forKey: .secret)
try container.encode(accessedAt, forKey: .accessedAt)
try container.encode(sdks, forKey: .sdks)
}
public func toMap() -> [String: Any] {
return [
"$id": id as Any,
"$createdAt": createdAt as Any,
"$updatedAt": updatedAt as Any,
"name": name as Any,
"expire": expire as Any,
"scopes": scopes as Any,
"secret": secret as Any,
"accessedAt": accessedAt as Any,
"sdks": sdks as Any
]
}
public static func from(map: [String: Any] ) -> Key {
return Key(
id: map["$id"] as! String,
createdAt: map["$createdAt"] as! String,
updatedAt: map["$updatedAt"] as! String,
name: map["name"] as! String,
expire: map["expire"] as! String,
scopes: map["scopes"] as! [String],
secret: map["secret"] as! String,
accessedAt: map["accessedAt"] as! String,
sdks: map["sdks"] as! [String]
)
}
}
+52
View File
@@ -0,0 +1,52 @@
import Foundation
import JSONCodable
/// API Keys List
open class KeyList: Codable {
enum CodingKeys: String, CodingKey {
case total = "total"
case keys = "keys"
}
/// Total number of keys that matched your query.
public let total: Int
/// List of keys.
public let keys: [Key]
init(
total: Int,
keys: [Key]
) {
self.total = total
self.keys = keys
}
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.keys = try container.decode([Key].self, forKey: .keys)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(total, forKey: .total)
try container.encode(keys, forKey: .keys)
}
public func toMap() -> [String: Any] {
return [
"total": total as Any,
"keys": keys.map { $0.toMap() } as Any
]
}
public static func from(map: [String: Any] ) -> KeyList {
return KeyList(
total: map["total"] as! Int,
keys: (map["keys"] as! [[String: Any]]).map { Key.from(map: $0) }
)
}
}
@@ -0,0 +1,88 @@
import Foundation
import JSONCodable
/// UsageResource
open class UsageResources: Codable {
enum CodingKeys: String, CodingKey {
case name = "name"
case value = "value"
case amount = "amount"
case rate = "rate"
case desc = "desc"
case resourceId = "resourceId"
}
/// Invoice name
public let name: String
/// Invoice value
public let value: Int
/// Invoice amount
public let amount: Double
/// Invoice rate
public let rate: Double
/// Invoice description
public let desc: String
/// Resource ID
public let resourceId: String
init(
name: String,
value: Int,
amount: Double,
rate: Double,
desc: String,
resourceId: String
) {
self.name = name
self.value = value
self.amount = amount
self.rate = rate
self.desc = desc
self.resourceId = resourceId
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.name = try container.decode(String.self, forKey: .name)
self.value = try container.decode(Int.self, forKey: .value)
self.amount = try container.decode(Double.self, forKey: .amount)
self.rate = try container.decode(Double.self, forKey: .rate)
self.desc = try container.decode(String.self, forKey: .desc)
self.resourceId = try container.decode(String.self, forKey: .resourceId)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(name, forKey: .name)
try container.encode(value, forKey: .value)
try container.encode(amount, forKey: .amount)
try container.encode(rate, forKey: .rate)
try container.encode(desc, forKey: .desc)
try container.encode(resourceId, forKey: .resourceId)
}
public func toMap() -> [String: Any] {
return [
"name": name as Any,
"value": value as Any,
"amount": amount as Any,
"rate": rate as Any,
"desc": desc as Any,
"resourceId": resourceId as Any
]
}
public static func from(map: [String: Any] ) -> UsageResources {
return UsageResources(
name: map["name"] as! String,
value: map["value"] as! Int,
amount: map["amount"] as! Double,
rate: map["rate"] as! Double,
desc: map["desc"] as! String,
resourceId: map["resourceId"] as! String
)
}
}
+18
View File
@@ -0,0 +1,18 @@
```swift
import Appwrite
import AppwriteEnums
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setSession("") // The user session to authenticate with
let account = Account(client)
let key = try await account.createKey(
name: "<NAME>",
scopes: [.account],
expire: "" // 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
.setSession("") // The user session to authenticate with
let account = Account(client)
let result = try await account.deleteKey(
keyId: "<KEY_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
.setSession("") // The user session to authenticate with
let account = Account(client)
let key = try await account.getKey(
keyId: "<KEY_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
.setSession("") // The user session to authenticate with
let account = Account(client)
let keyList = try await account.listKeys(
total: false // optional
)
```
+19
View File
@@ -0,0 +1,19 @@
```swift
import Appwrite
import AppwriteEnums
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setSession("") // The user session to authenticate with
let account = Account(client)
let key = try await account.updateKey(
keyId: "<KEY_ID>",
name: "<NAME>",
scopes: [.account],
expire: "" // optional
)
```
+17
View File
@@ -0,0 +1,17 @@
```swift
import Appwrite
import AppwriteEnums
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 backups = Backups(client)
let backupArchive = try await backups.createArchive(
services: [.databases],
resourceId: "<RESOURCE_ID>" // optional
)
```
+22
View File
@@ -0,0 +1,22 @@
```swift
import Appwrite
import AppwriteEnums
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 backups = Backups(client)
let backupPolicy = try await backups.createPolicy(
policyId: "<POLICY_ID>",
services: [.databases],
retention: 1,
schedule: "",
name: "<NAME>", // optional
resourceId: "<RESOURCE_ID>", // optional
enabled: false // optional
)
```
@@ -0,0 +1,19 @@
```swift
import Appwrite
import AppwriteEnums
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 backups = Backups(client)
let backupRestoration = try await backups.createRestoration(
archiveId: "<ARCHIVE_ID>",
services: [.databases],
newResourceId: "<NEW_RESOURCE_ID>", // optional
newResourceName: "<NEW_RESOURCE_NAME>" // 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 backups = Backups(client)
let result = try await backups.deleteArchive(
archiveId: "<ARCHIVE_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 backups = Backups(client)
let result = try await backups.deletePolicy(
policyId: "<POLICY_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 backups = Backups(client)
let backupArchive = try await backups.getArchive(
archiveId: "<ARCHIVE_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 backups = Backups(client)
let backupPolicy = try await backups.getPolicy(
policyId: "<POLICY_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 backups = Backups(client)
let backupRestoration = try await backups.getRestoration(
restorationId: "<RESTORATION_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 backups = Backups(client)
let backupArchiveList = try await backups.listArchives(
queries: [] // 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 backups = Backups(client)
let backupPolicyList = try await backups.listPolicies(
queries: [] // 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 backups = Backups(client)
let backupRestorationList = try await backups.listRestorations(
queries: [] // optional
)
```
+19
View File
@@ -0,0 +1,19 @@
```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 backups = Backups(client)
let backupPolicy = try await backups.updatePolicy(
policyId: "<POLICY_ID>",
name: "<NAME>", // optional
retention: 1, // optional
schedule: "", // optional
enabled: 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 health = Health(client)
let healthQueue = try await health.getQueueBillingProjectAggregation(
threshold: 0 // 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 health = Health(client)
let healthQueue = try await health.getQueueBillingTeamAggregation(
threshold: 0 // 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 health = Health(client)
let healthQueue = try await health.getQueuePriorityBuilds(
threshold: 0 // 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 health = Health(client)
let healthQueue = try await health.getQueueRegionManager(
threshold: 0 // 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 health = Health(client)
let healthQueue = try await health.getQueueThreats(
threshold: 0 // 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
.setSession("") // The user session to authenticate with
let organizations = Organizations(client)
let result = try await organizations.delete(
organizationId: "<ORGANIZATION_ID>"
)
```
@@ -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
.setSession("") // The user session to authenticate with
let organizations = Organizations(client)
let estimationDeleteOrganization = try await organizations.estimationDeleteOrganization(
organizationId: "<ORGANIZATION_ID>"
)
```