diff --git a/README.md b/README.md index cd54e45..0b9e3f1 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 3c745db..1cfd55c 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -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. diff --git a/Sources/Appwrite/Services/Backups.swift b/Sources/Appwrite/Services/Backups.swift new file mode 100644 index 0000000..260683d --- /dev/null +++ b/Sources/Appwrite/Services/Backups.swift @@ -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 + ) + } + + +} \ No newline at end of file diff --git a/Sources/Appwrite/Services/Health.swift b/Sources/Appwrite/Services/Health.swift index 6f3023f..3a68227 100644 --- a/Sources/Appwrite/Services/Health.swift +++ b/Sources/Appwrite/Services/Health.swift @@ -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. diff --git a/Sources/Appwrite/Services/Organizations.swift b/Sources/Appwrite/Services/Organizations.swift new file mode 100644 index 0000000..f5ef8b7 --- /dev/null +++ b/Sources/Appwrite/Services/Organizations.swift @@ -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 + ) + } + + +} \ No newline at end of file diff --git a/Sources/AppwriteEnums/BackupServices.swift b/Sources/AppwriteEnums/BackupServices.swift new file mode 100644 index 0000000..b137619 --- /dev/null +++ b/Sources/AppwriteEnums/BackupServices.swift @@ -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 + } +} diff --git a/Sources/AppwriteEnums/BuildRuntime.swift b/Sources/AppwriteEnums/BuildRuntime.swift index ebdee92..20ce5d1 100644 --- a/Sources/AppwriteEnums/BuildRuntime.swift +++ b/Sources/AppwriteEnums/BuildRuntime.swift @@ -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" diff --git a/Sources/AppwriteEnums/OAuthProvider.swift b/Sources/AppwriteEnums/OAuthProvider.swift index fb715a4..88effa3 100644 --- a/Sources/AppwriteEnums/OAuthProvider.swift +++ b/Sources/AppwriteEnums/OAuthProvider.swift @@ -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 diff --git a/Sources/AppwriteEnums/Runtime.swift b/Sources/AppwriteEnums/Runtime.swift index f8cf2dd..21f64c7 100644 --- a/Sources/AppwriteEnums/Runtime.swift +++ b/Sources/AppwriteEnums/Runtime.swift @@ -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" diff --git a/Sources/AppwriteEnums/Scopes.swift b/Sources/AppwriteEnums/Scopes.swift index c92ee54..95c5343 100644 --- a/Sources/AppwriteEnums/Scopes.swift +++ b/Sources/AppwriteEnums/Scopes.swift @@ -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 diff --git a/Sources/AppwriteModels/BackupArchive.swift b/Sources/AppwriteModels/BackupArchive.swift new file mode 100644 index 0000000..b7a5774 --- /dev/null +++ b/Sources/AppwriteModels/BackupArchive.swift @@ -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 + ) + } +} diff --git a/Sources/AppwriteModels/BackupArchiveList.swift b/Sources/AppwriteModels/BackupArchiveList.swift new file mode 100644 index 0000000..56a0417 --- /dev/null +++ b/Sources/AppwriteModels/BackupArchiveList.swift @@ -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) } + ) + } +} diff --git a/Sources/AppwriteModels/BackupPolicy.swift b/Sources/AppwriteModels/BackupPolicy.swift new file mode 100644 index 0000000..bc52f9b --- /dev/null +++ b/Sources/AppwriteModels/BackupPolicy.swift @@ -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 + ) + } +} diff --git a/Sources/AppwriteModels/BackupPolicyList.swift b/Sources/AppwriteModels/BackupPolicyList.swift new file mode 100644 index 0000000..b1fe5bc --- /dev/null +++ b/Sources/AppwriteModels/BackupPolicyList.swift @@ -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) } + ) + } +} diff --git a/Sources/AppwriteModels/BackupRestoration.swift b/Sources/AppwriteModels/BackupRestoration.swift new file mode 100644 index 0000000..83b4b49 --- /dev/null +++ b/Sources/AppwriteModels/BackupRestoration.swift @@ -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 + ) + } +} diff --git a/Sources/AppwriteModels/BackupRestorationList.swift b/Sources/AppwriteModels/BackupRestorationList.swift new file mode 100644 index 0000000..5f34fc4 --- /dev/null +++ b/Sources/AppwriteModels/BackupRestorationList.swift @@ -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) } + ) + } +} diff --git a/Sources/AppwriteModels/Database.swift b/Sources/AppwriteModels/Database.swift index d325d0c..b4a8234 100644 --- a/Sources/AppwriteModels/Database.swift +++ b/Sources/AppwriteModels/Database.swift @@ -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) } ) } } diff --git a/Sources/AppwriteModels/EstimationDeleteOrganization.swift b/Sources/AppwriteModels/EstimationDeleteOrganization.swift new file mode 100644 index 0000000..0620a3e --- /dev/null +++ b/Sources/AppwriteModels/EstimationDeleteOrganization.swift @@ -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) } + ) + } +} diff --git a/Sources/AppwriteModels/Invoice.swift b/Sources/AppwriteModels/Invoice.swift new file mode 100644 index 0000000..87106de --- /dev/null +++ b/Sources/AppwriteModels/Invoice.swift @@ -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 + ) + } +} diff --git a/Sources/AppwriteModels/Key.swift b/Sources/AppwriteModels/Key.swift new file mode 100644 index 0000000..9376ede --- /dev/null +++ b/Sources/AppwriteModels/Key.swift @@ -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] + ) + } +} diff --git a/Sources/AppwriteModels/KeyList.swift b/Sources/AppwriteModels/KeyList.swift new file mode 100644 index 0000000..17ee326 --- /dev/null +++ b/Sources/AppwriteModels/KeyList.swift @@ -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) } + ) + } +} diff --git a/Sources/AppwriteModels/UsageResources.swift b/Sources/AppwriteModels/UsageResources.swift new file mode 100644 index 0000000..5673af3 --- /dev/null +++ b/Sources/AppwriteModels/UsageResources.swift @@ -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 + ) + } +} diff --git a/docs/examples/account/create-key.md b/docs/examples/account/create-key.md new file mode 100644 index 0000000..ad895df --- /dev/null +++ b/docs/examples/account/create-key.md @@ -0,0 +1,18 @@ +```swift +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + +let account = Account(client) + +let key = try await account.createKey( + name: "", + scopes: [.account], + expire: "" // optional +) + +``` diff --git a/docs/examples/account/delete-key.md b/docs/examples/account/delete-key.md new file mode 100644 index 0000000..1989809 --- /dev/null +++ b/docs/examples/account/delete-key.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + +let account = Account(client) + +let result = try await account.deleteKey( + keyId: "" +) + +``` diff --git a/docs/examples/account/get-key.md b/docs/examples/account/get-key.md new file mode 100644 index 0000000..092d3f7 --- /dev/null +++ b/docs/examples/account/get-key.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + +let account = Account(client) + +let key = try await account.getKey( + keyId: "" +) + +``` diff --git a/docs/examples/account/list-keys.md b/docs/examples/account/list-keys.md new file mode 100644 index 0000000..7ad06f6 --- /dev/null +++ b/docs/examples/account/list-keys.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + +let account = Account(client) + +let keyList = try await account.listKeys( + total: false // optional +) + +``` diff --git a/docs/examples/account/update-key.md b/docs/examples/account/update-key.md new file mode 100644 index 0000000..f8a470f --- /dev/null +++ b/docs/examples/account/update-key.md @@ -0,0 +1,19 @@ +```swift +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + +let account = Account(client) + +let key = try await account.updateKey( + keyId: "", + name: "", + scopes: [.account], + expire: "" // optional +) + +``` diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md new file mode 100644 index 0000000..ec92ce0 --- /dev/null +++ b/docs/examples/backups/create-archive.md @@ -0,0 +1,17 @@ +```swift +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupArchive = try await backups.createArchive( + services: [.databases], + resourceId: "" // optional +) + +``` diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md new file mode 100644 index 0000000..9e97b88 --- /dev/null +++ b/docs/examples/backups/create-policy.md @@ -0,0 +1,22 @@ +```swift +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupPolicy = try await backups.createPolicy( + policyId: "", + services: [.databases], + retention: 1, + schedule: "", + name: "", // optional + resourceId: "", // optional + enabled: false // optional +) + +``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md new file mode 100644 index 0000000..b709fa7 --- /dev/null +++ b/docs/examples/backups/create-restoration.md @@ -0,0 +1,19 @@ +```swift +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupRestoration = try await backups.createRestoration( + archiveId: "", + services: [.databases], + newResourceId: "", // optional + newResourceName: "" // optional +) + +``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md new file mode 100644 index 0000000..a0201d3 --- /dev/null +++ b/docs/examples/backups/delete-archive.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let result = try await backups.deleteArchive( + archiveId: "" +) + +``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md new file mode 100644 index 0000000..75b4692 --- /dev/null +++ b/docs/examples/backups/delete-policy.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let result = try await backups.deletePolicy( + policyId: "" +) + +``` diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md new file mode 100644 index 0000000..c35f21d --- /dev/null +++ b/docs/examples/backups/get-archive.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupArchive = try await backups.getArchive( + archiveId: "" +) + +``` diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md new file mode 100644 index 0000000..969113a --- /dev/null +++ b/docs/examples/backups/get-policy.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupPolicy = try await backups.getPolicy( + policyId: "" +) + +``` diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md new file mode 100644 index 0000000..35d370a --- /dev/null +++ b/docs/examples/backups/get-restoration.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupRestoration = try await backups.getRestoration( + restorationId: "" +) + +``` diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md new file mode 100644 index 0000000..9761b35 --- /dev/null +++ b/docs/examples/backups/list-archives.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupArchiveList = try await backups.listArchives( + queries: [] // optional +) + +``` diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md new file mode 100644 index 0000000..5af3f4a --- /dev/null +++ b/docs/examples/backups/list-policies.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupPolicyList = try await backups.listPolicies( + queries: [] // optional +) + +``` diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md new file mode 100644 index 0000000..b140e64 --- /dev/null +++ b/docs/examples/backups/list-restorations.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupRestorationList = try await backups.listRestorations( + queries: [] // optional +) + +``` diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md new file mode 100644 index 0000000..c00f847 --- /dev/null +++ b/docs/examples/backups/update-policy.md @@ -0,0 +1,19 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let backups = Backups(client) + +let backupPolicy = try await backups.updatePolicy( + policyId: "", + name: "", // optional + retention: 1, // optional + schedule: "", // optional + enabled: false // optional +) + +``` diff --git a/docs/examples/health/get-queue-billing-project-aggregation.md b/docs/examples/health/get-queue-billing-project-aggregation.md new file mode 100644 index 0000000..e69ea6a --- /dev/null +++ b/docs/examples/health/get-queue-billing-project-aggregation.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let health = Health(client) + +let healthQueue = try await health.getQueueBillingProjectAggregation( + threshold: 0 // optional +) + +``` diff --git a/docs/examples/health/get-queue-billing-team-aggregation.md b/docs/examples/health/get-queue-billing-team-aggregation.md new file mode 100644 index 0000000..5aec80d --- /dev/null +++ b/docs/examples/health/get-queue-billing-team-aggregation.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let health = Health(client) + +let healthQueue = try await health.getQueueBillingTeamAggregation( + threshold: 0 // optional +) + +``` diff --git a/docs/examples/health/get-queue-priority-builds.md b/docs/examples/health/get-queue-priority-builds.md new file mode 100644 index 0000000..e809be5 --- /dev/null +++ b/docs/examples/health/get-queue-priority-builds.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let health = Health(client) + +let healthQueue = try await health.getQueuePriorityBuilds( + threshold: 0 // optional +) + +``` diff --git a/docs/examples/health/get-queue-region-manager.md b/docs/examples/health/get-queue-region-manager.md new file mode 100644 index 0000000..8db3e47 --- /dev/null +++ b/docs/examples/health/get-queue-region-manager.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let health = Health(client) + +let healthQueue = try await health.getQueueRegionManager( + threshold: 0 // optional +) + +``` diff --git a/docs/examples/health/get-queue-threats.md b/docs/examples/health/get-queue-threats.md new file mode 100644 index 0000000..6a717c7 --- /dev/null +++ b/docs/examples/health/get-queue-threats.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let health = Health(client) + +let healthQueue = try await health.getQueueThreats( + threshold: 0 // optional +) + +``` diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md new file mode 100644 index 0000000..49766b6 --- /dev/null +++ b/docs/examples/organizations/delete.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + +let organizations = Organizations(client) + +let result = try await organizations.delete( + organizationId: "" +) + +``` diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md new file mode 100644 index 0000000..050856b --- /dev/null +++ b/docs/examples/organizations/estimation-delete-organization.md @@ -0,0 +1,15 @@ +```swift +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + +let organizations = Organizations(client) + +let estimationDeleteOrganization = try await organizations.estimationDeleteOrganization( + organizationId: "" +) + +```