From 56bcd31f9c310e4497803b2e39033c308b20de0b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 20 Aug 2025 03:13:31 +1200 Subject: [PATCH 1/7] Add 1.8.x support --- README.md | 6 +- Sources/Appwrite/Client.swift | 4 +- Sources/Appwrite/Query.swift | 84 + Sources/Appwrite/Services/Account.swift | 2 + Sources/Appwrite/Services/Databases.swift | 111 +- Sources/Appwrite/Services/TablesDb.swift | 2567 +++++++++++++++++ Sources/AppwriteEnums/Type.swift | 10 + Sources/AppwriteModels/BucketList.swift | 2 +- Sources/AppwriteModels/CollectionList.swift | 2 +- Sources/AppwriteModels/ColumnBoolean.swift | 124 + Sources/AppwriteModels/ColumnDatetime.swift | 134 + Sources/AppwriteModels/ColumnEmail.swift | 134 + Sources/AppwriteModels/ColumnEnum.swift | 144 + Sources/AppwriteModels/ColumnFloat.swift | 144 + Sources/AppwriteModels/ColumnIndex.swift | 134 + Sources/AppwriteModels/ColumnIndexList.swift | 54 + Sources/AppwriteModels/ColumnInteger.swift | 144 + Sources/AppwriteModels/ColumnIp.swift | 134 + Sources/AppwriteModels/ColumnList.swift | 54 + .../AppwriteModels/ColumnRelationship.swift | 174 ++ Sources/AppwriteModels/ColumnString.swift | 144 + Sources/AppwriteModels/ColumnUrl.swift | 134 + Sources/AppwriteModels/ContinentList.swift | 2 +- Sources/AppwriteModels/CountryList.swift | 2 +- Sources/AppwriteModels/CurrencyList.swift | 2 +- Sources/AppwriteModels/Database.swift | 16 +- Sources/AppwriteModels/DatabaseList.swift | 2 +- Sources/AppwriteModels/DeploymentList.swift | 2 +- Sources/AppwriteModels/DocumentList.swift | 2 +- Sources/AppwriteModels/ExecutionList.swift | 2 +- Sources/AppwriteModels/FileList.swift | 2 +- Sources/AppwriteModels/FrameworkList.swift | 2 +- Sources/AppwriteModels/FunctionList.swift | 2 +- Sources/AppwriteModels/IdentityList.swift | 2 +- Sources/AppwriteModels/Index.swift | 58 +- Sources/AppwriteModels/IndexList.swift | 2 +- Sources/AppwriteModels/LanguageList.swift | 2 +- Sources/AppwriteModels/LocaleCodeList.swift | 2 +- Sources/AppwriteModels/LogList.swift | 2 +- Sources/AppwriteModels/MembershipList.swift | 2 +- Sources/AppwriteModels/MessageList.swift | 2 +- Sources/AppwriteModels/PhoneList.swift | 2 +- Sources/AppwriteModels/ProviderList.swift | 2 +- .../AppwriteModels/ResourceTokenList.swift | 2 +- Sources/AppwriteModels/Row.swift | 113 + Sources/AppwriteModels/RowList.swift | 54 + Sources/AppwriteModels/RuntimeList.swift | 2 +- Sources/AppwriteModels/SessionList.swift | 2 +- Sources/AppwriteModels/SiteList.swift | 2 +- .../AppwriteModels/SpecificationList.swift | 2 +- Sources/AppwriteModels/SubscriberList.swift | 2 +- Sources/AppwriteModels/Table.swift | 134 + Sources/AppwriteModels/TableList.swift | 54 + Sources/AppwriteModels/TargetList.swift | 2 +- Sources/AppwriteModels/TeamList.swift | 2 +- Sources/AppwriteModels/TopicList.swift | 2 +- Sources/AppwriteModels/UserList.swift | 2 +- Sources/AppwriteModels/VariableList.swift | 2 +- docs/examples/databases/create.md | 4 +- docs/examples/functions/create-execution.md | 2 +- .../tablesdb/create-boolean-column.md | 18 + .../tablesdb/create-datetime-column.md | 18 + docs/examples/tablesdb/create-email-column.md | 18 + docs/examples/tablesdb/create-enum-column.md | 19 + docs/examples/tablesdb/create-float-column.md | 20 + docs/examples/tablesdb/create-index.md | 20 + .../tablesdb/create-integer-column.md | 20 + docs/examples/tablesdb/create-ip-column.md | 18 + .../tablesdb/create-relationship-column.md | 21 + docs/examples/tablesdb/create-row.md | 17 + docs/examples/tablesdb/create-rows.md | 15 + .../examples/tablesdb/create-string-column.md | 20 + docs/examples/tablesdb/create-table.md | 18 + docs/examples/tablesdb/create-url-column.md | 18 + docs/examples/tablesdb/create.md | 17 + .../examples/tablesdb/decrement-row-column.md | 18 + docs/examples/tablesdb/delete-column.md | 15 + docs/examples/tablesdb/delete-index.md | 15 + docs/examples/tablesdb/delete-row.md | 15 + docs/examples/tablesdb/delete-rows.md | 15 + docs/examples/tablesdb/delete-table.md | 14 + docs/examples/tablesdb/delete.md | 13 + docs/examples/tablesdb/get-column.md | 15 + docs/examples/tablesdb/get-index.md | 15 + docs/examples/tablesdb/get-row.md | 16 + docs/examples/tablesdb/get-table.md | 14 + docs/examples/tablesdb/get.md | 13 + .../examples/tablesdb/increment-row-column.md | 18 + docs/examples/tablesdb/list-columns.md | 15 + docs/examples/tablesdb/list-indexes.md | 15 + docs/examples/tablesdb/list-rows.md | 15 + docs/examples/tablesdb/list-tables.md | 15 + docs/examples/tablesdb/list.md | 14 + .../tablesdb/update-boolean-column.md | 18 + .../tablesdb/update-datetime-column.md | 18 + docs/examples/tablesdb/update-email-column.md | 18 + docs/examples/tablesdb/update-enum-column.md | 19 + docs/examples/tablesdb/update-float-column.md | 20 + .../tablesdb/update-integer-column.md | 20 + docs/examples/tablesdb/update-ip-column.md | 18 + .../tablesdb/update-relationship-column.md | 18 + docs/examples/tablesdb/update-row.md | 17 + docs/examples/tablesdb/update-rows.md | 16 + .../examples/tablesdb/update-string-column.md | 19 + docs/examples/tablesdb/update-table.md | 18 + docs/examples/tablesdb/update-url-column.md | 18 + docs/examples/tablesdb/update.md | 15 + docs/examples/tablesdb/upsert-row.md | 17 + docs/examples/tablesdb/upsert-rows.md | 15 + 109 files changed, 5656 insertions(+), 110 deletions(-) create mode 100644 Sources/Appwrite/Services/TablesDb.swift create mode 100644 Sources/AppwriteEnums/Type.swift create mode 100644 Sources/AppwriteModels/ColumnBoolean.swift create mode 100644 Sources/AppwriteModels/ColumnDatetime.swift create mode 100644 Sources/AppwriteModels/ColumnEmail.swift create mode 100644 Sources/AppwriteModels/ColumnEnum.swift create mode 100644 Sources/AppwriteModels/ColumnFloat.swift create mode 100644 Sources/AppwriteModels/ColumnIndex.swift create mode 100644 Sources/AppwriteModels/ColumnIndexList.swift create mode 100644 Sources/AppwriteModels/ColumnInteger.swift create mode 100644 Sources/AppwriteModels/ColumnIp.swift create mode 100644 Sources/AppwriteModels/ColumnList.swift create mode 100644 Sources/AppwriteModels/ColumnRelationship.swift create mode 100644 Sources/AppwriteModels/ColumnString.swift create mode 100644 Sources/AppwriteModels/ColumnUrl.swift create mode 100644 Sources/AppwriteModels/Row.swift create mode 100644 Sources/AppwriteModels/RowList.swift create mode 100644 Sources/AppwriteModels/Table.swift create mode 100644 Sources/AppwriteModels/TableList.swift create mode 100644 docs/examples/tablesdb/create-boolean-column.md create mode 100644 docs/examples/tablesdb/create-datetime-column.md create mode 100644 docs/examples/tablesdb/create-email-column.md create mode 100644 docs/examples/tablesdb/create-enum-column.md create mode 100644 docs/examples/tablesdb/create-float-column.md create mode 100644 docs/examples/tablesdb/create-index.md create mode 100644 docs/examples/tablesdb/create-integer-column.md create mode 100644 docs/examples/tablesdb/create-ip-column.md create mode 100644 docs/examples/tablesdb/create-relationship-column.md create mode 100644 docs/examples/tablesdb/create-row.md create mode 100644 docs/examples/tablesdb/create-rows.md create mode 100644 docs/examples/tablesdb/create-string-column.md create mode 100644 docs/examples/tablesdb/create-table.md create mode 100644 docs/examples/tablesdb/create-url-column.md create mode 100644 docs/examples/tablesdb/create.md create mode 100644 docs/examples/tablesdb/decrement-row-column.md create mode 100644 docs/examples/tablesdb/delete-column.md create mode 100644 docs/examples/tablesdb/delete-index.md create mode 100644 docs/examples/tablesdb/delete-row.md create mode 100644 docs/examples/tablesdb/delete-rows.md create mode 100644 docs/examples/tablesdb/delete-table.md create mode 100644 docs/examples/tablesdb/delete.md create mode 100644 docs/examples/tablesdb/get-column.md create mode 100644 docs/examples/tablesdb/get-index.md create mode 100644 docs/examples/tablesdb/get-row.md create mode 100644 docs/examples/tablesdb/get-table.md create mode 100644 docs/examples/tablesdb/get.md create mode 100644 docs/examples/tablesdb/increment-row-column.md create mode 100644 docs/examples/tablesdb/list-columns.md create mode 100644 docs/examples/tablesdb/list-indexes.md create mode 100644 docs/examples/tablesdb/list-rows.md create mode 100644 docs/examples/tablesdb/list-tables.md create mode 100644 docs/examples/tablesdb/list.md create mode 100644 docs/examples/tablesdb/update-boolean-column.md create mode 100644 docs/examples/tablesdb/update-datetime-column.md create mode 100644 docs/examples/tablesdb/update-email-column.md create mode 100644 docs/examples/tablesdb/update-enum-column.md create mode 100644 docs/examples/tablesdb/update-float-column.md create mode 100644 docs/examples/tablesdb/update-integer-column.md create mode 100644 docs/examples/tablesdb/update-ip-column.md create mode 100644 docs/examples/tablesdb/update-relationship-column.md create mode 100644 docs/examples/tablesdb/update-row.md create mode 100644 docs/examples/tablesdb/update-rows.md create mode 100644 docs/examples/tablesdb/update-string-column.md create mode 100644 docs/examples/tablesdb/update-table.md create mode 100644 docs/examples/tablesdb/update-url-column.md create mode 100644 docs/examples/tablesdb/update.md create mode 100644 docs/examples/tablesdb/upsert-row.md create mode 100644 docs/examples/tablesdb/upsert-rows.md diff --git a/README.md b/README.md index f18bc63..5655f98 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ ![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).** > This is the Swift SDK for integrating with Appwrite from your Swift server-side code. If you're looking for the Apple SDK you should check [appwrite/sdk-for-apple](https://github.com/appwrite/sdk-for-apple) @@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies: ```swift dependencies: [ - .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "10.2.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "11.0.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 6a21d52..1eb5a93 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -21,8 +21,8 @@ open class Client { "x-sdk-name": "Swift", "x-sdk-platform": "server", "x-sdk-language": "swift", - "x-sdk-version": "10.2.0", - "x-appwrite-response-format": "1.7.0" + "x-sdk-version": "11.0.0", + "x-appwrite-response-format": "1.8.0" ] internal var config: [String: String] = [:] diff --git a/Sources/Appwrite/Query.swift b/Sources/Appwrite/Query.swift index 20c499e..1956cdd 100644 --- a/Sources/Appwrite/Query.swift +++ b/Sources/Appwrite/Query.swift @@ -284,6 +284,90 @@ public struct Query : Codable, CustomStringConvertible { ).description } + public static func notContains(_ attribute: String, value: Any) -> String { + return Query( + method: "notContains", + attribute: attribute, + values: Query.parseValue(value) + ).description + } + + public static func notSearch(_ attribute: String, value: String) -> String { + return Query( + method: "notSearch", + attribute: attribute, + values: [value] + ).description + } + + public static func notBetween(_ attribute: String, start: Int, end: Int) -> String { + return Query( + method: "notBetween", + attribute: attribute, + values: [start, end] + ).description + } + + public static func notBetween(_ attribute: String, start: Double, end: Double) -> String { + return Query( + method: "notBetween", + attribute: attribute, + values: [start, end] + ).description + } + + public static func notBetween(_ attribute: String, start: String, end: String) -> String { + return Query( + method: "notBetween", + attribute: attribute, + values: [start, end] + ).description + } + + public static func notStartsWith(_ attribute: String, value: String) -> String { + return Query( + method: "notStartsWith", + attribute: attribute, + values: [value] + ).description + } + + public static func notEndsWith(_ attribute: String, value: String) -> String { + return Query( + method: "notEndsWith", + attribute: attribute, + values: [value] + ).description + } + + public static func createdBefore(_ value: String) -> String { + return Query( + method: "createdBefore", + values: [value] + ).description + } + + public static func createdAfter(_ value: String) -> String { + return Query( + method: "createdAfter", + values: [value] + ).description + } + + public static func updatedBefore(_ value: String) -> String { + return Query( + method: "updatedBefore", + values: [value] + ).description + } + + public static func updatedAfter(_ value: String) -> String { + return Query( + method: "updatedAfter", + values: [value] + ).description + } + public static func or(_ queries: [String]) -> String { let decoder = JSONDecoder() let decodedQueries = queries.compactMap { queryStr -> Query? in diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 8e93bc4..810f685 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -1214,6 +1214,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// + @available(*, deprecated, message: "This API has been deprecated.") open func updateMagicURLSession( userId: String, secret: String @@ -1253,6 +1254,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// + @available(*, deprecated, message: "This API has been deprecated.") open func updatePhoneSession( userId: String, secret: String diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index 86e8362..eb5a9bf 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -18,6 +18,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DatabaseList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.list` instead.") open func list( queries: [String]? = nil, search: String? = nil @@ -52,20 +53,24 @@ open class Databases: Service { /// - databaseId: String /// - name: String /// - enabled: Bool (optional) + /// - type: AppwriteEnums.Type (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Database /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createDatabase` instead.") open func create( databaseId: String, name: String, - enabled: Bool? = nil + enabled: Bool? = nil, + type: AppwriteEnums.Type? = nil ) async throws -> AppwriteModels.Database { let apiPath: String = "/databases" let apiParams: [String: Any?] = [ "databaseId": databaseId, "name": name, - "enabled": enabled + "enabled": enabled, + "type": type ] let apiHeaders: [String: String] = [ @@ -94,6 +99,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Database /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.get` instead.") open func get( databaseId: String ) async throws -> AppwriteModels.Database { @@ -127,6 +133,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Database /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.update` instead.") open func update( databaseId: String, name: String, @@ -166,6 +173,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.delete` instead.") open func delete( databaseId: String ) async throws -> Any { @@ -196,6 +204,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.CollectionList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listTables` instead.") open func listCollections( databaseId: String, queries: [String]? = nil, @@ -240,6 +249,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Collection /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createTable` instead.") open func createCollection( databaseId: String, collectionId: String, @@ -286,6 +296,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Collection /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getTable` instead.") open func getCollection( databaseId: String, collectionId: String @@ -324,6 +335,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Collection /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateTable` instead.") open func updateCollection( databaseId: String, collectionId: String, @@ -370,6 +382,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteTable` instead.") open func deleteCollection( databaseId: String, collectionId: String @@ -401,6 +414,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listColumns` instead.") open func listAttributes( databaseId: String, collectionId: String, @@ -443,6 +457,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeBoolean /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createBooleanColumn` instead.") open func createBooleanAttribute( databaseId: String, collectionId: String, @@ -493,6 +508,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeBoolean /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateBooleanColumn` instead.") open func updateBooleanAttribute( databaseId: String, collectionId: String, @@ -542,6 +558,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeDatetime /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createDatetimeColumn` instead.") open func createDatetimeAttribute( databaseId: String, collectionId: String, @@ -592,6 +609,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeDatetime /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateDatetimeColumn` instead.") open func updateDatetimeAttribute( databaseId: String, collectionId: String, @@ -642,6 +660,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeEmail /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createEmailColumn` instead.") open func createEmailAttribute( databaseId: String, collectionId: String, @@ -693,6 +712,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeEmail /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateEmailColumn` instead.") open func updateEmailAttribute( databaseId: String, collectionId: String, @@ -730,8 +750,8 @@ open class Databases: Service { } /// - /// Create an enumeration attribute. The `elements` param acts as a white-list - /// of accepted values for this attribute. + /// Create an enum attribute. The `elements` param acts as a white-list of + /// accepted values for this attribute. /// /// /// - Parameters: @@ -745,6 +765,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeEnum /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createEnumColumn` instead.") open func createEnumAttribute( databaseId: String, collectionId: String, @@ -799,6 +820,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeEnum /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateEnumColumn` instead.") open func updateEnumAttribute( databaseId: String, collectionId: String, @@ -854,6 +876,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeFloat /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createFloatColumn` instead.") open func createFloatAttribute( databaseId: String, collectionId: String, @@ -911,6 +934,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeFloat /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateFloatColumn` instead.") open func updateFloatAttribute( databaseId: String, collectionId: String, @@ -968,6 +992,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeInteger /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createIntegerColumn` instead.") open func createIntegerAttribute( databaseId: String, collectionId: String, @@ -1025,6 +1050,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeInteger /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateIntegerColumn` instead.") open func updateIntegerAttribute( databaseId: String, collectionId: String, @@ -1079,6 +1105,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeIp /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createIpColumn` instead.") open func createIpAttribute( databaseId: String, collectionId: String, @@ -1130,6 +1157,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeIp /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateIpColumn` instead.") open func updateIpAttribute( databaseId: String, collectionId: String, @@ -1183,6 +1211,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeRelationship /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRelationshipColumn` instead.") open func createRelationshipAttribute( databaseId: String, collectionId: String, @@ -1239,6 +1268,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeString /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createStringColumn` instead.") open func createStringAttribute( databaseId: String, collectionId: String, @@ -1295,6 +1325,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeString /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateStringColumn` instead.") open func updateStringAttribute( databaseId: String, collectionId: String, @@ -1347,6 +1378,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeUrl /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createUrlColumn` instead.") open func createUrlAttribute( databaseId: String, collectionId: String, @@ -1398,6 +1430,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeUrl /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateUrlColumn` instead.") open func updateUrlAttribute( databaseId: String, collectionId: String, @@ -1444,6 +1477,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getColumn` instead.") open func getAttribute( databaseId: String, collectionId: String, @@ -1475,6 +1509,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteColumn` instead.") open func deleteAttribute( databaseId: String, collectionId: String, @@ -1512,6 +1547,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeRelationship /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRelationshipColumn` instead.") open func updateRelationshipAttribute( databaseId: String, collectionId: String, @@ -1557,6 +1593,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -1597,6 +1634,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -1625,6 +1663,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -1675,6 +1714,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -1693,10 +1733,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create new Documents. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1709,6 +1745,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRows` instead.") open func createDocuments( databaseId: String, collectionId: String, @@ -1741,10 +1778,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create new Documents. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1757,6 +1790,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRows` instead.") open func createDocuments( databaseId: String, collectionId: String, @@ -1771,10 +1805,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create or update Documents. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1788,6 +1818,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRows` instead.") open func upsertDocuments( databaseId: String, collectionId: String, @@ -1820,10 +1851,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create or update Documents. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1837,6 +1864,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRows` instead.") open func upsertDocuments( databaseId: String, collectionId: String, @@ -1851,10 +1879,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Update all documents that match your queries, if no queries are submitted /// then all documents are updated. You can pass only specific fields to be /// updated. @@ -1867,6 +1891,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRows` instead.") open func updateDocuments( databaseId: String, collectionId: String, @@ -1901,10 +1926,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Update all documents that match your queries, if no queries are submitted /// then all documents are updated. You can pass only specific fields to be /// updated. @@ -1917,6 +1938,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRows` instead.") open func updateDocuments( databaseId: String, collectionId: String, @@ -1933,10 +1955,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Bulk delete documents using queries, if no queries are passed then all /// documents are deleted. /// @@ -1947,6 +1965,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRows` instead.") open func deleteDocuments( databaseId: String, collectionId: String, @@ -1979,10 +1998,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Bulk delete documents using queries, if no queries are passed then all /// documents are deleted. /// @@ -1993,6 +2008,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRows` instead.") open func deleteDocuments( databaseId: String, collectionId: String, @@ -2018,6 +2034,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -2061,6 +2078,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -2077,10 +2095,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -2095,6 +2109,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, @@ -2131,10 +2146,6 @@ open class Databases: Service { } /// - /// **WARNING: Experimental Feature** - This endpoint is experimental and not - /// yet officially supported. It may be subject to breaking changes or removal - /// in future versions. - /// /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -2149,6 +2160,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, @@ -2179,6 +2191,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -2227,6 +2240,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -2254,6 +2268,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRow` instead.") open func deleteDocument( databaseId: String, collectionId: String, @@ -2290,6 +2305,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2340,6 +2356,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2372,6 +2389,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2422,6 +2440,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2451,6 +2470,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.IndexList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listIndexes` instead.") open func listIndexes( databaseId: String, collectionId: String, @@ -2495,6 +2515,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Index /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createIndex` instead.") open func createIndex( databaseId: String, collectionId: String, @@ -2543,6 +2564,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Index /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getIndex` instead.") open func getIndex( databaseId: String, collectionId: String, @@ -2580,6 +2602,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteIndex` instead.") open func deleteIndex( databaseId: String, collectionId: String, diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDb.swift new file mode 100644 index 0000000..3614e05 --- /dev/null +++ b/Sources/Appwrite/Services/TablesDb.swift @@ -0,0 +1,2567 @@ +import AsyncHTTPClient +import Foundation +import NIO +import JSONCodable +import AppwriteEnums +import AppwriteModels + +/// +open class TablesDb: Service { + + /// + /// Get a list of all databases from the current Appwrite project. You can use + /// the search parameter to filter your results. + /// + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DatabaseList + /// + open func list( + queries: [String]? = nil, + search: String? = nil + ) async throws -> AppwriteModels.DatabaseList { + let apiPath: String = "/tablesdb" + + let apiParams: [String: Any?] = [ + "queries": queries, + "search": search + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.DatabaseList = { response in + return AppwriteModels.DatabaseList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a new Database. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - name: String + /// - enabled: Bool (optional) + /// - type: AppwriteEnums.Type (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Database + /// + open func create( + databaseId: String, + name: String, + enabled: Bool? = nil, + type: AppwriteEnums.Type? = nil + ) async throws -> AppwriteModels.Database { + let apiPath: String = "/tablesdb" + + let apiParams: [String: Any?] = [ + "databaseId": databaseId, + "name": name, + "enabled": enabled, + "type": type + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Database = { response in + return AppwriteModels.Database.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get a database by its unique ID. This endpoint response returns a JSON + /// object with the database metadata. + /// + /// - Parameters: + /// - databaseId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Database + /// + open func get( + databaseId: String + ) async throws -> AppwriteModels.Database { + let apiPath: String = "/tablesdb/{databaseId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.Database = { response in + return AppwriteModels.Database.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a database by its unique ID. + /// + /// - Parameters: + /// - databaseId: String + /// - name: String + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Database + /// + open func update( + databaseId: String, + name: String, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Database { + let apiPath: String = "/tablesdb/{databaseId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + + let apiParams: [String: Any?] = [ + "name": name, + "enabled": enabled + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Database = { response in + return AppwriteModels.Database.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Delete a database by its unique ID. Only API keys with with databases.write + /// scope can delete a database. + /// + /// - Parameters: + /// - databaseId: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func delete( + databaseId: String + ) async throws -> Any { + let apiPath: String = "/tablesdb/{databaseId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + + 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 a list of all tables that belong to the provided databaseId. You can + /// use the search parameter to filter your results. + /// + /// - Parameters: + /// - databaseId: String + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.TableList + /// + open func listTables( + databaseId: String, + queries: [String]? = nil, + search: String? = nil + ) async throws -> AppwriteModels.TableList { + let apiPath: String = "/tablesdb/{databaseId}/tables" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + + let apiParams: [String: Any?] = [ + "queries": queries, + "search": search + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.TableList = { response in + return AppwriteModels.TableList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a new Table. Before using this route, you should create a new + /// database resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - name: String + /// - permissions: [String] (optional) + /// - rowSecurity: Bool (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Table + /// + open func createTable( + databaseId: String, + tableId: String, + name: String, + permissions: [String]? = nil, + rowSecurity: Bool? = nil, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Table { + let apiPath: String = "/tablesdb/{databaseId}/tables" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + + let apiParams: [String: Any?] = [ + "tableId": tableId, + "name": name, + "permissions": permissions, + "rowSecurity": rowSecurity, + "enabled": enabled + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Table = { response in + return AppwriteModels.Table.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get a table by its unique ID. This endpoint response returns a JSON object + /// with the table metadata. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Table + /// + open func getTable( + databaseId: String, + tableId: String + ) async throws -> AppwriteModels.Table { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.Table = { response in + return AppwriteModels.Table.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a table by its unique ID. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - name: String + /// - permissions: [String] (optional) + /// - rowSecurity: Bool (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Table + /// + open func updateTable( + databaseId: String, + tableId: String, + name: String, + permissions: [String]? = nil, + rowSecurity: Bool? = nil, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Table { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "name": name, + "permissions": permissions, + "rowSecurity": rowSecurity, + "enabled": enabled + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Table = { response in + return AppwriteModels.Table.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Delete a table by its unique ID. Only users with write permissions have + /// access to delete this resource. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteTable( + databaseId: String, + tableId: String + ) async throws -> Any { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + 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 columns in the table. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnList + /// + open func listColumns( + databaseId: String, + tableId: String, + queries: [String]? = nil + ) async throws -> AppwriteModels.ColumnList { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "queries": queries + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.ColumnList = { response in + return AppwriteModels.ColumnList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a boolean column. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: Bool (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnBoolean + /// + open func createBooleanColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: Bool? = nil, + array: Bool? = nil + ) async throws -> AppwriteModels.ColumnBoolean { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default`, + "array": array + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnBoolean = { response in + return AppwriteModels.ColumnBoolean.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a boolean column. Changing the `default` value will not update + /// already existing rows. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: Bool (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnBoolean + /// + open func updateBooleanColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: Bool? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnBoolean { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnBoolean = { response in + return AppwriteModels.ColumnBoolean.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a date time column according to the ISO 8601 standard. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnDatetime + /// + open func createDatetimeColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: String? = nil, + array: Bool? = nil + ) async throws -> AppwriteModels.ColumnDatetime { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default`, + "array": array + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnDatetime = { response in + return AppwriteModels.ColumnDatetime.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a date time column. Changing the `default` value will not update + /// already existing rows. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnDatetime + /// + open func updateDatetimeColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: String? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnDatetime { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnDatetime = { response in + return AppwriteModels.ColumnDatetime.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create an email column. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnEmail + /// + open func createEmailColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: String? = nil, + array: Bool? = nil + ) async throws -> AppwriteModels.ColumnEmail { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/email" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default`, + "array": array + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnEmail = { response in + return AppwriteModels.ColumnEmail.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update an email column. Changing the `default` value will not update + /// already existing rows. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnEmail + /// + open func updateEmailColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: String? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnEmail { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnEmail = { response in + return AppwriteModels.ColumnEmail.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create an enumeration column. The `elements` param acts as a white-list of + /// accepted values for this column. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - elements: [String] + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnEnum + /// + open func createEnumColumn( + databaseId: String, + tableId: String, + key: String, + elements: [String], + `required`: Bool, + `default`: String? = nil, + array: Bool? = nil + ) async throws -> AppwriteModels.ColumnEnum { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "elements": elements, + "required": `required`, + "default": `default`, + "array": array + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnEnum = { response in + return AppwriteModels.ColumnEnum.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update an enum column. Changing the `default` value will not update already + /// existing rows. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - elements: [String] + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnEnum + /// + open func updateEnumColumn( + databaseId: String, + tableId: String, + key: String, + elements: [String], + `required`: Bool, + `default`: String? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnEnum { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "elements": elements, + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnEnum = { response in + return AppwriteModels.ColumnEnum.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a float column. Optionally, minimum and maximum values can be + /// provided. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - min: Double (optional) + /// - max: Double (optional) + /// - default: Double (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnFloat + /// + open func createFloatColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + min: Double? = nil, + max: Double? = nil, + `default`: Double? = nil, + array: Bool? = nil + ) async throws -> AppwriteModels.ColumnFloat { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/float" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "min": min, + "max": max, + "default": `default`, + "array": array + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnFloat = { response in + return AppwriteModels.ColumnFloat.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a float column. Changing the `default` value will not update already + /// existing rows. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: Double (optional) + /// - min: Double (optional) + /// - max: Double (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnFloat + /// + open func updateFloatColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: Double? = nil, + min: Double? = nil, + max: Double? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnFloat { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "min": min, + "max": max, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnFloat = { response in + return AppwriteModels.ColumnFloat.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create an integer column. Optionally, minimum and maximum values can be + /// provided. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - min: Int (optional) + /// - max: Int (optional) + /// - default: Int (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnInteger + /// + open func createIntegerColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + min: Int? = nil, + max: Int? = nil, + `default`: Int? = nil, + array: Bool? = nil + ) async throws -> AppwriteModels.ColumnInteger { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "min": min, + "max": max, + "default": `default`, + "array": array + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnInteger = { response in + return AppwriteModels.ColumnInteger.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update an integer column. Changing the `default` value will not update + /// already existing rows. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: Int (optional) + /// - min: Int (optional) + /// - max: Int (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnInteger + /// + open func updateIntegerColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: Int? = nil, + min: Int? = nil, + max: Int? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnInteger { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "min": min, + "max": max, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnInteger = { response in + return AppwriteModels.ColumnInteger.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create IP address column. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnIp + /// + open func createIpColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: String? = nil, + array: Bool? = nil + ) async throws -> AppwriteModels.ColumnIp { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default`, + "array": array + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnIp = { response in + return AppwriteModels.ColumnIp.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update an ip column. Changing the `default` value will not update already + /// existing rows. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnIp + /// + open func updateIpColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: String? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnIp { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnIp = { response in + return AppwriteModels.ColumnIp.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create relationship column. [Learn more about relationship + /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - relatedTableId: String + /// - type: AppwriteEnums.RelationshipType + /// - twoWay: Bool (optional) + /// - key: String (optional) + /// - twoWayKey: String (optional) + /// - onDelete: AppwriteEnums.RelationMutate (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnRelationship + /// + open func createRelationshipColumn( + databaseId: String, + tableId: String, + relatedTableId: String, + type: AppwriteEnums.RelationshipType, + twoWay: Bool? = nil, + key: String? = nil, + twoWayKey: String? = nil, + onDelete: AppwriteEnums.RelationMutate? = nil + ) async throws -> AppwriteModels.ColumnRelationship { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "relatedTableId": relatedTableId, + "type": type, + "twoWay": twoWay, + "key": key, + "twoWayKey": twoWayKey, + "onDelete": onDelete + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnRelationship = { response in + return AppwriteModels.ColumnRelationship.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a string column. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - size: Int + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - encrypt: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnString + /// + open func createStringColumn( + databaseId: String, + tableId: String, + key: String, + size: Int, + `required`: Bool, + `default`: String? = nil, + array: Bool? = nil, + encrypt: Bool? = nil + ) async throws -> AppwriteModels.ColumnString { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/string" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "size": size, + "required": `required`, + "default": `default`, + "array": array, + "encrypt": encrypt + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnString = { response in + return AppwriteModels.ColumnString.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a string column. Changing the `default` value will not update + /// already existing rows. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - size: Int (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnString + /// + open func updateStringColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: String? = nil, + size: Int? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnString { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "size": size, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnString = { response in + return AppwriteModels.ColumnString.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a URL column. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnUrl + /// + open func createUrlColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: String? = nil, + array: Bool? = nil + ) async throws -> AppwriteModels.ColumnUrl { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/url" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "required": `required`, + "default": `default`, + "array": array + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnUrl = { response in + return AppwriteModels.ColumnUrl.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update an url column. Changing the `default` value will not update already + /// existing rows. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnUrl + /// + open func updateUrlColumn( + databaseId: String, + tableId: String, + key: String, + `required`: Bool, + `default`: String? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnUrl { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "required": `required`, + "default": `default`, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnUrl = { response in + return AppwriteModels.ColumnUrl.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get column by ID. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func getColumn( + databaseId: String, + tableId: String, + key: String + ) async throws -> Any { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams ) + } + + /// + /// Deletes a column. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteColumn( + databaseId: String, + tableId: String, + key: String + ) async throws -> Any { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + return try await client.call( + method: "DELETE", + path: apiPath, + headers: apiHeaders, + params: apiParams ) + } + + /// + /// Update relationship column. [Learn more about relationship + /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - onDelete: AppwriteEnums.RelationMutate (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnRelationship + /// + open func updateRelationshipColumn( + databaseId: String, + tableId: String, + key: String, + onDelete: AppwriteEnums.RelationMutate? = nil, + newKey: String? = nil + ) async throws -> AppwriteModels.ColumnRelationship { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any?] = [ + "onDelete": onDelete, + "newKey": newKey + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnRelationship = { response in + return AppwriteModels.ColumnRelationship.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// List indexes in the collection. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnIndexList + /// + open func listIndexes( + databaseId: String, + tableId: String, + queries: [String]? = nil + ) async throws -> AppwriteModels.ColumnIndexList { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/indexes" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "queries": queries + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.ColumnIndexList = { response in + return AppwriteModels.ColumnIndexList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Creates an index on the columns listed. Your index should include all the + /// columns you will query in a single request. + /// Attributes can be `key`, `fulltext`, and `unique`. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - type: AppwriteEnums.IndexType + /// - columns: [String] + /// - orders: [String] (optional) + /// - lengths: [Int] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnIndex + /// + open func createIndex( + databaseId: String, + tableId: String, + key: String, + type: AppwriteEnums.IndexType, + columns: [String], + orders: [String]? = nil, + lengths: [Int]? = nil + ) async throws -> AppwriteModels.ColumnIndex { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/indexes" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "key": key, + "type": type, + "columns": columns, + "orders": orders, + "lengths": lengths + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.ColumnIndex = { response in + return AppwriteModels.ColumnIndex.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get index by ID. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ColumnIndex + /// + open func getIndex( + databaseId: String, + tableId: String, + key: String + ) async throws -> AppwriteModels.ColumnIndex { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.ColumnIndex = { response in + return AppwriteModels.ColumnIndex.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Delete an index. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - key: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteIndex( + databaseId: String, + tableId: String, + key: String + ) async throws -> Any { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{key}", with: key) + + 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 a list of all the user's rows in a given table. You can use the query + /// params to filter your results. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func listRows( + databaseId: String, + tableId: String, + queries: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.RowList { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "queries": queries + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.RowList = { response in + return AppwriteModels.RowList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get a list of all the user's rows in a given table. You can use the query + /// params to filter your results. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func listRows( + databaseId: String, + tableId: String, + queries: [String]? = nil + ) async throws -> AppwriteModels.RowList<[String: AnyCodable]> { + return try await listRows( + databaseId: databaseId, + tableId: tableId, + queries: queries, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Create a new Row. Before using this route, you should create a new table + /// resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "rowId": rowId, + "data": data, + "permissions": permissions + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create a new Row. Before using this route, you should create a new table + /// resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: [String]? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await createRow( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + data: data, + permissions: permissions, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Create new Rows. Before using this route, you should create a new table + /// resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rows: [Any] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func createRows( + databaseId: String, + tableId: String, + rows: [Any], + nestedType: T.Type + ) async throws -> AppwriteModels.RowList { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "rows": rows + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.RowList = { response in + return AppwriteModels.RowList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create new Rows. Before using this route, you should create a new table + /// resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rows: [Any] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func createRows( + databaseId: String, + tableId: String, + rows: [Any] + ) async throws -> AppwriteModels.RowList<[String: AnyCodable]> { + return try await createRows( + databaseId: databaseId, + tableId: tableId, + rows: rows, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Create or update Rows. Before using this route, you should create a new + /// table resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rows: [Any] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func upsertRows( + databaseId: String, + tableId: String, + rows: [Any], + nestedType: T.Type + ) async throws -> AppwriteModels.RowList { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "rows": rows + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.RowList = { response in + return AppwriteModels.RowList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create or update Rows. Before using this route, you should create a new + /// table resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rows: [Any] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func upsertRows( + databaseId: String, + tableId: String, + rows: [Any] + ) async throws -> AppwriteModels.RowList<[String: AnyCodable]> { + return try await upsertRows( + databaseId: databaseId, + tableId: tableId, + rows: rows, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Update all rows that match your queries, if no queries are submitted then + /// all rows are updated. You can pass only specific fields to be updated. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - data: Any (optional) + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func updateRows( + databaseId: String, + tableId: String, + data: Any? = nil, + queries: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.RowList { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "data": data, + "queries": queries + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.RowList = { response in + return AppwriteModels.RowList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update all rows that match your queries, if no queries are submitted then + /// all rows are updated. You can pass only specific fields to be updated. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - data: Any (optional) + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func updateRows( + databaseId: String, + tableId: String, + data: Any? = nil, + queries: [String]? = nil + ) async throws -> AppwriteModels.RowList<[String: AnyCodable]> { + return try await updateRows( + databaseId: databaseId, + tableId: tableId, + data: data, + queries: queries, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Bulk delete rows using queries, if no queries are passed then all rows are + /// deleted. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func deleteRows( + databaseId: String, + tableId: String, + queries: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.RowList { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any?] = [ + "queries": queries + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.RowList = { response in + return AppwriteModels.RowList.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "DELETE", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Bulk delete rows using queries, if no queries are passed then all rows are + /// deleted. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func deleteRows( + databaseId: String, + tableId: String, + queries: [String]? = nil + ) async throws -> AppwriteModels.RowList<[String: AnyCodable]> { + return try await deleteRows( + databaseId: databaseId, + tableId: tableId, + queries: queries, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Get a row by its unique ID. This endpoint response returns a JSON object + /// with the row data. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + + let apiParams: [String: Any?] = [ + "queries": queries + ] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Get a row by its unique ID. This endpoint response returns a JSON object + /// with the row data. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: [String]? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await getRow( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + queries: queries, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Create or update a Row. Before using this route, you should create a new + /// table resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func upsertRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = nil, + permissions: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + + let apiParams: [String: Any?] = [ + "data": data, + "permissions": permissions + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Create or update a Row. Before using this route, you should create a new + /// table resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// API or directly from your database console. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func upsertRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = nil, + permissions: [String]? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await upsertRow( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + data: data, + permissions: permissions, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Update a row by its unique ID. Using the patch method you can pass only + /// specific fields that will get updated. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = nil, + permissions: [String]? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + + let apiParams: [String: Any?] = [ + "data": data, + "permissions": permissions + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Update a row by its unique ID. Using the patch method you can pass only + /// specific fields that will get updated. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = nil, + permissions: [String]? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await updateRow( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + data: data, + permissions: permissions, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Delete a row by its unique ID. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteRow( + databaseId: String, + tableId: String, + rowId: String + ) async throws -> Any { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + + 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 ) + } + + /// + /// Decrement a specific column of a row by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - column: String + /// - value: Double (optional) + /// - min: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func decrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = nil, + min: Double? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + .replacingOccurrences(of: "{column}", with: column) + + let apiParams: [String: Any?] = [ + "value": value, + "min": min + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Decrement a specific column of a row by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - column: String + /// - value: Double (optional) + /// - min: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func decrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = nil, + min: Double? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await decrementRowColumn( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + column: column, + value: value, + min: min, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Increment a specific column of a row by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - column: String + /// - value: Double (optional) + /// - max: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func incrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = nil, + max: Double? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + .replacingOccurrences(of: "{rowId}", with: rowId) + .replacingOccurrences(of: "{column}", with: column) + + let apiParams: [String: Any?] = [ + "value": value, + "max": max + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Row = { response in + return AppwriteModels.Row.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Increment a specific column of a row by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - tableId: String + /// - rowId: String + /// - column: String + /// - value: Double (optional) + /// - max: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func incrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = nil, + max: Double? = nil + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await incrementRowColumn( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + column: column, + value: value, + max: max, + nestedType: [String: AnyCodable].self + ) + } + + +} \ No newline at end of file diff --git a/Sources/AppwriteEnums/Type.swift b/Sources/AppwriteEnums/Type.swift new file mode 100644 index 0000000..f6d4e27 --- /dev/null +++ b/Sources/AppwriteEnums/Type.swift @@ -0,0 +1,10 @@ +import Foundation + +public enum Type: String, CustomStringConvertible { + case tablesdb = "tablesdb" + case legacy = "legacy" + + public var description: String { + return rawValue + } +} diff --git a/Sources/AppwriteModels/BucketList.swift b/Sources/AppwriteModels/BucketList.swift index 8fca4e4..89a718e 100644 --- a/Sources/AppwriteModels/BucketList.swift +++ b/Sources/AppwriteModels/BucketList.swift @@ -9,7 +9,7 @@ open class BucketList: Codable { case buckets = "buckets" } - /// Total number of buckets documents that matched your query. + /// Total number of buckets rows that matched your query. public let total: Int /// List of buckets. diff --git a/Sources/AppwriteModels/CollectionList.swift b/Sources/AppwriteModels/CollectionList.swift index f5f383f..54ccbfc 100644 --- a/Sources/AppwriteModels/CollectionList.swift +++ b/Sources/AppwriteModels/CollectionList.swift @@ -9,7 +9,7 @@ open class CollectionList: Codable { case collections = "collections" } - /// Total number of collections documents that matched your query. + /// Total number of collections rows that matched your query. public let total: Int /// List of collections. diff --git a/Sources/AppwriteModels/ColumnBoolean.swift b/Sources/AppwriteModels/ColumnBoolean.swift new file mode 100644 index 0000000..84f99b9 --- /dev/null +++ b/Sources/AppwriteModels/ColumnBoolean.swift @@ -0,0 +1,124 @@ +import Foundation +import JSONCodable + +/// ColumnBoolean +open class ColumnBoolean: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + public let `default`: Bool? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + `default`: Bool? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.`default` = try container.decodeIfPresent(Bool.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "`default`": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnBoolean { + return ColumnBoolean( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + default: map["default"] as? Bool + ) + } +} diff --git a/Sources/AppwriteModels/ColumnDatetime.swift b/Sources/AppwriteModels/ColumnDatetime.swift new file mode 100644 index 0000000..5d5dc37 --- /dev/null +++ b/Sources/AppwriteModels/ColumnDatetime.swift @@ -0,0 +1,134 @@ +import Foundation +import JSONCodable + +/// ColumnDatetime +open class ColumnDatetime: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case format = "format" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// ISO 8601 format. + public let format: String + + /// Default value for attribute when not provided. Only null is optional + public let `default`: String? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + format: String, + `default`: String? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.format = format + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "format": format as Any, + "`default`": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnDatetime { + return ColumnDatetime( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + format: map["format"] as! String, + default: map["default"] as? String + ) + } +} diff --git a/Sources/AppwriteModels/ColumnEmail.swift b/Sources/AppwriteModels/ColumnEmail.swift new file mode 100644 index 0000000..8ffc084 --- /dev/null +++ b/Sources/AppwriteModels/ColumnEmail.swift @@ -0,0 +1,134 @@ +import Foundation +import JSONCodable + +/// ColumnEmail +open class ColumnEmail: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case format = "format" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// String format. + public let format: String + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + public let `default`: String? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + format: String, + `default`: String? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.format = format + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "format": format as Any, + "`default`": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnEmail { + return ColumnEmail( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + format: map["format"] as! String, + default: map["default"] as? String + ) + } +} diff --git a/Sources/AppwriteModels/ColumnEnum.swift b/Sources/AppwriteModels/ColumnEnum.swift new file mode 100644 index 0000000..e9fcbbd --- /dev/null +++ b/Sources/AppwriteModels/ColumnEnum.swift @@ -0,0 +1,144 @@ +import Foundation +import JSONCodable + +/// ColumnEnum +open class ColumnEnum: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case elements = "elements" + case format = "format" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// Array of elements in enumerated type. + public let elements: [String] + + /// String format. + public let format: String + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + public let `default`: String? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + elements: [String], + format: String, + `default`: String? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.elements = elements + self.format = format + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.elements = try container.decode([String].self, forKey: .elements) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(elements, forKey: .elements) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "elements": elements as Any, + "format": format as Any, + "`default`": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnEnum { + return ColumnEnum( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + elements: map["elements"] as! [String], + format: map["format"] as! String, + default: map["default"] as? String + ) + } +} diff --git a/Sources/AppwriteModels/ColumnFloat.swift b/Sources/AppwriteModels/ColumnFloat.swift new file mode 100644 index 0000000..7609ffc --- /dev/null +++ b/Sources/AppwriteModels/ColumnFloat.swift @@ -0,0 +1,144 @@ +import Foundation +import JSONCodable + +/// ColumnFloat +open class ColumnFloat: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case min = "min" + case max = "max" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// Minimum value to enforce for new documents. + public let min: Double? + + /// Maximum value to enforce for new documents. + public let max: Double? + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + public let `default`: Double? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + min: Double?, + max: Double?, + `default`: Double? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.min = min + self.max = max + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.min = try container.decodeIfPresent(Double.self, forKey: .min) + self.max = try container.decodeIfPresent(Double.self, forKey: .max) + self.`default` = try container.decodeIfPresent(Double.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(min, forKey: .min) + try container.encodeIfPresent(max, forKey: .max) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "min": min as Any, + "max": max as Any, + "`default`": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnFloat { + return ColumnFloat( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + min: map["min"] as? Double, + max: map["max"] as? Double, + default: map["default"] as? Double + ) + } +} diff --git a/Sources/AppwriteModels/ColumnIndex.swift b/Sources/AppwriteModels/ColumnIndex.swift new file mode 100644 index 0000000..c75fdb0 --- /dev/null +++ b/Sources/AppwriteModels/ColumnIndex.swift @@ -0,0 +1,134 @@ +import Foundation +import JSONCodable + +/// Index +open class ColumnIndex: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case columns = "columns" + case lengths = "lengths" + case orders = "orders" + } + + /// Index ID. + public let id: String + + /// Index creation date in ISO 8601 format. + public let createdAt: String + + /// Index update date in ISO 8601 format. + public let updatedAt: String + + /// Index Key. + public let key: String + + /// Index type. + public let type: String + + /// Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an index. + public let error: String + + /// Index columns. + public let columns: [String] + + /// Index columns length. + public let lengths: [Int] + + /// Index orders. + public let orders: [String]? + + + init( + id: String, + createdAt: String, + updatedAt: String, + key: String, + type: String, + status: String, + error: String, + columns: [String], + lengths: [Int], + orders: [String]? + ) { + self.id = id + self.createdAt = createdAt + self.updatedAt = updatedAt + self.key = key + self.type = type + self.status = status + self.error = error + self.columns = columns + self.lengths = lengths + self.orders = orders + } + + 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.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.columns = try container.decode([String].self, forKey: .columns) + self.lengths = try container.decode([Int].self, forKey: .lengths) + self.orders = try container.decodeIfPresent([String].self, forKey: .orders) + } + + 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(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(columns, forKey: .columns) + try container.encode(lengths, forKey: .lengths) + try container.encodeIfPresent(orders, forKey: .orders) + } + + public func toMap() -> [String: Any] { + return [ + "$id": id as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "columns": columns as Any, + "lengths": lengths as Any, + "orders": orders as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnIndex { + return ColumnIndex( + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + columns: map["columns"] as! [String], + lengths: map["lengths"] as! [Int], + orders: map["orders"] as? [String] + ) + } +} diff --git a/Sources/AppwriteModels/ColumnIndexList.swift b/Sources/AppwriteModels/ColumnIndexList.swift new file mode 100644 index 0000000..5ce8061 --- /dev/null +++ b/Sources/AppwriteModels/ColumnIndexList.swift @@ -0,0 +1,54 @@ +import Foundation +import JSONCodable + +/// Column Indexes List +open class ColumnIndexList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case indexes = "indexes" + } + + /// Total number of indexes rows that matched your query. + public let total: Int + + /// List of indexes. + public let indexes: [ColumnIndex] + + + init( + total: Int, + indexes: [ColumnIndex] + ) { + self.total = total + self.indexes = indexes + } + + 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.indexes = try container.decode([ColumnIndex].self, forKey: .indexes) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(indexes, forKey: .indexes) + } + + public func toMap() -> [String: Any] { + return [ + "total": total as Any, + "indexes": indexes.map { $0.toMap() } as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnIndexList { + return ColumnIndexList( + total: map["total"] as! Int, + indexes: (map["indexes"] as! [[String: Any]]).map { ColumnIndex.from(map: $0) } + ) + } +} diff --git a/Sources/AppwriteModels/ColumnInteger.swift b/Sources/AppwriteModels/ColumnInteger.swift new file mode 100644 index 0000000..22ba42c --- /dev/null +++ b/Sources/AppwriteModels/ColumnInteger.swift @@ -0,0 +1,144 @@ +import Foundation +import JSONCodable + +/// ColumnInteger +open class ColumnInteger: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case min = "min" + case max = "max" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// Minimum value to enforce for new documents. + public let min: Int? + + /// Maximum value to enforce for new documents. + public let max: Int? + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + public let `default`: Int? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + min: Int?, + max: Int?, + `default`: Int? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.min = min + self.max = max + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.min = try container.decodeIfPresent(Int.self, forKey: .min) + self.max = try container.decodeIfPresent(Int.self, forKey: .max) + self.`default` = try container.decodeIfPresent(Int.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encodeIfPresent(min, forKey: .min) + try container.encodeIfPresent(max, forKey: .max) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "min": min as Any, + "max": max as Any, + "`default`": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnInteger { + return ColumnInteger( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + min: map["min"] as? Int, + max: map["max"] as? Int, + default: map["default"] as? Int + ) + } +} diff --git a/Sources/AppwriteModels/ColumnIp.swift b/Sources/AppwriteModels/ColumnIp.swift new file mode 100644 index 0000000..d0f358e --- /dev/null +++ b/Sources/AppwriteModels/ColumnIp.swift @@ -0,0 +1,134 @@ +import Foundation +import JSONCodable + +/// ColumnIP +open class ColumnIp: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case format = "format" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// String format. + public let format: String + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + public let `default`: String? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + format: String, + `default`: String? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.format = format + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "format": format as Any, + "`default`": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnIp { + return ColumnIp( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + format: map["format"] as! String, + default: map["default"] as? String + ) + } +} diff --git a/Sources/AppwriteModels/ColumnList.swift b/Sources/AppwriteModels/ColumnList.swift new file mode 100644 index 0000000..dead6f0 --- /dev/null +++ b/Sources/AppwriteModels/ColumnList.swift @@ -0,0 +1,54 @@ +import Foundation +import JSONCodable + +/// Columns List +open class ColumnList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case columns = "columns" + } + + /// Total number of columns in the given table. + public let total: Int + + /// List of columns. + public let columns: [AnyCodable] + + + init( + total: Int, + columns: [AnyCodable] + ) { + self.total = total + self.columns = columns + } + + 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.columns = try container.decode([AnyCodable].self, forKey: .columns) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(columns, forKey: .columns) + } + + public func toMap() -> [String: Any] { + return [ + "total": total as Any, + "columns": columns as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnList { + return ColumnList( + total: map["total"] as! Int, + columns: (map["columns"] as! [Any]).map { AnyCodable($0) } + ) + } +} diff --git a/Sources/AppwriteModels/ColumnRelationship.swift b/Sources/AppwriteModels/ColumnRelationship.swift new file mode 100644 index 0000000..e738c5f --- /dev/null +++ b/Sources/AppwriteModels/ColumnRelationship.swift @@ -0,0 +1,174 @@ +import Foundation +import JSONCodable + +/// ColumnRelationship +open class ColumnRelationship: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case relatedTable = "relatedTable" + case relationType = "relationType" + case twoWay = "twoWay" + case twoWayKey = "twoWayKey" + case onDelete = "onDelete" + case side = "side" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// The ID of the related table. + public let relatedTable: String + + /// The type of the relationship. + public let relationType: String + + /// Is the relationship two-way? + public let twoWay: Bool + + /// The key of the two-way relationship. + public let twoWayKey: String + + /// How deleting the parent document will propagate to child documents. + public let onDelete: String + + /// Whether this is the parent or child side of the relationship + public let side: String + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + relatedTable: String, + relationType: String, + twoWay: Bool, + twoWayKey: String, + onDelete: String, + side: String + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.relatedTable = relatedTable + self.relationType = relationType + self.twoWay = twoWay + self.twoWayKey = twoWayKey + self.onDelete = onDelete + self.side = side + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.relatedTable = try container.decode(String.self, forKey: .relatedTable) + self.relationType = try container.decode(String.self, forKey: .relationType) + self.twoWay = try container.decode(Bool.self, forKey: .twoWay) + self.twoWayKey = try container.decode(String.self, forKey: .twoWayKey) + self.onDelete = try container.decode(String.self, forKey: .onDelete) + self.side = try container.decode(String.self, forKey: .side) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(relatedTable, forKey: .relatedTable) + try container.encode(relationType, forKey: .relationType) + try container.encode(twoWay, forKey: .twoWay) + try container.encode(twoWayKey, forKey: .twoWayKey) + try container.encode(onDelete, forKey: .onDelete) + try container.encode(side, forKey: .side) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "relatedTable": relatedTable as Any, + "relationType": relationType as Any, + "twoWay": twoWay as Any, + "twoWayKey": twoWayKey as Any, + "onDelete": onDelete as Any, + "side": side as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnRelationship { + return ColumnRelationship( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + relatedTable: map["relatedTable"] as! String, + relationType: map["relationType"] as! String, + twoWay: map["twoWay"] as! Bool, + twoWayKey: map["twoWayKey"] as! String, + onDelete: map["onDelete"] as! String, + side: map["side"] as! String + ) + } +} diff --git a/Sources/AppwriteModels/ColumnString.swift b/Sources/AppwriteModels/ColumnString.swift new file mode 100644 index 0000000..77f625c --- /dev/null +++ b/Sources/AppwriteModels/ColumnString.swift @@ -0,0 +1,144 @@ +import Foundation +import JSONCodable + +/// ColumnString +open class ColumnString: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case size = "size" + case `default` = "default" + case encrypt = "encrypt" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// Column size. + public let size: Int + + /// Default value for column when not provided. Cannot be set when column is required. + public let `default`: String? + + /// Defines whether this column is encrypted or not. + public let encrypt: Bool? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + size: Int, + `default`: String?, + encrypt: Bool? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.size = size + self.`default` = `default` + self.encrypt = encrypt + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.size = try container.decode(Int.self, forKey: .size) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + self.encrypt = try container.decodeIfPresent(Bool.self, forKey: .encrypt) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(size, forKey: .size) + try container.encodeIfPresent(`default`, forKey: .`default`) + try container.encodeIfPresent(encrypt, forKey: .encrypt) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "size": size as Any, + "`default`": `default` as Any, + "encrypt": encrypt as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnString { + return ColumnString( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + size: map["size"] as! Int, + default: map["default"] as? String, + encrypt: map["encrypt"] as? Bool + ) + } +} diff --git a/Sources/AppwriteModels/ColumnUrl.swift b/Sources/AppwriteModels/ColumnUrl.swift new file mode 100644 index 0000000..62aa875 --- /dev/null +++ b/Sources/AppwriteModels/ColumnUrl.swift @@ -0,0 +1,134 @@ +import Foundation +import JSONCodable + +/// ColumnURL +open class ColumnUrl: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case `required` = "required" + case array = "array" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case format = "format" + case `default` = "default" + } + + /// Column Key. + public let key: String + + /// Column type. + public let type: String + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + public let status: String + + /// Error message. Displays error generated on failure of creating or deleting an column. + public let error: String + + /// Is column required? + public let `required`: Bool + + /// Is column an array? + public let array: Bool? + + /// Column creation date in ISO 8601 format. + public let createdAt: String + + /// Column update date in ISO 8601 format. + public let updatedAt: String + + /// String format. + public let format: String + + /// Default value for column when not provided. Cannot be set when column is required. + public let `default`: String? + + + init( + key: String, + type: String, + status: String, + error: String, + `required`: Bool, + array: Bool?, + createdAt: String, + updatedAt: String, + format: String, + `default`: String? + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.`required` = `required` + self.array = array + self.createdAt = createdAt + self.updatedAt = updatedAt + self.format = format + self.`default` = `default` + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.key = try container.decode(String.self, forKey: .key) + self.type = try container.decode(String.self, forKey: .type) + self.status = try container.decode(String.self, forKey: .status) + self.error = try container.decode(String.self, forKey: .error) + self.`required` = try container.decode(Bool.self, forKey: .`required`) + self.array = try container.decodeIfPresent(Bool.self, forKey: .array) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.format = try container.decode(String.self, forKey: .format) + self.`default` = try container.decodeIfPresent(String.self, forKey: .`default`) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(key, forKey: .key) + try container.encode(type, forKey: .type) + try container.encode(status, forKey: .status) + try container.encode(error, forKey: .error) + try container.encode(`required`, forKey: .`required`) + try container.encodeIfPresent(array, forKey: .array) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(format, forKey: .format) + try container.encodeIfPresent(`default`, forKey: .`default`) + } + + public func toMap() -> [String: Any] { + return [ + "key": key as Any, + "type": type as Any, + "status": status as Any, + "error": error as Any, + "`required`": `required` as Any, + "array": array as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "format": format as Any, + "`default`": `default` as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnUrl { + return ColumnUrl( + key: map["key"] as! String, + type: map["type"] as! String, + status: map["status"] as! String, + error: map["error"] as! String, + required: map["required"] as! Bool, + array: map["array"] as? Bool, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + format: map["format"] as! String, + default: map["default"] as? String + ) + } +} diff --git a/Sources/AppwriteModels/ContinentList.swift b/Sources/AppwriteModels/ContinentList.swift index fa9a90f..7ebd966 100644 --- a/Sources/AppwriteModels/ContinentList.swift +++ b/Sources/AppwriteModels/ContinentList.swift @@ -9,7 +9,7 @@ open class ContinentList: Codable { case continents = "continents" } - /// Total number of continents documents that matched your query. + /// Total number of continents rows that matched your query. public let total: Int /// List of continents. diff --git a/Sources/AppwriteModels/CountryList.swift b/Sources/AppwriteModels/CountryList.swift index 865cc19..61389ba 100644 --- a/Sources/AppwriteModels/CountryList.swift +++ b/Sources/AppwriteModels/CountryList.swift @@ -9,7 +9,7 @@ open class CountryList: Codable { case countries = "countries" } - /// Total number of countries documents that matched your query. + /// Total number of countries rows that matched your query. public let total: Int /// List of countries. diff --git a/Sources/AppwriteModels/CurrencyList.swift b/Sources/AppwriteModels/CurrencyList.swift index 1e0dff9..12962a6 100644 --- a/Sources/AppwriteModels/CurrencyList.swift +++ b/Sources/AppwriteModels/CurrencyList.swift @@ -9,7 +9,7 @@ open class CurrencyList: Codable { case currencies = "currencies" } - /// Total number of currencies documents that matched your query. + /// Total number of currencies rows that matched your query. public let total: Int /// List of currencies. diff --git a/Sources/AppwriteModels/Database.swift b/Sources/AppwriteModels/Database.swift index c35c0b3..c3e5a10 100644 --- a/Sources/AppwriteModels/Database.swift +++ b/Sources/AppwriteModels/Database.swift @@ -10,6 +10,7 @@ open class Database: Codable { case createdAt = "$createdAt" case updatedAt = "$updatedAt" case enabled = "enabled" + case type = "type" } /// Database ID. @@ -27,19 +28,24 @@ open class Database: Codable { /// If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. public let enabled: Bool + /// Database type. + public let type: String + init( id: String, name: String, createdAt: String, updatedAt: String, - enabled: Bool + enabled: Bool, + type: String ) { self.id = id self.name = name self.createdAt = createdAt self.updatedAt = updatedAt self.enabled = enabled + self.type = type } public required init(from decoder: Decoder) throws { @@ -50,6 +56,7 @@ open class Database: Codable { self.createdAt = try container.decode(String.self, forKey: .createdAt) self.updatedAt = try container.decode(String.self, forKey: .updatedAt) self.enabled = try container.decode(Bool.self, forKey: .enabled) + self.type = try container.decode(String.self, forKey: .type) } public func encode(to encoder: Encoder) throws { @@ -60,6 +67,7 @@ open class Database: Codable { try container.encode(createdAt, forKey: .createdAt) try container.encode(updatedAt, forKey: .updatedAt) try container.encode(enabled, forKey: .enabled) + try container.encode(type, forKey: .type) } public func toMap() -> [String: Any] { @@ -68,7 +76,8 @@ open class Database: Codable { "name": name as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, - "enabled": enabled as Any + "enabled": enabled as Any, + "type": type as Any ] } @@ -78,7 +87,8 @@ open class Database: Codable { name: map["name"] as! String, createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, - enabled: map["enabled"] as! Bool + enabled: map["enabled"] as! Bool, + type: map["type"] as! String ) } } diff --git a/Sources/AppwriteModels/DatabaseList.swift b/Sources/AppwriteModels/DatabaseList.swift index 588cbaa..509a136 100644 --- a/Sources/AppwriteModels/DatabaseList.swift +++ b/Sources/AppwriteModels/DatabaseList.swift @@ -9,7 +9,7 @@ open class DatabaseList: Codable { case databases = "databases" } - /// Total number of databases documents that matched your query. + /// Total number of databases rows that matched your query. public let total: Int /// List of databases. diff --git a/Sources/AppwriteModels/DeploymentList.swift b/Sources/AppwriteModels/DeploymentList.swift index e218064..615849d 100644 --- a/Sources/AppwriteModels/DeploymentList.swift +++ b/Sources/AppwriteModels/DeploymentList.swift @@ -9,7 +9,7 @@ open class DeploymentList: Codable { case deployments = "deployments" } - /// Total number of deployments documents that matched your query. + /// Total number of deployments rows that matched your query. public let total: Int /// List of deployments. diff --git a/Sources/AppwriteModels/DocumentList.swift b/Sources/AppwriteModels/DocumentList.swift index a129182..abed99a 100644 --- a/Sources/AppwriteModels/DocumentList.swift +++ b/Sources/AppwriteModels/DocumentList.swift @@ -9,7 +9,7 @@ open class DocumentList: Codable { case documents = "documents" } - /// Total number of documents documents that matched your query. + /// Total number of documents rows that matched your query. public let total: Int /// List of documents. diff --git a/Sources/AppwriteModels/ExecutionList.swift b/Sources/AppwriteModels/ExecutionList.swift index 72d43a6..da9ea78 100644 --- a/Sources/AppwriteModels/ExecutionList.swift +++ b/Sources/AppwriteModels/ExecutionList.swift @@ -9,7 +9,7 @@ open class ExecutionList: Codable { case executions = "executions" } - /// Total number of executions documents that matched your query. + /// Total number of executions rows that matched your query. public let total: Int /// List of executions. diff --git a/Sources/AppwriteModels/FileList.swift b/Sources/AppwriteModels/FileList.swift index bec7b76..bd4e332 100644 --- a/Sources/AppwriteModels/FileList.swift +++ b/Sources/AppwriteModels/FileList.swift @@ -9,7 +9,7 @@ open class FileList: Codable { case files = "files" } - /// Total number of files documents that matched your query. + /// Total number of files rows that matched your query. public let total: Int /// List of files. diff --git a/Sources/AppwriteModels/FrameworkList.swift b/Sources/AppwriteModels/FrameworkList.swift index 7aa2ce7..5de77fb 100644 --- a/Sources/AppwriteModels/FrameworkList.swift +++ b/Sources/AppwriteModels/FrameworkList.swift @@ -9,7 +9,7 @@ open class FrameworkList: Codable { case frameworks = "frameworks" } - /// Total number of frameworks documents that matched your query. + /// Total number of frameworks rows that matched your query. public let total: Int /// List of frameworks. diff --git a/Sources/AppwriteModels/FunctionList.swift b/Sources/AppwriteModels/FunctionList.swift index c00badb..4c87be3 100644 --- a/Sources/AppwriteModels/FunctionList.swift +++ b/Sources/AppwriteModels/FunctionList.swift @@ -9,7 +9,7 @@ open class FunctionList: Codable { case functions = "functions" } - /// Total number of functions documents that matched your query. + /// Total number of functions rows that matched your query. public let total: Int /// List of functions. diff --git a/Sources/AppwriteModels/IdentityList.swift b/Sources/AppwriteModels/IdentityList.swift index 6065fad..958284c 100644 --- a/Sources/AppwriteModels/IdentityList.swift +++ b/Sources/AppwriteModels/IdentityList.swift @@ -9,7 +9,7 @@ open class IdentityList: Codable { case identities = "identities" } - /// Total number of identities documents that matched your query. + /// Total number of identities rows that matched your query. public let total: Int /// List of identities. diff --git a/Sources/AppwriteModels/Index.swift b/Sources/AppwriteModels/Index.swift index 7b5fb13..a2cc1c8 100644 --- a/Sources/AppwriteModels/Index.swift +++ b/Sources/AppwriteModels/Index.swift @@ -5,6 +5,9 @@ import JSONCodable open class Index: Codable { enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" case key = "key" case type = "type" case status = "status" @@ -12,11 +15,18 @@ open class Index: Codable { case attributes = "attributes" case lengths = "lengths" case orders = "orders" - case createdAt = "$createdAt" - case updatedAt = "$updatedAt" } - /// Index Key. + /// Index ID. + public let id: String + + /// Index creation date in ISO 8601 format. + public let createdAt: String + + /// Index update date in ISO 8601 format. + public let updatedAt: String + + /// Index key. public let key: String /// Index type. @@ -37,24 +47,22 @@ open class Index: Codable { /// Index orders. public let orders: [String]? - /// Index creation date in ISO 8601 format. - public let createdAt: String - - /// Index update date in ISO 8601 format. - public let updatedAt: String - init( + id: String, + createdAt: String, + updatedAt: String, key: String, type: String, status: String, error: String, attributes: [String], lengths: [Int], - orders: [String]?, - createdAt: String, - updatedAt: String + orders: [String]? ) { + self.id = id + self.createdAt = createdAt + self.updatedAt = updatedAt self.key = key self.type = type self.status = status @@ -62,13 +70,14 @@ open class Index: Codable { self.attributes = attributes self.lengths = lengths self.orders = orders - self.createdAt = createdAt - self.updatedAt = updatedAt } 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.key = try container.decode(String.self, forKey: .key) self.type = try container.decode(String.self, forKey: .type) self.status = try container.decode(String.self, forKey: .status) @@ -76,13 +85,14 @@ open class Index: Codable { self.attributes = try container.decode([String].self, forKey: .attributes) self.lengths = try container.decode([Int].self, forKey: .lengths) self.orders = try container.decodeIfPresent([String].self, forKey: .orders) - self.createdAt = try container.decode(String.self, forKey: .createdAt) - self.updatedAt = try container.decode(String.self, forKey: .updatedAt) } 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(key, forKey: .key) try container.encode(type, forKey: .type) try container.encode(status, forKey: .status) @@ -90,35 +100,35 @@ open class Index: Codable { try container.encode(attributes, forKey: .attributes) try container.encode(lengths, forKey: .lengths) try container.encodeIfPresent(orders, forKey: .orders) - try container.encode(createdAt, forKey: .createdAt) - try container.encode(updatedAt, forKey: .updatedAt) } public func toMap() -> [String: Any] { return [ + "$id": id as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, "key": key as Any, "type": type as Any, "status": status as Any, "error": error as Any, "attributes": attributes as Any, "lengths": lengths as Any, - "orders": orders as Any, - "$createdAt": createdAt as Any, - "$updatedAt": updatedAt as Any + "orders": orders as Any ] } public static func from(map: [String: Any] ) -> Index { return Index( + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, key: map["key"] as! String, type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, attributes: map["attributes"] as! [String], lengths: map["lengths"] as! [Int], - orders: map["orders"] as? [String], - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String + orders: map["orders"] as? [String] ) } } diff --git a/Sources/AppwriteModels/IndexList.swift b/Sources/AppwriteModels/IndexList.swift index 2f3ae30..4b87aff 100644 --- a/Sources/AppwriteModels/IndexList.swift +++ b/Sources/AppwriteModels/IndexList.swift @@ -9,7 +9,7 @@ open class IndexList: Codable { case indexes = "indexes" } - /// Total number of indexes documents that matched your query. + /// Total number of indexes rows that matched your query. public let total: Int /// List of indexes. diff --git a/Sources/AppwriteModels/LanguageList.swift b/Sources/AppwriteModels/LanguageList.swift index 13c6e4a..0edfa80 100644 --- a/Sources/AppwriteModels/LanguageList.swift +++ b/Sources/AppwriteModels/LanguageList.swift @@ -9,7 +9,7 @@ open class LanguageList: Codable { case languages = "languages" } - /// Total number of languages documents that matched your query. + /// Total number of languages rows that matched your query. public let total: Int /// List of languages. diff --git a/Sources/AppwriteModels/LocaleCodeList.swift b/Sources/AppwriteModels/LocaleCodeList.swift index 5ef0653..0d22818 100644 --- a/Sources/AppwriteModels/LocaleCodeList.swift +++ b/Sources/AppwriteModels/LocaleCodeList.swift @@ -9,7 +9,7 @@ open class LocaleCodeList: Codable { case localeCodes = "localeCodes" } - /// Total number of localeCodes documents that matched your query. + /// Total number of localeCodes rows that matched your query. public let total: Int /// List of localeCodes. diff --git a/Sources/AppwriteModels/LogList.swift b/Sources/AppwriteModels/LogList.swift index 7ff2d07..c9207b8 100644 --- a/Sources/AppwriteModels/LogList.swift +++ b/Sources/AppwriteModels/LogList.swift @@ -9,7 +9,7 @@ open class LogList: Codable { case logs = "logs" } - /// Total number of logs documents that matched your query. + /// Total number of logs rows that matched your query. public let total: Int /// List of logs. diff --git a/Sources/AppwriteModels/MembershipList.swift b/Sources/AppwriteModels/MembershipList.swift index a7b0cd6..9290f69 100644 --- a/Sources/AppwriteModels/MembershipList.swift +++ b/Sources/AppwriteModels/MembershipList.swift @@ -9,7 +9,7 @@ open class MembershipList: Codable { case memberships = "memberships" } - /// Total number of memberships documents that matched your query. + /// Total number of memberships rows that matched your query. public let total: Int /// List of memberships. diff --git a/Sources/AppwriteModels/MessageList.swift b/Sources/AppwriteModels/MessageList.swift index f62fcaa..865f605 100644 --- a/Sources/AppwriteModels/MessageList.swift +++ b/Sources/AppwriteModels/MessageList.swift @@ -9,7 +9,7 @@ open class MessageList: Codable { case messages = "messages" } - /// Total number of messages documents that matched your query. + /// Total number of messages rows that matched your query. public let total: Int /// List of messages. diff --git a/Sources/AppwriteModels/PhoneList.swift b/Sources/AppwriteModels/PhoneList.swift index 6f3bee3..63371a6 100644 --- a/Sources/AppwriteModels/PhoneList.swift +++ b/Sources/AppwriteModels/PhoneList.swift @@ -9,7 +9,7 @@ open class PhoneList: Codable { case phones = "phones" } - /// Total number of phones documents that matched your query. + /// Total number of phones rows that matched your query. public let total: Int /// List of phones. diff --git a/Sources/AppwriteModels/ProviderList.swift b/Sources/AppwriteModels/ProviderList.swift index 76fd4eb..b440d6d 100644 --- a/Sources/AppwriteModels/ProviderList.swift +++ b/Sources/AppwriteModels/ProviderList.swift @@ -9,7 +9,7 @@ open class ProviderList: Codable { case providers = "providers" } - /// Total number of providers documents that matched your query. + /// Total number of providers rows that matched your query. public let total: Int /// List of providers. diff --git a/Sources/AppwriteModels/ResourceTokenList.swift b/Sources/AppwriteModels/ResourceTokenList.swift index 6d894b6..575c758 100644 --- a/Sources/AppwriteModels/ResourceTokenList.swift +++ b/Sources/AppwriteModels/ResourceTokenList.swift @@ -9,7 +9,7 @@ open class ResourceTokenList: Codable { case tokens = "tokens" } - /// Total number of tokens documents that matched your query. + /// Total number of tokens rows that matched your query. public let total: Int /// List of tokens. diff --git a/Sources/AppwriteModels/Row.swift b/Sources/AppwriteModels/Row.swift new file mode 100644 index 0000000..6e94a9e --- /dev/null +++ b/Sources/AppwriteModels/Row.swift @@ -0,0 +1,113 @@ +import Foundation +import JSONCodable + +/// Row +open class Row: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case sequence = "$sequence" + case tableId = "$tableId" + case databaseId = "$databaseId" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case data + } + + /// Row ID. + public let id: String + + /// Row automatically incrementing ID. + public let sequence: Int + + /// Table ID. + public let tableId: String + + /// Database ID. + public let databaseId: String + + /// Row creation date in ISO 8601 format. + public let createdAt: String + + /// Row update date in ISO 8601 format. + public let updatedAt: String + + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + public let permissions: [String] + + /// Additional properties + public let data: T + + init( + id: String, + sequence: Int, + tableId: String, + databaseId: String, + createdAt: String, + updatedAt: String, + permissions: [String], + data: T + ) { + self.id = id + self.sequence = sequence + self.tableId = tableId + self.databaseId = databaseId + self.createdAt = createdAt + self.updatedAt = updatedAt + self.permissions = permissions + self.data = data + } + + 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.sequence = try container.decode(Int.self, forKey: .sequence) + self.tableId = try container.decode(String.self, forKey: .tableId) + self.databaseId = try container.decode(String.self, forKey: .databaseId) + self.createdAt = try container.decode(String.self, forKey: .createdAt) + self.updatedAt = try container.decode(String.self, forKey: .updatedAt) + self.permissions = try container.decode([String].self, forKey: .permissions) + self.data = try container.decode(T.self, forKey: .data) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: .id) + try container.encode(sequence, forKey: .sequence) + try container.encode(tableId, forKey: .tableId) + try container.encode(databaseId, forKey: .databaseId) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + try container.encode(permissions, forKey: .permissions) + try container.encode(data, forKey: .data) + } + + public func toMap() -> [String: Any] { + return [ + "$id": id as Any, + "$sequence": sequence as Any, + "$tableId": tableId as Any, + "$databaseId": databaseId as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "$permissions": permissions as Any, + "data": try! JSONEncoder().encode(data) + ] + } + + public static func from(map: [String: Any] ) -> Row { + return Row( + id: map["$id"] as! String, + sequence: map["$sequence"] as! Int, + tableId: map["$tableId"] as! String, + databaseId: map["$databaseId"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + permissions: map["$permissions"] as! [String], + data: try! JSONDecoder().decode(T.self, from: JSONSerialization.data(withJSONObject: map, options: [])) + ) + } +} diff --git a/Sources/AppwriteModels/RowList.swift b/Sources/AppwriteModels/RowList.swift new file mode 100644 index 0000000..8eb7d80 --- /dev/null +++ b/Sources/AppwriteModels/RowList.swift @@ -0,0 +1,54 @@ +import Foundation +import JSONCodable + +/// Rows List +open class RowList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case rows = "rows" + } + + /// Total number of rows rows that matched your query. + public let total: Int + + /// List of rows. + public let rows: [Row] + + + init( + total: Int, + rows: [Row] + ) { + self.total = total + self.rows = rows + } + + 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.rows = try container.decode([Row].self, forKey: .rows) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(rows, forKey: .rows) + } + + public func toMap() -> [String: Any] { + return [ + "total": total as Any, + "rows": rows.map { $0.toMap() } as Any + ] + } + + public static func from(map: [String: Any] ) -> RowList { + return RowList( + total: map["total"] as! Int, + rows: (map["rows"] as! [[String: Any]]).map { Row.from(map: $0) } + ) + } +} diff --git a/Sources/AppwriteModels/RuntimeList.swift b/Sources/AppwriteModels/RuntimeList.swift index ab99ed1..36fcdef 100644 --- a/Sources/AppwriteModels/RuntimeList.swift +++ b/Sources/AppwriteModels/RuntimeList.swift @@ -9,7 +9,7 @@ open class RuntimeList: Codable { case runtimes = "runtimes" } - /// Total number of runtimes documents that matched your query. + /// Total number of runtimes rows that matched your query. public let total: Int /// List of runtimes. diff --git a/Sources/AppwriteModels/SessionList.swift b/Sources/AppwriteModels/SessionList.swift index 13b6b3d..5a227e5 100644 --- a/Sources/AppwriteModels/SessionList.swift +++ b/Sources/AppwriteModels/SessionList.swift @@ -9,7 +9,7 @@ open class SessionList: Codable { case sessions = "sessions" } - /// Total number of sessions documents that matched your query. + /// Total number of sessions rows that matched your query. public let total: Int /// List of sessions. diff --git a/Sources/AppwriteModels/SiteList.swift b/Sources/AppwriteModels/SiteList.swift index 6c37fae..0375cd1 100644 --- a/Sources/AppwriteModels/SiteList.swift +++ b/Sources/AppwriteModels/SiteList.swift @@ -9,7 +9,7 @@ open class SiteList: Codable { case sites = "sites" } - /// Total number of sites documents that matched your query. + /// Total number of sites rows that matched your query. public let total: Int /// List of sites. diff --git a/Sources/AppwriteModels/SpecificationList.swift b/Sources/AppwriteModels/SpecificationList.swift index f2b9766..3e684f9 100644 --- a/Sources/AppwriteModels/SpecificationList.swift +++ b/Sources/AppwriteModels/SpecificationList.swift @@ -9,7 +9,7 @@ open class SpecificationList: Codable { case specifications = "specifications" } - /// Total number of specifications documents that matched your query. + /// Total number of specifications rows that matched your query. public let total: Int /// List of specifications. diff --git a/Sources/AppwriteModels/SubscriberList.swift b/Sources/AppwriteModels/SubscriberList.swift index 2d63f07..1c41642 100644 --- a/Sources/AppwriteModels/SubscriberList.swift +++ b/Sources/AppwriteModels/SubscriberList.swift @@ -9,7 +9,7 @@ open class SubscriberList: Codable { case subscribers = "subscribers" } - /// Total number of subscribers documents that matched your query. + /// Total number of subscribers rows that matched your query. public let total: Int /// List of subscribers. diff --git a/Sources/AppwriteModels/Table.swift b/Sources/AppwriteModels/Table.swift new file mode 100644 index 0000000..82bdd3d --- /dev/null +++ b/Sources/AppwriteModels/Table.swift @@ -0,0 +1,134 @@ +import Foundation +import JSONCodable + +/// Table +open class Table: Codable { + + enum CodingKeys: String, CodingKey { + case id = "$id" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + case permissions = "$permissions" + case databaseId = "databaseId" + case name = "name" + case enabled = "enabled" + case rowSecurity = "rowSecurity" + case columns = "columns" + case indexes = "indexes" + } + + /// Table ID. + public let id: String + + /// Table creation date in ISO 8601 format. + public let createdAt: String + + /// Table update date in ISO 8601 format. + public let updatedAt: String + + /// Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + public let permissions: [String] + + /// Database ID. + public let databaseId: String + + /// Table name. + public let name: String + + /// Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. + public let enabled: Bool + + /// Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + public let rowSecurity: Bool + + /// Table columns. + public let columns: [AnyCodable] + + /// Table indexes. + public let indexes: [ColumnIndex] + + + init( + id: String, + createdAt: String, + updatedAt: String, + permissions: [String], + databaseId: String, + name: String, + enabled: Bool, + rowSecurity: Bool, + columns: [AnyCodable], + indexes: [ColumnIndex] + ) { + self.id = id + self.createdAt = createdAt + self.updatedAt = updatedAt + self.permissions = permissions + self.databaseId = databaseId + self.name = name + self.enabled = enabled + self.rowSecurity = rowSecurity + self.columns = columns + self.indexes = indexes + } + + 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.databaseId = try container.decode(String.self, forKey: .databaseId) + self.name = try container.decode(String.self, forKey: .name) + self.enabled = try container.decode(Bool.self, forKey: .enabled) + self.rowSecurity = try container.decode(Bool.self, forKey: .rowSecurity) + self.columns = try container.decode([AnyCodable].self, forKey: .columns) + self.indexes = try container.decode([ColumnIndex].self, forKey: .indexes) + } + + 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(databaseId, forKey: .databaseId) + try container.encode(name, forKey: .name) + try container.encode(enabled, forKey: .enabled) + try container.encode(rowSecurity, forKey: .rowSecurity) + try container.encode(columns, forKey: .columns) + try container.encode(indexes, forKey: .indexes) + } + + public func toMap() -> [String: Any] { + return [ + "$id": id as Any, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any, + "$permissions": permissions as Any, + "databaseId": databaseId as Any, + "name": name as Any, + "enabled": enabled as Any, + "rowSecurity": rowSecurity as Any, + "columns": columns as Any, + "indexes": indexes.map { $0.toMap() } as Any + ] + } + + public static func from(map: [String: Any] ) -> Table { + return Table( + id: map["$id"] as! String, + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] as! String, + permissions: map["$permissions"] as! [String], + databaseId: map["databaseId"] as! String, + name: map["name"] as! String, + enabled: map["enabled"] as! Bool, + rowSecurity: map["rowSecurity"] as! Bool, + columns: (map["columns"] as! [Any]).map { AnyCodable($0) }, + indexes: (map["indexes"] as! [[String: Any]]).map { ColumnIndex.from(map: $0) } + ) + } +} diff --git a/Sources/AppwriteModels/TableList.swift b/Sources/AppwriteModels/TableList.swift new file mode 100644 index 0000000..50a8bea --- /dev/null +++ b/Sources/AppwriteModels/TableList.swift @@ -0,0 +1,54 @@ +import Foundation +import JSONCodable + +/// Tables List +open class TableList: Codable { + + enum CodingKeys: String, CodingKey { + case total = "total" + case tables = "tables" + } + + /// Total number of tables rows that matched your query. + public let total: Int + + /// List of tables. + public let tables: [Table] + + + init( + total: Int, + tables: [Table] + ) { + self.total = total + self.tables = tables + } + + 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.tables = try container.decode([Table].self, forKey: .tables) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(total, forKey: .total) + try container.encode(tables, forKey: .tables) + } + + public func toMap() -> [String: Any] { + return [ + "total": total as Any, + "tables": tables.map { $0.toMap() } as Any + ] + } + + public static func from(map: [String: Any] ) -> TableList { + return TableList( + total: map["total"] as! Int, + tables: (map["tables"] as! [[String: Any]]).map { Table.from(map: $0) } + ) + } +} diff --git a/Sources/AppwriteModels/TargetList.swift b/Sources/AppwriteModels/TargetList.swift index 6c9f247..b28034f 100644 --- a/Sources/AppwriteModels/TargetList.swift +++ b/Sources/AppwriteModels/TargetList.swift @@ -9,7 +9,7 @@ open class TargetList: Codable { case targets = "targets" } - /// Total number of targets documents that matched your query. + /// Total number of targets rows that matched your query. public let total: Int /// List of targets. diff --git a/Sources/AppwriteModels/TeamList.swift b/Sources/AppwriteModels/TeamList.swift index 384d9f6..988a1ec 100644 --- a/Sources/AppwriteModels/TeamList.swift +++ b/Sources/AppwriteModels/TeamList.swift @@ -9,7 +9,7 @@ open class TeamList: Codable { case teams = "teams" } - /// Total number of teams documents that matched your query. + /// Total number of teams rows that matched your query. public let total: Int /// List of teams. diff --git a/Sources/AppwriteModels/TopicList.swift b/Sources/AppwriteModels/TopicList.swift index 66eae2c..f2393b2 100644 --- a/Sources/AppwriteModels/TopicList.swift +++ b/Sources/AppwriteModels/TopicList.swift @@ -9,7 +9,7 @@ open class TopicList: Codable { case topics = "topics" } - /// Total number of topics documents that matched your query. + /// Total number of topics rows that matched your query. public let total: Int /// List of topics. diff --git a/Sources/AppwriteModels/UserList.swift b/Sources/AppwriteModels/UserList.swift index 7bf7413..4c5c1cd 100644 --- a/Sources/AppwriteModels/UserList.swift +++ b/Sources/AppwriteModels/UserList.swift @@ -9,7 +9,7 @@ open class UserList: Codable { case users = "users" } - /// Total number of users documents that matched your query. + /// Total number of users rows that matched your query. public let total: Int /// List of users. diff --git a/Sources/AppwriteModels/VariableList.swift b/Sources/AppwriteModels/VariableList.swift index 8345d0b..e0537d3 100644 --- a/Sources/AppwriteModels/VariableList.swift +++ b/Sources/AppwriteModels/VariableList.swift @@ -9,7 +9,7 @@ open class VariableList: Codable { case variables = "variables" } - /// Total number of variables documents that matched your query. + /// Total number of variables rows that matched your query. public let total: Int /// List of variables. diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index b0362bb..bd10f63 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -1,4 +1,5 @@ import Appwrite +import AppwriteEnums let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -10,6 +11,7 @@ let databases = Databases(client) let database = try await databases.create( databaseId: "", name: "", - enabled: false // optional + enabled: false, // optional + type: .tablesdb // optional ) diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index aae7a0f..46c9d69 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -15,6 +15,6 @@ let execution = try await functions.createExecution( path: "", // optional method: .gET, // optional headers: [:], // optional - scheduledAt: "" // optional + scheduledAt: "" // optional ) diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md new file mode 100644 index 0000000..2e25e1b --- /dev/null +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnBoolean = try await tablesDb.createBooleanColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: false, // optional + array: false // optional +) + diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md new file mode 100644 index 0000000..b60b1da --- /dev/null +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnDatetime = try await tablesDb.createDatetimeColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", // optional + array: false // optional +) + diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md new file mode 100644 index 0000000..859fce5 --- /dev/null +++ b/docs/examples/tablesdb/create-email-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnEmail = try await tablesDb.createEmailColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "email@example.com", // optional + array: false // optional +) + diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md new file mode 100644 index 0000000..d19f724 --- /dev/null +++ b/docs/examples/tablesdb/create-enum-column.md @@ -0,0 +1,19 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnEnum = try await tablesDb.createEnumColumn( + databaseId: "", + tableId: "", + key: "", + elements: [], + required: false, + default: "", // optional + array: false // optional +) + diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md new file mode 100644 index 0000000..5a2aee0 --- /dev/null +++ b/docs/examples/tablesdb/create-float-column.md @@ -0,0 +1,20 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnFloat = try await tablesDb.createFloatColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + min: 0, // optional + max: 0, // optional + default: 0, // optional + array: false // optional +) + diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md new file mode 100644 index 0000000..f01174c --- /dev/null +++ b/docs/examples/tablesdb/create-index.md @@ -0,0 +1,20 @@ +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 tablesDb = TablesDb(client) + +let columnIndex = try await tablesDb.createIndex( + databaseId: "", + tableId: "", + key: "", + type: .key, + columns: [], + orders: [], // optional + lengths: [] // optional +) + diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md new file mode 100644 index 0000000..5131617 --- /dev/null +++ b/docs/examples/tablesdb/create-integer-column.md @@ -0,0 +1,20 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnInteger = try await tablesDb.createIntegerColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + min: 0, // optional + max: 0, // optional + default: 0, // optional + array: false // optional +) + diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md new file mode 100644 index 0000000..2388c89 --- /dev/null +++ b/docs/examples/tablesdb/create-ip-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnIp = try await tablesDb.createIpColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", // optional + array: false // optional +) + diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md new file mode 100644 index 0000000..3dc765a --- /dev/null +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -0,0 +1,21 @@ +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 tablesDb = TablesDb(client) + +let columnRelationship = try await tablesDb.createRelationshipColumn( + databaseId: "", + tableId: "", + relatedTableId: "", + type: .oneToOne, + twoWay: false, // optional + key: "", // optional + twoWayKey: "", // optional + onDelete: .cascade // optional +) + diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md new file mode 100644 index 0000000..601bd32 --- /dev/null +++ b/docs/examples/tablesdb/create-row.md @@ -0,0 +1,17 @@ +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 tablesDb = TablesDb(client) + +let row = try await tablesDb.createRow( + databaseId: "", + tableId: "", + rowId: "", + data: [:], + permissions: ["read("any")"] // optional +) + diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md new file mode 100644 index 0000000..e685ae7 --- /dev/null +++ b/docs/examples/tablesdb/create-rows.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let rowList = try await tablesDb.createRows( + databaseId: "", + tableId: "", + rows: [] +) + diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md new file mode 100644 index 0000000..c1f3082 --- /dev/null +++ b/docs/examples/tablesdb/create-string-column.md @@ -0,0 +1,20 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnString = try await tablesDb.createStringColumn( + databaseId: "", + tableId: "", + key: "", + size: 1, + required: false, + default: "", // optional + array: false, // optional + encrypt: false // optional +) + diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md new file mode 100644 index 0000000..631afb6 --- /dev/null +++ b/docs/examples/tablesdb/create-table.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let table = try await tablesDb.createTable( + databaseId: "", + tableId: "", + name: "", + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +) + diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md new file mode 100644 index 0000000..b2e9917 --- /dev/null +++ b/docs/examples/tablesdb/create-url-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnUrl = try await tablesDb.createUrlColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "https://example.com", // optional + array: false // optional +) + diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md new file mode 100644 index 0000000..ebf7a92 --- /dev/null +++ b/docs/examples/tablesdb/create.md @@ -0,0 +1,17 @@ +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 tablesDb = TablesDb(client) + +let database = try await tablesDb.create( + databaseId: "", + name: "", + enabled: false, // optional + type: .tablesdb // optional +) + diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md new file mode 100644 index 0000000..0ebad7b --- /dev/null +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let row = try await tablesDb.decrementRowColumn( + databaseId: "", + tableId: "", + rowId: "", + column: "", + value: 0, // optional + min: 0 // optional +) + diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md new file mode 100644 index 0000000..781b109 --- /dev/null +++ b/docs/examples/tablesdb/delete-column.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let result = try await tablesDb.deleteColumn( + databaseId: "", + tableId: "", + key: "" +) + diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md new file mode 100644 index 0000000..8fb2386 --- /dev/null +++ b/docs/examples/tablesdb/delete-index.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let result = try await tablesDb.deleteIndex( + databaseId: "", + tableId: "", + key: "" +) + diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md new file mode 100644 index 0000000..e533aa3 --- /dev/null +++ b/docs/examples/tablesdb/delete-row.md @@ -0,0 +1,15 @@ +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 tablesDb = TablesDb(client) + +let result = try await tablesDb.deleteRow( + databaseId: "", + tableId: "", + rowId: "" +) + diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md new file mode 100644 index 0000000..7007369 --- /dev/null +++ b/docs/examples/tablesdb/delete-rows.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let rowList = try await tablesDb.deleteRows( + databaseId: "", + tableId: "", + queries: [] // optional +) + diff --git a/docs/examples/tablesdb/delete-table.md b/docs/examples/tablesdb/delete-table.md new file mode 100644 index 0000000..2d2df8f --- /dev/null +++ b/docs/examples/tablesdb/delete-table.md @@ -0,0 +1,14 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let result = try await tablesDb.deleteTable( + databaseId: "", + tableId: "" +) + diff --git a/docs/examples/tablesdb/delete.md b/docs/examples/tablesdb/delete.md new file mode 100644 index 0000000..0c26a0d --- /dev/null +++ b/docs/examples/tablesdb/delete.md @@ -0,0 +1,13 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let result = try await tablesDb.delete( + databaseId: "" +) + diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md new file mode 100644 index 0000000..21fe88c --- /dev/null +++ b/docs/examples/tablesdb/get-column.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let result = try await tablesDb.getColumn( + databaseId: "", + tableId: "", + key: "" +) + diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md new file mode 100644 index 0000000..2022d1e --- /dev/null +++ b/docs/examples/tablesdb/get-index.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnIndex = try await tablesDb.getIndex( + databaseId: "", + tableId: "", + key: "" +) + diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md new file mode 100644 index 0000000..45961f8 --- /dev/null +++ b/docs/examples/tablesdb/get-row.md @@ -0,0 +1,16 @@ +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 tablesDb = TablesDb(client) + +let row = try await tablesDb.getRow( + databaseId: "", + tableId: "", + rowId: "", + queries: [] // optional +) + diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md new file mode 100644 index 0000000..391adcd --- /dev/null +++ b/docs/examples/tablesdb/get-table.md @@ -0,0 +1,14 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let table = try await tablesDb.getTable( + databaseId: "", + tableId: "" +) + diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md new file mode 100644 index 0000000..2442a7d --- /dev/null +++ b/docs/examples/tablesdb/get.md @@ -0,0 +1,13 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let database = try await tablesDb.get( + databaseId: "" +) + diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md new file mode 100644 index 0000000..5f1ee4c --- /dev/null +++ b/docs/examples/tablesdb/increment-row-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let row = try await tablesDb.incrementRowColumn( + databaseId: "", + tableId: "", + rowId: "", + column: "", + value: 0, // optional + max: 0 // optional +) + diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md new file mode 100644 index 0000000..33010e6 --- /dev/null +++ b/docs/examples/tablesdb/list-columns.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnList = try await tablesDb.listColumns( + databaseId: "", + tableId: "", + queries: [] // optional +) + diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md new file mode 100644 index 0000000..621ffa1 --- /dev/null +++ b/docs/examples/tablesdb/list-indexes.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnIndexList = try await tablesDb.listIndexes( + databaseId: "", + tableId: "", + queries: [] // optional +) + diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md new file mode 100644 index 0000000..de9b682 --- /dev/null +++ b/docs/examples/tablesdb/list-rows.md @@ -0,0 +1,15 @@ +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 tablesDb = TablesDb(client) + +let rowList = try await tablesDb.listRows( + databaseId: "", + tableId: "", + queries: [] // optional +) + diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md new file mode 100644 index 0000000..8fe8d56 --- /dev/null +++ b/docs/examples/tablesdb/list-tables.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let tableList = try await tablesDb.listTables( + databaseId: "", + queries: [], // optional + search: "" // optional +) + diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md new file mode 100644 index 0000000..cc10b51 --- /dev/null +++ b/docs/examples/tablesdb/list.md @@ -0,0 +1,14 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let databaseList = try await tablesDb.list( + queries: [], // optional + search: "" // optional +) + diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md new file mode 100644 index 0000000..c3d7e07 --- /dev/null +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnBoolean = try await tablesDb.updateBooleanColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: false, + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md new file mode 100644 index 0000000..a2d71f4 --- /dev/null +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnDatetime = try await tablesDb.updateDatetimeColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md new file mode 100644 index 0000000..d59c833 --- /dev/null +++ b/docs/examples/tablesdb/update-email-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnEmail = try await tablesDb.updateEmailColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "email@example.com", + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md new file mode 100644 index 0000000..5f1b05e --- /dev/null +++ b/docs/examples/tablesdb/update-enum-column.md @@ -0,0 +1,19 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnEnum = try await tablesDb.updateEnumColumn( + databaseId: "", + tableId: "", + key: "", + elements: [], + required: false, + default: "", + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md new file mode 100644 index 0000000..b2459e5 --- /dev/null +++ b/docs/examples/tablesdb/update-float-column.md @@ -0,0 +1,20 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnFloat = try await tablesDb.updateFloatColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: 0, + min: 0, // optional + max: 0, // optional + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md new file mode 100644 index 0000000..091664a --- /dev/null +++ b/docs/examples/tablesdb/update-integer-column.md @@ -0,0 +1,20 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnInteger = try await tablesDb.updateIntegerColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: 0, + min: 0, // optional + max: 0, // optional + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md new file mode 100644 index 0000000..87f2915 --- /dev/null +++ b/docs/examples/tablesdb/update-ip-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnIp = try await tablesDb.updateIpColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md new file mode 100644 index 0000000..27e7460 --- /dev/null +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -0,0 +1,18 @@ +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 tablesDb = TablesDb(client) + +let columnRelationship = try await tablesDb.updateRelationshipColumn( + databaseId: "", + tableId: "", + key: "", + onDelete: .cascade, // optional + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md new file mode 100644 index 0000000..6e7bd35 --- /dev/null +++ b/docs/examples/tablesdb/update-row.md @@ -0,0 +1,17 @@ +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 tablesDb = TablesDb(client) + +let row = try await tablesDb.updateRow( + databaseId: "", + tableId: "", + rowId: "", + data: [:], // optional + permissions: ["read("any")"] // optional +) + diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md new file mode 100644 index 0000000..4d33169 --- /dev/null +++ b/docs/examples/tablesdb/update-rows.md @@ -0,0 +1,16 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let rowList = try await tablesDb.updateRows( + databaseId: "", + tableId: "", + data: [:], // optional + queries: [] // optional +) + diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md new file mode 100644 index 0000000..defa48e --- /dev/null +++ b/docs/examples/tablesdb/update-string-column.md @@ -0,0 +1,19 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnString = try await tablesDb.updateStringColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", + size: 1, // optional + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md new file mode 100644 index 0000000..3483535 --- /dev/null +++ b/docs/examples/tablesdb/update-table.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let table = try await tablesDb.updateTable( + databaseId: "", + tableId: "", + name: "", + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +) + diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md new file mode 100644 index 0000000..e1fe5ce --- /dev/null +++ b/docs/examples/tablesdb/update-url-column.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let columnUrl = try await tablesDb.updateUrlColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "https://example.com", + newKey: "" // optional +) + diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md new file mode 100644 index 0000000..041f026 --- /dev/null +++ b/docs/examples/tablesdb/update.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let database = try await tablesDb.update( + databaseId: "", + name: "", + enabled: false // optional +) + diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md new file mode 100644 index 0000000..6b1ddaf --- /dev/null +++ b/docs/examples/tablesdb/upsert-row.md @@ -0,0 +1,17 @@ +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 tablesDb = TablesDb(client) + +let row = try await tablesDb.upsertRow( + databaseId: "", + tableId: "", + rowId: "", + data: [:], // optional + permissions: ["read("any")"] // optional +) + diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md new file mode 100644 index 0000000..62737e6 --- /dev/null +++ b/docs/examples/tablesdb/upsert-rows.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let tablesDb = TablesDb(client) + +let rowList = try await tablesDb.upsertRows( + databaseId: "", + tableId: "", + rows: [] +) + From 28cfbdd6f9109d1093fd6217691566117d3aefa6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 20 Aug 2025 18:26:46 +1200 Subject: [PATCH 2/7] Add 1.8.x support --- Sources/Appwrite/Services/Databases.swift | 7 ++----- Sources/Appwrite/Services/TablesDb.swift | 11 ++++------- Sources/AppwriteEnums/Type.swift | 10 ---------- docs/examples/databases/create.md | 4 +--- docs/examples/tablesdb/create.md | 4 +--- 5 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 Sources/AppwriteEnums/Type.swift diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index eb5a9bf..8b8f61a 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -53,7 +53,6 @@ open class Databases: Service { /// - databaseId: String /// - name: String /// - enabled: Bool (optional) - /// - type: AppwriteEnums.Type (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Database /// @@ -61,16 +60,14 @@ open class Databases: Service { open func create( databaseId: String, name: String, - enabled: Bool? = nil, - type: AppwriteEnums.Type? = nil + enabled: Bool? = nil ) async throws -> AppwriteModels.Database { let apiPath: String = "/databases" let apiParams: [String: Any?] = [ "databaseId": databaseId, "name": name, - "enabled": enabled, - "type": type + "enabled": enabled ] let apiHeaders: [String: String] = [ diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDb.swift index 3614e05..a2ef3f8 100644 --- a/Sources/Appwrite/Services/TablesDb.swift +++ b/Sources/Appwrite/Services/TablesDb.swift @@ -52,23 +52,20 @@ open class TablesDb: Service { /// - databaseId: String /// - name: String /// - enabled: Bool (optional) - /// - type: AppwriteEnums.Type (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Database /// open func create( databaseId: String, name: String, - enabled: Bool? = nil, - type: AppwriteEnums.Type? = nil + enabled: Bool? = nil ) async throws -> AppwriteModels.Database { let apiPath: String = "/tablesdb" let apiParams: [String: Any?] = [ "databaseId": databaseId, "name": name, - "enabled": enabled, - "type": type + "enabled": enabled ] let apiHeaders: [String: String] = [ @@ -1549,7 +1546,7 @@ open class TablesDb: Service { } /// - /// List indexes in the collection. + /// List indexes on the table. /// /// - Parameters: /// - databaseId: String @@ -1589,7 +1586,7 @@ open class TablesDb: Service { /// /// Creates an index on the columns listed. Your index should include all the /// columns you will query in a single request. - /// Attributes can be `key`, `fulltext`, and `unique`. + /// Type can be `key`, `fulltext`, or `unique`. /// /// - Parameters: /// - databaseId: String diff --git a/Sources/AppwriteEnums/Type.swift b/Sources/AppwriteEnums/Type.swift deleted file mode 100644 index f6d4e27..0000000 --- a/Sources/AppwriteEnums/Type.swift +++ /dev/null @@ -1,10 +0,0 @@ -import Foundation - -public enum Type: String, CustomStringConvertible { - case tablesdb = "tablesdb" - case legacy = "legacy" - - public var description: String { - return rawValue - } -} diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index bd10f63..b0362bb 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -1,5 +1,4 @@ import Appwrite -import AppwriteEnums let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,7 +10,6 @@ let databases = Databases(client) let database = try await databases.create( databaseId: "", name: "", - enabled: false, // optional - type: .tablesdb // optional + enabled: false // optional ) diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index ebf7a92..2586404 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -1,5 +1,4 @@ import Appwrite -import AppwriteEnums let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,7 +10,6 @@ let tablesDb = TablesDb(client) let database = try await tablesDb.create( databaseId: "", name: "", - enabled: false, // optional - type: .tablesdb // optional + enabled: false // optional ) From d33ee2466acef821ed2875e55f095944c4223b61 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 20 Aug 2025 19:21:25 +1200 Subject: [PATCH 3/7] Add 1.8.x support --- docs/examples/databases/decrement-document-attribute.md | 2 +- docs/examples/databases/increment-document-attribute.md | 2 +- docs/examples/tablesdb/decrement-row-column.md | 2 +- docs/examples/tablesdb/increment-row-column.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index 88ba9ae..81516fa 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -3,7 +3,7 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID - .setKey("") // Your secret API key + .setSession("") // The user session to authenticate with let databases = Databases(client) diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 452b200..64ba46b 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -3,7 +3,7 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID - .setKey("") // Your secret API key + .setSession("") // The user session to authenticate with let databases = Databases(client) diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index 0ebad7b..b7b8ae5 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -3,7 +3,7 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID - .setKey("") // Your secret API key + .setSession("") // The user session to authenticate with let tablesDb = TablesDb(client) diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index 5f1ee4c..63054fa 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -3,7 +3,7 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID - .setKey("") // Your secret API key + .setSession("") // The user session to authenticate with let tablesDb = TablesDb(client) From 8c491c4f8e20e3754e2818eb69131c49450c0525 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 21 Aug 2025 22:20:42 +1200 Subject: [PATCH 4/7] Fix casing --- Sources/Appwrite/Services/Account.swift | 334 +++++++++++++ Sources/Appwrite/Services/Databases.swift | 120 ++--- Sources/Appwrite/Services/Messaging.swift | 457 ++++++++++++++++++ Sources/Appwrite/Services/TablesDb.swift | 20 +- Sources/Appwrite/Services/Users.swift | 232 +++++++++ Sources/AppwriteModels/AttributeBoolean.swift | 4 +- .../AppwriteModels/AttributeDatetime.swift | 4 +- Sources/AppwriteModels/AttributeEmail.swift | 4 +- Sources/AppwriteModels/AttributeEnum.swift | 4 +- Sources/AppwriteModels/AttributeFloat.swift | 4 +- Sources/AppwriteModels/AttributeInteger.swift | 4 +- Sources/AppwriteModels/AttributeIp.swift | 4 +- .../AttributeRelationship.swift | 2 +- Sources/AppwriteModels/AttributeString.swift | 4 +- Sources/AppwriteModels/AttributeUrl.swift | 4 +- Sources/AppwriteModels/BucketList.swift | 2 +- Sources/AppwriteModels/CollectionList.swift | 2 +- Sources/AppwriteModels/ColumnBoolean.swift | 4 +- Sources/AppwriteModels/ColumnDatetime.swift | 4 +- Sources/AppwriteModels/ColumnEmail.swift | 4 +- Sources/AppwriteModels/ColumnEnum.swift | 4 +- Sources/AppwriteModels/ColumnFloat.swift | 4 +- Sources/AppwriteModels/ColumnIndexList.swift | 2 +- Sources/AppwriteModels/ColumnInteger.swift | 4 +- Sources/AppwriteModels/ColumnIp.swift | 4 +- .../AppwriteModels/ColumnRelationship.swift | 2 +- Sources/AppwriteModels/ColumnString.swift | 4 +- Sources/AppwriteModels/ColumnUrl.swift | 4 +- Sources/AppwriteModels/ContinentList.swift | 2 +- Sources/AppwriteModels/CountryList.swift | 2 +- Sources/AppwriteModels/CurrencyList.swift | 2 +- Sources/AppwriteModels/DatabaseList.swift | 2 +- Sources/AppwriteModels/DeploymentList.swift | 2 +- Sources/AppwriteModels/DocumentList.swift | 2 +- Sources/AppwriteModels/ExecutionList.swift | 2 +- Sources/AppwriteModels/FileList.swift | 2 +- Sources/AppwriteModels/FrameworkList.swift | 2 +- Sources/AppwriteModels/FunctionList.swift | 2 +- Sources/AppwriteModels/IdentityList.swift | 2 +- Sources/AppwriteModels/IndexList.swift | 2 +- Sources/AppwriteModels/LanguageList.swift | 2 +- Sources/AppwriteModels/LocaleCodeList.swift | 2 +- Sources/AppwriteModels/LogList.swift | 2 +- Sources/AppwriteModels/MembershipList.swift | 2 +- Sources/AppwriteModels/MessageList.swift | 2 +- Sources/AppwriteModels/PhoneList.swift | 2 +- Sources/AppwriteModels/ProviderList.swift | 2 +- .../AppwriteModels/ResourceTokenList.swift | 2 +- Sources/AppwriteModels/RowList.swift | 2 +- Sources/AppwriteModels/RuntimeList.swift | 2 +- Sources/AppwriteModels/SessionList.swift | 2 +- Sources/AppwriteModels/SiteList.swift | 2 +- .../AppwriteModels/SpecificationList.swift | 2 +- Sources/AppwriteModels/SubscriberList.swift | 2 +- Sources/AppwriteModels/TableList.swift | 2 +- Sources/AppwriteModels/TargetList.swift | 2 +- Sources/AppwriteModels/TeamList.swift | 2 +- Sources/AppwriteModels/TopicList.swift | 2 +- Sources/AppwriteModels/UserList.swift | 2 +- Sources/AppwriteModels/VariableList.swift | 2 +- .../account/create-m-f-a-authenticator.md | 14 + .../account/create-m-f-a-challenge.md | 13 + .../account/create-m-f-a-recovery-codes.md | 11 + .../account/delete-m-f-a-authenticator.md | 14 + .../account/get-m-f-a-recovery-codes.md | 11 + docs/examples/account/list-m-f-a-factors.md | 11 + .../account/update-m-f-a-authenticator.md | 15 + .../account/update-m-f-a-challenge.md | 14 + .../account/update-m-f-a-recovery-codes.md | 11 + .../messaging/create-a-p-n-s-provider.md | 20 + .../messaging/create-f-c-m-provider.md | 16 + docs/examples/messaging/create-s-m-s.md | 19 + .../messaging/create-s-m-t-p-provider.md | 27 ++ .../messaging/update-a-p-n-s-provider.md | 20 + .../messaging/update-f-c-m-provider.md | 16 + docs/examples/messaging/update-s-m-s.md | 19 + .../messaging/update-s-m-t-p-provider.md | 27 ++ .../tablesdb/create-boolean-column.md | 4 +- .../tablesdb/create-datetime-column.md | 4 +- docs/examples/tablesdb/create-email-column.md | 4 +- docs/examples/tablesdb/create-enum-column.md | 4 +- docs/examples/tablesdb/create-float-column.md | 4 +- docs/examples/tablesdb/create-index.md | 4 +- .../tablesdb/create-integer-column.md | 4 +- docs/examples/tablesdb/create-ip-column.md | 4 +- .../tablesdb/create-relationship-column.md | 4 +- docs/examples/tablesdb/create-row.md | 4 +- docs/examples/tablesdb/create-rows.md | 4 +- .../examples/tablesdb/create-string-column.md | 4 +- docs/examples/tablesdb/create-table.md | 4 +- docs/examples/tablesdb/create-url-column.md | 4 +- docs/examples/tablesdb/create.md | 4 +- .../examples/tablesdb/decrement-row-column.md | 4 +- docs/examples/tablesdb/delete-column.md | 4 +- docs/examples/tablesdb/delete-index.md | 4 +- docs/examples/tablesdb/delete-row.md | 4 +- docs/examples/tablesdb/delete-rows.md | 4 +- docs/examples/tablesdb/delete-table.md | 4 +- docs/examples/tablesdb/delete.md | 4 +- docs/examples/tablesdb/get-column.md | 4 +- docs/examples/tablesdb/get-index.md | 4 +- docs/examples/tablesdb/get-row.md | 4 +- docs/examples/tablesdb/get-table.md | 4 +- docs/examples/tablesdb/get.md | 4 +- .../examples/tablesdb/increment-row-column.md | 4 +- docs/examples/tablesdb/list-columns.md | 4 +- docs/examples/tablesdb/list-indexes.md | 4 +- docs/examples/tablesdb/list-rows.md | 4 +- docs/examples/tablesdb/list-tables.md | 4 +- docs/examples/tablesdb/list.md | 4 +- .../tablesdb/update-boolean-column.md | 4 +- .../tablesdb/update-datetime-column.md | 4 +- docs/examples/tablesdb/update-email-column.md | 4 +- docs/examples/tablesdb/update-enum-column.md | 4 +- docs/examples/tablesdb/update-float-column.md | 4 +- .../tablesdb/update-integer-column.md | 4 +- docs/examples/tablesdb/update-ip-column.md | 4 +- .../tablesdb/update-relationship-column.md | 4 +- docs/examples/tablesdb/update-row.md | 4 +- docs/examples/tablesdb/update-rows.md | 4 +- .../examples/tablesdb/update-string-column.md | 4 +- docs/examples/tablesdb/update-table.md | 4 +- docs/examples/tablesdb/update-url-column.md | 4 +- docs/examples/tablesdb/update.md | 4 +- docs/examples/tablesdb/upsert-row.md | 4 +- docs/examples/tablesdb/upsert-rows.md | 4 +- .../users/create-m-f-a-recovery-codes.md | 13 + .../users/delete-m-f-a-authenticator.md | 15 + .../users/get-m-f-a-recovery-codes.md | 13 + docs/examples/users/list-m-f-a-factors.md | 13 + .../users/update-m-f-a-recovery-codes.md | 13 + docs/examples/users/update-m-f-a.md | 14 + 132 files changed, 1623 insertions(+), 241 deletions(-) create mode 100644 docs/examples/account/create-m-f-a-authenticator.md create mode 100644 docs/examples/account/create-m-f-a-challenge.md create mode 100644 docs/examples/account/create-m-f-a-recovery-codes.md create mode 100644 docs/examples/account/delete-m-f-a-authenticator.md create mode 100644 docs/examples/account/get-m-f-a-recovery-codes.md create mode 100644 docs/examples/account/list-m-f-a-factors.md create mode 100644 docs/examples/account/update-m-f-a-authenticator.md create mode 100644 docs/examples/account/update-m-f-a-challenge.md create mode 100644 docs/examples/account/update-m-f-a-recovery-codes.md create mode 100644 docs/examples/messaging/create-a-p-n-s-provider.md create mode 100644 docs/examples/messaging/create-f-c-m-provider.md create mode 100644 docs/examples/messaging/create-s-m-s.md create mode 100644 docs/examples/messaging/create-s-m-t-p-provider.md create mode 100644 docs/examples/messaging/update-a-p-n-s-provider.md create mode 100644 docs/examples/messaging/update-f-c-m-provider.md create mode 100644 docs/examples/messaging/update-s-m-s.md create mode 100644 docs/examples/messaging/update-s-m-t-p-provider.md create mode 100644 docs/examples/users/create-m-f-a-recovery-codes.md create mode 100644 docs/examples/users/delete-m-f-a-authenticator.md create mode 100644 docs/examples/users/get-m-f-a-recovery-codes.md create mode 100644 docs/examples/users/list-m-f-a-factors.md create mode 100644 docs/examples/users/update-m-f-a-recovery-codes.md create mode 100644 docs/examples/users/update-m-f-a.md diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 810f685..53638c3 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -391,6 +391,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaType /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFAAuthenticator` instead.") open func createMfaAuthenticator( type: AppwriteEnums.AuthenticatorType ) async throws -> AppwriteModels.MfaType { @@ -416,6 +417,42 @@ open class Account: Service { ) } + /// + /// Add an authenticator app to be used as an MFA factor. Verify the + /// authenticator using the [verify + /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) + /// method. + /// + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaType + /// + open func createMFAAuthenticator( + type: AppwriteEnums.AuthenticatorType + ) async throws -> AppwriteModels.MfaType { + let apiPath: String = "/account/mfa/authenticators/{type}" + .replacingOccurrences(of: "{type}", with: type.rawValue) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaType = { response in + return AppwriteModels.MfaType.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) @@ -427,6 +464,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.") open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, otp: String, @@ -467,6 +505,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.") open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, otp: String @@ -478,6 +517,68 @@ open class Account: Service { ) } + /// + /// Verify an authenticator app after adding it using the [add + /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) + /// method. + /// + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - otp: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User + /// + open func updateMFAAuthenticator( + type: AppwriteEnums.AuthenticatorType, + otp: String, + nestedType: T.Type + ) async throws -> AppwriteModels.User { + let apiPath: String = "/account/mfa/authenticators/{type}" + .replacingOccurrences(of: "{type}", with: type.rawValue) + + let apiParams: [String: Any?] = [ + "otp": otp + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.User = { response in + return AppwriteModels.User.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Verify an authenticator app after adding it using the [add + /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) + /// method. + /// + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - otp: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User + /// + open func updateMFAAuthenticator( + type: AppwriteEnums.AuthenticatorType, + otp: String + ) async throws -> AppwriteModels.User<[String: AnyCodable]> { + return try await updateMFAAuthenticator( + type: type, + otp: otp, + nestedType: [String: AnyCodable].self + ) + } + /// /// Delete an authenticator for a user by ID. /// @@ -486,6 +587,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `DeleteMFAAuthenticator` instead.") open func deleteMfaAuthenticator( type: AppwriteEnums.AuthenticatorType ) async throws -> Any { @@ -505,6 +607,33 @@ open class Account: Service { params: apiParams ) } + /// + /// Delete an authenticator for a user by ID. + /// + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteMFAAuthenticator( + type: AppwriteEnums.AuthenticatorType + ) async throws -> Any { + let apiPath: String = "/account/mfa/authenticators/{type}" + .replacingOccurrences(of: "{type}", with: type.rawValue) + + 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 ) + } + /// /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) @@ -515,6 +644,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaChallenge /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFAChallenge` instead.") open func createMfaChallenge( factor: AppwriteEnums.AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { @@ -541,6 +671,42 @@ open class Account: Service { ) } + /// + /// Begin the process of MFA verification after sign-in. Finish the flow with + /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) + /// method. + /// + /// - Parameters: + /// - factor: AppwriteEnums.AuthenticationFactor + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaChallenge + /// + open func createMFAChallenge( + factor: AppwriteEnums.AuthenticationFactor + ) async throws -> AppwriteModels.MfaChallenge { + let apiPath: String = "/account/mfa/challenge" + + let apiParams: [String: Any?] = [ + "factor": factor + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaChallenge = { response in + return AppwriteModels.MfaChallenge.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Complete the MFA challenge by providing the one-time password. Finish the /// process of MFA verification by providing the one-time password. To begin @@ -554,6 +720,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAChallenge` instead.") open func updateMfaChallenge( challengeId: String, otp: String @@ -582,12 +749,54 @@ open class Account: Service { ) } + /// + /// Complete the MFA challenge by providing the one-time password. Finish the + /// process of MFA verification by providing the one-time password. To begin + /// the flow, use + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method. + /// + /// - Parameters: + /// - challengeId: String + /// - otp: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session + /// + open func updateMFAChallenge( + challengeId: String, + otp: String + ) async throws -> AppwriteModels.Session { + let apiPath: String = "/account/mfa/challenge" + + let apiParams: [String: Any?] = [ + "challengeId": challengeId, + "otp": otp + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Session = { response in + return AppwriteModels.Session.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// List the factors available on the account to be used as a MFA challange. /// /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaFactors /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `ListMFAFactors` instead.") open func listMfaFactors( ) async throws -> AppwriteModels.MfaFactors { let apiPath: String = "/account/mfa/factors" @@ -609,6 +818,33 @@ open class Account: Service { ) } + /// + /// List the factors available on the account to be used as a MFA challange. + /// + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaFactors + /// + open func listMFAFactors( + ) async throws -> AppwriteModels.MfaFactors { + let apiPath: String = "/account/mfa/factors" + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.MfaFactors = { response in + return AppwriteModels.MfaFactors.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using @@ -618,6 +854,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `GetMFARecoveryCodes` instead.") open func getMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -639,6 +876,36 @@ open class Account: Service { ) } + /// + /// Get recovery codes that can be used as backup for MFA flow. Before getting + /// codes, they must be generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. An OTP challenge is required to read recovery codes. + /// + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes + /// + open func getMFARecoveryCodes( + ) async throws -> AppwriteModels.MfaRecoveryCodes { + let apiPath: String = "/account/mfa/recovery-codes" + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in + return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Generate recovery codes as backup for MFA flow. It's recommended to /// generate and show then immediately after user successfully adds their @@ -649,6 +916,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFARecoveryCodes` instead.") open func createMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -672,6 +940,39 @@ open class Account: Service { ) } + /// + /// Generate recovery codes as backup for MFA flow. It's recommended to + /// generate and show then immediately after user successfully adds their + /// authehticator. Recovery codes can be used as a MFA verification type in + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method. + /// + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes + /// + open func createMFARecoveryCodes( + ) async throws -> AppwriteModels.MfaRecoveryCodes { + let apiPath: String = "/account/mfa/recovery-codes" + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in + return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using @@ -681,6 +982,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFARecoveryCodes` instead.") open func updateMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -704,6 +1006,38 @@ open class Account: Service { ) } + /// + /// Regenerate recovery codes that can be used as backup for MFA flow. Before + /// regenerating codes, they must be first generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. An OTP challenge is required to regenreate recovery codes. + /// + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes + /// + open func updateMFARecoveryCodes( + ) async throws -> AppwriteModels.MfaRecoveryCodes { + let apiPath: String = "/account/mfa/recovery-codes" + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in + return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Update currently logged in user account name. /// diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index 8b8f61a..12e0c8a 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -18,7 +18,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DatabaseList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.list` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.list` instead.") open func list( queries: [String]? = nil, search: String? = nil @@ -56,7 +56,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Database /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createDatabase` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createDatabase` instead.") open func create( databaseId: String, name: String, @@ -96,7 +96,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Database /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.get` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.get` instead.") open func get( databaseId: String ) async throws -> AppwriteModels.Database { @@ -130,7 +130,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Database /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.update` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.update` instead.") open func update( databaseId: String, name: String, @@ -170,7 +170,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.delete` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.delete` instead.") open func delete( databaseId: String ) async throws -> Any { @@ -201,7 +201,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.CollectionList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listTables` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.listTables` instead.") open func listCollections( databaseId: String, queries: [String]? = nil, @@ -246,7 +246,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Collection /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createTable` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead.") open func createCollection( databaseId: String, collectionId: String, @@ -293,7 +293,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Collection /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getTable` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.getTable` instead.") open func getCollection( databaseId: String, collectionId: String @@ -332,7 +332,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Collection /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateTable` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateTable` instead.") open func updateCollection( databaseId: String, collectionId: String, @@ -379,7 +379,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteTable` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTable` instead.") open func deleteCollection( databaseId: String, collectionId: String @@ -411,7 +411,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listColumns` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.listColumns` instead.") open func listAttributes( databaseId: String, collectionId: String, @@ -454,7 +454,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeBoolean /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createBooleanColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createBooleanColumn` instead.") open func createBooleanAttribute( databaseId: String, collectionId: String, @@ -505,7 +505,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeBoolean /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateBooleanColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead.") open func updateBooleanAttribute( databaseId: String, collectionId: String, @@ -555,7 +555,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeDatetime /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createDatetimeColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createDatetimeColumn` instead.") open func createDatetimeAttribute( databaseId: String, collectionId: String, @@ -606,7 +606,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeDatetime /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateDatetimeColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead.") open func updateDatetimeAttribute( databaseId: String, collectionId: String, @@ -657,7 +657,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeEmail /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createEmailColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createEmailColumn` instead.") open func createEmailAttribute( databaseId: String, collectionId: String, @@ -709,7 +709,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeEmail /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateEmailColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead.") open func updateEmailAttribute( databaseId: String, collectionId: String, @@ -762,7 +762,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeEnum /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createEnumColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createEnumColumn` instead.") open func createEnumAttribute( databaseId: String, collectionId: String, @@ -817,7 +817,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeEnum /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateEnumColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead.") open func updateEnumAttribute( databaseId: String, collectionId: String, @@ -873,7 +873,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeFloat /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createFloatColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createFloatColumn` instead.") open func createFloatAttribute( databaseId: String, collectionId: String, @@ -931,7 +931,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeFloat /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateFloatColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead.") open func updateFloatAttribute( databaseId: String, collectionId: String, @@ -989,7 +989,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeInteger /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createIntegerColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createIntegerColumn` instead.") open func createIntegerAttribute( databaseId: String, collectionId: String, @@ -1047,7 +1047,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeInteger /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateIntegerColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead.") open func updateIntegerAttribute( databaseId: String, collectionId: String, @@ -1102,7 +1102,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeIp /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createIpColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createIpColumn` instead.") open func createIpAttribute( databaseId: String, collectionId: String, @@ -1154,7 +1154,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeIp /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateIpColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead.") open func updateIpAttribute( databaseId: String, collectionId: String, @@ -1208,7 +1208,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeRelationship /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRelationshipColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createRelationshipColumn` instead.") open func createRelationshipAttribute( databaseId: String, collectionId: String, @@ -1265,7 +1265,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeString /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createStringColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createStringColumn` instead.") open func createStringAttribute( databaseId: String, collectionId: String, @@ -1322,7 +1322,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeString /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateStringColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead.") open func updateStringAttribute( databaseId: String, collectionId: String, @@ -1375,7 +1375,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeUrl /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createUrlColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createUrlColumn` instead.") open func createUrlAttribute( databaseId: String, collectionId: String, @@ -1427,7 +1427,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeUrl /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateUrlColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead.") open func updateUrlAttribute( databaseId: String, collectionId: String, @@ -1474,7 +1474,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead.") open func getAttribute( databaseId: String, collectionId: String, @@ -1506,7 +1506,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteColumn` instead.") open func deleteAttribute( databaseId: String, collectionId: String, @@ -1544,7 +1544,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.AttributeRelationship /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRelationshipColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead.") open func updateRelationshipAttribute( databaseId: String, collectionId: String, @@ -1590,7 +1590,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -1631,7 +1631,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -1660,7 +1660,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -1711,7 +1711,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -1742,7 +1742,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead.") open func createDocuments( databaseId: String, collectionId: String, @@ -1787,7 +1787,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead.") open func createDocuments( databaseId: String, collectionId: String, @@ -1815,7 +1815,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead.") open func upsertDocuments( databaseId: String, collectionId: String, @@ -1861,7 +1861,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead.") open func upsertDocuments( databaseId: String, collectionId: String, @@ -1888,7 +1888,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead.") open func updateDocuments( databaseId: String, collectionId: String, @@ -1935,7 +1935,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead.") open func updateDocuments( databaseId: String, collectionId: String, @@ -1962,7 +1962,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead.") open func deleteDocuments( databaseId: String, collectionId: String, @@ -2005,7 +2005,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRows` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead.") open func deleteDocuments( databaseId: String, collectionId: String, @@ -2031,7 +2031,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -2075,7 +2075,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -2106,7 +2106,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, @@ -2157,7 +2157,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, @@ -2188,7 +2188,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -2237,7 +2237,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -2265,7 +2265,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRow` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.") open func deleteDocument( databaseId: String, collectionId: String, @@ -2302,7 +2302,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2353,7 +2353,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2386,7 +2386,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2437,7 +2437,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2467,7 +2467,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.IndexList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.listIndexes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.listIndexes` instead.") open func listIndexes( databaseId: String, collectionId: String, @@ -2512,7 +2512,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Index /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.createIndex` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead.") open func createIndex( databaseId: String, collectionId: String, @@ -2561,7 +2561,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Index /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.getIndex` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.getIndex` instead.") open func getIndex( databaseId: String, collectionId: String, @@ -2599,7 +2599,7 @@ open class Databases: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteIndex` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteIndex` instead.") open func deleteIndex( databaseId: String, collectionId: String, diff --git a/Sources/Appwrite/Services/Messaging.swift b/Sources/Appwrite/Services/Messaging.swift index 5a97dfd..2dbd143 100644 --- a/Sources/Appwrite/Services/Messaging.swift +++ b/Sources/Appwrite/Services/Messaging.swift @@ -373,6 +373,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Message /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateSMS` instead.") open func createSms( messageId: String, content: String, @@ -411,6 +412,58 @@ open class Messaging: Service { ) } + /// + /// Create a new SMS message. + /// + /// - Parameters: + /// - messageId: String + /// - content: String + /// - topics: [String] (optional) + /// - users: [String] (optional) + /// - targets: [String] (optional) + /// - draft: Bool (optional) + /// - scheduledAt: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Message + /// + open func createSMS( + messageId: String, + content: String, + topics: [String]? = nil, + users: [String]? = nil, + targets: [String]? = nil, + draft: Bool? = nil, + scheduledAt: String? = nil + ) async throws -> AppwriteModels.Message { + let apiPath: String = "/messaging/messages/sms" + + let apiParams: [String: Any?] = [ + "messageId": messageId, + "content": content, + "topics": topics, + "users": users, + "targets": targets, + "draft": draft, + "scheduledAt": scheduledAt + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Message = { response in + return AppwriteModels.Message.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Update an SMS message by its unique ID. This endpoint only works on /// messages that are in draft status. Messages that are already processing, @@ -428,6 +481,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Message /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateSMS` instead.") open func updateSms( messageId: String, topics: [String]? = nil, @@ -466,6 +520,61 @@ open class Messaging: Service { ) } + /// + /// Update an SMS message by its unique ID. This endpoint only works on + /// messages that are in draft status. Messages that are already processing, + /// sent, or failed cannot be updated. + /// + /// + /// - Parameters: + /// - messageId: String + /// - topics: [String] (optional) + /// - users: [String] (optional) + /// - targets: [String] (optional) + /// - content: String (optional) + /// - draft: Bool (optional) + /// - scheduledAt: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Message + /// + open func updateSMS( + messageId: String, + topics: [String]? = nil, + users: [String]? = nil, + targets: [String]? = nil, + content: String? = nil, + draft: Bool? = nil, + scheduledAt: String? = nil + ) async throws -> AppwriteModels.Message { + let apiPath: String = "/messaging/messages/sms/{messageId}" + .replacingOccurrences(of: "{messageId}", with: messageId) + + let apiParams: [String: Any?] = [ + "topics": topics, + "users": users, + "targets": targets, + "content": content, + "draft": draft, + "scheduledAt": scheduledAt + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Message = { response in + return AppwriteModels.Message.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Get a message by its unique ID. /// @@ -646,6 +755,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateAPNSProvider` instead.") open func createApnsProvider( providerId: String, name: String, @@ -686,6 +796,61 @@ open class Messaging: Service { ) } + /// + /// Create a new Apple Push Notification service provider. + /// + /// - Parameters: + /// - providerId: String + /// - name: String + /// - authKey: String (optional) + /// - authKeyId: String (optional) + /// - teamId: String (optional) + /// - bundleId: String (optional) + /// - sandbox: Bool (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider + /// + open func createAPNSProvider( + providerId: String, + name: String, + authKey: String? = nil, + authKeyId: String? = nil, + teamId: String? = nil, + bundleId: String? = nil, + sandbox: Bool? = nil, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Provider { + let apiPath: String = "/messaging/providers/apns" + + let apiParams: [String: Any?] = [ + "providerId": providerId, + "name": name, + "authKey": authKey, + "authKeyId": authKeyId, + "teamId": teamId, + "bundleId": bundleId, + "sandbox": sandbox, + "enabled": enabled + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Provider = { response in + return AppwriteModels.Provider.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Update a Apple Push Notification service provider by its unique ID. /// @@ -701,6 +866,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateAPNSProvider` instead.") open func updateApnsProvider( providerId: String, name: String? = nil, @@ -741,6 +907,61 @@ open class Messaging: Service { ) } + /// + /// Update a Apple Push Notification service provider by its unique ID. + /// + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - enabled: Bool (optional) + /// - authKey: String (optional) + /// - authKeyId: String (optional) + /// - teamId: String (optional) + /// - bundleId: String (optional) + /// - sandbox: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider + /// + open func updateAPNSProvider( + providerId: String, + name: String? = nil, + enabled: Bool? = nil, + authKey: String? = nil, + authKeyId: String? = nil, + teamId: String? = nil, + bundleId: String? = nil, + sandbox: Bool? = nil + ) async throws -> AppwriteModels.Provider { + let apiPath: String = "/messaging/providers/apns/{providerId}" + .replacingOccurrences(of: "{providerId}", with: providerId) + + let apiParams: [String: Any?] = [ + "name": name, + "enabled": enabled, + "authKey": authKey, + "authKeyId": authKeyId, + "teamId": teamId, + "bundleId": bundleId, + "sandbox": sandbox + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Provider = { response in + return AppwriteModels.Provider.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Create a new Firebase Cloud Messaging provider. /// @@ -752,6 +973,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateFCMProvider` instead.") open func createFcmProvider( providerId: String, name: String, @@ -784,6 +1006,49 @@ open class Messaging: Service { ) } + /// + /// Create a new Firebase Cloud Messaging provider. + /// + /// - Parameters: + /// - providerId: String + /// - name: String + /// - serviceAccountJSON: Any (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider + /// + open func createFCMProvider( + providerId: String, + name: String, + serviceAccountJSON: Any? = nil, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Provider { + let apiPath: String = "/messaging/providers/fcm" + + let apiParams: [String: Any?] = [ + "providerId": providerId, + "name": name, + "serviceAccountJSON": serviceAccountJSON, + "enabled": enabled + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Provider = { response in + return AppwriteModels.Provider.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Update a Firebase Cloud Messaging provider by its unique ID. /// @@ -795,6 +1060,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateFCMProvider` instead.") open func updateFcmProvider( providerId: String, name: String? = nil, @@ -827,6 +1093,49 @@ open class Messaging: Service { ) } + /// + /// Update a Firebase Cloud Messaging provider by its unique ID. + /// + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - enabled: Bool (optional) + /// - serviceAccountJSON: Any (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider + /// + open func updateFCMProvider( + providerId: String, + name: String? = nil, + enabled: Bool? = nil, + serviceAccountJSON: Any? = nil + ) async throws -> AppwriteModels.Provider { + let apiPath: String = "/messaging/providers/fcm/{providerId}" + .replacingOccurrences(of: "{providerId}", with: providerId) + + let apiParams: [String: Any?] = [ + "name": name, + "enabled": enabled, + "serviceAccountJSON": serviceAccountJSON + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Provider = { response in + return AppwriteModels.Provider.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Create a new Mailgun provider. /// @@ -1178,6 +1487,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateSMTPProvider` instead.") open func createSmtpProvider( providerId: String, name: String, @@ -1230,6 +1540,79 @@ open class Messaging: Service { ) } + /// + /// Create a new SMTP provider. + /// + /// - Parameters: + /// - providerId: String + /// - name: String + /// - host: String + /// - port: Int (optional) + /// - username: String (optional) + /// - password: String (optional) + /// - encryption: AppwriteEnums.SmtpEncryption (optional) + /// - autoTLS: Bool (optional) + /// - mailer: String (optional) + /// - fromName: String (optional) + /// - fromEmail: String (optional) + /// - replyToName: String (optional) + /// - replyToEmail: String (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider + /// + open func createSMTPProvider( + providerId: String, + name: String, + host: String, + port: Int? = nil, + username: String? = nil, + password: String? = nil, + encryption: AppwriteEnums.SmtpEncryption? = nil, + autoTLS: Bool? = nil, + mailer: String? = nil, + fromName: String? = nil, + fromEmail: String? = nil, + replyToName: String? = nil, + replyToEmail: String? = nil, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Provider { + let apiPath: String = "/messaging/providers/smtp" + + let apiParams: [String: Any?] = [ + "providerId": providerId, + "name": name, + "host": host, + "port": port, + "username": username, + "password": password, + "encryption": encryption, + "autoTLS": autoTLS, + "mailer": mailer, + "fromName": fromName, + "fromEmail": fromEmail, + "replyToName": replyToName, + "replyToEmail": replyToEmail, + "enabled": enabled + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Provider = { response in + return AppwriteModels.Provider.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Update a SMTP provider by its unique ID. /// @@ -1251,6 +1634,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateSMTPProvider` instead.") open func updateSmtpProvider( providerId: String, name: String? = nil, @@ -1303,6 +1687,79 @@ open class Messaging: Service { ) } + /// + /// Update a SMTP provider by its unique ID. + /// + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - host: String (optional) + /// - port: Int (optional) + /// - username: String (optional) + /// - password: String (optional) + /// - encryption: AppwriteEnums.SmtpEncryption (optional) + /// - autoTLS: Bool (optional) + /// - mailer: String (optional) + /// - fromName: String (optional) + /// - fromEmail: String (optional) + /// - replyToName: String (optional) + /// - replyToEmail: String (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider + /// + open func updateSMTPProvider( + providerId: String, + name: String? = nil, + host: String? = nil, + port: Int? = nil, + username: String? = nil, + password: String? = nil, + encryption: AppwriteEnums.SmtpEncryption? = nil, + autoTLS: Bool? = nil, + mailer: String? = nil, + fromName: String? = nil, + fromEmail: String? = nil, + replyToName: String? = nil, + replyToEmail: String? = nil, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Provider { + let apiPath: String = "/messaging/providers/smtp/{providerId}" + .replacingOccurrences(of: "{providerId}", with: providerId) + + let apiParams: [String: Any?] = [ + "name": name, + "host": host, + "port": port, + "username": username, + "password": password, + "encryption": encryption, + "autoTLS": autoTLS, + "mailer": mailer, + "fromName": fromName, + "fromEmail": fromEmail, + "replyToName": replyToName, + "replyToEmail": replyToEmail, + "enabled": enabled + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Provider = { response in + return AppwriteModels.Provider.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Create a new Telesign provider. /// diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDb.swift index a2ef3f8..e1c3790 100644 --- a/Sources/Appwrite/Services/TablesDb.swift +++ b/Sources/Appwrite/Services/TablesDb.swift @@ -6,7 +6,7 @@ import AppwriteEnums import AppwriteModels /// -open class TablesDb: Service { +open class TablesDB: Service { /// /// Get a list of all databases from the current Appwrite project. You can use @@ -227,7 +227,7 @@ open class TablesDb: Service { /// /// Create a new Table. Before using this route, you should create a new /// database resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: @@ -1774,7 +1774,7 @@ open class TablesDb: Service { /// /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: @@ -1824,7 +1824,7 @@ open class TablesDb: Service { /// /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: @@ -1856,7 +1856,7 @@ open class TablesDb: Service { /// /// Create new Rows. Before using this route, you should create a new table /// resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: @@ -1900,7 +1900,7 @@ open class TablesDb: Service { /// /// Create new Rows. Before using this route, you should create a new table /// resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: @@ -1926,7 +1926,7 @@ open class TablesDb: Service { /// /// Create or update Rows. Before using this route, you should create a new /// table resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// @@ -1971,7 +1971,7 @@ open class TablesDb: Service { /// /// Create or update Rows. Before using this route, you should create a new /// table resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// @@ -2206,7 +2206,7 @@ open class TablesDb: Service { /// /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: @@ -2256,7 +2256,7 @@ open class TablesDb: Service { /// /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server - /// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. /// /// - Parameters: diff --git a/Sources/Appwrite/Services/Users.swift b/Sources/Appwrite/Services/Users.swift index a2d3d6b..7122842 100644 --- a/Sources/Appwrite/Services/Users.swift +++ b/Sources/Appwrite/Services/Users.swift @@ -1123,6 +1123,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFA` instead.") open func updateMfa( userId: String, mfa: Bool, @@ -1161,6 +1162,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFA` instead.") open func updateMfa( userId: String, mfa: Bool @@ -1172,6 +1174,64 @@ open class Users: Service { ) } + /// + /// Enable or disable MFA on a user account. + /// + /// - Parameters: + /// - userId: String + /// - mfa: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User + /// + open func updateMFA( + userId: String, + mfa: Bool, + nestedType: T.Type + ) async throws -> AppwriteModels.User { + let apiPath: String = "/users/{userId}/mfa" + .replacingOccurrences(of: "{userId}", with: userId) + + let apiParams: [String: Any?] = [ + "mfa": mfa + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.User = { response in + return AppwriteModels.User.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Enable or disable MFA on a user account. + /// + /// - Parameters: + /// - userId: String + /// - mfa: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User + /// + open func updateMFA( + userId: String, + mfa: Bool + ) async throws -> AppwriteModels.User<[String: AnyCodable]> { + return try await updateMFA( + userId: userId, + mfa: mfa, + nestedType: [String: AnyCodable].self + ) + } + /// /// Delete an authenticator app. /// @@ -1181,6 +1241,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `DeleteMFAAuthenticator` instead.") open func deleteMfaAuthenticator( userId: String, type: AppwriteEnums.AuthenticatorType @@ -1202,6 +1263,36 @@ open class Users: Service { params: apiParams ) } + /// + /// Delete an authenticator app. + /// + /// - Parameters: + /// - userId: String + /// - type: AppwriteEnums.AuthenticatorType + /// - Throws: Exception if the request fails + /// - Returns: Any + /// + open func deleteMFAAuthenticator( + userId: String, + type: AppwriteEnums.AuthenticatorType + ) async throws -> Any { + let apiPath: String = "/users/{userId}/mfa/authenticators/{type}" + .replacingOccurrences(of: "{userId}", with: userId) + .replacingOccurrences(of: "{type}", with: type.rawValue) + + 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 the factors available on the account to be used as a MFA challange. /// @@ -1210,6 +1301,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaFactors /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `ListMFAFactors` instead.") open func listMfaFactors( userId: String ) async throws -> AppwriteModels.MfaFactors { @@ -1233,6 +1325,37 @@ open class Users: Service { ) } + /// + /// List the factors available on the account to be used as a MFA challange. + /// + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaFactors + /// + open func listMFAFactors( + userId: String + ) async throws -> AppwriteModels.MfaFactors { + let apiPath: String = "/users/{userId}/mfa/factors" + .replacingOccurrences(of: "{userId}", with: userId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.MfaFactors = { response in + return AppwriteModels.MfaFactors.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Get recovery codes that can be used as backup for MFA flow by User ID. /// Before getting codes, they must be generated using @@ -1244,6 +1367,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `GetMFARecoveryCodes` instead.") open func getMfaRecoveryCodes( userId: String ) async throws -> AppwriteModels.MfaRecoveryCodes { @@ -1267,6 +1391,40 @@ open class Users: Service { ) } + /// + /// Get recovery codes that can be used as backup for MFA flow by User ID. + /// Before getting codes, they must be generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. + /// + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes + /// + open func getMFARecoveryCodes( + userId: String + ) async throws -> AppwriteModels.MfaRecoveryCodes { + let apiPath: String = "/users/{userId}/mfa/recovery-codes" + .replacingOccurrences(of: "{userId}", with: userId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [:] + + let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in + return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "GET", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Regenerate recovery codes that can be used as backup for MFA flow by User /// ID. Before regenerating codes, they must be first generated using @@ -1278,6 +1436,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFARecoveryCodes` instead.") open func updateMfaRecoveryCodes( userId: String ) async throws -> AppwriteModels.MfaRecoveryCodes { @@ -1303,6 +1462,42 @@ open class Users: Service { ) } + /// + /// Regenerate recovery codes that can be used as backup for MFA flow by User + /// ID. Before regenerating codes, they must be first generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. + /// + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes + /// + open func updateMFARecoveryCodes( + userId: String + ) async throws -> AppwriteModels.MfaRecoveryCodes { + let apiPath: String = "/users/{userId}/mfa/recovery-codes" + .replacingOccurrences(of: "{userId}", with: userId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in + return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Generate recovery codes used as backup for MFA flow for User ID. Recovery /// codes can be used as a MFA verification type in @@ -1314,6 +1509,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFARecoveryCodes` instead.") open func createMfaRecoveryCodes( userId: String ) async throws -> AppwriteModels.MfaRecoveryCodes { @@ -1339,6 +1535,42 @@ open class Users: Service { ) } + /// + /// Generate recovery codes used as backup for MFA flow for User ID. Recovery + /// codes can be used as a MFA verification type in + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method by client SDK. + /// + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes + /// + open func createMFARecoveryCodes( + userId: String + ) async throws -> AppwriteModels.MfaRecoveryCodes { + let apiPath: String = "/users/{userId}/mfa/recovery-codes" + .replacingOccurrences(of: "{userId}", with: userId) + + let apiParams: [String: Any] = [:] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in + return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + /// /// Update the user name by its unique ID. /// diff --git a/Sources/AppwriteModels/AttributeBoolean.swift b/Sources/AppwriteModels/AttributeBoolean.swift index feb0462..ffc9325 100644 --- a/Sources/AppwriteModels/AttributeBoolean.swift +++ b/Sources/AppwriteModels/AttributeBoolean.swift @@ -100,11 +100,11 @@ open class AttributeBoolean: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/AttributeDatetime.swift b/Sources/AppwriteModels/AttributeDatetime.swift index 6922821..1aca4c2 100644 --- a/Sources/AppwriteModels/AttributeDatetime.swift +++ b/Sources/AppwriteModels/AttributeDatetime.swift @@ -108,12 +108,12 @@ open class AttributeDatetime: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/AttributeEmail.swift b/Sources/AppwriteModels/AttributeEmail.swift index a8aa6d2..1b8bd3f 100644 --- a/Sources/AppwriteModels/AttributeEmail.swift +++ b/Sources/AppwriteModels/AttributeEmail.swift @@ -108,12 +108,12 @@ open class AttributeEmail: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/AttributeEnum.swift b/Sources/AppwriteModels/AttributeEnum.swift index e5f3482..7de4bc0 100644 --- a/Sources/AppwriteModels/AttributeEnum.swift +++ b/Sources/AppwriteModels/AttributeEnum.swift @@ -116,13 +116,13 @@ open class AttributeEnum: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "elements": elements as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/AttributeFloat.swift b/Sources/AppwriteModels/AttributeFloat.swift index fceef5f..e57a8c1 100644 --- a/Sources/AppwriteModels/AttributeFloat.swift +++ b/Sources/AppwriteModels/AttributeFloat.swift @@ -116,13 +116,13 @@ open class AttributeFloat: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "min": min as Any, "max": max as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/AttributeInteger.swift b/Sources/AppwriteModels/AttributeInteger.swift index acb5d36..f3251b7 100644 --- a/Sources/AppwriteModels/AttributeInteger.swift +++ b/Sources/AppwriteModels/AttributeInteger.swift @@ -116,13 +116,13 @@ open class AttributeInteger: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "min": min as Any, "max": max as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/AttributeIp.swift b/Sources/AppwriteModels/AttributeIp.swift index 47b46de..b4f628d 100644 --- a/Sources/AppwriteModels/AttributeIp.swift +++ b/Sources/AppwriteModels/AttributeIp.swift @@ -108,12 +108,12 @@ open class AttributeIp: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/AttributeRelationship.swift b/Sources/AppwriteModels/AttributeRelationship.swift index c7c38d7..6a973aa 100644 --- a/Sources/AppwriteModels/AttributeRelationship.swift +++ b/Sources/AppwriteModels/AttributeRelationship.swift @@ -140,7 +140,7 @@ open class AttributeRelationship: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, diff --git a/Sources/AppwriteModels/AttributeString.swift b/Sources/AppwriteModels/AttributeString.swift index b7da6a8..b9d352b 100644 --- a/Sources/AppwriteModels/AttributeString.swift +++ b/Sources/AppwriteModels/AttributeString.swift @@ -116,12 +116,12 @@ open class AttributeString: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "size": size as Any, - "`default`": `default` as Any, + "default": `default` as Any, "encrypt": encrypt as Any ] } diff --git a/Sources/AppwriteModels/AttributeUrl.swift b/Sources/AppwriteModels/AttributeUrl.swift index b45607b..b6a7a41 100644 --- a/Sources/AppwriteModels/AttributeUrl.swift +++ b/Sources/AppwriteModels/AttributeUrl.swift @@ -108,12 +108,12 @@ open class AttributeUrl: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/BucketList.swift b/Sources/AppwriteModels/BucketList.swift index 89a718e..b302f36 100644 --- a/Sources/AppwriteModels/BucketList.swift +++ b/Sources/AppwriteModels/BucketList.swift @@ -9,7 +9,7 @@ open class BucketList: Codable { case buckets = "buckets" } - /// Total number of buckets rows that matched your query. + /// Total number of buckets that matched your query. public let total: Int /// List of buckets. diff --git a/Sources/AppwriteModels/CollectionList.swift b/Sources/AppwriteModels/CollectionList.swift index 54ccbfc..b078619 100644 --- a/Sources/AppwriteModels/CollectionList.swift +++ b/Sources/AppwriteModels/CollectionList.swift @@ -9,7 +9,7 @@ open class CollectionList: Codable { case collections = "collections" } - /// Total number of collections rows that matched your query. + /// Total number of collections that matched your query. public let total: Int /// List of collections. diff --git a/Sources/AppwriteModels/ColumnBoolean.swift b/Sources/AppwriteModels/ColumnBoolean.swift index 84f99b9..cd22e7c 100644 --- a/Sources/AppwriteModels/ColumnBoolean.swift +++ b/Sources/AppwriteModels/ColumnBoolean.swift @@ -100,11 +100,11 @@ open class ColumnBoolean: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/ColumnDatetime.swift b/Sources/AppwriteModels/ColumnDatetime.swift index 5d5dc37..f1059df 100644 --- a/Sources/AppwriteModels/ColumnDatetime.swift +++ b/Sources/AppwriteModels/ColumnDatetime.swift @@ -108,12 +108,12 @@ open class ColumnDatetime: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/ColumnEmail.swift b/Sources/AppwriteModels/ColumnEmail.swift index 8ffc084..1e904fa 100644 --- a/Sources/AppwriteModels/ColumnEmail.swift +++ b/Sources/AppwriteModels/ColumnEmail.swift @@ -108,12 +108,12 @@ open class ColumnEmail: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/ColumnEnum.swift b/Sources/AppwriteModels/ColumnEnum.swift index e9fcbbd..96c9c56 100644 --- a/Sources/AppwriteModels/ColumnEnum.swift +++ b/Sources/AppwriteModels/ColumnEnum.swift @@ -116,13 +116,13 @@ open class ColumnEnum: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "elements": elements as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/ColumnFloat.swift b/Sources/AppwriteModels/ColumnFloat.swift index 7609ffc..a2bf470 100644 --- a/Sources/AppwriteModels/ColumnFloat.swift +++ b/Sources/AppwriteModels/ColumnFloat.swift @@ -116,13 +116,13 @@ open class ColumnFloat: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "min": min as Any, "max": max as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/ColumnIndexList.swift b/Sources/AppwriteModels/ColumnIndexList.swift index 5ce8061..476809c 100644 --- a/Sources/AppwriteModels/ColumnIndexList.swift +++ b/Sources/AppwriteModels/ColumnIndexList.swift @@ -9,7 +9,7 @@ open class ColumnIndexList: Codable { case indexes = "indexes" } - /// Total number of indexes rows that matched your query. + /// Total number of indexes that matched your query. public let total: Int /// List of indexes. diff --git a/Sources/AppwriteModels/ColumnInteger.swift b/Sources/AppwriteModels/ColumnInteger.swift index 22ba42c..fb565a4 100644 --- a/Sources/AppwriteModels/ColumnInteger.swift +++ b/Sources/AppwriteModels/ColumnInteger.swift @@ -116,13 +116,13 @@ open class ColumnInteger: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "min": min as Any, "max": max as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/ColumnIp.swift b/Sources/AppwriteModels/ColumnIp.swift index d0f358e..e19b49a 100644 --- a/Sources/AppwriteModels/ColumnIp.swift +++ b/Sources/AppwriteModels/ColumnIp.swift @@ -108,12 +108,12 @@ open class ColumnIp: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/ColumnRelationship.swift b/Sources/AppwriteModels/ColumnRelationship.swift index e738c5f..b4c388c 100644 --- a/Sources/AppwriteModels/ColumnRelationship.swift +++ b/Sources/AppwriteModels/ColumnRelationship.swift @@ -140,7 +140,7 @@ open class ColumnRelationship: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, diff --git a/Sources/AppwriteModels/ColumnString.swift b/Sources/AppwriteModels/ColumnString.swift index 77f625c..6dd146b 100644 --- a/Sources/AppwriteModels/ColumnString.swift +++ b/Sources/AppwriteModels/ColumnString.swift @@ -116,12 +116,12 @@ open class ColumnString: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "size": size as Any, - "`default`": `default` as Any, + "default": `default` as Any, "encrypt": encrypt as Any ] } diff --git a/Sources/AppwriteModels/ColumnUrl.swift b/Sources/AppwriteModels/ColumnUrl.swift index 62aa875..29ef440 100644 --- a/Sources/AppwriteModels/ColumnUrl.swift +++ b/Sources/AppwriteModels/ColumnUrl.swift @@ -108,12 +108,12 @@ open class ColumnUrl: Codable { "type": type as Any, "status": status as Any, "error": error as Any, - "`required`": `required` as Any, + "required": `required` as Any, "array": array as Any, "$createdAt": createdAt as Any, "$updatedAt": updatedAt as Any, "format": format as Any, - "`default`": `default` as Any + "default": `default` as Any ] } diff --git a/Sources/AppwriteModels/ContinentList.swift b/Sources/AppwriteModels/ContinentList.swift index 7ebd966..0e697e7 100644 --- a/Sources/AppwriteModels/ContinentList.swift +++ b/Sources/AppwriteModels/ContinentList.swift @@ -9,7 +9,7 @@ open class ContinentList: Codable { case continents = "continents" } - /// Total number of continents rows that matched your query. + /// Total number of continents that matched your query. public let total: Int /// List of continents. diff --git a/Sources/AppwriteModels/CountryList.swift b/Sources/AppwriteModels/CountryList.swift index 61389ba..15a8d89 100644 --- a/Sources/AppwriteModels/CountryList.swift +++ b/Sources/AppwriteModels/CountryList.swift @@ -9,7 +9,7 @@ open class CountryList: Codable { case countries = "countries" } - /// Total number of countries rows that matched your query. + /// Total number of countries that matched your query. public let total: Int /// List of countries. diff --git a/Sources/AppwriteModels/CurrencyList.swift b/Sources/AppwriteModels/CurrencyList.swift index 12962a6..81d1c26 100644 --- a/Sources/AppwriteModels/CurrencyList.swift +++ b/Sources/AppwriteModels/CurrencyList.swift @@ -9,7 +9,7 @@ open class CurrencyList: Codable { case currencies = "currencies" } - /// Total number of currencies rows that matched your query. + /// Total number of currencies that matched your query. public let total: Int /// List of currencies. diff --git a/Sources/AppwriteModels/DatabaseList.swift b/Sources/AppwriteModels/DatabaseList.swift index 509a136..57d9221 100644 --- a/Sources/AppwriteModels/DatabaseList.swift +++ b/Sources/AppwriteModels/DatabaseList.swift @@ -9,7 +9,7 @@ open class DatabaseList: Codable { case databases = "databases" } - /// Total number of databases rows that matched your query. + /// Total number of databases that matched your query. public let total: Int /// List of databases. diff --git a/Sources/AppwriteModels/DeploymentList.swift b/Sources/AppwriteModels/DeploymentList.swift index 615849d..12b984b 100644 --- a/Sources/AppwriteModels/DeploymentList.swift +++ b/Sources/AppwriteModels/DeploymentList.swift @@ -9,7 +9,7 @@ open class DeploymentList: Codable { case deployments = "deployments" } - /// Total number of deployments rows that matched your query. + /// Total number of deployments that matched your query. public let total: Int /// List of deployments. diff --git a/Sources/AppwriteModels/DocumentList.swift b/Sources/AppwriteModels/DocumentList.swift index abed99a..77f2679 100644 --- a/Sources/AppwriteModels/DocumentList.swift +++ b/Sources/AppwriteModels/DocumentList.swift @@ -9,7 +9,7 @@ open class DocumentList: Codable { case documents = "documents" } - /// Total number of documents rows that matched your query. + /// Total number of documents that matched your query. public let total: Int /// List of documents. diff --git a/Sources/AppwriteModels/ExecutionList.swift b/Sources/AppwriteModels/ExecutionList.swift index da9ea78..c903b34 100644 --- a/Sources/AppwriteModels/ExecutionList.swift +++ b/Sources/AppwriteModels/ExecutionList.swift @@ -9,7 +9,7 @@ open class ExecutionList: Codable { case executions = "executions" } - /// Total number of executions rows that matched your query. + /// Total number of executions that matched your query. public let total: Int /// List of executions. diff --git a/Sources/AppwriteModels/FileList.swift b/Sources/AppwriteModels/FileList.swift index bd4e332..19d52a0 100644 --- a/Sources/AppwriteModels/FileList.swift +++ b/Sources/AppwriteModels/FileList.swift @@ -9,7 +9,7 @@ open class FileList: Codable { case files = "files" } - /// Total number of files rows that matched your query. + /// Total number of files that matched your query. public let total: Int /// List of files. diff --git a/Sources/AppwriteModels/FrameworkList.swift b/Sources/AppwriteModels/FrameworkList.swift index 5de77fb..cbe4ae3 100644 --- a/Sources/AppwriteModels/FrameworkList.swift +++ b/Sources/AppwriteModels/FrameworkList.swift @@ -9,7 +9,7 @@ open class FrameworkList: Codable { case frameworks = "frameworks" } - /// Total number of frameworks rows that matched your query. + /// Total number of frameworks that matched your query. public let total: Int /// List of frameworks. diff --git a/Sources/AppwriteModels/FunctionList.swift b/Sources/AppwriteModels/FunctionList.swift index 4c87be3..33604a5 100644 --- a/Sources/AppwriteModels/FunctionList.swift +++ b/Sources/AppwriteModels/FunctionList.swift @@ -9,7 +9,7 @@ open class FunctionList: Codable { case functions = "functions" } - /// Total number of functions rows that matched your query. + /// Total number of functions that matched your query. public let total: Int /// List of functions. diff --git a/Sources/AppwriteModels/IdentityList.swift b/Sources/AppwriteModels/IdentityList.swift index 958284c..abcc362 100644 --- a/Sources/AppwriteModels/IdentityList.swift +++ b/Sources/AppwriteModels/IdentityList.swift @@ -9,7 +9,7 @@ open class IdentityList: Codable { case identities = "identities" } - /// Total number of identities rows that matched your query. + /// Total number of identities that matched your query. public let total: Int /// List of identities. diff --git a/Sources/AppwriteModels/IndexList.swift b/Sources/AppwriteModels/IndexList.swift index 4b87aff..52fa458 100644 --- a/Sources/AppwriteModels/IndexList.swift +++ b/Sources/AppwriteModels/IndexList.swift @@ -9,7 +9,7 @@ open class IndexList: Codable { case indexes = "indexes" } - /// Total number of indexes rows that matched your query. + /// Total number of indexes that matched your query. public let total: Int /// List of indexes. diff --git a/Sources/AppwriteModels/LanguageList.swift b/Sources/AppwriteModels/LanguageList.swift index 0edfa80..2b1f03c 100644 --- a/Sources/AppwriteModels/LanguageList.swift +++ b/Sources/AppwriteModels/LanguageList.swift @@ -9,7 +9,7 @@ open class LanguageList: Codable { case languages = "languages" } - /// Total number of languages rows that matched your query. + /// Total number of languages that matched your query. public let total: Int /// List of languages. diff --git a/Sources/AppwriteModels/LocaleCodeList.swift b/Sources/AppwriteModels/LocaleCodeList.swift index 0d22818..f1d1678 100644 --- a/Sources/AppwriteModels/LocaleCodeList.swift +++ b/Sources/AppwriteModels/LocaleCodeList.swift @@ -9,7 +9,7 @@ open class LocaleCodeList: Codable { case localeCodes = "localeCodes" } - /// Total number of localeCodes rows that matched your query. + /// Total number of localeCodes that matched your query. public let total: Int /// List of localeCodes. diff --git a/Sources/AppwriteModels/LogList.swift b/Sources/AppwriteModels/LogList.swift index c9207b8..ba76a8a 100644 --- a/Sources/AppwriteModels/LogList.swift +++ b/Sources/AppwriteModels/LogList.swift @@ -9,7 +9,7 @@ open class LogList: Codable { case logs = "logs" } - /// Total number of logs rows that matched your query. + /// Total number of logs that matched your query. public let total: Int /// List of logs. diff --git a/Sources/AppwriteModels/MembershipList.swift b/Sources/AppwriteModels/MembershipList.swift index 9290f69..7d6ffd1 100644 --- a/Sources/AppwriteModels/MembershipList.swift +++ b/Sources/AppwriteModels/MembershipList.swift @@ -9,7 +9,7 @@ open class MembershipList: Codable { case memberships = "memberships" } - /// Total number of memberships rows that matched your query. + /// Total number of memberships that matched your query. public let total: Int /// List of memberships. diff --git a/Sources/AppwriteModels/MessageList.swift b/Sources/AppwriteModels/MessageList.swift index 865f605..5030392 100644 --- a/Sources/AppwriteModels/MessageList.swift +++ b/Sources/AppwriteModels/MessageList.swift @@ -9,7 +9,7 @@ open class MessageList: Codable { case messages = "messages" } - /// Total number of messages rows that matched your query. + /// Total number of messages that matched your query. public let total: Int /// List of messages. diff --git a/Sources/AppwriteModels/PhoneList.swift b/Sources/AppwriteModels/PhoneList.swift index 63371a6..f09d239 100644 --- a/Sources/AppwriteModels/PhoneList.swift +++ b/Sources/AppwriteModels/PhoneList.swift @@ -9,7 +9,7 @@ open class PhoneList: Codable { case phones = "phones" } - /// Total number of phones rows that matched your query. + /// Total number of phones that matched your query. public let total: Int /// List of phones. diff --git a/Sources/AppwriteModels/ProviderList.swift b/Sources/AppwriteModels/ProviderList.swift index b440d6d..feefae6 100644 --- a/Sources/AppwriteModels/ProviderList.swift +++ b/Sources/AppwriteModels/ProviderList.swift @@ -9,7 +9,7 @@ open class ProviderList: Codable { case providers = "providers" } - /// Total number of providers rows that matched your query. + /// Total number of providers that matched your query. public let total: Int /// List of providers. diff --git a/Sources/AppwriteModels/ResourceTokenList.swift b/Sources/AppwriteModels/ResourceTokenList.swift index 575c758..938c1f8 100644 --- a/Sources/AppwriteModels/ResourceTokenList.swift +++ b/Sources/AppwriteModels/ResourceTokenList.swift @@ -9,7 +9,7 @@ open class ResourceTokenList: Codable { case tokens = "tokens" } - /// Total number of tokens rows that matched your query. + /// Total number of tokens that matched your query. public let total: Int /// List of tokens. diff --git a/Sources/AppwriteModels/RowList.swift b/Sources/AppwriteModels/RowList.swift index 8eb7d80..c14c83b 100644 --- a/Sources/AppwriteModels/RowList.swift +++ b/Sources/AppwriteModels/RowList.swift @@ -9,7 +9,7 @@ open class RowList: Codable { case rows = "rows" } - /// Total number of rows rows that matched your query. + /// Total number of rows that matched your query. public let total: Int /// List of rows. diff --git a/Sources/AppwriteModels/RuntimeList.swift b/Sources/AppwriteModels/RuntimeList.swift index 36fcdef..26e9be6 100644 --- a/Sources/AppwriteModels/RuntimeList.swift +++ b/Sources/AppwriteModels/RuntimeList.swift @@ -9,7 +9,7 @@ open class RuntimeList: Codable { case runtimes = "runtimes" } - /// Total number of runtimes rows that matched your query. + /// Total number of runtimes that matched your query. public let total: Int /// List of runtimes. diff --git a/Sources/AppwriteModels/SessionList.swift b/Sources/AppwriteModels/SessionList.swift index 5a227e5..c9c8394 100644 --- a/Sources/AppwriteModels/SessionList.swift +++ b/Sources/AppwriteModels/SessionList.swift @@ -9,7 +9,7 @@ open class SessionList: Codable { case sessions = "sessions" } - /// Total number of sessions rows that matched your query. + /// Total number of sessions that matched your query. public let total: Int /// List of sessions. diff --git a/Sources/AppwriteModels/SiteList.swift b/Sources/AppwriteModels/SiteList.swift index 0375cd1..60c1d89 100644 --- a/Sources/AppwriteModels/SiteList.swift +++ b/Sources/AppwriteModels/SiteList.swift @@ -9,7 +9,7 @@ open class SiteList: Codable { case sites = "sites" } - /// Total number of sites rows that matched your query. + /// Total number of sites that matched your query. public let total: Int /// List of sites. diff --git a/Sources/AppwriteModels/SpecificationList.swift b/Sources/AppwriteModels/SpecificationList.swift index 3e684f9..fc13cd3 100644 --- a/Sources/AppwriteModels/SpecificationList.swift +++ b/Sources/AppwriteModels/SpecificationList.swift @@ -9,7 +9,7 @@ open class SpecificationList: Codable { case specifications = "specifications" } - /// Total number of specifications rows that matched your query. + /// Total number of specifications that matched your query. public let total: Int /// List of specifications. diff --git a/Sources/AppwriteModels/SubscriberList.swift b/Sources/AppwriteModels/SubscriberList.swift index 1c41642..8d82866 100644 --- a/Sources/AppwriteModels/SubscriberList.swift +++ b/Sources/AppwriteModels/SubscriberList.swift @@ -9,7 +9,7 @@ open class SubscriberList: Codable { case subscribers = "subscribers" } - /// Total number of subscribers rows that matched your query. + /// Total number of subscribers that matched your query. public let total: Int /// List of subscribers. diff --git a/Sources/AppwriteModels/TableList.swift b/Sources/AppwriteModels/TableList.swift index 50a8bea..d0c8059 100644 --- a/Sources/AppwriteModels/TableList.swift +++ b/Sources/AppwriteModels/TableList.swift @@ -9,7 +9,7 @@ open class TableList: Codable { case tables = "tables" } - /// Total number of tables rows that matched your query. + /// Total number of tables that matched your query. public let total: Int /// List of tables. diff --git a/Sources/AppwriteModels/TargetList.swift b/Sources/AppwriteModels/TargetList.swift index b28034f..cc5557d 100644 --- a/Sources/AppwriteModels/TargetList.swift +++ b/Sources/AppwriteModels/TargetList.swift @@ -9,7 +9,7 @@ open class TargetList: Codable { case targets = "targets" } - /// Total number of targets rows that matched your query. + /// Total number of targets that matched your query. public let total: Int /// List of targets. diff --git a/Sources/AppwriteModels/TeamList.swift b/Sources/AppwriteModels/TeamList.swift index 988a1ec..2b789d9 100644 --- a/Sources/AppwriteModels/TeamList.swift +++ b/Sources/AppwriteModels/TeamList.swift @@ -9,7 +9,7 @@ open class TeamList: Codable { case teams = "teams" } - /// Total number of teams rows that matched your query. + /// Total number of teams that matched your query. public let total: Int /// List of teams. diff --git a/Sources/AppwriteModels/TopicList.swift b/Sources/AppwriteModels/TopicList.swift index f2393b2..53cfd49 100644 --- a/Sources/AppwriteModels/TopicList.swift +++ b/Sources/AppwriteModels/TopicList.swift @@ -9,7 +9,7 @@ open class TopicList: Codable { case topics = "topics" } - /// Total number of topics rows that matched your query. + /// Total number of topics that matched your query. public let total: Int /// List of topics. diff --git a/Sources/AppwriteModels/UserList.swift b/Sources/AppwriteModels/UserList.swift index 4c5c1cd..445e9c9 100644 --- a/Sources/AppwriteModels/UserList.swift +++ b/Sources/AppwriteModels/UserList.swift @@ -9,7 +9,7 @@ open class UserList: Codable { case users = "users" } - /// Total number of users rows that matched your query. + /// Total number of users that matched your query. public let total: Int /// List of users. diff --git a/Sources/AppwriteModels/VariableList.swift b/Sources/AppwriteModels/VariableList.swift index e0537d3..b97b1d0 100644 --- a/Sources/AppwriteModels/VariableList.swift +++ b/Sources/AppwriteModels/VariableList.swift @@ -9,7 +9,7 @@ open class VariableList: Codable { case variables = "variables" } - /// Total number of variables rows that matched your query. + /// Total number of variables that matched your query. public let total: Int /// List of variables. diff --git a/docs/examples/account/create-m-f-a-authenticator.md b/docs/examples/account/create-m-f-a-authenticator.md new file mode 100644 index 0000000..dd3a7d1 --- /dev/null +++ b/docs/examples/account/create-m-f-a-authenticator.md @@ -0,0 +1,14 @@ +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 mfaType = try await account.createMFAAuthenticator( + type: .totp +) + diff --git a/docs/examples/account/create-m-f-a-challenge.md b/docs/examples/account/create-m-f-a-challenge.md new file mode 100644 index 0000000..27f1bc1 --- /dev/null +++ b/docs/examples/account/create-m-f-a-challenge.md @@ -0,0 +1,13 @@ +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let mfaChallenge = try await account.createMFAChallenge( + factor: .email +) + diff --git a/docs/examples/account/create-m-f-a-recovery-codes.md b/docs/examples/account/create-m-f-a-recovery-codes.md new file mode 100644 index 0000000..3595cda --- /dev/null +++ b/docs/examples/account/create-m-f-a-recovery-codes.md @@ -0,0 +1,11 @@ +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 mfaRecoveryCodes = try await account.createMFARecoveryCodes() + diff --git a/docs/examples/account/delete-m-f-a-authenticator.md b/docs/examples/account/delete-m-f-a-authenticator.md new file mode 100644 index 0000000..5a85cdc --- /dev/null +++ b/docs/examples/account/delete-m-f-a-authenticator.md @@ -0,0 +1,14 @@ +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 result = try await account.deleteMFAAuthenticator( + type: .totp +) + diff --git a/docs/examples/account/get-m-f-a-recovery-codes.md b/docs/examples/account/get-m-f-a-recovery-codes.md new file mode 100644 index 0000000..86c435d --- /dev/null +++ b/docs/examples/account/get-m-f-a-recovery-codes.md @@ -0,0 +1,11 @@ +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 mfaRecoveryCodes = try await account.getMFARecoveryCodes() + diff --git a/docs/examples/account/list-m-f-a-factors.md b/docs/examples/account/list-m-f-a-factors.md new file mode 100644 index 0000000..be41b2b --- /dev/null +++ b/docs/examples/account/list-m-f-a-factors.md @@ -0,0 +1,11 @@ +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 mfaFactors = try await account.listMFAFactors() + diff --git a/docs/examples/account/update-m-f-a-authenticator.md b/docs/examples/account/update-m-f-a-authenticator.md new file mode 100644 index 0000000..79f408e --- /dev/null +++ b/docs/examples/account/update-m-f-a-authenticator.md @@ -0,0 +1,15 @@ +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 user = try await account.updateMFAAuthenticator( + type: .totp, + otp: "" +) + diff --git a/docs/examples/account/update-m-f-a-challenge.md b/docs/examples/account/update-m-f-a-challenge.md new file mode 100644 index 0000000..c595f1e --- /dev/null +++ b/docs/examples/account/update-m-f-a-challenge.md @@ -0,0 +1,14 @@ +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 session = try await account.updateMFAChallenge( + challengeId: "", + otp: "" +) + diff --git a/docs/examples/account/update-m-f-a-recovery-codes.md b/docs/examples/account/update-m-f-a-recovery-codes.md new file mode 100644 index 0000000..ee6f9ac --- /dev/null +++ b/docs/examples/account/update-m-f-a-recovery-codes.md @@ -0,0 +1,11 @@ +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 mfaRecoveryCodes = try await account.updateMFARecoveryCodes() + diff --git a/docs/examples/messaging/create-a-p-n-s-provider.md b/docs/examples/messaging/create-a-p-n-s-provider.md new file mode 100644 index 0000000..772084d --- /dev/null +++ b/docs/examples/messaging/create-a-p-n-s-provider.md @@ -0,0 +1,20 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let messaging = Messaging(client) + +let provider = try await messaging.createAPNSProvider( + providerId: "", + name: "", + authKey: "", // optional + authKeyId: "", // optional + teamId: "", // optional + bundleId: "", // optional + sandbox: false, // optional + enabled: false // optional +) + diff --git a/docs/examples/messaging/create-f-c-m-provider.md b/docs/examples/messaging/create-f-c-m-provider.md new file mode 100644 index 0000000..2b00450 --- /dev/null +++ b/docs/examples/messaging/create-f-c-m-provider.md @@ -0,0 +1,16 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let messaging = Messaging(client) + +let provider = try await messaging.createFCMProvider( + providerId: "", + name: "", + serviceAccountJSON: [:], // optional + enabled: false // optional +) + diff --git a/docs/examples/messaging/create-s-m-s.md b/docs/examples/messaging/create-s-m-s.md new file mode 100644 index 0000000..28a6ba7 --- /dev/null +++ b/docs/examples/messaging/create-s-m-s.md @@ -0,0 +1,19 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let messaging = Messaging(client) + +let message = try await messaging.createSMS( + messageId: "", + content: "", + topics: [], // optional + users: [], // optional + targets: [], // optional + draft: false, // optional + scheduledAt: "" // optional +) + diff --git a/docs/examples/messaging/create-s-m-t-p-provider.md b/docs/examples/messaging/create-s-m-t-p-provider.md new file mode 100644 index 0000000..ec9b92c --- /dev/null +++ b/docs/examples/messaging/create-s-m-t-p-provider.md @@ -0,0 +1,27 @@ +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 messaging = Messaging(client) + +let provider = try await messaging.createSMTPProvider( + providerId: "", + name: "", + host: "", + port: 1, // optional + username: "", // optional + password: "", // optional + encryption: .none, // optional + autoTLS: false, // optional + mailer: "", // optional + fromName: "", // optional + fromEmail: "email@example.com", // optional + replyToName: "", // optional + replyToEmail: "email@example.com", // optional + enabled: false // optional +) + diff --git a/docs/examples/messaging/update-a-p-n-s-provider.md b/docs/examples/messaging/update-a-p-n-s-provider.md new file mode 100644 index 0000000..bed92ba --- /dev/null +++ b/docs/examples/messaging/update-a-p-n-s-provider.md @@ -0,0 +1,20 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let messaging = Messaging(client) + +let provider = try await messaging.updateAPNSProvider( + providerId: "", + name: "", // optional + enabled: false, // optional + authKey: "", // optional + authKeyId: "", // optional + teamId: "", // optional + bundleId: "", // optional + sandbox: false // optional +) + diff --git a/docs/examples/messaging/update-f-c-m-provider.md b/docs/examples/messaging/update-f-c-m-provider.md new file mode 100644 index 0000000..efd7e1f --- /dev/null +++ b/docs/examples/messaging/update-f-c-m-provider.md @@ -0,0 +1,16 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let messaging = Messaging(client) + +let provider = try await messaging.updateFCMProvider( + providerId: "", + name: "", // optional + enabled: false, // optional + serviceAccountJSON: [:] // optional +) + diff --git a/docs/examples/messaging/update-s-m-s.md b/docs/examples/messaging/update-s-m-s.md new file mode 100644 index 0000000..d6dc207 --- /dev/null +++ b/docs/examples/messaging/update-s-m-s.md @@ -0,0 +1,19 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let messaging = Messaging(client) + +let message = try await messaging.updateSMS( + messageId: "", + topics: [], // optional + users: [], // optional + targets: [], // optional + content: "", // optional + draft: false, // optional + scheduledAt: "" // optional +) + diff --git a/docs/examples/messaging/update-s-m-t-p-provider.md b/docs/examples/messaging/update-s-m-t-p-provider.md new file mode 100644 index 0000000..402c267 --- /dev/null +++ b/docs/examples/messaging/update-s-m-t-p-provider.md @@ -0,0 +1,27 @@ +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 messaging = Messaging(client) + +let provider = try await messaging.updateSMTPProvider( + providerId: "", + name: "", // optional + host: "", // optional + port: 1, // optional + username: "", // optional + password: "", // optional + encryption: .none, // optional + autoTLS: false, // optional + mailer: "", // optional + fromName: "", // optional + fromEmail: "email@example.com", // optional + replyToName: "", // optional + replyToEmail: "", // optional + enabled: false // optional +) + diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md index 2e25e1b..af4b7bd 100644 --- a/docs/examples/tablesdb/create-boolean-column.md +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnBoolean = try await tablesDb.createBooleanColumn( +let columnBoolean = try await tablesDB.createBooleanColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md index b60b1da..ee1945d 100644 --- a/docs/examples/tablesdb/create-datetime-column.md +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnDatetime = try await tablesDb.createDatetimeColumn( +let columnDatetime = try await tablesDB.createDatetimeColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md index 859fce5..4ca0fe7 100644 --- a/docs/examples/tablesdb/create-email-column.md +++ b/docs/examples/tablesdb/create-email-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnEmail = try await tablesDb.createEmailColumn( +let columnEmail = try await tablesDB.createEmailColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md index d19f724..ccddf52 100644 --- a/docs/examples/tablesdb/create-enum-column.md +++ b/docs/examples/tablesdb/create-enum-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnEnum = try await tablesDb.createEnumColumn( +let columnEnum = try await tablesDB.createEnumColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md index 5a2aee0..c1c685b 100644 --- a/docs/examples/tablesdb/create-float-column.md +++ b/docs/examples/tablesdb/create-float-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnFloat = try await tablesDb.createFloatColumn( +let columnFloat = try await tablesDB.createFloatColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index f01174c..3620c62 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -6,9 +6,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnIndex = try await tablesDb.createIndex( +let columnIndex = try await tablesDB.createIndex( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md index 5131617..52ad14a 100644 --- a/docs/examples/tablesdb/create-integer-column.md +++ b/docs/examples/tablesdb/create-integer-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnInteger = try await tablesDb.createIntegerColumn( +let columnInteger = try await tablesDB.createIntegerColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md index 2388c89..d8801c5 100644 --- a/docs/examples/tablesdb/create-ip-column.md +++ b/docs/examples/tablesdb/create-ip-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnIp = try await tablesDb.createIpColumn( +let columnIp = try await tablesDB.createIpColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md index 3dc765a..4c464b5 100644 --- a/docs/examples/tablesdb/create-relationship-column.md +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -6,9 +6,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnRelationship = try await tablesDb.createRelationshipColumn( +let columnRelationship = try await tablesDB.createRelationshipColumn( databaseId: "", tableId: "", relatedTableId: "", diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 601bd32..31e0ea9 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setSession("") // The user session to authenticate with -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.createRow( +let row = try await tablesDB.createRow( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index e685ae7..25ea512 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let rowList = try await tablesDb.createRows( +let rowList = try await tablesDB.createRows( databaseId: "", tableId: "", rows: [] diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md index c1f3082..e38dcb8 100644 --- a/docs/examples/tablesdb/create-string-column.md +++ b/docs/examples/tablesdb/create-string-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnString = try await tablesDb.createStringColumn( +let columnString = try await tablesDB.createStringColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md index 631afb6..11d14e1 100644 --- a/docs/examples/tablesdb/create-table.md +++ b/docs/examples/tablesdb/create-table.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let table = try await tablesDb.createTable( +let table = try await tablesDB.createTable( databaseId: "", tableId: "", name: "", diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md index b2e9917..083556f 100644 --- a/docs/examples/tablesdb/create-url-column.md +++ b/docs/examples/tablesdb/create-url-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnUrl = try await tablesDb.createUrlColumn( +let columnUrl = try await tablesDB.createUrlColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index 2586404..be88b59 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let database = try await tablesDb.create( +let database = try await tablesDB.create( databaseId: "", name: "", enabled: false // optional diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index b7b8ae5..196289e 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setSession("") // The user session to authenticate with -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.decrementRowColumn( +let row = try await tablesDB.decrementRowColumn( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md index 781b109..f9f2c5c 100644 --- a/docs/examples/tablesdb/delete-column.md +++ b/docs/examples/tablesdb/delete-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let result = try await tablesDb.deleteColumn( +let result = try await tablesDB.deleteColumn( databaseId: "", tableId: "", key: "" diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md index 8fb2386..0a413b6 100644 --- a/docs/examples/tablesdb/delete-index.md +++ b/docs/examples/tablesdb/delete-index.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let result = try await tablesDb.deleteIndex( +let result = try await tablesDB.deleteIndex( databaseId: "", tableId: "", key: "" diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md index e533aa3..5449c74 100644 --- a/docs/examples/tablesdb/delete-row.md +++ b/docs/examples/tablesdb/delete-row.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setSession("") // The user session to authenticate with -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let result = try await tablesDb.deleteRow( +let result = try await tablesDB.deleteRow( databaseId: "", tableId: "", rowId: "" diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 7007369..85d8957 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let rowList = try await tablesDb.deleteRows( +let rowList = try await tablesDB.deleteRows( databaseId: "", tableId: "", queries: [] // optional diff --git a/docs/examples/tablesdb/delete-table.md b/docs/examples/tablesdb/delete-table.md index 2d2df8f..1986f3a 100644 --- a/docs/examples/tablesdb/delete-table.md +++ b/docs/examples/tablesdb/delete-table.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let result = try await tablesDb.deleteTable( +let result = try await tablesDB.deleteTable( databaseId: "", tableId: "" ) diff --git a/docs/examples/tablesdb/delete.md b/docs/examples/tablesdb/delete.md index 0c26a0d..08e6ddc 100644 --- a/docs/examples/tablesdb/delete.md +++ b/docs/examples/tablesdb/delete.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let result = try await tablesDb.delete( +let result = try await tablesDB.delete( databaseId: "" ) diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md index 21fe88c..2d88b03 100644 --- a/docs/examples/tablesdb/get-column.md +++ b/docs/examples/tablesdb/get-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let result = try await tablesDb.getColumn( +let result = try await tablesDB.getColumn( databaseId: "", tableId: "", key: "" diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md index 2022d1e..6f65fdb 100644 --- a/docs/examples/tablesdb/get-index.md +++ b/docs/examples/tablesdb/get-index.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnIndex = try await tablesDb.getIndex( +let columnIndex = try await tablesDB.getIndex( databaseId: "", tableId: "", key: "" diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md index 45961f8..17e6ccb 100644 --- a/docs/examples/tablesdb/get-row.md +++ b/docs/examples/tablesdb/get-row.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setSession("") // The user session to authenticate with -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.getRow( +let row = try await tablesDB.getRow( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md index 391adcd..e9167d4 100644 --- a/docs/examples/tablesdb/get-table.md +++ b/docs/examples/tablesdb/get-table.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let table = try await tablesDb.getTable( +let table = try await tablesDB.getTable( databaseId: "", tableId: "" ) diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md index 2442a7d..d670cf7 100644 --- a/docs/examples/tablesdb/get.md +++ b/docs/examples/tablesdb/get.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let database = try await tablesDb.get( +let database = try await tablesDB.get( databaseId: "" ) diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index 63054fa..38aa758 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setSession("") // The user session to authenticate with -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.incrementRowColumn( +let row = try await tablesDB.incrementRowColumn( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md index 33010e6..271a6d4 100644 --- a/docs/examples/tablesdb/list-columns.md +++ b/docs/examples/tablesdb/list-columns.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnList = try await tablesDb.listColumns( +let columnList = try await tablesDB.listColumns( databaseId: "", tableId: "", queries: [] // optional diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md index 621ffa1..a8e2770 100644 --- a/docs/examples/tablesdb/list-indexes.md +++ b/docs/examples/tablesdb/list-indexes.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnIndexList = try await tablesDb.listIndexes( +let columnIndexList = try await tablesDB.listIndexes( databaseId: "", tableId: "", queries: [] // optional diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index de9b682..7320147 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setSession("") // The user session to authenticate with -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let rowList = try await tablesDb.listRows( +let rowList = try await tablesDB.listRows( databaseId: "", tableId: "", queries: [] // optional diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md index 8fe8d56..46fcdcf 100644 --- a/docs/examples/tablesdb/list-tables.md +++ b/docs/examples/tablesdb/list-tables.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let tableList = try await tablesDb.listTables( +let tableList = try await tablesDB.listTables( databaseId: "", queries: [], // optional search: "" // optional diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md index cc10b51..6923d8a 100644 --- a/docs/examples/tablesdb/list.md +++ b/docs/examples/tablesdb/list.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let databaseList = try await tablesDb.list( +let databaseList = try await tablesDB.list( queries: [], // optional search: "" // optional ) diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md index c3d7e07..c8ca0fc 100644 --- a/docs/examples/tablesdb/update-boolean-column.md +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnBoolean = try await tablesDb.updateBooleanColumn( +let columnBoolean = try await tablesDB.updateBooleanColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md index a2d71f4..67e411b 100644 --- a/docs/examples/tablesdb/update-datetime-column.md +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnDatetime = try await tablesDb.updateDatetimeColumn( +let columnDatetime = try await tablesDB.updateDatetimeColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md index d59c833..56a7d07 100644 --- a/docs/examples/tablesdb/update-email-column.md +++ b/docs/examples/tablesdb/update-email-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnEmail = try await tablesDb.updateEmailColumn( +let columnEmail = try await tablesDB.updateEmailColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md index 5f1b05e..a86d114 100644 --- a/docs/examples/tablesdb/update-enum-column.md +++ b/docs/examples/tablesdb/update-enum-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnEnum = try await tablesDb.updateEnumColumn( +let columnEnum = try await tablesDB.updateEnumColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md index b2459e5..10806aa 100644 --- a/docs/examples/tablesdb/update-float-column.md +++ b/docs/examples/tablesdb/update-float-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnFloat = try await tablesDb.updateFloatColumn( +let columnFloat = try await tablesDB.updateFloatColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md index 091664a..ba6bfa5 100644 --- a/docs/examples/tablesdb/update-integer-column.md +++ b/docs/examples/tablesdb/update-integer-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnInteger = try await tablesDb.updateIntegerColumn( +let columnInteger = try await tablesDB.updateIntegerColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md index 87f2915..5686e71 100644 --- a/docs/examples/tablesdb/update-ip-column.md +++ b/docs/examples/tablesdb/update-ip-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnIp = try await tablesDb.updateIpColumn( +let columnIp = try await tablesDB.updateIpColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md index 27e7460..0a021ff 100644 --- a/docs/examples/tablesdb/update-relationship-column.md +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -6,9 +6,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnRelationship = try await tablesDb.updateRelationshipColumn( +let columnRelationship = try await tablesDB.updateRelationshipColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 6e7bd35..e06338b 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setSession("") // The user session to authenticate with -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.updateRow( +let row = try await tablesDB.updateRow( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 4d33169..58894f5 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let rowList = try await tablesDb.updateRows( +let rowList = try await tablesDB.updateRows( databaseId: "", tableId: "", data: [:], // optional diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md index defa48e..55efca1 100644 --- a/docs/examples/tablesdb/update-string-column.md +++ b/docs/examples/tablesdb/update-string-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnString = try await tablesDb.updateStringColumn( +let columnString = try await tablesDB.updateStringColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index 3483535..278d6e6 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let table = try await tablesDb.updateTable( +let table = try await tablesDB.updateTable( databaseId: "", tableId: "", name: "", diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md index e1fe5ce..693fe52 100644 --- a/docs/examples/tablesdb/update-url-column.md +++ b/docs/examples/tablesdb/update-url-column.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let columnUrl = try await tablesDb.updateUrlColumn( +let columnUrl = try await tablesDB.updateUrlColumn( databaseId: "", tableId: "", key: "", diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 041f026..4a7dcc8 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let database = try await tablesDb.update( +let database = try await tablesDB.update( databaseId: "", name: "", enabled: false // optional diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 6b1ddaf..dc133f6 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setSession("") // The user session to authenticate with -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let row = try await tablesDb.upsertRow( +let row = try await tablesDB.upsertRow( databaseId: "", tableId: "", rowId: "", diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 62737e6..fe35f0d 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -5,9 +5,9 @@ let client = Client() .setProject("") // Your project ID .setKey("") // Your secret API key -let tablesDb = TablesDb(client) +let tablesDB = TablesDB(client) -let rowList = try await tablesDb.upsertRows( +let rowList = try await tablesDB.upsertRows( databaseId: "", tableId: "", rows: [] diff --git a/docs/examples/users/create-m-f-a-recovery-codes.md b/docs/examples/users/create-m-f-a-recovery-codes.md new file mode 100644 index 0000000..5f073d1 --- /dev/null +++ b/docs/examples/users/create-m-f-a-recovery-codes.md @@ -0,0 +1,13 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let users = Users(client) + +let mfaRecoveryCodes = try await users.createMFARecoveryCodes( + userId: "" +) + diff --git a/docs/examples/users/delete-m-f-a-authenticator.md b/docs/examples/users/delete-m-f-a-authenticator.md new file mode 100644 index 0000000..be9f395 --- /dev/null +++ b/docs/examples/users/delete-m-f-a-authenticator.md @@ -0,0 +1,15 @@ +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 users = Users(client) + +let result = try await users.deleteMFAAuthenticator( + userId: "", + type: .totp +) + diff --git a/docs/examples/users/get-m-f-a-recovery-codes.md b/docs/examples/users/get-m-f-a-recovery-codes.md new file mode 100644 index 0000000..874076c --- /dev/null +++ b/docs/examples/users/get-m-f-a-recovery-codes.md @@ -0,0 +1,13 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let users = Users(client) + +let mfaRecoveryCodes = try await users.getMFARecoveryCodes( + userId: "" +) + diff --git a/docs/examples/users/list-m-f-a-factors.md b/docs/examples/users/list-m-f-a-factors.md new file mode 100644 index 0000000..4a58a07 --- /dev/null +++ b/docs/examples/users/list-m-f-a-factors.md @@ -0,0 +1,13 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let users = Users(client) + +let mfaFactors = try await users.listMFAFactors( + userId: "" +) + diff --git a/docs/examples/users/update-m-f-a-recovery-codes.md b/docs/examples/users/update-m-f-a-recovery-codes.md new file mode 100644 index 0000000..7ebb34e --- /dev/null +++ b/docs/examples/users/update-m-f-a-recovery-codes.md @@ -0,0 +1,13 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let users = Users(client) + +let mfaRecoveryCodes = try await users.updateMFARecoveryCodes( + userId: "" +) + diff --git a/docs/examples/users/update-m-f-a.md b/docs/examples/users/update-m-f-a.md new file mode 100644 index 0000000..ca442b3 --- /dev/null +++ b/docs/examples/users/update-m-f-a.md @@ -0,0 +1,14 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +let users = Users(client) + +let user = try await users.updateMFA( + userId: "", + mfa: false +) + From 0d35472e1aa717af2e67d93208ffc6c7193df5a0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 23 Aug 2025 20:13:50 +1200 Subject: [PATCH 5/7] Add 1.8.x support --- Sources/Appwrite/Services/Account.swift | 8 ++++++-- Sources/AppwriteModels/Execution.swift | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 53638c3..ac76fae 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -1803,8 +1803,11 @@ open class Account: Service { /// /// Sends the user an email with a secret key for creating a session. If the - /// provided user ID has not be registered, a new user will be created. Use the - /// returned user ID and secret and submit a request to the [POST + /// email address has never been used, a **new account is created** using the + /// provided `userId`. Otherwise, if the email address is already attached to + /// an account, the **user ID is ignored**. Then, the user will receive an + /// email with the one-time password. Use the returned user ID and secret and + /// submit a request to the [POST /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. @@ -1812,6 +1815,7 @@ open class Account: Service { /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). + /// /// /// - Parameters: /// - userId: String diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index 6e81532..d216290 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -10,6 +10,7 @@ open class Execution: Codable { case updatedAt = "$updatedAt" case permissions = "$permissions" case functionId = "functionId" + case deploymentId = "deploymentId" case trigger = "trigger" case status = "status" case requestMethod = "requestMethod" @@ -39,6 +40,9 @@ open class Execution: Codable { /// Function ID. public let functionId: String + /// Function's deployment ID used to create the execution. + public let deploymentId: String + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. public let trigger: String @@ -82,6 +86,7 @@ open class Execution: Codable { updatedAt: String, permissions: [String], functionId: String, + deploymentId: String, trigger: String, status: String, requestMethod: String, @@ -100,6 +105,7 @@ open class Execution: Codable { self.updatedAt = updatedAt self.permissions = permissions self.functionId = functionId + self.deploymentId = deploymentId self.trigger = trigger self.status = status self.requestMethod = requestMethod @@ -122,6 +128,7 @@ open class Execution: Codable { self.updatedAt = try container.decode(String.self, forKey: .updatedAt) self.permissions = try container.decode([String].self, forKey: .permissions) self.functionId = try container.decode(String.self, forKey: .functionId) + self.deploymentId = try container.decode(String.self, forKey: .deploymentId) self.trigger = try container.decode(String.self, forKey: .trigger) self.status = try container.decode(String.self, forKey: .status) self.requestMethod = try container.decode(String.self, forKey: .requestMethod) @@ -144,6 +151,7 @@ open class Execution: Codable { try container.encode(updatedAt, forKey: .updatedAt) try container.encode(permissions, forKey: .permissions) try container.encode(functionId, forKey: .functionId) + try container.encode(deploymentId, forKey: .deploymentId) try container.encode(trigger, forKey: .trigger) try container.encode(status, forKey: .status) try container.encode(requestMethod, forKey: .requestMethod) @@ -165,6 +173,7 @@ open class Execution: Codable { "$updatedAt": updatedAt as Any, "$permissions": permissions as Any, "functionId": functionId as Any, + "deploymentId": deploymentId as Any, "trigger": trigger as Any, "status": status as Any, "requestMethod": requestMethod as Any, @@ -187,6 +196,7 @@ open class Execution: Codable { updatedAt: map["$updatedAt"] as! String, permissions: map["$permissions"] as! [String], functionId: map["functionId"] as! String, + deploymentId: map["deploymentId"] as! String, trigger: map["trigger"] as! String, status: map["status"] as! String, requestMethod: map["requestMethod"] as! String, From d5d46324e0f9134cdf7fc3c2c033d2599c4f1897 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 23 Aug 2025 22:19:03 +1200 Subject: [PATCH 6/7] Add 1.8.x support --- Sources/Appwrite/Services/Account.swift | 20 ++++++++++---------- Sources/Appwrite/Services/Messaging.swift | 16 ++++++++-------- Sources/Appwrite/Services/Users.swift | 14 +++++++------- Sources/AppwriteModels/ColumnBoolean.swift | 2 +- Sources/AppwriteModels/ColumnDatetime.swift | 2 +- Sources/AppwriteModels/ColumnEmail.swift | 2 +- Sources/AppwriteModels/ColumnEnum.swift | 2 +- Sources/AppwriteModels/ColumnFloat.swift | 2 +- Sources/AppwriteModels/ColumnInteger.swift | 2 +- Sources/AppwriteModels/ColumnIp.swift | 2 +- Sources/AppwriteModels/Execution.swift | 2 +- 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index ac76fae..b68ba76 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -391,7 +391,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaType /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFAAuthenticator` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.") open func createMfaAuthenticator( type: AppwriteEnums.AuthenticatorType ) async throws -> AppwriteModels.MfaType { @@ -464,7 +464,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.") open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, otp: String, @@ -505,7 +505,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.") open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, otp: String @@ -587,7 +587,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `DeleteMFAAuthenticator` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.") open func deleteMfaAuthenticator( type: AppwriteEnums.AuthenticatorType ) async throws -> Any { @@ -644,7 +644,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaChallenge /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFAChallenge` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.") open func createMfaChallenge( factor: AppwriteEnums.AuthenticationFactor ) async throws -> AppwriteModels.MfaChallenge { @@ -720,7 +720,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Session /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFAChallenge` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.") open func updateMfaChallenge( challengeId: String, otp: String @@ -796,7 +796,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaFactors /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `ListMFAFactors` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.") open func listMfaFactors( ) async throws -> AppwriteModels.MfaFactors { let apiPath: String = "/account/mfa/factors" @@ -854,7 +854,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `GetMFARecoveryCodes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.") open func getMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -916,7 +916,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFARecoveryCodes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.") open func createMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" @@ -982,7 +982,7 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFARecoveryCodes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.") open func updateMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { let apiPath: String = "/account/mfa/recovery-codes" diff --git a/Sources/Appwrite/Services/Messaging.swift b/Sources/Appwrite/Services/Messaging.swift index 2dbd143..1b97c72 100644 --- a/Sources/Appwrite/Services/Messaging.swift +++ b/Sources/Appwrite/Services/Messaging.swift @@ -373,7 +373,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Message /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateSMS` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead.") open func createSms( messageId: String, content: String, @@ -481,7 +481,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Message /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateSMS` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead.") open func updateSms( messageId: String, topics: [String]? = nil, @@ -755,7 +755,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateAPNSProvider` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead.") open func createApnsProvider( providerId: String, name: String, @@ -866,7 +866,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateAPNSProvider` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead.") open func updateApnsProvider( providerId: String, name: String? = nil, @@ -973,7 +973,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateFCMProvider` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead.") open func createFcmProvider( providerId: String, name: String, @@ -1060,7 +1060,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateFCMProvider` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead.") open func updateFcmProvider( providerId: String, name: String? = nil, @@ -1487,7 +1487,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateSMTPProvider` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead.") open func createSmtpProvider( providerId: String, name: String, @@ -1634,7 +1634,7 @@ open class Messaging: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Provider /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateSMTPProvider` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead.") open func updateSmtpProvider( providerId: String, name: String? = nil, diff --git a/Sources/Appwrite/Services/Users.swift b/Sources/Appwrite/Services/Users.swift index 7122842..e1ea976 100644 --- a/Sources/Appwrite/Services/Users.swift +++ b/Sources/Appwrite/Services/Users.swift @@ -1123,7 +1123,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFA` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Users.updateMFA` instead.") open func updateMfa( userId: String, mfa: Bool, @@ -1162,7 +1162,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.User /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFA` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Users.updateMFA` instead.") open func updateMfa( userId: String, mfa: Bool @@ -1241,7 +1241,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: Any /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `DeleteMFAAuthenticator` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Users.deleteMFAAuthenticator` instead.") open func deleteMfaAuthenticator( userId: String, type: AppwriteEnums.AuthenticatorType @@ -1301,7 +1301,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaFactors /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `ListMFAFactors` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Users.listMFAFactors` instead.") open func listMfaFactors( userId: String ) async throws -> AppwriteModels.MfaFactors { @@ -1367,7 +1367,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `GetMFARecoveryCodes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Users.getMFARecoveryCodes` instead.") open func getMfaRecoveryCodes( userId: String ) async throws -> AppwriteModels.MfaRecoveryCodes { @@ -1436,7 +1436,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `UpdateMFARecoveryCodes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Users.updateMFARecoveryCodes` instead.") open func updateMfaRecoveryCodes( userId: String ) async throws -> AppwriteModels.MfaRecoveryCodes { @@ -1509,7 +1509,7 @@ open class Users: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.MfaRecoveryCodes /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `CreateMFARecoveryCodes` instead.") + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Users.createMFARecoveryCodes` instead.") open func createMfaRecoveryCodes( userId: String ) async throws -> AppwriteModels.MfaRecoveryCodes { diff --git a/Sources/AppwriteModels/ColumnBoolean.swift b/Sources/AppwriteModels/ColumnBoolean.swift index cd22e7c..8a73ca0 100644 --- a/Sources/AppwriteModels/ColumnBoolean.swift +++ b/Sources/AppwriteModels/ColumnBoolean.swift @@ -40,7 +40,7 @@ open class ColumnBoolean: Codable { /// Column update date in ISO 8601 format. public let updatedAt: String - /// Default value for attribute when not provided. Cannot be set when attribute is required. + /// Default value for column when not provided. Cannot be set when column is required. public let `default`: Bool? diff --git a/Sources/AppwriteModels/ColumnDatetime.swift b/Sources/AppwriteModels/ColumnDatetime.swift index f1059df..00cdc6d 100644 --- a/Sources/AppwriteModels/ColumnDatetime.swift +++ b/Sources/AppwriteModels/ColumnDatetime.swift @@ -44,7 +44,7 @@ open class ColumnDatetime: Codable { /// ISO 8601 format. public let format: String - /// Default value for attribute when not provided. Only null is optional + /// Default value for column when not provided. Only null is optional public let `default`: String? diff --git a/Sources/AppwriteModels/ColumnEmail.swift b/Sources/AppwriteModels/ColumnEmail.swift index 1e904fa..940062e 100644 --- a/Sources/AppwriteModels/ColumnEmail.swift +++ b/Sources/AppwriteModels/ColumnEmail.swift @@ -44,7 +44,7 @@ open class ColumnEmail: Codable { /// String format. public let format: String - /// Default value for attribute when not provided. Cannot be set when attribute is required. + /// Default value for column when not provided. Cannot be set when column is required. public let `default`: String? diff --git a/Sources/AppwriteModels/ColumnEnum.swift b/Sources/AppwriteModels/ColumnEnum.swift index 96c9c56..ef78f80 100644 --- a/Sources/AppwriteModels/ColumnEnum.swift +++ b/Sources/AppwriteModels/ColumnEnum.swift @@ -48,7 +48,7 @@ open class ColumnEnum: Codable { /// String format. public let format: String - /// Default value for attribute when not provided. Cannot be set when attribute is required. + /// Default value for column when not provided. Cannot be set when column is required. public let `default`: String? diff --git a/Sources/AppwriteModels/ColumnFloat.swift b/Sources/AppwriteModels/ColumnFloat.swift index a2bf470..6cdd019 100644 --- a/Sources/AppwriteModels/ColumnFloat.swift +++ b/Sources/AppwriteModels/ColumnFloat.swift @@ -48,7 +48,7 @@ open class ColumnFloat: Codable { /// Maximum value to enforce for new documents. public let max: Double? - /// Default value for attribute when not provided. Cannot be set when attribute is required. + /// Default value for column when not provided. Cannot be set when column is required. public let `default`: Double? diff --git a/Sources/AppwriteModels/ColumnInteger.swift b/Sources/AppwriteModels/ColumnInteger.swift index fb565a4..4451550 100644 --- a/Sources/AppwriteModels/ColumnInteger.swift +++ b/Sources/AppwriteModels/ColumnInteger.swift @@ -48,7 +48,7 @@ open class ColumnInteger: Codable { /// Maximum value to enforce for new documents. public let max: Int? - /// Default value for attribute when not provided. Cannot be set when attribute is required. + /// Default value for column when not provided. Cannot be set when column is required. public let `default`: Int? diff --git a/Sources/AppwriteModels/ColumnIp.swift b/Sources/AppwriteModels/ColumnIp.swift index e19b49a..43ddaee 100644 --- a/Sources/AppwriteModels/ColumnIp.swift +++ b/Sources/AppwriteModels/ColumnIp.swift @@ -44,7 +44,7 @@ open class ColumnIp: Codable { /// String format. public let format: String - /// Default value for attribute when not provided. Cannot be set when attribute is required. + /// Default value for column when not provided. Cannot be set when column is required. public let `default`: String? diff --git a/Sources/AppwriteModels/Execution.swift b/Sources/AppwriteModels/Execution.swift index d216290..baaf71e 100644 --- a/Sources/AppwriteModels/Execution.swift +++ b/Sources/AppwriteModels/Execution.swift @@ -31,7 +31,7 @@ open class Execution: Codable { /// Execution creation date in ISO 8601 format. public let createdAt: String - /// Execution upate date in ISO 8601 format. + /// Execution update date in ISO 8601 format. public let updatedAt: String /// Execution roles. From 096c3069340ef5f1cc2a2e1f6968a93e428e1137 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 26 Aug 2025 04:26:14 +1200 Subject: [PATCH 7/7] Fix docs --- .../{create-j-w-t.md => create-jwt.md} | 0 .../account/create-m-f-a-authenticator.md | 14 ---------- .../account/create-m-f-a-challenge.md | 13 --------- .../account/create-m-f-a-recovery-codes.md | 11 -------- ...r-l-token.md => create-magic-url-token.md} | 0 .../account/create-mfa-authenticator.md | 2 +- docs/examples/account/create-mfa-challenge.md | 2 +- .../account/create-mfa-recovery-codes.md | 2 +- ...auth2token.md => create-o-auth-2-token.md} | 0 .../account/delete-m-f-a-authenticator.md | 14 ---------- .../account/delete-mfa-authenticator.md | 2 +- .../account/get-m-f-a-recovery-codes.md | 11 -------- .../account/get-mfa-recovery-codes.md | 2 +- docs/examples/account/list-m-f-a-factors.md | 11 -------- docs/examples/account/list-mfa-factors.md | 2 +- .../account/update-m-f-a-authenticator.md | 15 ----------- .../account/update-m-f-a-challenge.md | 14 ---------- .../account/update-m-f-a-recovery-codes.md | 11 -------- ...session.md => update-magic-url-session.md} | 0 .../account/update-mfa-authenticator.md | 2 +- docs/examples/account/update-mfa-challenge.md | 2 +- .../account/update-mfa-recovery-codes.md | 2 +- .../{update-m-f-a.md => update-mfa.md} | 0 .../avatars/{get-q-r.md => get-qr.md} | 0 .../examples/health/{get-d-b.md => get-db.md} | 0 ...-countries-e-u.md => list-countries-eu.md} | 0 .../messaging/create-a-p-n-s-provider.md | 20 -------------- .../messaging/create-apns-provider.md | 2 +- .../messaging/create-f-c-m-provider.md | 16 ----------- .../examples/messaging/create-fcm-provider.md | 2 +- ...1provider.md => create-msg-91-provider.md} | 0 docs/examples/messaging/create-s-m-s.md | 19 ------------- .../messaging/create-s-m-t-p-provider.md | 27 ------------------- docs/examples/messaging/create-sms.md | 2 +- .../messaging/create-smtp-provider.md | 2 +- .../messaging/update-a-p-n-s-provider.md | 20 -------------- .../messaging/update-apns-provider.md | 2 +- .../messaging/update-f-c-m-provider.md | 16 ----------- .../examples/messaging/update-fcm-provider.md | 2 +- ...1provider.md => update-msg-91-provider.md} | 0 docs/examples/messaging/update-s-m-s.md | 19 ------------- .../messaging/update-s-m-t-p-provider.md | 27 ------------------- docs/examples/messaging/update-sms.md | 2 +- .../messaging/update-smtp-provider.md | 2 +- ...e-argon2user.md => create-argon-2-user.md} | 0 .../users/{create-j-w-t.md => create-jwt.md} | 0 .../users/create-m-f-a-recovery-codes.md | 13 --------- ...create-m-d5user.md => create-md-5-user.md} | 0 .../users/create-mfa-recovery-codes.md | 2 +- ...-h-pass-user.md => create-ph-pass-user.md} | 0 ...reate-s-h-a-user.md => create-sha-user.md} | 0 .../users/delete-m-f-a-authenticator.md | 15 ----------- .../users/delete-mfa-authenticator.md | 2 +- .../users/get-m-f-a-recovery-codes.md | 13 --------- docs/examples/users/get-mfa-recovery-codes.md | 2 +- docs/examples/users/list-m-f-a-factors.md | 13 --------- docs/examples/users/list-mfa-factors.md | 2 +- .../users/update-m-f-a-recovery-codes.md | 13 --------- docs/examples/users/update-m-f-a.md | 14 ---------- .../users/update-mfa-recovery-codes.md | 2 +- docs/examples/users/update-mfa.md | 2 +- 61 files changed, 23 insertions(+), 382 deletions(-) rename docs/examples/account/{create-j-w-t.md => create-jwt.md} (100%) delete mode 100644 docs/examples/account/create-m-f-a-authenticator.md delete mode 100644 docs/examples/account/create-m-f-a-challenge.md delete mode 100644 docs/examples/account/create-m-f-a-recovery-codes.md rename docs/examples/account/{create-magic-u-r-l-token.md => create-magic-url-token.md} (100%) rename docs/examples/account/{create-o-auth2token.md => create-o-auth-2-token.md} (100%) delete mode 100644 docs/examples/account/delete-m-f-a-authenticator.md delete mode 100644 docs/examples/account/get-m-f-a-recovery-codes.md delete mode 100644 docs/examples/account/list-m-f-a-factors.md delete mode 100644 docs/examples/account/update-m-f-a-authenticator.md delete mode 100644 docs/examples/account/update-m-f-a-challenge.md delete mode 100644 docs/examples/account/update-m-f-a-recovery-codes.md rename docs/examples/account/{update-magic-u-r-l-session.md => update-magic-url-session.md} (100%) rename docs/examples/account/{update-m-f-a.md => update-mfa.md} (100%) rename docs/examples/avatars/{get-q-r.md => get-qr.md} (100%) rename docs/examples/health/{get-d-b.md => get-db.md} (100%) rename docs/examples/locale/{list-countries-e-u.md => list-countries-eu.md} (100%) delete mode 100644 docs/examples/messaging/create-a-p-n-s-provider.md delete mode 100644 docs/examples/messaging/create-f-c-m-provider.md rename docs/examples/messaging/{create-msg91provider.md => create-msg-91-provider.md} (100%) delete mode 100644 docs/examples/messaging/create-s-m-s.md delete mode 100644 docs/examples/messaging/create-s-m-t-p-provider.md delete mode 100644 docs/examples/messaging/update-a-p-n-s-provider.md delete mode 100644 docs/examples/messaging/update-f-c-m-provider.md rename docs/examples/messaging/{update-msg91provider.md => update-msg-91-provider.md} (100%) delete mode 100644 docs/examples/messaging/update-s-m-s.md delete mode 100644 docs/examples/messaging/update-s-m-t-p-provider.md rename docs/examples/users/{create-argon2user.md => create-argon-2-user.md} (100%) rename docs/examples/users/{create-j-w-t.md => create-jwt.md} (100%) delete mode 100644 docs/examples/users/create-m-f-a-recovery-codes.md rename docs/examples/users/{create-m-d5user.md => create-md-5-user.md} (100%) rename docs/examples/users/{create-p-h-pass-user.md => create-ph-pass-user.md} (100%) rename docs/examples/users/{create-s-h-a-user.md => create-sha-user.md} (100%) delete mode 100644 docs/examples/users/delete-m-f-a-authenticator.md delete mode 100644 docs/examples/users/get-m-f-a-recovery-codes.md delete mode 100644 docs/examples/users/list-m-f-a-factors.md delete mode 100644 docs/examples/users/update-m-f-a-recovery-codes.md delete mode 100644 docs/examples/users/update-m-f-a.md diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-jwt.md similarity index 100% rename from docs/examples/account/create-j-w-t.md rename to docs/examples/account/create-jwt.md diff --git a/docs/examples/account/create-m-f-a-authenticator.md b/docs/examples/account/create-m-f-a-authenticator.md deleted file mode 100644 index dd3a7d1..0000000 --- a/docs/examples/account/create-m-f-a-authenticator.md +++ /dev/null @@ -1,14 +0,0 @@ -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 mfaType = try await account.createMFAAuthenticator( - type: .totp -) - diff --git a/docs/examples/account/create-m-f-a-challenge.md b/docs/examples/account/create-m-f-a-challenge.md deleted file mode 100644 index 27f1bc1..0000000 --- a/docs/examples/account/create-m-f-a-challenge.md +++ /dev/null @@ -1,13 +0,0 @@ -import Appwrite -import AppwriteEnums - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let mfaChallenge = try await account.createMFAChallenge( - factor: .email -) - diff --git a/docs/examples/account/create-m-f-a-recovery-codes.md b/docs/examples/account/create-m-f-a-recovery-codes.md deleted file mode 100644 index 3595cda..0000000 --- a/docs/examples/account/create-m-f-a-recovery-codes.md +++ /dev/null @@ -1,11 +0,0 @@ -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 mfaRecoveryCodes = try await account.createMFARecoveryCodes() - diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-url-token.md similarity index 100% rename from docs/examples/account/create-magic-u-r-l-token.md rename to docs/examples/account/create-magic-url-token.md diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index 4dd91d8..dd3a7d1 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -8,7 +8,7 @@ let client = Client() let account = Account(client) -let mfaType = try await account.createMfaAuthenticator( +let mfaType = try await account.createMFAAuthenticator( type: .totp ) diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index 0b5d385..27f1bc1 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -7,7 +7,7 @@ let client = Client() let account = Account(client) -let mfaChallenge = try await account.createMfaChallenge( +let mfaChallenge = try await account.createMFAChallenge( factor: .email ) diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index a73e4f6..3595cda 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -7,5 +7,5 @@ let client = Client() let account = Account(client) -let mfaRecoveryCodes = try await account.createMfaRecoveryCodes() +let mfaRecoveryCodes = try await account.createMFARecoveryCodes() diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth-2-token.md similarity index 100% rename from docs/examples/account/create-o-auth2token.md rename to docs/examples/account/create-o-auth-2-token.md diff --git a/docs/examples/account/delete-m-f-a-authenticator.md b/docs/examples/account/delete-m-f-a-authenticator.md deleted file mode 100644 index 5a85cdc..0000000 --- a/docs/examples/account/delete-m-f-a-authenticator.md +++ /dev/null @@ -1,14 +0,0 @@ -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 result = try await account.deleteMFAAuthenticator( - type: .totp -) - diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index e4209a2..5a85cdc 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -8,7 +8,7 @@ let client = Client() let account = Account(client) -let result = try await account.deleteMfaAuthenticator( +let result = try await account.deleteMFAAuthenticator( type: .totp ) diff --git a/docs/examples/account/get-m-f-a-recovery-codes.md b/docs/examples/account/get-m-f-a-recovery-codes.md deleted file mode 100644 index 86c435d..0000000 --- a/docs/examples/account/get-m-f-a-recovery-codes.md +++ /dev/null @@ -1,11 +0,0 @@ -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 mfaRecoveryCodes = try await account.getMFARecoveryCodes() - diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index 69455f4..86c435d 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -7,5 +7,5 @@ let client = Client() let account = Account(client) -let mfaRecoveryCodes = try await account.getMfaRecoveryCodes() +let mfaRecoveryCodes = try await account.getMFARecoveryCodes() diff --git a/docs/examples/account/list-m-f-a-factors.md b/docs/examples/account/list-m-f-a-factors.md deleted file mode 100644 index be41b2b..0000000 --- a/docs/examples/account/list-m-f-a-factors.md +++ /dev/null @@ -1,11 +0,0 @@ -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 mfaFactors = try await account.listMFAFactors() - diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index a63d4d0..be41b2b 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -7,5 +7,5 @@ let client = Client() let account = Account(client) -let mfaFactors = try await account.listMfaFactors() +let mfaFactors = try await account.listMFAFactors() diff --git a/docs/examples/account/update-m-f-a-authenticator.md b/docs/examples/account/update-m-f-a-authenticator.md deleted file mode 100644 index 79f408e..0000000 --- a/docs/examples/account/update-m-f-a-authenticator.md +++ /dev/null @@ -1,15 +0,0 @@ -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 user = try await account.updateMFAAuthenticator( - type: .totp, - otp: "" -) - diff --git a/docs/examples/account/update-m-f-a-challenge.md b/docs/examples/account/update-m-f-a-challenge.md deleted file mode 100644 index c595f1e..0000000 --- a/docs/examples/account/update-m-f-a-challenge.md +++ /dev/null @@ -1,14 +0,0 @@ -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 session = try await account.updateMFAChallenge( - challengeId: "", - otp: "" -) - diff --git a/docs/examples/account/update-m-f-a-recovery-codes.md b/docs/examples/account/update-m-f-a-recovery-codes.md deleted file mode 100644 index ee6f9ac..0000000 --- a/docs/examples/account/update-m-f-a-recovery-codes.md +++ /dev/null @@ -1,11 +0,0 @@ -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 mfaRecoveryCodes = try await account.updateMFARecoveryCodes() - diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-url-session.md similarity index 100% rename from docs/examples/account/update-magic-u-r-l-session.md rename to docs/examples/account/update-magic-url-session.md diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index fedbc95..79f408e 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -8,7 +8,7 @@ let client = Client() let account = Account(client) -let user = try await account.updateMfaAuthenticator( +let user = try await account.updateMFAAuthenticator( type: .totp, otp: "" ) diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index 4edb1fb..c595f1e 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -7,7 +7,7 @@ let client = Client() let account = Account(client) -let session = try await account.updateMfaChallenge( +let session = try await account.updateMFAChallenge( challengeId: "", otp: "" ) diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index d0a2b8c..ee6f9ac 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -7,5 +7,5 @@ let client = Client() let account = Account(client) -let mfaRecoveryCodes = try await account.updateMfaRecoveryCodes() +let mfaRecoveryCodes = try await account.updateMFARecoveryCodes() diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-mfa.md similarity index 100% rename from docs/examples/account/update-m-f-a.md rename to docs/examples/account/update-mfa.md diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-qr.md similarity index 100% rename from docs/examples/avatars/get-q-r.md rename to docs/examples/avatars/get-qr.md diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-db.md similarity index 100% rename from docs/examples/health/get-d-b.md rename to docs/examples/health/get-db.md diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-eu.md similarity index 100% rename from docs/examples/locale/list-countries-e-u.md rename to docs/examples/locale/list-countries-eu.md diff --git a/docs/examples/messaging/create-a-p-n-s-provider.md b/docs/examples/messaging/create-a-p-n-s-provider.md deleted file mode 100644 index 772084d..0000000 --- a/docs/examples/messaging/create-a-p-n-s-provider.md +++ /dev/null @@ -1,20 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let messaging = Messaging(client) - -let provider = try await messaging.createAPNSProvider( - providerId: "", - name: "", - authKey: "", // optional - authKeyId: "", // optional - teamId: "", // optional - bundleId: "", // optional - sandbox: false, // optional - enabled: false // optional -) - diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index 5e20018..772084d 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -7,7 +7,7 @@ let client = Client() let messaging = Messaging(client) -let provider = try await messaging.createApnsProvider( +let provider = try await messaging.createAPNSProvider( providerId: "", name: "", authKey: "", // optional diff --git a/docs/examples/messaging/create-f-c-m-provider.md b/docs/examples/messaging/create-f-c-m-provider.md deleted file mode 100644 index 2b00450..0000000 --- a/docs/examples/messaging/create-f-c-m-provider.md +++ /dev/null @@ -1,16 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let messaging = Messaging(client) - -let provider = try await messaging.createFCMProvider( - providerId: "", - name: "", - serviceAccountJSON: [:], // optional - enabled: false // optional -) - diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index 0071e47..2b00450 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -7,7 +7,7 @@ let client = Client() let messaging = Messaging(client) -let provider = try await messaging.createFcmProvider( +let provider = try await messaging.createFCMProvider( providerId: "", name: "", serviceAccountJSON: [:], // optional diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg-91-provider.md similarity index 100% rename from docs/examples/messaging/create-msg91provider.md rename to docs/examples/messaging/create-msg-91-provider.md diff --git a/docs/examples/messaging/create-s-m-s.md b/docs/examples/messaging/create-s-m-s.md deleted file mode 100644 index 28a6ba7..0000000 --- a/docs/examples/messaging/create-s-m-s.md +++ /dev/null @@ -1,19 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let messaging = Messaging(client) - -let message = try await messaging.createSMS( - messageId: "", - content: "", - topics: [], // optional - users: [], // optional - targets: [], // optional - draft: false, // optional - scheduledAt: "" // optional -) - diff --git a/docs/examples/messaging/create-s-m-t-p-provider.md b/docs/examples/messaging/create-s-m-t-p-provider.md deleted file mode 100644 index ec9b92c..0000000 --- a/docs/examples/messaging/create-s-m-t-p-provider.md +++ /dev/null @@ -1,27 +0,0 @@ -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 messaging = Messaging(client) - -let provider = try await messaging.createSMTPProvider( - providerId: "", - name: "", - host: "", - port: 1, // optional - username: "", // optional - password: "", // optional - encryption: .none, // optional - autoTLS: false, // optional - mailer: "", // optional - fromName: "", // optional - fromEmail: "email@example.com", // optional - replyToName: "", // optional - replyToEmail: "email@example.com", // optional - enabled: false // optional -) - diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 4f57931..28a6ba7 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -7,7 +7,7 @@ let client = Client() let messaging = Messaging(client) -let message = try await messaging.createSms( +let message = try await messaging.createSMS( messageId: "", content: "", topics: [], // optional diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index 18d25df..ec9b92c 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -8,7 +8,7 @@ let client = Client() let messaging = Messaging(client) -let provider = try await messaging.createSmtpProvider( +let provider = try await messaging.createSMTPProvider( providerId: "", name: "", host: "", diff --git a/docs/examples/messaging/update-a-p-n-s-provider.md b/docs/examples/messaging/update-a-p-n-s-provider.md deleted file mode 100644 index bed92ba..0000000 --- a/docs/examples/messaging/update-a-p-n-s-provider.md +++ /dev/null @@ -1,20 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let messaging = Messaging(client) - -let provider = try await messaging.updateAPNSProvider( - providerId: "", - name: "", // optional - enabled: false, // optional - authKey: "", // optional - authKeyId: "", // optional - teamId: "", // optional - bundleId: "", // optional - sandbox: false // optional -) - diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index 03afe55..bed92ba 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -7,7 +7,7 @@ let client = Client() let messaging = Messaging(client) -let provider = try await messaging.updateApnsProvider( +let provider = try await messaging.updateAPNSProvider( providerId: "", name: "", // optional enabled: false, // optional diff --git a/docs/examples/messaging/update-f-c-m-provider.md b/docs/examples/messaging/update-f-c-m-provider.md deleted file mode 100644 index efd7e1f..0000000 --- a/docs/examples/messaging/update-f-c-m-provider.md +++ /dev/null @@ -1,16 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let messaging = Messaging(client) - -let provider = try await messaging.updateFCMProvider( - providerId: "", - name: "", // optional - enabled: false, // optional - serviceAccountJSON: [:] // optional -) - diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index c4548f6..efd7e1f 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -7,7 +7,7 @@ let client = Client() let messaging = Messaging(client) -let provider = try await messaging.updateFcmProvider( +let provider = try await messaging.updateFCMProvider( providerId: "", name: "", // optional enabled: false, // optional diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg-91-provider.md similarity index 100% rename from docs/examples/messaging/update-msg91provider.md rename to docs/examples/messaging/update-msg-91-provider.md diff --git a/docs/examples/messaging/update-s-m-s.md b/docs/examples/messaging/update-s-m-s.md deleted file mode 100644 index d6dc207..0000000 --- a/docs/examples/messaging/update-s-m-s.md +++ /dev/null @@ -1,19 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let messaging = Messaging(client) - -let message = try await messaging.updateSMS( - messageId: "", - topics: [], // optional - users: [], // optional - targets: [], // optional - content: "", // optional - draft: false, // optional - scheduledAt: "" // optional -) - diff --git a/docs/examples/messaging/update-s-m-t-p-provider.md b/docs/examples/messaging/update-s-m-t-p-provider.md deleted file mode 100644 index 402c267..0000000 --- a/docs/examples/messaging/update-s-m-t-p-provider.md +++ /dev/null @@ -1,27 +0,0 @@ -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 messaging = Messaging(client) - -let provider = try await messaging.updateSMTPProvider( - providerId: "", - name: "", // optional - host: "", // optional - port: 1, // optional - username: "", // optional - password: "", // optional - encryption: .none, // optional - autoTLS: false, // optional - mailer: "", // optional - fromName: "", // optional - fromEmail: "email@example.com", // optional - replyToName: "", // optional - replyToEmail: "", // optional - enabled: false // optional -) - diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 46b225f..d6dc207 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -7,7 +7,7 @@ let client = Client() let messaging = Messaging(client) -let message = try await messaging.updateSms( +let message = try await messaging.updateSMS( messageId: "", topics: [], // optional users: [], // optional diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index 7ef8f2e..402c267 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -8,7 +8,7 @@ let client = Client() let messaging = Messaging(client) -let provider = try await messaging.updateSmtpProvider( +let provider = try await messaging.updateSMTPProvider( providerId: "", name: "", // optional host: "", // optional diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon-2-user.md similarity index 100% rename from docs/examples/users/create-argon2user.md rename to docs/examples/users/create-argon-2-user.md diff --git a/docs/examples/users/create-j-w-t.md b/docs/examples/users/create-jwt.md similarity index 100% rename from docs/examples/users/create-j-w-t.md rename to docs/examples/users/create-jwt.md diff --git a/docs/examples/users/create-m-f-a-recovery-codes.md b/docs/examples/users/create-m-f-a-recovery-codes.md deleted file mode 100644 index 5f073d1..0000000 --- a/docs/examples/users/create-m-f-a-recovery-codes.md +++ /dev/null @@ -1,13 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let users = Users(client) - -let mfaRecoveryCodes = try await users.createMFARecoveryCodes( - userId: "" -) - diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-md-5-user.md similarity index 100% rename from docs/examples/users/create-m-d5user.md rename to docs/examples/users/create-md-5-user.md diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index 577a533..5f073d1 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -7,7 +7,7 @@ let client = Client() let users = Users(client) -let mfaRecoveryCodes = try await users.createMfaRecoveryCodes( +let mfaRecoveryCodes = try await users.createMFARecoveryCodes( userId: "" ) diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-ph-pass-user.md similarity index 100% rename from docs/examples/users/create-p-h-pass-user.md rename to docs/examples/users/create-ph-pass-user.md diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-sha-user.md similarity index 100% rename from docs/examples/users/create-s-h-a-user.md rename to docs/examples/users/create-sha-user.md diff --git a/docs/examples/users/delete-m-f-a-authenticator.md b/docs/examples/users/delete-m-f-a-authenticator.md deleted file mode 100644 index be9f395..0000000 --- a/docs/examples/users/delete-m-f-a-authenticator.md +++ /dev/null @@ -1,15 +0,0 @@ -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 users = Users(client) - -let result = try await users.deleteMFAAuthenticator( - userId: "", - type: .totp -) - diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md index da2b8e0..be9f395 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -8,7 +8,7 @@ let client = Client() let users = Users(client) -let result = try await users.deleteMfaAuthenticator( +let result = try await users.deleteMFAAuthenticator( userId: "", type: .totp ) diff --git a/docs/examples/users/get-m-f-a-recovery-codes.md b/docs/examples/users/get-m-f-a-recovery-codes.md deleted file mode 100644 index 874076c..0000000 --- a/docs/examples/users/get-m-f-a-recovery-codes.md +++ /dev/null @@ -1,13 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let users = Users(client) - -let mfaRecoveryCodes = try await users.getMFARecoveryCodes( - userId: "" -) - diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md index 1ae2851..874076c 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -7,7 +7,7 @@ let client = Client() let users = Users(client) -let mfaRecoveryCodes = try await users.getMfaRecoveryCodes( +let mfaRecoveryCodes = try await users.getMFARecoveryCodes( userId: "" ) diff --git a/docs/examples/users/list-m-f-a-factors.md b/docs/examples/users/list-m-f-a-factors.md deleted file mode 100644 index 4a58a07..0000000 --- a/docs/examples/users/list-m-f-a-factors.md +++ /dev/null @@ -1,13 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let users = Users(client) - -let mfaFactors = try await users.listMFAFactors( - userId: "" -) - diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index a5b5e38..4a58a07 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -7,7 +7,7 @@ let client = Client() let users = Users(client) -let mfaFactors = try await users.listMfaFactors( +let mfaFactors = try await users.listMFAFactors( userId: "" ) diff --git a/docs/examples/users/update-m-f-a-recovery-codes.md b/docs/examples/users/update-m-f-a-recovery-codes.md deleted file mode 100644 index 7ebb34e..0000000 --- a/docs/examples/users/update-m-f-a-recovery-codes.md +++ /dev/null @@ -1,13 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let users = Users(client) - -let mfaRecoveryCodes = try await users.updateMFARecoveryCodes( - userId: "" -) - diff --git a/docs/examples/users/update-m-f-a.md b/docs/examples/users/update-m-f-a.md deleted file mode 100644 index ca442b3..0000000 --- a/docs/examples/users/update-m-f-a.md +++ /dev/null @@ -1,14 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setKey("") // Your secret API key - -let users = Users(client) - -let user = try await users.updateMFA( - userId: "", - mfa: false -) - diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md index a6169a7..7ebb34e 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -7,7 +7,7 @@ let client = Client() let users = Users(client) -let mfaRecoveryCodes = try await users.updateMfaRecoveryCodes( +let mfaRecoveryCodes = try await users.updateMFARecoveryCodes( userId: "" ) diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index ad010f3..ca442b3 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -7,7 +7,7 @@ let client = Client() let users = Users(client) -let user = try await users.updateMfa( +let user = try await users.updateMFA( userId: "", mfa: false )