From 482729e16cdd2d811e54d72dc3508313e201c87e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 18 Jul 2025 12:52:13 +1200 Subject: [PATCH 1/5] Add inc/dec --- README.md | 4 +- Sources/Appwrite/Client.swift | 2 +- Sources/Appwrite/Services/Account.swift | 399 +++---- Sources/Appwrite/Services/Avatars.swift | 83 +- Sources/Appwrite/Services/Databases.swift | 980 +++++++++++------- Sources/Appwrite/Services/Functions.swift | 326 +++--- Sources/Appwrite/Services/Graphql.swift | 14 +- Sources/Appwrite/Services/Health.swift | 134 +-- Sources/Appwrite/Services/Locale.swift | 32 +- Sources/Appwrite/Services/Messaging.swift | 754 +++++++------- Sources/Appwrite/Services/Sites.swift | 307 +++--- Sources/Appwrite/Services/Storage.swift | 183 ++-- Sources/Appwrite/Services/Teams.swift | 183 ++-- Sources/Appwrite/Services/Tokens.swift | 45 +- Sources/Appwrite/Services/Users.swift | 665 ++++++------ Sources/AppwriteEnums/BuildRuntime.swift | 2 + Sources/AppwriteEnums/ImageFormat.swift | 1 + Sources/AppwriteEnums/Runtime.swift | 2 + 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/Document.swift | 10 + docs/examples/databases/create-document.md | 1 + .../databases/decrement-document-attribute.md | 18 + .../databases/increment-document-attribute.md | 18 + docs/examples/databases/upsert-documents.md | 2 +- 33 files changed, 2368 insertions(+), 1835 deletions(-) create mode 100644 docs/examples/databases/decrement-document-attribute.md create mode 100644 docs/examples/databases/increment-document-attribute.md diff --git a/README.md b/README.md index 7de6f65..1b70833 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Appwrite is an open-source backend as a service server that abstract and simplif The Appwrite Swift SDK is available via Swift Package Manager. In order to use the Appwrite Swift SDK from Xcode, select File > **Add Packages** -In the dialog that appears, enter the Appwrite Swift SDK [package URL](git@github.com:appwrite/sdk-for-swift.git) in the search field. Once found, select `sdk-for-apple`. +In the dialog that appears, enter the Appwrite Swift SDK [package URL](git@github.com:appwrite/sdk-for-swift.git) in the search field. Once found, select `sdk-for-swift`. On the right, select your version rules and ensure your desired target is selected in the **Add to Project** field. @@ -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.1.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "10.2.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 0436599..6a21d52 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -21,7 +21,7 @@ open class Client { "x-sdk-name": "Swift", "x-sdk-platform": "server", "x-sdk-language": "swift", - "x-sdk-version": "10.1.0", + "x-sdk-version": "10.2.0", "x-appwrite-response-format": "1.7.0" ] diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 629614a..8e93bc4 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -11,8 +11,8 @@ open class Account: Service { /// /// Get the currently logged in user. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func get( nestedType: T.Type @@ -39,8 +39,8 @@ open class Account: Service { /// /// Get the currently logged in user. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func get( ) async throws -> AppwriteModels.User<[String: AnyCodable]> { @@ -58,12 +58,13 @@ open class Account: Service { /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func create( userId: String, @@ -107,12 +108,13 @@ open class Account: Service { /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func create( userId: String, @@ -139,10 +141,11 @@ open class Account: Service { /// one, by passing an email address and a new password. /// /// - /// @param String email - /// @param String password - /// @throws Exception - /// @return array + /// - Parameters: + /// - email: String + /// - password: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateEmail( email: String, @@ -183,10 +186,11 @@ open class Account: Service { /// one, by passing an email address and a new password. /// /// - /// @param String email - /// @param String password - /// @throws Exception - /// @return array + /// - Parameters: + /// - email: String + /// - password: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateEmail( email: String, @@ -202,9 +206,10 @@ open class Account: Service { /// /// Get the list of identities for the currently logged in user. /// - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.IdentityList /// open func listIdentities( queries: [String]? = nil @@ -233,9 +238,10 @@ open class Account: Service { /// /// Delete an identity by its unique ID. /// - /// @param String identityId - /// @throws Exception - /// @return array + /// - Parameters: + /// - identityId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteIdentity( identityId: String @@ -263,8 +269,8 @@ open class Account: Service { /// from its creation and will be invalid if the user will logout in that time /// frame. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Jwt /// open func createJWT( ) async throws -> AppwriteModels.Jwt { @@ -293,9 +299,10 @@ open class Account: Service { /// Get the list of latest security activity logs for the currently logged in /// user. Each log returns user IP address, location and date and time of log. /// - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.LogList /// open func listLogs( queries: [String]? = nil @@ -324,9 +331,10 @@ open class Account: Service { /// /// Enable or disable MFA on an account. /// - /// @param Bool mfa - /// @throws Exception - /// @return array + /// - Parameters: + /// - mfa: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateMFA( mfa: Bool, @@ -358,9 +366,10 @@ open class Account: Service { /// /// Enable or disable MFA on an account. /// - /// @param Bool mfa - /// @throws Exception - /// @return array + /// - Parameters: + /// - mfa: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateMFA( mfa: Bool @@ -377,9 +386,10 @@ open class Account: Service { /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. /// - /// @param AppwriteEnums.AuthenticatorType type - /// @throws Exception - /// @return array + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaType /// open func createMfaAuthenticator( type: AppwriteEnums.AuthenticatorType @@ -411,10 +421,11 @@ open class Account: Service { /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. /// - /// @param AppwriteEnums.AuthenticatorType type - /// @param String otp - /// @throws Exception - /// @return array + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - otp: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, @@ -450,10 +461,11 @@ open class Account: Service { /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. /// - /// @param AppwriteEnums.AuthenticatorType type - /// @param String otp - /// @throws Exception - /// @return array + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - otp: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateMfaAuthenticator( type: AppwriteEnums.AuthenticatorType, @@ -469,9 +481,10 @@ open class Account: Service { /// /// Delete an authenticator for a user by ID. /// - /// @param AppwriteEnums.AuthenticatorType type - /// @throws Exception - /// @return array + /// - Parameters: + /// - type: AppwriteEnums.AuthenticatorType + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteMfaAuthenticator( type: AppwriteEnums.AuthenticatorType @@ -497,9 +510,10 @@ open class Account: Service { /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. /// - /// @param AppwriteEnums.AuthenticationFactor factor - /// @throws Exception - /// @return array + /// - Parameters: + /// - factor: AppwriteEnums.AuthenticationFactor + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaChallenge /// open func createMfaChallenge( factor: AppwriteEnums.AuthenticationFactor @@ -534,10 +548,11 @@ open class Account: Service { /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. /// - /// @param String challengeId - /// @param String otp - /// @throws Exception - /// @return array + /// - Parameters: + /// - challengeId: String + /// - otp: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session /// open func updateMfaChallenge( challengeId: String, @@ -570,8 +585,8 @@ open class Account: Service { /// /// List the factors available on the account to be used as a MFA challange. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaFactors /// open func listMfaFactors( ) async throws -> AppwriteModels.MfaFactors { @@ -600,8 +615,8 @@ open class Account: Service { /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes /// open func getMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { @@ -631,8 +646,8 @@ open class Account: Service { /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes /// open func createMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { @@ -663,8 +678,8 @@ open class Account: Service { /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes /// open func updateMfaRecoveryCodes( ) async throws -> AppwriteModels.MfaRecoveryCodes { @@ -692,9 +707,10 @@ open class Account: Service { /// /// Update currently logged in user account name. /// - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - name: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateName( name: String, @@ -726,9 +742,10 @@ open class Account: Service { /// /// Update currently logged in user account name. /// - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - name: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateName( name: String @@ -744,10 +761,11 @@ open class Account: Service { /// to pass in the new password, and the old password. For users created with /// OAuth, Team Invites and Magic URL, oldPassword is optional. /// - /// @param String password - /// @param String oldPassword - /// @throws Exception - /// @return array + /// - Parameters: + /// - password: String + /// - oldPassword: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePassword( password: String, @@ -783,10 +801,11 @@ open class Account: Service { /// to pass in the new password, and the old password. For users created with /// OAuth, Team Invites and Magic URL, oldPassword is optional. /// - /// @param String password - /// @param String oldPassword - /// @throws Exception - /// @return array + /// - Parameters: + /// - password: String + /// - oldPassword: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePassword( password: String, @@ -806,10 +825,11 @@ open class Account: Service { /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. /// - /// @param String phone - /// @param String password - /// @throws Exception - /// @return array + /// - Parameters: + /// - phone: String + /// - password: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePhone( phone: String, @@ -847,10 +867,11 @@ open class Account: Service { /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. /// - /// @param String phone - /// @param String password - /// @throws Exception - /// @return array + /// - Parameters: + /// - phone: String + /// - password: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePhone( phone: String, @@ -866,8 +887,8 @@ open class Account: Service { /// /// Get the preferences as a key-value object for the currently logged in user. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func getPrefs( nestedType: T.Type @@ -894,8 +915,8 @@ open class Account: Service { /// /// Get the preferences as a key-value object for the currently logged in user. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func getPrefs( ) async throws -> AppwriteModels.Preferences<[String: AnyCodable]> { @@ -909,9 +930,10 @@ open class Account: Service { /// stored as is, and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws error if exceeded. /// - /// @param Any prefs - /// @throws Exception - /// @return array + /// - Parameters: + /// - prefs: Any + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePrefs( prefs: Any, @@ -945,9 +967,10 @@ open class Account: Service { /// stored as is, and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws error if exceeded. /// - /// @param Any prefs - /// @throws Exception - /// @return array + /// - Parameters: + /// - prefs: Any + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePrefs( prefs: Any @@ -968,10 +991,11 @@ open class Account: Service { /// endpoint to complete the process. The verification link sent to the user's /// email address is valid for 1 hour. /// - /// @param String email - /// @param String url - /// @throws Exception - /// @return array + /// - Parameters: + /// - email: String + /// - url: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func createRecovery( email: String, @@ -1013,11 +1037,12 @@ open class Account: Service { /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. /// - /// @param String userId - /// @param String secret - /// @param String password - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - secret: String + /// - password: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func updateRecovery( userId: String, @@ -1053,8 +1078,8 @@ open class Account: Service { /// Get the list of active sessions across different devices for the currently /// logged in user. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.SessionList /// open func listSessions( ) async throws -> AppwriteModels.SessionList { @@ -1081,8 +1106,8 @@ open class Account: Service { /// Delete all sessions from the user account and remove any sessions cookies /// from the end client. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteSessions( ) async throws -> Any { @@ -1110,8 +1135,8 @@ open class Account: Service { /// or create an [OAuth2 /// session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session /// open func createAnonymousSession( ) async throws -> AppwriteModels.Session { @@ -1144,10 +1169,11 @@ open class Account: Service { /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). /// - /// @param String email - /// @param String password - /// @throws Exception - /// @return array + /// - Parameters: + /// - email: String + /// - password: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session /// open func createEmailPasswordSession( email: String, @@ -1182,10 +1208,11 @@ open class Account: Service { /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. /// - /// @param String userId - /// @param String secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - secret: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session /// open func updateMagicURLSession( userId: String, @@ -1220,10 +1247,11 @@ open class Account: Service { /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. /// - /// @param String userId - /// @param String secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - secret: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session /// open func updatePhoneSession( userId: String, @@ -1258,10 +1286,11 @@ open class Account: Service { /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. /// - /// @param String userId - /// @param String secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - secret: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session /// open func createSession( userId: String, @@ -1295,9 +1324,10 @@ open class Account: Service { /// Use this endpoint to get a logged in user's session using a Session ID. /// Inputting 'current' will return the current session being used. /// - /// @param String sessionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - sessionId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session /// open func getSession( sessionId: String @@ -1327,9 +1357,10 @@ open class Account: Service { /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. /// - /// @param String sessionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - sessionId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session /// open func updateSession( sessionId: String @@ -1363,9 +1394,10 @@ open class Account: Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. /// - /// @param String sessionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - sessionId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteSession( sessionId: String @@ -1391,8 +1423,8 @@ open class Account: Service { /// record is not deleted but permanently blocked from any access. To /// completely delete a user, use the Users API instead. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateStatus( nestedType: T.Type @@ -1423,8 +1455,8 @@ open class Account: Service { /// record is not deleted but permanently blocked from any access. To /// completely delete a user, use the Users API instead. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateStatus( ) async throws -> AppwriteModels.User<[String: AnyCodable]> { @@ -1445,11 +1477,12 @@ open class Account: Service { /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). /// - /// @param String userId - /// @param String email - /// @param Bool phrase - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - phrase: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func createEmailToken( userId: String, @@ -1497,12 +1530,13 @@ open class Account: Service { /// limits](https://appwrite.io/docs/authentication-security#limits). /// /// - /// @param String userId - /// @param String email - /// @param String url - /// @param Bool phrase - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - url: String (optional) + /// - phrase: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func createMagicURLToken( userId: String, @@ -1552,12 +1586,13 @@ open class Account: Service { /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). /// - /// @param AppwriteEnums.OAuthProvider provider - /// @param String success - /// @param String failure - /// @param [String] scopes - /// @throws Exception - /// @return array + /// - Parameters: + /// - provider: AppwriteEnums.OAuthProvider + /// - success: String (optional) + /// - failure: String (optional) + /// - scopes: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: String? /// open func createOAuth2Token( provider: AppwriteEnums.OAuthProvider, @@ -1597,10 +1632,11 @@ open class Account: Service { /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). /// - /// @param String userId - /// @param String phone - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - phone: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func createPhoneToken( userId: String, @@ -1647,9 +1683,10 @@ open class Account: Service { /// adding your platforms in the console interface. /// /// - /// @param String url - /// @throws Exception - /// @return array + /// - Parameters: + /// - url: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func createVerification( url: String @@ -1683,10 +1720,11 @@ open class Account: Service { /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. /// - /// @param String userId - /// @param String secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - secret: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func updateVerification( userId: String, @@ -1726,8 +1764,8 @@ open class Account: Service { /// The verification code sent to the user's phone number is valid for 15 /// minutes. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func createPhoneVerification( ) async throws -> AppwriteModels.Token { @@ -1758,10 +1796,11 @@ open class Account: Service { /// verify the user email ownership. If confirmed this route will return a 200 /// status code. /// - /// @param String userId - /// @param String secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - secret: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func updatePhoneVerification( userId: String, diff --git a/Sources/Appwrite/Services/Avatars.swift b/Sources/Appwrite/Services/Avatars.swift index 6c70f98..24f4b07 100644 --- a/Sources/Appwrite/Services/Avatars.swift +++ b/Sources/Appwrite/Services/Avatars.swift @@ -20,12 +20,13 @@ open class Avatars: Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. /// - /// @param AppwriteEnums.Browser code - /// @param Int width - /// @param Int height - /// @param Int quality - /// @throws Exception - /// @return array + /// - Parameters: + /// - code: AppwriteEnums.Browser + /// - width: Int (optional) + /// - height: Int (optional) + /// - quality: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getBrowser( code: AppwriteEnums.Browser, @@ -64,12 +65,13 @@ open class Avatars: Service { /// of image returned is 100x100px. /// /// - /// @param AppwriteEnums.CreditCard code - /// @param Int width - /// @param Int height - /// @param Int quality - /// @throws Exception - /// @return array + /// - Parameters: + /// - code: AppwriteEnums.CreditCard + /// - width: Int (optional) + /// - height: Int (optional) + /// - quality: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getCreditCard( code: AppwriteEnums.CreditCard, @@ -103,9 +105,10 @@ open class Avatars: Service { /// /// This endpoint does not follow HTTP redirects. /// - /// @param String url - /// @throws Exception - /// @return array + /// - Parameters: + /// - url: String + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getFavicon( url: String @@ -139,12 +142,13 @@ open class Avatars: Service { /// of image returned is 100x100px. /// /// - /// @param AppwriteEnums.Flag code - /// @param Int width - /// @param Int height - /// @param Int quality - /// @throws Exception - /// @return array + /// - Parameters: + /// - code: AppwriteEnums.Flag + /// - width: Int (optional) + /// - height: Int (optional) + /// - quality: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getFlag( code: AppwriteEnums.Flag, @@ -185,11 +189,12 @@ open class Avatars: Service { /// /// This endpoint does not follow HTTP redirects. /// - /// @param String url - /// @param Int width - /// @param Int height - /// @throws Exception - /// @return array + /// - Parameters: + /// - url: String + /// - width: Int (optional) + /// - height: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getImage( url: String, @@ -233,12 +238,13 @@ open class Avatars: Service { /// of image returned is 100x100px. /// /// - /// @param String name - /// @param Int width - /// @param Int height - /// @param String background - /// @throws Exception - /// @return array + /// - Parameters: + /// - name: String (optional) + /// - width: Int (optional) + /// - height: Int (optional) + /// - background: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getInitials( name: String? = nil, @@ -271,12 +277,13 @@ open class Avatars: Service { /// parameters to change the size and style of the resulting image. /// /// - /// @param String text - /// @param Int size - /// @param Int margin - /// @param Bool download - /// @throws Exception - /// @return array + /// - Parameters: + /// - text: String + /// - size: Int (optional) + /// - margin: Int (optional) + /// - download: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getQR( text: String, diff --git a/Sources/Appwrite/Services/Databases.swift b/Sources/Appwrite/Services/Databases.swift index aae760f..2f175f6 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -12,10 +12,11 @@ open class Databases: Service { /// Get a list of all databases from the current Appwrite project. You can use /// the search parameter to filter your results. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DatabaseList /// open func list( queries: [String]? = nil, @@ -47,11 +48,12 @@ open class Databases: Service { /// Create a new Database. /// /// - /// @param String databaseId - /// @param String name - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - name: String + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Database /// open func create( databaseId: String, @@ -87,9 +89,10 @@ open class Databases: Service { /// Get a database by its unique ID. This endpoint response returns a JSON /// object with the database metadata. /// - /// @param String databaseId - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Database /// open func get( databaseId: String @@ -117,11 +120,12 @@ open class Databases: Service { /// /// Update a database by its unique ID. /// - /// @param String databaseId - /// @param String name - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - name: String + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Database /// open func update( databaseId: String, @@ -157,9 +161,10 @@ open class Databases: Service { /// Delete a database by its unique ID. Only API keys with with databases.write /// scope can delete a database. /// - /// @param String databaseId - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func delete( databaseId: String @@ -184,11 +189,12 @@ open class Databases: Service { /// Get a list of all collections that belong to the provided databaseId. You /// can use the search parameter to filter your results. /// - /// @param String databaseId - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.CollectionList /// open func listCollections( databaseId: String, @@ -224,14 +230,15 @@ open class Databases: Service { /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. /// - /// @param String databaseId - /// @param String collectionId - /// @param String name - /// @param [String] permissions - /// @param Bool documentSecurity - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - name: String + /// - permissions: [String] (optional) + /// - documentSecurity: Bool (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Collection /// open func createCollection( databaseId: String, @@ -273,10 +280,11 @@ open class Databases: Service { /// Get a collection by its unique ID. This endpoint response returns a JSON /// object with the collection metadata. /// - /// @param String databaseId - /// @param String collectionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Collection /// open func getCollection( databaseId: String, @@ -306,14 +314,15 @@ open class Databases: Service { /// /// Update a collection by its unique ID. /// - /// @param String databaseId - /// @param String collectionId - /// @param String name - /// @param [String] permissions - /// @param Bool documentSecurity - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - name: String + /// - permissions: [String] (optional) + /// - documentSecurity: Bool (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Collection /// open func updateCollection( databaseId: String, @@ -355,10 +364,11 @@ open class Databases: Service { /// Delete a collection by its unique ID. Only users with write permissions /// have access to delete this resource. /// - /// @param String databaseId - /// @param String collectionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteCollection( databaseId: String, @@ -384,11 +394,12 @@ open class Databases: Service { /// /// List attributes in the collection. /// - /// @param String databaseId - /// @param String collectionId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeList /// open func listAttributes( databaseId: String, @@ -422,14 +433,15 @@ open class Databases: Service { /// Create a boolean attribute. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param Bool default - /// @param Bool array - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: Bool (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeBoolean /// open func createBooleanAttribute( databaseId: String, @@ -471,14 +483,15 @@ open class Databases: Service { /// Update a boolean attribute. Changing the `default` value will not update /// already existing documents. /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param Bool default - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: Bool (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeBoolean /// open func updateBooleanAttribute( databaseId: String, @@ -519,14 +532,15 @@ open class Databases: Service { /// /// Create a date time attribute according to the ISO 8601 standard. /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param String default - /// @param Bool array - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeDatetime /// open func createDatetimeAttribute( databaseId: String, @@ -568,14 +582,15 @@ open class Databases: Service { /// Update a date time attribute. Changing the `default` value will not update /// already existing documents. /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param String default - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeDatetime /// open func updateDatetimeAttribute( databaseId: String, @@ -617,14 +632,15 @@ open class Databases: Service { /// Create an email attribute. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param String default - /// @param Bool array - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeEmail /// open func createEmailAttribute( databaseId: String, @@ -667,14 +683,15 @@ open class Databases: Service { /// already existing documents. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param String default - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeEmail /// open func updateEmailAttribute( databaseId: String, @@ -717,15 +734,16 @@ open class Databases: Service { /// of accepted values for this attribute. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param [String] elements - /// @param Bool required - /// @param String default - /// @param Bool array - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - elements: [String] + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeEnum /// open func createEnumAttribute( databaseId: String, @@ -770,15 +788,16 @@ open class Databases: Service { /// already existing documents. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param [String] elements - /// @param Bool required - /// @param String default - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - elements: [String] + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeEnum /// open func updateEnumAttribute( databaseId: String, @@ -823,16 +842,17 @@ open class Databases: Service { /// provided. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param Double min - /// @param Double max - /// @param Double default - /// @param Bool array - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: 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.AttributeFloat /// open func createFloatAttribute( databaseId: String, @@ -879,16 +899,17 @@ open class Databases: Service { /// already existing documents. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param Double default - /// @param Double min - /// @param Double max - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: 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.AttributeFloat /// open func updateFloatAttribute( databaseId: String, @@ -935,16 +956,17 @@ open class Databases: Service { /// provided. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param Int min - /// @param Int max - /// @param Int default - /// @param Bool array - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: 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.AttributeInteger /// open func createIntegerAttribute( databaseId: String, @@ -991,16 +1013,17 @@ open class Databases: Service { /// already existing documents. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param Int default - /// @param Int min - /// @param Int max - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: 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.AttributeInteger /// open func updateIntegerAttribute( databaseId: String, @@ -1046,14 +1069,15 @@ open class Databases: Service { /// Create IP address attribute. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param String default - /// @param Bool array - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeIp /// open func createIpAttribute( databaseId: String, @@ -1096,14 +1120,15 @@ open class Databases: Service { /// already existing documents. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param String default - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeIp /// open func updateIpAttribute( databaseId: String, @@ -1146,16 +1171,17 @@ open class Databases: Service { /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String relatedCollectionId - /// @param AppwriteEnums.RelationshipType type - /// @param Bool twoWay - /// @param String key - /// @param String twoWayKey - /// @param AppwriteEnums.RelationMutate onDelete - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - relatedCollectionId: 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.AttributeRelationship /// open func createRelationshipAttribute( databaseId: String, @@ -1201,16 +1227,17 @@ open class Databases: Service { /// Create a string attribute. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Int size - /// @param Bool required - /// @param String default - /// @param Bool array - /// @param Bool encrypt - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - size: Int + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - encrypt: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeString /// open func createStringAttribute( databaseId: String, @@ -1257,15 +1284,16 @@ open class Databases: Service { /// already existing documents. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param String default - /// @param Int size - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - size: Int (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeString /// open func updateStringAttribute( databaseId: String, @@ -1309,14 +1337,15 @@ open class Databases: Service { /// Create a URL attribute. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param String default - /// @param Bool array - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - array: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeUrl /// open func createUrlAttribute( databaseId: String, @@ -1359,14 +1388,15 @@ open class Databases: Service { /// already existing documents. /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param Bool required - /// @param String default - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - required: Bool + /// - default: String (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeUrl /// open func updateUrlAttribute( databaseId: String, @@ -1407,11 +1437,12 @@ open class Databases: Service { /// /// Get attribute by ID. /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func getAttribute( databaseId: String, @@ -1437,11 +1468,12 @@ open class Databases: Service { /// /// Deletes an attribute. /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteAttribute( databaseId: String, @@ -1471,13 +1503,14 @@ open class Databases: Service { /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). /// /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param AppwriteEnums.RelationMutate onDelete - /// @param String newKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - onDelete: AppwriteEnums.RelationMutate (optional) + /// - newKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.AttributeRelationship /// open func updateRelationshipAttribute( databaseId: String, @@ -1517,11 +1550,12 @@ open class Databases: Service { /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. /// - /// @param String databaseId - /// @param String collectionId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func listDocuments( databaseId: String, @@ -1556,11 +1590,12 @@ open class Databases: Service { /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. /// - /// @param String databaseId - /// @param String collectionId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func listDocuments( databaseId: String, @@ -1581,13 +1616,14 @@ open class Databases: Service { /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. /// - /// @param String databaseId - /// @param String collectionId - /// @param String documentId - /// @param Any data - /// @param [String] permissions - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - data: Any + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document /// open func createDocument( databaseId: String, @@ -1630,13 +1666,14 @@ open class Databases: Service { /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. /// - /// @param String databaseId - /// @param String collectionId - /// @param String documentId - /// @param Any data - /// @param [String] permissions - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - data: Any + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document /// open func createDocument( databaseId: String, @@ -1665,11 +1702,12 @@ open class Databases: Service { /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. /// - /// @param String databaseId - /// @param String collectionId - /// @param [Any] documents - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documents: [Any] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func createDocuments( databaseId: String, @@ -1712,11 +1750,12 @@ open class Databases: Service { /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. /// - /// @param String databaseId - /// @param String collectionId - /// @param [Any] documents - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documents: [Any] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func createDocuments( databaseId: String, @@ -1740,18 +1779,18 @@ open class Databases: Service { /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - /// /// - /// @param String databaseId - /// @param String collectionId - /// @param [Any] documents - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documents: [Any] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func upsertDocuments( databaseId: String, collectionId: String, - documents: [Any]? = nil, + documents: [Any], nestedType: T.Type ) async throws -> AppwriteModels.DocumentList { let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -1788,18 +1827,18 @@ open class Databases: Service { /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - /// /// - /// @param String databaseId - /// @param String collectionId - /// @param [Any] documents - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documents: [Any] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func upsertDocuments( databaseId: String, collectionId: String, - documents: [Any]? = nil + documents: [Any] ) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> { return try await upsertDocuments( databaseId: databaseId, @@ -1810,16 +1849,21 @@ 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. /// - /// @param String databaseId - /// @param String collectionId - /// @param Any data - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - data: Any (optional) + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func updateDocuments( databaseId: String, @@ -1855,16 +1899,21 @@ 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. /// - /// @param String databaseId - /// @param String collectionId - /// @param Any data - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - data: Any (optional) + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func updateDocuments( databaseId: String, @@ -1889,11 +1938,12 @@ open class Databases: Service { /// Bulk delete documents using queries, if no queries are passed then all /// documents are deleted. /// - /// @param String databaseId - /// @param String collectionId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func deleteDocuments( databaseId: String, @@ -1934,11 +1984,12 @@ open class Databases: Service { /// Bulk delete documents using queries, if no queries are passed then all /// documents are deleted. /// - /// @param String databaseId - /// @param String collectionId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DocumentList /// open func deleteDocuments( databaseId: String, @@ -1957,12 +2008,13 @@ open class Databases: Service { /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. /// - /// @param String databaseId - /// @param String collectionId - /// @param String documentId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document /// open func getDocument( databaseId: String, @@ -1999,12 +2051,13 @@ open class Databases: Service { /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. /// - /// @param String databaseId - /// @param String collectionId - /// @param String documentId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document /// open func getDocument( databaseId: String, @@ -2031,13 +2084,14 @@ open class Databases: Service { /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. /// - /// @param String databaseId - /// @param String collectionId - /// @param String documentId - /// @param Any data - /// @param [String] permissions - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - data: Any + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document /// open func upsertDocument( databaseId: String, @@ -2084,13 +2138,14 @@ open class Databases: Service { /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. /// - /// @param String databaseId - /// @param String collectionId - /// @param String documentId - /// @param Any data - /// @param [String] permissions - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - data: Any + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document /// open func upsertDocument( databaseId: String, @@ -2113,13 +2168,14 @@ open class Databases: Service { /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. /// - /// @param String databaseId - /// @param String collectionId - /// @param String documentId - /// @param Any data - /// @param [String] permissions - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document /// open func updateDocument( databaseId: String, @@ -2160,13 +2216,14 @@ open class Databases: Service { /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. /// - /// @param String databaseId - /// @param String collectionId - /// @param String documentId - /// @param Any data - /// @param [String] permissions - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - data: Any (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document /// open func updateDocument( databaseId: String, @@ -2188,11 +2245,12 @@ open class Databases: Service { /// /// Delete a document by its unique ID. /// - /// @param String databaseId - /// @param String collectionId - /// @param String documentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteDocument( databaseId: String, @@ -2217,14 +2275,179 @@ open class Databases: Service { params: apiParams ) } + /// + /// Decrement a specific attribute of a document by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - attribute: String + /// - value: Double (optional) + /// - min: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document + /// + open func decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = nil, + min: Double? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Document { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + .replacingOccurrences(of: "{documentId}", with: documentId) + .replacingOccurrences(of: "{attribute}", with: attribute) + + let apiParams: [String: Any?] = [ + "value": value, + "min": min + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Document = { response in + return AppwriteModels.Document.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Decrement a specific attribute of a document by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - attribute: String + /// - value: Double (optional) + /// - min: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document + /// + open func decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = nil, + min: Double? = nil + ) async throws -> AppwriteModels.Document<[String: AnyCodable]> { + return try await decrementDocumentAttribute( + databaseId: databaseId, + collectionId: collectionId, + documentId: documentId, + attribute: attribute, + value: value, + min: min, + nestedType: [String: AnyCodable].self + ) + } + + /// + /// Increment a specific attribute of a document by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - attribute: String + /// - value: Double (optional) + /// - max: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document + /// + open func incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = nil, + max: Double? = nil, + nestedType: T.Type + ) async throws -> AppwriteModels.Document { + let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{collectionId}", with: collectionId) + .replacingOccurrences(of: "{documentId}", with: documentId) + .replacingOccurrences(of: "{attribute}", with: attribute) + + let apiParams: [String: Any?] = [ + "value": value, + "max": max + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Document = { response in + return AppwriteModels.Document.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Increment a specific attribute of a document by a given value. + /// + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - documentId: String + /// - attribute: String + /// - value: Double (optional) + /// - max: Double (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Document + /// + open func incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = nil, + max: Double? = nil + ) async throws -> AppwriteModels.Document<[String: AnyCodable]> { + return try await incrementDocumentAttribute( + databaseId: databaseId, + collectionId: collectionId, + documentId: documentId, + attribute: attribute, + value: value, + max: max, + nestedType: [String: AnyCodable].self + ) + } + /// /// List indexes in the collection. /// - /// @param String databaseId - /// @param String collectionId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.IndexList /// open func listIndexes( databaseId: String, @@ -2259,15 +2482,16 @@ open class Databases: Service { /// the attributes you will query in a single request. /// Attributes can be `key`, `fulltext`, and `unique`. /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @param AppwriteEnums.IndexType type - /// @param [String] attributes - /// @param [String] orders - /// @param [Int] lengths - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - type: AppwriteEnums.IndexType + /// - attributes: [String] + /// - orders: [String] (optional) + /// - lengths: [Int] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Index /// open func createIndex( databaseId: String, @@ -2310,11 +2534,12 @@ open class Databases: Service { /// /// Get index by ID. /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Index /// open func getIndex( databaseId: String, @@ -2346,11 +2571,12 @@ open class Databases: Service { /// /// Delete an index. /// - /// @param String databaseId - /// @param String collectionId - /// @param String key - /// @throws Exception - /// @return array + /// - Parameters: + /// - databaseId: String + /// - collectionId: String + /// - key: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteIndex( databaseId: String, diff --git a/Sources/Appwrite/Services/Functions.swift b/Sources/Appwrite/Services/Functions.swift index 130e3d5..a26353f 100644 --- a/Sources/Appwrite/Services/Functions.swift +++ b/Sources/Appwrite/Services/Functions.swift @@ -12,10 +12,11 @@ open class Functions: Service { /// Get a list of all the project's functions. You can use the query params to /// filter your results. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.FunctionList /// open func list( queries: [String]? = nil, @@ -49,26 +50,27 @@ open class Functions: Service { /// project users or team with access to execute the function using the client /// API. /// - /// @param String functionId - /// @param String name - /// @param AppwriteEnums.Runtime runtime - /// @param [String] execute - /// @param [String] events - /// @param String schedule - /// @param Int timeout - /// @param Bool enabled - /// @param Bool logging - /// @param String entrypoint - /// @param String commands - /// @param [String] scopes - /// @param String installationId - /// @param String providerRepositoryId - /// @param String providerBranch - /// @param Bool providerSilentMode - /// @param String providerRootDirectory - /// @param String specification - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - name: String + /// - runtime: AppwriteEnums.Runtime + /// - execute: [String] (optional) + /// - events: [String] (optional) + /// - schedule: String (optional) + /// - timeout: Int (optional) + /// - enabled: Bool (optional) + /// - logging: Bool (optional) + /// - entrypoint: String (optional) + /// - commands: String (optional) + /// - scopes: [String] (optional) + /// - installationId: String (optional) + /// - providerRepositoryId: String (optional) + /// - providerBranch: String (optional) + /// - providerSilentMode: Bool (optional) + /// - providerRootDirectory: String (optional) + /// - specification: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Function /// open func create( functionId: String, @@ -133,8 +135,8 @@ open class Functions: Service { /// /// Get a list of all runtimes that are currently active on your instance. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RuntimeList /// open func listRuntimes( ) async throws -> AppwriteModels.RuntimeList { @@ -160,8 +162,8 @@ open class Functions: Service { /// /// List allowed function specifications for this instance. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.SpecificationList /// open func listSpecifications( ) async throws -> AppwriteModels.SpecificationList { @@ -187,9 +189,10 @@ open class Functions: Service { /// /// Get a function by its unique ID. /// - /// @param String functionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Function /// open func get( functionId: String @@ -217,26 +220,27 @@ open class Functions: Service { /// /// Update function by its unique ID. /// - /// @param String functionId - /// @param String name - /// @param AppwriteEnums.Runtime runtime - /// @param [String] execute - /// @param [String] events - /// @param String schedule - /// @param Int timeout - /// @param Bool enabled - /// @param Bool logging - /// @param String entrypoint - /// @param String commands - /// @param [String] scopes - /// @param String installationId - /// @param String providerRepositoryId - /// @param String providerBranch - /// @param Bool providerSilentMode - /// @param String providerRootDirectory - /// @param String specification - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - name: String + /// - runtime: AppwriteEnums.Runtime (optional) + /// - execute: [String] (optional) + /// - events: [String] (optional) + /// - schedule: String (optional) + /// - timeout: Int (optional) + /// - enabled: Bool (optional) + /// - logging: Bool (optional) + /// - entrypoint: String (optional) + /// - commands: String (optional) + /// - scopes: [String] (optional) + /// - installationId: String (optional) + /// - providerRepositoryId: String (optional) + /// - providerBranch: String (optional) + /// - providerSilentMode: Bool (optional) + /// - providerRootDirectory: String (optional) + /// - specification: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Function /// open func update( functionId: String, @@ -301,9 +305,10 @@ open class Functions: Service { /// /// Delete a function by its unique ID. /// - /// @param String functionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func delete( functionId: String @@ -328,10 +333,11 @@ open class Functions: Service { /// Update the function active deployment. Use this endpoint to switch the code /// deployment that should be used when visitor opens your function. /// - /// @param String functionId - /// @param String deploymentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - deploymentId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Function /// open func updateFunctionDeployment( functionId: String, @@ -365,11 +371,12 @@ open class Functions: Service { /// Get a list of all the function's code deployments. You can use the query /// params to filter your results. /// - /// @param String functionId - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DeploymentList /// open func listDeployments( functionId: String, @@ -411,13 +418,14 @@ open class Functions: Service { /// /// Use the "command" param to set the entrypoint used to execute your code. /// - /// @param String functionId - /// @param InputFile code - /// @param Bool activate - /// @param String entrypoint - /// @param String commands - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - code: InputFile + /// - activate: Bool + /// - entrypoint: String (optional) + /// - commands: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func createDeployment( functionId: String, @@ -465,11 +473,12 @@ open class Functions: Service { /// build process will be queued and executed asynchronously. The original /// deployment's code will be preserved and used for the new build. /// - /// @param String functionId - /// @param String deploymentId - /// @param String buildId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - deploymentId: String + /// - buildId: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func createDuplicateDeployment( functionId: String, @@ -508,14 +517,15 @@ open class Functions: Service { /// [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to /// find the template details. /// - /// @param String functionId - /// @param String repository - /// @param String owner - /// @param String rootDirectory - /// @param String version - /// @param Bool activate - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - repository: String + /// - owner: String + /// - rootDirectory: String + /// - version: String + /// - activate: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func createTemplateDeployment( functionId: String, @@ -558,12 +568,13 @@ open class Functions: Service { /// /// This endpoint lets you create deployment from a branch, commit, or a tag. /// - /// @param String functionId - /// @param AppwriteEnums.VCSDeploymentType type - /// @param String reference - /// @param Bool activate - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - type: AppwriteEnums.VCSDeploymentType + /// - reference: String + /// - activate: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func createVcsDeployment( functionId: String, @@ -600,10 +611,11 @@ open class Functions: Service { /// /// Get a function deployment by its unique ID. /// - /// @param String functionId - /// @param String deploymentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - deploymentId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func getDeployment( functionId: String, @@ -633,10 +645,11 @@ open class Functions: Service { /// /// Delete a code deployment by its unique ID. /// - /// @param String functionId - /// @param String deploymentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - deploymentId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteDeployment( functionId: String, @@ -664,11 +677,12 @@ open class Functions: Service { /// return with a 'Content-Disposition: attachment' header that tells the /// browser to start downloading the file to user downloads directory. /// - /// @param String functionId - /// @param String deploymentId - /// @param AppwriteEnums.DeploymentDownloadType type - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - deploymentId: String + /// - type: AppwriteEnums.DeploymentDownloadType (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getDeploymentDownload( functionId: String, @@ -701,10 +715,11 @@ open class Functions: Service { /// cancel builds that have already completed (status 'ready') or failed. The /// response includes the final build status and details. /// - /// @param String functionId - /// @param String deploymentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - deploymentId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func updateDeploymentStatus( functionId: String, @@ -737,10 +752,11 @@ open class Functions: Service { /// Get a list of all the current user function execution logs. You can use the /// query params to filter your results. /// - /// @param String functionId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ExecutionList /// open func listExecutions( functionId: String, @@ -774,15 +790,16 @@ open class Functions: Service { /// updates on the current execution status. Once this endpoint is called, your /// function execution process will start asynchronously. /// - /// @param String functionId - /// @param String body - /// @param Bool async - /// @param String path - /// @param AppwriteEnums.ExecutionMethod method - /// @param Any headers - /// @param String scheduledAt - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - body: String (optional) + /// - async: Bool (optional) + /// - path: String (optional) + /// - method: AppwriteEnums.ExecutionMethod (optional) + /// - headers: Any (optional) + /// - scheduledAt: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Execution /// open func createExecution( functionId: String, @@ -825,10 +842,11 @@ open class Functions: Service { /// /// Get a function execution log by its unique ID. /// - /// @param String functionId - /// @param String executionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - executionId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Execution /// open func getExecution( functionId: String, @@ -858,10 +876,11 @@ open class Functions: Service { /// /// Delete a function execution by its unique ID. /// - /// @param String functionId - /// @param String executionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - executionId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteExecution( functionId: String, @@ -887,9 +906,10 @@ open class Functions: Service { /// /// Get a list of all variables of a specific function. /// - /// @param String functionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.VariableList /// open func listVariables( functionId: String @@ -918,12 +938,13 @@ open class Functions: Service { /// Create a new function environment variable. These variables can be accessed /// in the function at runtime as environment variables. /// - /// @param String functionId - /// @param String key - /// @param String value - /// @param Bool secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - key: String + /// - value: String + /// - secret: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Variable /// open func createVariable( functionId: String, @@ -960,10 +981,11 @@ open class Functions: Service { /// /// Get a variable by its unique ID. /// - /// @param String functionId - /// @param String variableId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - variableId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Variable /// open func getVariable( functionId: String, @@ -993,13 +1015,14 @@ open class Functions: Service { /// /// Update variable by its unique ID. /// - /// @param String functionId - /// @param String variableId - /// @param String key - /// @param String value - /// @param Bool secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - variableId: String + /// - key: String + /// - value: String (optional) + /// - secret: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Variable /// open func updateVariable( functionId: String, @@ -1038,10 +1061,11 @@ open class Functions: Service { /// /// Delete a variable by its unique ID. /// - /// @param String functionId - /// @param String variableId - /// @throws Exception - /// @return array + /// - Parameters: + /// - functionId: String + /// - variableId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteVariable( functionId: String, diff --git a/Sources/Appwrite/Services/Graphql.swift b/Sources/Appwrite/Services/Graphql.swift index 68c326f..6089958 100644 --- a/Sources/Appwrite/Services/Graphql.swift +++ b/Sources/Appwrite/Services/Graphql.swift @@ -11,9 +11,10 @@ open class Graphql: Service { /// /// Execute a GraphQL mutation. /// - /// @param Any query - /// @throws Exception - /// @return array + /// - Parameters: + /// - query: Any + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func query( query: Any @@ -45,9 +46,10 @@ open class Graphql: Service { /// /// Execute a GraphQL mutation. /// - /// @param Any query - /// @throws Exception - /// @return array + /// - Parameters: + /// - query: Any + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func mutation( query: Any diff --git a/Sources/Appwrite/Services/Health.swift b/Sources/Appwrite/Services/Health.swift index f8103a4..e0bab3d 100644 --- a/Sources/Appwrite/Services/Health.swift +++ b/Sources/Appwrite/Services/Health.swift @@ -11,8 +11,8 @@ open class Health: Service { /// /// Check the Appwrite HTTP server is up and responsive. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthStatus /// open func get( ) async throws -> AppwriteModels.HealthStatus { @@ -38,8 +38,8 @@ open class Health: Service { /// /// Check the Appwrite Antivirus server is up and connection is successful. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthAntivirus /// open func getAntivirus( ) async throws -> AppwriteModels.HealthAntivirus { @@ -66,8 +66,8 @@ open class Health: Service { /// Check the Appwrite in-memory cache servers are up and connection is /// successful. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthStatus /// open func getCache( ) async throws -> AppwriteModels.HealthStatus { @@ -93,9 +93,10 @@ open class Health: Service { /// /// Get the SSL certificate for a domain /// - /// @param String domain - /// @throws Exception - /// @return array + /// - Parameters: + /// - domain: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthCertificate /// open func getCertificate( domain: String? = nil @@ -124,8 +125,8 @@ open class Health: Service { /// /// Check the Appwrite database servers are up and connection is successful. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthStatus /// open func getDB( ) async throws -> AppwriteModels.HealthStatus { @@ -151,8 +152,8 @@ open class Health: Service { /// /// Check the Appwrite pub-sub servers are up and connection is successful. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthStatus /// open func getPubSub( ) async throws -> AppwriteModels.HealthStatus { @@ -179,9 +180,10 @@ open class Health: Service { /// Get the number of builds that are waiting to be processed in the Appwrite /// internal queue server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueBuilds( threshold: Int? = nil @@ -212,9 +214,10 @@ open class Health: Service { /// [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue /// server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueCertificates( threshold: Int? = nil @@ -244,10 +247,11 @@ open class Health: Service { /// Get the number of database changes that are waiting to be processed in the /// Appwrite internal queue server. /// - /// @param String name - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - name: String (optional) + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueDatabases( name: String? = nil, @@ -279,9 +283,10 @@ open class Health: Service { /// Get the number of background destructive changes that are waiting to be /// processed in the Appwrite internal queue server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueDeletes( threshold: Int? = nil @@ -311,10 +316,11 @@ open class Health: Service { /// Returns the amount of failed jobs in a given queue. /// /// - /// @param AppwriteEnums.Name name - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - name: AppwriteEnums.Name + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getFailedJobs( name: AppwriteEnums.Name, @@ -346,9 +352,10 @@ open class Health: Service { /// Get the number of function executions that are waiting to be processed in /// the Appwrite internal queue server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueFunctions( threshold: Int? = nil @@ -378,9 +385,10 @@ open class Health: Service { /// Get the number of logs that are waiting to be processed in the Appwrite /// internal queue server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueLogs( threshold: Int? = nil @@ -410,9 +418,10 @@ open class Health: Service { /// Get the number of mails that are waiting to be processed in the Appwrite /// internal queue server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueMails( threshold: Int? = nil @@ -442,9 +451,10 @@ open class Health: Service { /// Get the number of messages that are waiting to be processed in the Appwrite /// internal queue server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueMessaging( threshold: Int? = nil @@ -474,9 +484,10 @@ open class Health: Service { /// Get the number of migrations that are waiting to be processed in the /// Appwrite internal queue server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueMigrations( threshold: Int? = nil @@ -506,9 +517,10 @@ open class Health: Service { /// Get the number of metrics that are waiting to be processed in the Appwrite /// stats resources queue. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueStatsResources( threshold: Int? = nil @@ -538,9 +550,10 @@ open class Health: Service { /// Get the number of metrics that are waiting to be processed in the Appwrite /// internal queue server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueUsage( threshold: Int? = nil @@ -570,9 +583,10 @@ open class Health: Service { /// Get the number of webhooks that are waiting to be processed in the Appwrite /// internal queue server. /// - /// @param Int threshold - /// @throws Exception - /// @return array + /// - Parameters: + /// - threshold: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthQueue /// open func getQueueWebhooks( threshold: Int? = nil @@ -601,8 +615,8 @@ open class Health: Service { /// /// Check the Appwrite storage device is up and connection is successful. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthStatus /// open func getStorage( ) async throws -> AppwriteModels.HealthStatus { @@ -628,8 +642,8 @@ open class Health: Service { /// /// Check the Appwrite local storage device is up and connection is successful. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthStatus /// open func getStorageLocal( ) async throws -> AppwriteModels.HealthStatus { @@ -661,8 +675,8 @@ open class Health: Service { /// clocks over the Internet. If your computer sets its own clock, it likely /// uses NTP. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.HealthTime /// open func getTime( ) async throws -> AppwriteModels.HealthTime { diff --git a/Sources/Appwrite/Services/Locale.swift b/Sources/Appwrite/Services/Locale.swift index b9d2682..87c64c7 100644 --- a/Sources/Appwrite/Services/Locale.swift +++ b/Sources/Appwrite/Services/Locale.swift @@ -16,8 +16,8 @@ open class Locale: Service { /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Locale /// open func get( ) async throws -> AppwriteModels.Locale { @@ -44,8 +44,8 @@ open class Locale: Service { /// List of all locale codes in [ISO /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.LocaleCodeList /// open func listCodes( ) async throws -> AppwriteModels.LocaleCodeList { @@ -72,8 +72,8 @@ open class Locale: Service { /// List of all continents. You can use the locale header to get the data in a /// supported language. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ContinentList /// open func listContinents( ) async throws -> AppwriteModels.ContinentList { @@ -100,8 +100,8 @@ open class Locale: Service { /// List of all countries. You can use the locale header to get the data in a /// supported language. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.CountryList /// open func listCountries( ) async throws -> AppwriteModels.CountryList { @@ -128,8 +128,8 @@ open class Locale: Service { /// List of all countries that are currently members of the EU. You can use the /// locale header to get the data in a supported language. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.CountryList /// open func listCountriesEU( ) async throws -> AppwriteModels.CountryList { @@ -156,8 +156,8 @@ open class Locale: Service { /// List of all countries phone codes. You can use the locale header to get the /// data in a supported language. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.PhoneList /// open func listCountriesPhones( ) async throws -> AppwriteModels.PhoneList { @@ -185,8 +185,8 @@ open class Locale: Service { /// decimal digits for all major and minor currencies. You can use the locale /// header to get the data in a supported language. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.CurrencyList /// open func listCurrencies( ) async throws -> AppwriteModels.CurrencyList { @@ -213,8 +213,8 @@ open class Locale: Service { /// List of all languages classified by ISO 639-1 including 2-letter code, name /// in English, and name in the respective language. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.LanguageList /// open func listLanguages( ) async throws -> AppwriteModels.LanguageList { diff --git a/Sources/Appwrite/Services/Messaging.swift b/Sources/Appwrite/Services/Messaging.swift index 0ded4ce..5a97dfd 100644 --- a/Sources/Appwrite/Services/Messaging.swift +++ b/Sources/Appwrite/Services/Messaging.swift @@ -11,10 +11,11 @@ open class Messaging: Service { /// /// Get a list of all messages from the current Appwrite project. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MessageList /// open func listMessages( queries: [String]? = nil, @@ -45,20 +46,21 @@ open class Messaging: Service { /// /// Create a new email message. /// - /// @param String messageId - /// @param String subject - /// @param String content - /// @param [String] topics - /// @param [String] users - /// @param [String] targets - /// @param [String] cc - /// @param [String] bcc - /// @param [String] attachments - /// @param Bool draft - /// @param Bool html - /// @param String scheduledAt - /// @throws Exception - /// @return array + /// - Parameters: + /// - messageId: String + /// - subject: String + /// - content: String + /// - topics: [String] (optional) + /// - users: [String] (optional) + /// - targets: [String] (optional) + /// - cc: [String] (optional) + /// - bcc: [String] (optional) + /// - attachments: [String] (optional) + /// - draft: Bool (optional) + /// - html: Bool (optional) + /// - scheduledAt: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Message /// open func createEmail( messageId: String, @@ -114,20 +116,21 @@ open class Messaging: Service { /// sent, or failed cannot be updated. /// /// - /// @param String messageId - /// @param [String] topics - /// @param [String] users - /// @param [String] targets - /// @param String subject - /// @param String content - /// @param Bool draft - /// @param Bool html - /// @param [String] cc - /// @param [String] bcc - /// @param String scheduledAt - /// @param [String] attachments - /// @throws Exception - /// @return array + /// - Parameters: + /// - messageId: String + /// - topics: [String] (optional) + /// - users: [String] (optional) + /// - targets: [String] (optional) + /// - subject: String (optional) + /// - content: String (optional) + /// - draft: Bool (optional) + /// - html: Bool (optional) + /// - cc: [String] (optional) + /// - bcc: [String] (optional) + /// - scheduledAt: String (optional) + /// - attachments: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Message /// open func updateEmail( messageId: String, @@ -180,27 +183,28 @@ open class Messaging: Service { /// /// Create a new push notification. /// - /// @param String messageId - /// @param String title - /// @param String body - /// @param [String] topics - /// @param [String] users - /// @param [String] targets - /// @param Any data - /// @param String action - /// @param String image - /// @param String icon - /// @param String sound - /// @param String color - /// @param String tag - /// @param Int badge - /// @param Bool draft - /// @param String scheduledAt - /// @param Bool contentAvailable - /// @param Bool critical - /// @param AppwriteEnums.MessagePriority priority - /// @throws Exception - /// @return array + /// - Parameters: + /// - messageId: String + /// - title: String (optional) + /// - body: String (optional) + /// - topics: [String] (optional) + /// - users: [String] (optional) + /// - targets: [String] (optional) + /// - data: Any (optional) + /// - action: String (optional) + /// - image: String (optional) + /// - icon: String (optional) + /// - sound: String (optional) + /// - color: String (optional) + /// - tag: String (optional) + /// - badge: Int (optional) + /// - draft: Bool (optional) + /// - scheduledAt: String (optional) + /// - contentAvailable: Bool (optional) + /// - critical: Bool (optional) + /// - priority: AppwriteEnums.MessagePriority (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Message /// open func createPush( messageId: String, @@ -270,27 +274,28 @@ open class Messaging: Service { /// sent, or failed cannot be updated. /// /// - /// @param String messageId - /// @param [String] topics - /// @param [String] users - /// @param [String] targets - /// @param String title - /// @param String body - /// @param Any data - /// @param String action - /// @param String image - /// @param String icon - /// @param String sound - /// @param String color - /// @param String tag - /// @param Int badge - /// @param Bool draft - /// @param String scheduledAt - /// @param Bool contentAvailable - /// @param Bool critical - /// @param AppwriteEnums.MessagePriority priority - /// @throws Exception - /// @return array + /// - Parameters: + /// - messageId: String + /// - topics: [String] (optional) + /// - users: [String] (optional) + /// - targets: [String] (optional) + /// - title: String (optional) + /// - body: String (optional) + /// - data: Any (optional) + /// - action: String (optional) + /// - image: String (optional) + /// - icon: String (optional) + /// - sound: String (optional) + /// - color: String (optional) + /// - tag: String (optional) + /// - badge: Int (optional) + /// - draft: Bool (optional) + /// - scheduledAt: String (optional) + /// - contentAvailable: Bool (optional) + /// - critical: Bool (optional) + /// - priority: AppwriteEnums.MessagePriority (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Message /// open func updatePush( messageId: String, @@ -357,15 +362,16 @@ open class Messaging: Service { /// /// Create a new SMS message. /// - /// @param String messageId - /// @param String content - /// @param [String] topics - /// @param [String] users - /// @param [String] targets - /// @param Bool draft - /// @param String scheduledAt - /// @throws Exception - /// @return array + /// - 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, @@ -411,15 +417,16 @@ open class Messaging: Service { /// sent, or failed cannot be updated. /// /// - /// @param String messageId - /// @param [String] topics - /// @param [String] users - /// @param [String] targets - /// @param String content - /// @param Bool draft - /// @param String scheduledAt - /// @throws Exception - /// @return array + /// - 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, @@ -463,9 +470,10 @@ open class Messaging: Service { /// Get a message by its unique ID. /// /// - /// @param String messageId - /// @throws Exception - /// @return array + /// - Parameters: + /// - messageId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Message /// open func getMessage( messageId: String @@ -494,9 +502,10 @@ open class Messaging: Service { /// Delete a message. If the message is not a draft or scheduled, but has been /// sent, this will not recall the message. /// - /// @param String messageId - /// @throws Exception - /// @return array + /// - Parameters: + /// - messageId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func delete( messageId: String @@ -520,10 +529,11 @@ open class Messaging: Service { /// /// Get the message activity logs listed by its unique ID. /// - /// @param String messageId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - messageId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.LogList /// open func listMessageLogs( messageId: String, @@ -554,10 +564,11 @@ open class Messaging: Service { /// /// Get a list of the targets associated with a message. /// - /// @param String messageId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - messageId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.TargetList /// open func listTargets( messageId: String, @@ -588,10 +599,11 @@ open class Messaging: Service { /// /// Get a list of all providers from the current Appwrite project. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ProviderList /// open func listProviders( queries: [String]? = nil, @@ -622,16 +634,17 @@ open class Messaging: Service { /// /// Create a new Apple Push Notification service provider. /// - /// @param String providerId - /// @param String name - /// @param String authKey - /// @param String authKeyId - /// @param String teamId - /// @param String bundleId - /// @param Bool sandbox - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - 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, @@ -676,16 +689,17 @@ open class Messaging: Service { /// /// Update a Apple Push Notification service provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param Bool enabled - /// @param String authKey - /// @param String authKeyId - /// @param String teamId - /// @param String bundleId - /// @param Bool sandbox - /// @throws Exception - /// @return array + /// - 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, @@ -730,12 +744,13 @@ open class Messaging: Service { /// /// Create a new Firebase Cloud Messaging provider. /// - /// @param String providerId - /// @param String name - /// @param Any serviceAccountJSON - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - 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, @@ -772,12 +787,13 @@ open class Messaging: Service { /// /// Update a Firebase Cloud Messaging provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param Bool enabled - /// @param Any serviceAccountJSON - /// @throws Exception - /// @return array + /// - 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, @@ -814,18 +830,19 @@ open class Messaging: Service { /// /// Create a new Mailgun provider. /// - /// @param String providerId - /// @param String name - /// @param String apiKey - /// @param String domain - /// @param Bool isEuRegion - /// @param String fromName - /// @param String fromEmail - /// @param String replyToName - /// @param String replyToEmail - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String + /// - apiKey: String (optional) + /// - domain: String (optional) + /// - isEuRegion: Bool (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 createMailgunProvider( providerId: String, @@ -874,18 +891,19 @@ open class Messaging: Service { /// /// Update a Mailgun provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param String apiKey - /// @param String domain - /// @param Bool isEuRegion - /// @param Bool enabled - /// @param String fromName - /// @param String fromEmail - /// @param String replyToName - /// @param String replyToEmail - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - apiKey: String (optional) + /// - domain: String (optional) + /// - isEuRegion: Bool (optional) + /// - enabled: Bool (optional) + /// - fromName: String (optional) + /// - fromEmail: String (optional) + /// - replyToName: String (optional) + /// - replyToEmail: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func updateMailgunProvider( providerId: String, @@ -934,14 +952,15 @@ open class Messaging: Service { /// /// Create a new MSG91 provider. /// - /// @param String providerId - /// @param String name - /// @param String templateId - /// @param String senderId - /// @param String authKey - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String + /// - templateId: String (optional) + /// - senderId: String (optional) + /// - authKey: String (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func createMsg91Provider( providerId: String, @@ -982,14 +1001,15 @@ open class Messaging: Service { /// /// Update a MSG91 provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param Bool enabled - /// @param String templateId - /// @param String senderId - /// @param String authKey - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - enabled: Bool (optional) + /// - templateId: String (optional) + /// - senderId: String (optional) + /// - authKey: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func updateMsg91Provider( providerId: String, @@ -1030,16 +1050,17 @@ open class Messaging: Service { /// /// Create a new Sendgrid provider. /// - /// @param String providerId - /// @param String name - /// @param String apiKey - /// @param String fromName - /// @param String fromEmail - /// @param String replyToName - /// @param String replyToEmail - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String + /// - apiKey: 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 createSendgridProvider( providerId: String, @@ -1084,16 +1105,17 @@ open class Messaging: Service { /// /// Update a Sendgrid provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param Bool enabled - /// @param String apiKey - /// @param String fromName - /// @param String fromEmail - /// @param String replyToName - /// @param String replyToEmail - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - enabled: Bool (optional) + /// - apiKey: String (optional) + /// - fromName: String (optional) + /// - fromEmail: String (optional) + /// - replyToName: String (optional) + /// - replyToEmail: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func updateSendgridProvider( providerId: String, @@ -1138,22 +1160,23 @@ open class Messaging: Service { /// /// Create a new SMTP provider. /// - /// @param String providerId - /// @param String name - /// @param String host - /// @param Int port - /// @param String username - /// @param String password - /// @param AppwriteEnums.SmtpEncryption encryption - /// @param Bool autoTLS - /// @param String mailer - /// @param String fromName - /// @param String fromEmail - /// @param String replyToName - /// @param String replyToEmail - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - 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, @@ -1210,22 +1233,23 @@ open class Messaging: Service { /// /// Update a SMTP provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param String host - /// @param Int port - /// @param String username - /// @param String password - /// @param AppwriteEnums.SmtpEncryption encryption - /// @param Bool autoTLS - /// @param String mailer - /// @param String fromName - /// @param String fromEmail - /// @param String replyToName - /// @param String replyToEmail - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - 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, @@ -1282,14 +1306,15 @@ open class Messaging: Service { /// /// Create a new Telesign provider. /// - /// @param String providerId - /// @param String name - /// @param String from - /// @param String customerId - /// @param String apiKey - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String + /// - from: String (optional) + /// - customerId: String (optional) + /// - apiKey: String (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func createTelesignProvider( providerId: String, @@ -1330,14 +1355,15 @@ open class Messaging: Service { /// /// Update a Telesign provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param Bool enabled - /// @param String customerId - /// @param String apiKey - /// @param String from - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - enabled: Bool (optional) + /// - customerId: String (optional) + /// - apiKey: String (optional) + /// - from: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func updateTelesignProvider( providerId: String, @@ -1378,14 +1404,15 @@ open class Messaging: Service { /// /// Create a new Textmagic provider. /// - /// @param String providerId - /// @param String name - /// @param String from - /// @param String username - /// @param String apiKey - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String + /// - from: String (optional) + /// - username: String (optional) + /// - apiKey: String (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func createTextmagicProvider( providerId: String, @@ -1426,14 +1453,15 @@ open class Messaging: Service { /// /// Update a Textmagic provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param Bool enabled - /// @param String username - /// @param String apiKey - /// @param String from - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - enabled: Bool (optional) + /// - username: String (optional) + /// - apiKey: String (optional) + /// - from: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func updateTextmagicProvider( providerId: String, @@ -1474,14 +1502,15 @@ open class Messaging: Service { /// /// Create a new Twilio provider. /// - /// @param String providerId - /// @param String name - /// @param String from - /// @param String accountSid - /// @param String authToken - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String + /// - from: String (optional) + /// - accountSid: String (optional) + /// - authToken: String (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func createTwilioProvider( providerId: String, @@ -1522,14 +1551,15 @@ open class Messaging: Service { /// /// Update a Twilio provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param Bool enabled - /// @param String accountSid - /// @param String authToken - /// @param String from - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - enabled: Bool (optional) + /// - accountSid: String (optional) + /// - authToken: String (optional) + /// - from: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func updateTwilioProvider( providerId: String, @@ -1570,14 +1600,15 @@ open class Messaging: Service { /// /// Create a new Vonage provider. /// - /// @param String providerId - /// @param String name - /// @param String from - /// @param String apiKey - /// @param String apiSecret - /// @param Bool enabled - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String + /// - from: String (optional) + /// - apiKey: String (optional) + /// - apiSecret: String (optional) + /// - enabled: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func createVonageProvider( providerId: String, @@ -1618,14 +1649,15 @@ open class Messaging: Service { /// /// Update a Vonage provider by its unique ID. /// - /// @param String providerId - /// @param String name - /// @param Bool enabled - /// @param String apiKey - /// @param String apiSecret - /// @param String from - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - name: String (optional) + /// - enabled: Bool (optional) + /// - apiKey: String (optional) + /// - apiSecret: String (optional) + /// - from: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func updateVonageProvider( providerId: String, @@ -1667,9 +1699,10 @@ open class Messaging: Service { /// Get a provider by its unique ID. /// /// - /// @param String providerId - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Provider /// open func getProvider( providerId: String @@ -1697,9 +1730,10 @@ open class Messaging: Service { /// /// Delete a provider by its unique ID. /// - /// @param String providerId - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteProvider( providerId: String @@ -1723,10 +1757,11 @@ open class Messaging: Service { /// /// Get the provider activity logs listed by its unique ID. /// - /// @param String providerId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - providerId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.LogList /// open func listProviderLogs( providerId: String, @@ -1757,10 +1792,11 @@ open class Messaging: Service { /// /// Get the subscriber activity logs listed by its unique ID. /// - /// @param String subscriberId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - subscriberId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.LogList /// open func listSubscriberLogs( subscriberId: String, @@ -1791,10 +1827,11 @@ open class Messaging: Service { /// /// Get a list of all topics from the current Appwrite project. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.TopicList /// open func listTopics( queries: [String]? = nil, @@ -1825,11 +1862,12 @@ open class Messaging: Service { /// /// Create a new topic. /// - /// @param String topicId - /// @param String name - /// @param [String] subscribe - /// @throws Exception - /// @return array + /// - Parameters: + /// - topicId: String + /// - name: String + /// - subscribe: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Topic /// open func createTopic( topicId: String, @@ -1865,9 +1903,10 @@ open class Messaging: Service { /// Get a topic by its unique ID. /// /// - /// @param String topicId - /// @throws Exception - /// @return array + /// - Parameters: + /// - topicId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Topic /// open func getTopic( topicId: String @@ -1896,11 +1935,12 @@ open class Messaging: Service { /// Update a topic by its unique ID. /// /// - /// @param String topicId - /// @param String name - /// @param [String] subscribe - /// @throws Exception - /// @return array + /// - Parameters: + /// - topicId: String + /// - name: String (optional) + /// - subscribe: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Topic /// open func updateTopic( topicId: String, @@ -1935,9 +1975,10 @@ open class Messaging: Service { /// /// Delete a topic by its unique ID. /// - /// @param String topicId - /// @throws Exception - /// @return array + /// - Parameters: + /// - topicId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteTopic( topicId: String @@ -1961,10 +2002,11 @@ open class Messaging: Service { /// /// Get the topic activity logs listed by its unique ID. /// - /// @param String topicId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - topicId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.LogList /// open func listTopicLogs( topicId: String, @@ -1995,11 +2037,12 @@ open class Messaging: Service { /// /// Get a list of all subscribers from the current Appwrite project. /// - /// @param String topicId - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - topicId: String + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.SubscriberList /// open func listSubscribers( topicId: String, @@ -2032,11 +2075,12 @@ open class Messaging: Service { /// /// Create a new subscriber. /// - /// @param String topicId - /// @param String subscriberId - /// @param String targetId - /// @throws Exception - /// @return array + /// - Parameters: + /// - topicId: String + /// - subscriberId: String + /// - targetId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Subscriber /// open func createSubscriber( topicId: String, @@ -2072,10 +2116,11 @@ open class Messaging: Service { /// Get a subscriber by its unique ID. /// /// - /// @param String topicId - /// @param String subscriberId - /// @throws Exception - /// @return array + /// - Parameters: + /// - topicId: String + /// - subscriberId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Subscriber /// open func getSubscriber( topicId: String, @@ -2105,10 +2150,11 @@ open class Messaging: Service { /// /// Delete a subscriber by its unique ID. /// - /// @param String topicId - /// @param String subscriberId - /// @throws Exception - /// @return array + /// - Parameters: + /// - topicId: String + /// - subscriberId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteSubscriber( topicId: String, diff --git a/Sources/Appwrite/Services/Sites.swift b/Sources/Appwrite/Services/Sites.swift index deae24b..290e495 100644 --- a/Sources/Appwrite/Services/Sites.swift +++ b/Sources/Appwrite/Services/Sites.swift @@ -12,10 +12,11 @@ open class Sites: Service { /// Get a list of all the project's sites. You can use the query params to /// filter your results. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.SiteList /// open func list( queries: [String]? = nil, @@ -46,26 +47,27 @@ open class Sites: Service { /// /// Create a new site. /// - /// @param String siteId - /// @param String name - /// @param AppwriteEnums.Framework framework - /// @param AppwriteEnums.BuildRuntime buildRuntime - /// @param Bool enabled - /// @param Bool logging - /// @param Int timeout - /// @param String installCommand - /// @param String buildCommand - /// @param String outputDirectory - /// @param AppwriteEnums.Adapter adapter - /// @param String installationId - /// @param String fallbackFile - /// @param String providerRepositoryId - /// @param String providerBranch - /// @param Bool providerSilentMode - /// @param String providerRootDirectory - /// @param String specification - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - name: String + /// - framework: AppwriteEnums.Framework + /// - buildRuntime: AppwriteEnums.BuildRuntime + /// - enabled: Bool (optional) + /// - logging: Bool (optional) + /// - timeout: Int (optional) + /// - installCommand: String (optional) + /// - buildCommand: String (optional) + /// - outputDirectory: String (optional) + /// - adapter: AppwriteEnums.Adapter (optional) + /// - installationId: String (optional) + /// - fallbackFile: String (optional) + /// - providerRepositoryId: String (optional) + /// - providerBranch: String (optional) + /// - providerSilentMode: Bool (optional) + /// - providerRootDirectory: String (optional) + /// - specification: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Site /// open func create( siteId: String, @@ -131,8 +133,8 @@ open class Sites: Service { /// Get a list of all frameworks that are currently available on the server /// instance. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.FrameworkList /// open func listFrameworks( ) async throws -> AppwriteModels.FrameworkList { @@ -158,8 +160,8 @@ open class Sites: Service { /// /// List allowed site specifications for this instance. /// - /// @throws Exception - /// @return array + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.SpecificationList /// open func listSpecifications( ) async throws -> AppwriteModels.SpecificationList { @@ -185,9 +187,10 @@ open class Sites: Service { /// /// Get a site by its unique ID. /// - /// @param String siteId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Site /// open func get( siteId: String @@ -215,26 +218,27 @@ open class Sites: Service { /// /// Update site by its unique ID. /// - /// @param String siteId - /// @param String name - /// @param AppwriteEnums.Framework framework - /// @param Bool enabled - /// @param Bool logging - /// @param Int timeout - /// @param String installCommand - /// @param String buildCommand - /// @param String outputDirectory - /// @param AppwriteEnums.BuildRuntime buildRuntime - /// @param AppwriteEnums.Adapter adapter - /// @param String fallbackFile - /// @param String installationId - /// @param String providerRepositoryId - /// @param String providerBranch - /// @param Bool providerSilentMode - /// @param String providerRootDirectory - /// @param String specification - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - name: String + /// - framework: AppwriteEnums.Framework + /// - enabled: Bool (optional) + /// - logging: Bool (optional) + /// - timeout: Int (optional) + /// - installCommand: String (optional) + /// - buildCommand: String (optional) + /// - outputDirectory: String (optional) + /// - buildRuntime: AppwriteEnums.BuildRuntime (optional) + /// - adapter: AppwriteEnums.Adapter (optional) + /// - fallbackFile: String (optional) + /// - installationId: String (optional) + /// - providerRepositoryId: String (optional) + /// - providerBranch: String (optional) + /// - providerSilentMode: Bool (optional) + /// - providerRootDirectory: String (optional) + /// - specification: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Site /// open func update( siteId: String, @@ -299,9 +303,10 @@ open class Sites: Service { /// /// Delete a site by its unique ID. /// - /// @param String siteId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func delete( siteId: String @@ -326,10 +331,11 @@ open class Sites: Service { /// Update the site active deployment. Use this endpoint to switch the code /// deployment that should be used when visitor opens your site. /// - /// @param String siteId - /// @param String deploymentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - deploymentId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Site /// open func updateSiteDeployment( siteId: String, @@ -363,11 +369,12 @@ open class Sites: Service { /// Get a list of all the site's code deployments. You can use the query params /// to filter your results. /// - /// @param String siteId - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.DeploymentList /// open func listDeployments( siteId: String, @@ -402,14 +409,15 @@ open class Sites: Service { /// version of your site code. To activate your newly uploaded code, you'll /// need to update the function's deployment to use your new deployment ID. /// - /// @param String siteId - /// @param InputFile code - /// @param Bool activate - /// @param String installCommand - /// @param String buildCommand - /// @param String outputDirectory - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - code: InputFile + /// - activate: Bool + /// - installCommand: String (optional) + /// - buildCommand: String (optional) + /// - outputDirectory: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func createDeployment( siteId: String, @@ -459,10 +467,11 @@ open class Sites: Service { /// process will be queued and executed asynchronously. The original /// deployment's code will be preserved and used for the new build. /// - /// @param String siteId - /// @param String deploymentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - deploymentId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func createDuplicateDeployment( siteId: String, @@ -499,14 +508,15 @@ open class Sites: Service { /// [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to /// find the template details. /// - /// @param String siteId - /// @param String repository - /// @param String owner - /// @param String rootDirectory - /// @param String version - /// @param Bool activate - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - repository: String + /// - owner: String + /// - rootDirectory: String + /// - version: String + /// - activate: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func createTemplateDeployment( siteId: String, @@ -549,12 +559,13 @@ open class Sites: Service { /// /// This endpoint lets you create deployment from a branch, commit, or a tag. /// - /// @param String siteId - /// @param AppwriteEnums.VCSDeploymentType type - /// @param String reference - /// @param Bool activate - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - type: AppwriteEnums.VCSDeploymentType + /// - reference: String + /// - activate: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func createVcsDeployment( siteId: String, @@ -591,10 +602,11 @@ open class Sites: Service { /// /// Get a site deployment by its unique ID. /// - /// @param String siteId - /// @param String deploymentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - deploymentId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func getDeployment( siteId: String, @@ -624,10 +636,11 @@ open class Sites: Service { /// /// Delete a site deployment by its unique ID. /// - /// @param String siteId - /// @param String deploymentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - deploymentId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteDeployment( siteId: String, @@ -655,11 +668,12 @@ open class Sites: Service { /// return with a 'Content-Disposition: attachment' header that tells the /// browser to start downloading the file to user downloads directory. /// - /// @param String siteId - /// @param String deploymentId - /// @param AppwriteEnums.DeploymentDownloadType type - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - deploymentId: String + /// - type: AppwriteEnums.DeploymentDownloadType (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getDeploymentDownload( siteId: String, @@ -692,10 +706,11 @@ open class Sites: Service { /// cancel builds that have already completed (status 'ready') or failed. The /// response includes the final build status and details. /// - /// @param String siteId - /// @param String deploymentId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - deploymentId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Deployment /// open func updateDeploymentStatus( siteId: String, @@ -728,10 +743,11 @@ open class Sites: Service { /// Get a list of all site logs. You can use the query params to filter your /// results. /// - /// @param String siteId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ExecutionList /// open func listLogs( siteId: String, @@ -762,10 +778,11 @@ open class Sites: Service { /// /// Get a site request log by its unique ID. /// - /// @param String siteId - /// @param String logId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - logId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Execution /// open func getLog( siteId: String, @@ -795,10 +812,11 @@ open class Sites: Service { /// /// Delete a site log by its unique ID. /// - /// @param String siteId - /// @param String logId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - logId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteLog( siteId: String, @@ -824,9 +842,10 @@ open class Sites: Service { /// /// Get a list of all variables of a specific site. /// - /// @param String siteId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.VariableList /// open func listVariables( siteId: String @@ -855,12 +874,13 @@ open class Sites: Service { /// Create a new site variable. These variables can be accessed during build /// and runtime (server-side rendering) as environment variables. /// - /// @param String siteId - /// @param String key - /// @param String value - /// @param Bool secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - key: String + /// - value: String + /// - secret: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Variable /// open func createVariable( siteId: String, @@ -897,10 +917,11 @@ open class Sites: Service { /// /// Get a variable by its unique ID. /// - /// @param String siteId - /// @param String variableId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - variableId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Variable /// open func getVariable( siteId: String, @@ -930,13 +951,14 @@ open class Sites: Service { /// /// Update variable by its unique ID. /// - /// @param String siteId - /// @param String variableId - /// @param String key - /// @param String value - /// @param Bool secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - variableId: String + /// - key: String + /// - value: String (optional) + /// - secret: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Variable /// open func updateVariable( siteId: String, @@ -975,10 +997,11 @@ open class Sites: Service { /// /// Delete a variable by its unique ID. /// - /// @param String siteId - /// @param String variableId - /// @throws Exception - /// @return array + /// - Parameters: + /// - siteId: String + /// - variableId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteVariable( siteId: String, diff --git a/Sources/Appwrite/Services/Storage.swift b/Sources/Appwrite/Services/Storage.swift index 29976dd..7852911 100644 --- a/Sources/Appwrite/Services/Storage.swift +++ b/Sources/Appwrite/Services/Storage.swift @@ -12,10 +12,11 @@ open class Storage: Service { /// Get a list of all the storage buckets. You can use the query params to /// filter your results. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.BucketList /// open func listBuckets( queries: [String]? = nil, @@ -46,18 +47,19 @@ open class Storage: Service { /// /// Create a new storage bucket. /// - /// @param String bucketId - /// @param String name - /// @param [String] permissions - /// @param Bool fileSecurity - /// @param Bool enabled - /// @param Int maximumFileSize - /// @param [String] allowedFileExtensions - /// @param AppwriteEnums.Compression compression - /// @param Bool encryption - /// @param Bool antivirus - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - name: String + /// - permissions: [String] (optional) + /// - fileSecurity: Bool (optional) + /// - enabled: Bool (optional) + /// - maximumFileSize: Int (optional) + /// - allowedFileExtensions: [String] (optional) + /// - compression: AppwriteEnums.Compression (optional) + /// - encryption: Bool (optional) + /// - antivirus: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Bucket /// open func createBucket( bucketId: String, @@ -107,9 +109,10 @@ open class Storage: Service { /// Get a storage bucket by its unique ID. This endpoint response returns a /// JSON object with the storage bucket metadata. /// - /// @param String bucketId - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Bucket /// open func getBucket( bucketId: String @@ -137,18 +140,19 @@ open class Storage: Service { /// /// Update a storage bucket by its unique ID. /// - /// @param String bucketId - /// @param String name - /// @param [String] permissions - /// @param Bool fileSecurity - /// @param Bool enabled - /// @param Int maximumFileSize - /// @param [String] allowedFileExtensions - /// @param AppwriteEnums.Compression compression - /// @param Bool encryption - /// @param Bool antivirus - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - name: String + /// - permissions: [String] (optional) + /// - fileSecurity: Bool (optional) + /// - enabled: Bool (optional) + /// - maximumFileSize: Int (optional) + /// - allowedFileExtensions: [String] (optional) + /// - compression: AppwriteEnums.Compression (optional) + /// - encryption: Bool (optional) + /// - antivirus: Bool (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Bucket /// open func updateBucket( bucketId: String, @@ -197,9 +201,10 @@ open class Storage: Service { /// /// Delete a storage bucket by its unique ID. /// - /// @param String bucketId - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteBucket( bucketId: String @@ -224,11 +229,12 @@ open class Storage: Service { /// Get a list of all the user files. You can use the query params to filter /// your results. /// - /// @param String bucketId - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.FileList /// open func listFiles( bucketId: String, @@ -278,12 +284,13 @@ open class Storage: Service { /// chunking logic will be managed by the SDK internally. /// /// - /// @param String bucketId - /// @param String fileId - /// @param InputFile file - /// @param [String] permissions - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - fileId: String + /// - file: InputFile + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.File /// open func createFile( bucketId: String, @@ -326,10 +333,11 @@ open class Storage: Service { /// Get a file by its unique ID. This endpoint response returns a JSON object /// with the file metadata. /// - /// @param String bucketId - /// @param String fileId - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - fileId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.File /// open func getFile( bucketId: String, @@ -360,12 +368,13 @@ open class Storage: Service { /// Update a file by its unique ID. Only users with write permissions have /// access to update this resource. /// - /// @param String bucketId - /// @param String fileId - /// @param String name - /// @param [String] permissions - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - fileId: String + /// - name: String (optional) + /// - permissions: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.File /// open func updateFile( bucketId: String, @@ -403,10 +412,11 @@ open class Storage: Service { /// Delete a file by its unique ID. Only users with write permissions have /// access to delete this resource. /// - /// @param String bucketId - /// @param String fileId - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - fileId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteFile( bucketId: String, @@ -434,11 +444,12 @@ open class Storage: Service { /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. /// - /// @param String bucketId - /// @param String fileId - /// @param String token - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - fileId: String + /// - token: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getFileDownload( bucketId: String, @@ -471,22 +482,23 @@ open class Storage: Service { /// string arguments for cutting and resizing your preview image. Preview is /// supported only for image files smaller than 10MB. /// - /// @param String bucketId - /// @param String fileId - /// @param Int width - /// @param Int height - /// @param AppwriteEnums.ImageGravity gravity - /// @param Int quality - /// @param Int borderWidth - /// @param String borderColor - /// @param Int borderRadius - /// @param Double opacity - /// @param Int rotation - /// @param String background - /// @param AppwriteEnums.ImageFormat output - /// @param String token - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - fileId: String + /// - width: Int (optional) + /// - height: Int (optional) + /// - gravity: AppwriteEnums.ImageGravity (optional) + /// - quality: Int (optional) + /// - borderWidth: Int (optional) + /// - borderColor: String (optional) + /// - borderRadius: Int (optional) + /// - opacity: Double (optional) + /// - rotation: Int (optional) + /// - background: String (optional) + /// - output: AppwriteEnums.ImageFormat (optional) + /// - token: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getFilePreview( bucketId: String, @@ -539,11 +551,12 @@ open class Storage: Service { /// download method but returns with no 'Content-Disposition: attachment' /// header. /// - /// @param String bucketId - /// @param String fileId - /// @param String token - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - fileId: String + /// - token: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: ByteBuffer /// open func getFileView( bucketId: String, diff --git a/Sources/Appwrite/Services/Teams.swift b/Sources/Appwrite/Services/Teams.swift index 6b410ee..5441073 100644 --- a/Sources/Appwrite/Services/Teams.swift +++ b/Sources/Appwrite/Services/Teams.swift @@ -12,10 +12,11 @@ open class Teams: Service { /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.TeamList /// open func list( queries: [String]? = nil, @@ -48,10 +49,11 @@ open class Teams: Service { /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.TeamList /// open func list( queries: [String]? = nil, @@ -69,11 +71,12 @@ open class Teams: Service { /// assigned as the owner of the team. Only the users with the owner role can /// invite new members, add new owners and delete or update the team. /// - /// @param String teamId - /// @param String name - /// @param [String] roles - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - name: String + /// - roles: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Team /// open func create( teamId: String, @@ -111,11 +114,12 @@ open class Teams: Service { /// assigned as the owner of the team. Only the users with the owner role can /// invite new members, add new owners and delete or update the team. /// - /// @param String teamId - /// @param String name - /// @param [String] roles - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - name: String + /// - roles: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Team /// open func create( teamId: String, @@ -133,9 +137,10 @@ open class Teams: Service { /// /// Get a team by its ID. All team members have read access for this resource. /// - /// @param String teamId - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Team /// open func get( teamId: String, @@ -164,9 +169,10 @@ open class Teams: Service { /// /// Get a team by its ID. All team members have read access for this resource. /// - /// @param String teamId - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Team /// open func get( teamId: String @@ -180,10 +186,11 @@ open class Teams: Service { /// /// Update the team's name by its unique ID. /// - /// @param String teamId - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - name: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Team /// open func updateName( teamId: String, @@ -217,10 +224,11 @@ open class Teams: Service { /// /// Update the team's name by its unique ID. /// - /// @param String teamId - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - name: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Team /// open func updateName( teamId: String, @@ -237,9 +245,10 @@ open class Teams: Service { /// Delete a team using its ID. Only team members with the owner role can /// delete the team. /// - /// @param String teamId - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func delete( teamId: String @@ -265,11 +274,12 @@ open class Teams: Service { /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. /// - /// @param String teamId - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MembershipList /// open func listMemberships( teamId: String, @@ -322,15 +332,16 @@ open class Teams: Service { /// added as a platform on the Appwrite Console. /// /// - /// @param String teamId - /// @param [String] roles - /// @param String email - /// @param String userId - /// @param String phone - /// @param String url - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - roles: [String] + /// - email: String (optional) + /// - userId: String (optional) + /// - phone: String (optional) + /// - url: String (optional) + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Membership /// open func createMembership( teamId: String, @@ -375,10 +386,11 @@ open class Teams: Service { /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. /// - /// @param String teamId - /// @param String membershipId - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - membershipId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Membership /// open func getMembership( teamId: String, @@ -411,11 +423,12 @@ open class Teams: Service { /// permissions](https://appwrite.io/docs/permissions). /// /// - /// @param String teamId - /// @param String membershipId - /// @param [String] roles - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - membershipId: String + /// - roles: [String] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Membership /// open func updateMembership( teamId: String, @@ -452,10 +465,11 @@ open class Teams: Service { /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. /// - /// @param String teamId - /// @param String membershipId - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - membershipId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteMembership( teamId: String, @@ -487,12 +501,13 @@ open class Teams: Service { /// created. /// /// - /// @param String teamId - /// @param String membershipId - /// @param String userId - /// @param String secret - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - membershipId: String + /// - userId: String + /// - secret: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Membership /// open func updateMembershipStatus( teamId: String, @@ -531,9 +546,10 @@ open class Teams: Service { /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). /// - /// @param String teamId - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func getPrefs( teamId: String, @@ -564,9 +580,10 @@ open class Teams: Service { /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). /// - /// @param String teamId - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func getPrefs( teamId: String @@ -582,10 +599,11 @@ open class Teams: Service { /// stored as is and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws an error if exceeded. /// - /// @param String teamId - /// @param Any prefs - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - prefs: Any + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func updatePrefs( teamId: String, @@ -621,10 +639,11 @@ open class Teams: Service { /// stored as is and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws an error if exceeded. /// - /// @param String teamId - /// @param Any prefs - /// @throws Exception - /// @return array + /// - Parameters: + /// - teamId: String + /// - prefs: Any + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func updatePrefs( teamId: String, diff --git a/Sources/Appwrite/Services/Tokens.swift b/Sources/Appwrite/Services/Tokens.swift index b579e0f..02dbc4c 100644 --- a/Sources/Appwrite/Services/Tokens.swift +++ b/Sources/Appwrite/Services/Tokens.swift @@ -12,11 +12,12 @@ open class Tokens: Service { /// List all the tokens created for a specific file or bucket. You can use the /// query params to filter your results. /// - /// @param String bucketId - /// @param String fileId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - fileId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ResourceTokenList /// open func list( bucketId: String, @@ -50,11 +51,12 @@ open class Tokens: Service { /// Create a new token. A token is linked to a file. Token can be passed as a /// request URL search parameter. /// - /// @param String bucketId - /// @param String fileId - /// @param String expire - /// @throws Exception - /// @return array + /// - Parameters: + /// - bucketId: String + /// - fileId: String + /// - expire: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ResourceToken /// open func createFileToken( bucketId: String, @@ -89,9 +91,10 @@ open class Tokens: Service { /// /// Get a token by its unique ID. /// - /// @param String tokenId - /// @throws Exception - /// @return array + /// - Parameters: + /// - tokenId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ResourceToken /// open func get( tokenId: String @@ -120,10 +123,11 @@ open class Tokens: Service { /// Update a token by its unique ID. Use this endpoint to update a token's /// expiry date. /// - /// @param String tokenId - /// @param String expire - /// @throws Exception - /// @return array + /// - Parameters: + /// - tokenId: String + /// - expire: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.ResourceToken /// open func update( tokenId: String, @@ -156,9 +160,10 @@ open class Tokens: Service { /// /// Delete a token by its unique ID. /// - /// @param String tokenId - /// @throws Exception - /// @return array + /// - Parameters: + /// - tokenId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func delete( tokenId: String diff --git a/Sources/Appwrite/Services/Users.swift b/Sources/Appwrite/Services/Users.swift index 02505e6..a2d3d6b 100644 --- a/Sources/Appwrite/Services/Users.swift +++ b/Sources/Appwrite/Services/Users.swift @@ -12,10 +12,11 @@ open class Users: Service { /// Get a list of all the project's users. You can use the query params to /// filter your results. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.UserList /// open func list( queries: [String]? = nil, @@ -48,10 +49,11 @@ open class Users: Service { /// Get a list of all the project's users. You can use the query params to /// filter your results. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.UserList /// open func list( queries: [String]? = nil, @@ -67,13 +69,14 @@ open class Users: Service { /// /// Create a new user. /// - /// @param String userId - /// @param String email - /// @param String phone - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String (optional) + /// - phone: String (optional) + /// - password: String (optional) + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func create( userId: String, @@ -113,13 +116,14 @@ open class Users: Service { /// /// Create a new user. /// - /// @param String userId - /// @param String email - /// @param String phone - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String (optional) + /// - phone: String (optional) + /// - password: String (optional) + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func create( userId: String, @@ -144,12 +148,13 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createArgon2User( userId: String, @@ -190,12 +195,13 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createArgon2User( userId: String, @@ -218,12 +224,13 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createBcryptUser( userId: String, @@ -264,12 +271,13 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createBcryptUser( userId: String, @@ -289,10 +297,11 @@ open class Users: Service { /// /// Get identities for all users. /// - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.IdentityList /// open func listIdentities( queries: [String]? = nil, @@ -323,9 +332,10 @@ open class Users: Service { /// /// Delete an identity by its unique ID. /// - /// @param String identityId - /// @throws Exception - /// @return array + /// - Parameters: + /// - identityId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteIdentity( identityId: String @@ -352,12 +362,13 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createMD5User( userId: String, @@ -398,12 +409,13 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createMD5User( userId: String, @@ -426,12 +438,13 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createPHPassUser( userId: String, @@ -472,12 +485,13 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createPHPassUser( userId: String, @@ -500,17 +514,18 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String passwordSalt - /// @param Int passwordCpu - /// @param Int passwordMemory - /// @param Int passwordParallel - /// @param Int passwordLength - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - passwordSalt: String + /// - passwordCpu: Int + /// - passwordMemory: Int + /// - passwordParallel: Int + /// - passwordLength: Int + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createScryptUser( userId: String, @@ -561,17 +576,18 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String passwordSalt - /// @param Int passwordCpu - /// @param Int passwordMemory - /// @param Int passwordParallel - /// @param Int passwordLength - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - passwordSalt: String + /// - passwordCpu: Int + /// - passwordMemory: Int + /// - passwordParallel: Int + /// - passwordLength: Int + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createScryptUser( userId: String, @@ -605,15 +621,16 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String passwordSalt - /// @param String passwordSaltSeparator - /// @param String passwordSignerKey - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - passwordSalt: String + /// - passwordSaltSeparator: String + /// - passwordSignerKey: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createScryptModifiedUser( userId: String, @@ -661,15 +678,16 @@ open class Users: Service { /// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to /// create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param String passwordSalt - /// @param String passwordSaltSeparator - /// @param String passwordSignerKey - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - passwordSalt: String + /// - passwordSaltSeparator: String + /// - passwordSignerKey: String + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createScryptModifiedUser( userId: String, @@ -698,13 +716,14 @@ open class Users: Service { /// the [POST /users](https://appwrite.io/docs/server/users#usersCreate) /// endpoint to create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param AppwriteEnums.PasswordHash passwordVersion - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - passwordVersion: AppwriteEnums.PasswordHash (optional) + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createSHAUser( userId: String, @@ -747,13 +766,14 @@ open class Users: Service { /// the [POST /users](https://appwrite.io/docs/server/users#usersCreate) /// endpoint to create users with a plain text password. /// - /// @param String userId - /// @param String email - /// @param String password - /// @param AppwriteEnums.PasswordHash passwordVersion - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - password: String + /// - passwordVersion: AppwriteEnums.PasswordHash (optional) + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func createSHAUser( userId: String, @@ -775,9 +795,10 @@ open class Users: Service { /// /// Get a user by its unique ID. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func get( userId: String, @@ -806,9 +827,10 @@ open class Users: Service { /// /// Get a user by its unique ID. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func get( userId: String @@ -827,9 +849,10 @@ open class Users: Service { /// [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) /// endpoint instead. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func delete( userId: String @@ -853,10 +876,11 @@ open class Users: Service { /// /// Update the user email by its unique ID. /// - /// @param String userId - /// @param String email - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateEmail( userId: String, @@ -890,10 +914,11 @@ open class Users: Service { /// /// Update the user email by its unique ID. /// - /// @param String userId - /// @param String email - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - email: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateEmail( userId: String, @@ -911,11 +936,12 @@ open class Users: Service { /// can use the resulting JWT to authenticate on behalf of the user. The JWT /// secret will become invalid if the session it uses gets deleted. /// - /// @param String userId - /// @param String sessionId - /// @param Int duration - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - sessionId: String (optional) + /// - duration: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Jwt /// open func createJWT( userId: String, @@ -955,10 +981,11 @@ open class Users: Service { /// developer to grant access without an invitation. See the [Permissions /// docs](https://appwrite.io/docs/permissions) for more info. /// - /// @param String userId - /// @param [String] labels - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - labels: [String] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateLabels( userId: String, @@ -997,10 +1024,11 @@ open class Users: Service { /// developer to grant access without an invitation. See the [Permissions /// docs](https://appwrite.io/docs/permissions) for more info. /// - /// @param String userId - /// @param [String] labels - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - labels: [String] + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateLabels( userId: String, @@ -1016,10 +1044,11 @@ open class Users: Service { /// /// Get the user activity logs list by its unique ID. /// - /// @param String userId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.LogList /// open func listLogs( userId: String, @@ -1050,11 +1079,12 @@ open class Users: Service { /// /// Get the user membership list by its unique ID. /// - /// @param String userId - /// @param [String] queries - /// @param String search - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - queries: [String] (optional) + /// - search: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MembershipList /// open func listMemberships( userId: String, @@ -1087,10 +1117,11 @@ open class Users: Service { /// /// Enable or disable MFA on a user account. /// - /// @param String userId - /// @param Bool mfa - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - mfa: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateMfa( userId: String, @@ -1124,10 +1155,11 @@ open class Users: Service { /// /// Enable or disable MFA on a user account. /// - /// @param String userId - /// @param Bool mfa - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - mfa: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateMfa( userId: String, @@ -1143,10 +1175,11 @@ open class Users: Service { /// /// Delete an authenticator app. /// - /// @param String userId - /// @param AppwriteEnums.AuthenticatorType type - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - type: AppwriteEnums.AuthenticatorType + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteMfaAuthenticator( userId: String, @@ -1172,9 +1205,10 @@ open class Users: Service { /// /// List the factors available on the account to be used as a MFA challange. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaFactors /// open func listMfaFactors( userId: String @@ -1205,9 +1239,10 @@ open class Users: Service { /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes /// open func getMfaRecoveryCodes( userId: String @@ -1238,9 +1273,10 @@ open class Users: Service { /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes /// open func updateMfaRecoveryCodes( userId: String @@ -1273,9 +1309,10 @@ open class Users: Service { /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method by client SDK. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.MfaRecoveryCodes /// open func createMfaRecoveryCodes( userId: String @@ -1305,10 +1342,11 @@ open class Users: Service { /// /// Update the user name by its unique ID. /// - /// @param String userId - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - name: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateName( userId: String, @@ -1342,10 +1380,11 @@ open class Users: Service { /// /// Update the user name by its unique ID. /// - /// @param String userId - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - name: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateName( userId: String, @@ -1361,10 +1400,11 @@ open class Users: Service { /// /// Update the user password by its unique ID. /// - /// @param String userId - /// @param String password - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - password: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePassword( userId: String, @@ -1398,10 +1438,11 @@ open class Users: Service { /// /// Update the user password by its unique ID. /// - /// @param String userId - /// @param String password - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - password: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePassword( userId: String, @@ -1417,10 +1458,11 @@ open class Users: Service { /// /// Update the user phone by its unique ID. /// - /// @param String userId - /// @param String number - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - number: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePhone( userId: String, @@ -1454,10 +1496,11 @@ open class Users: Service { /// /// Update the user phone by its unique ID. /// - /// @param String userId - /// @param String number - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - number: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePhone( userId: String, @@ -1473,9 +1516,10 @@ open class Users: Service { /// /// Get the user preferences by its unique ID. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func getPrefs( userId: String, @@ -1504,9 +1548,10 @@ open class Users: Service { /// /// Get the user preferences by its unique ID. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func getPrefs( userId: String @@ -1522,10 +1567,11 @@ open class Users: Service { /// as is, and replaces any previous value. The maximum allowed prefs size is /// 64kB and throws error if exceeded. /// - /// @param String userId - /// @param Any prefs - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - prefs: Any + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func updatePrefs( userId: String, @@ -1561,10 +1607,11 @@ open class Users: Service { /// as is, and replaces any previous value. The maximum allowed prefs size is /// 64kB and throws error if exceeded. /// - /// @param String userId - /// @param Any prefs - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - prefs: Any + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Preferences /// open func updatePrefs( userId: String, @@ -1580,9 +1627,10 @@ open class Users: Service { /// /// Get the user sessions list by its unique ID. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.SessionList /// open func listSessions( userId: String @@ -1615,9 +1663,10 @@ open class Users: Service { /// /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) /// endpoint. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Session /// open func createSession( userId: String @@ -1647,9 +1696,10 @@ open class Users: Service { /// /// Delete all user's sessions by using the user's unique ID. /// - /// @param String userId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteSessions( userId: String @@ -1673,10 +1723,11 @@ open class Users: Service { /// /// Delete a user sessions by its unique ID. /// - /// @param String userId - /// @param String sessionId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - sessionId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteSession( userId: String, @@ -1703,10 +1754,11 @@ open class Users: Service { /// Update the user status by its unique ID. Use this endpoint as an /// alternative to deleting a user if you want to keep user's ID reserved. /// - /// @param String userId - /// @param Bool status - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - status: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateStatus( userId: String, @@ -1741,10 +1793,11 @@ open class Users: Service { /// Update the user status by its unique ID. Use this endpoint as an /// alternative to deleting a user if you want to keep user's ID reserved. /// - /// @param String userId - /// @param Bool status - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - status: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateStatus( userId: String, @@ -1760,10 +1813,11 @@ open class Users: Service { /// /// List the messaging targets that are associated with a user. /// - /// @param String userId - /// @param [String] queries - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - queries: [String] (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.TargetList /// open func listTargets( userId: String, @@ -1794,14 +1848,15 @@ open class Users: Service { /// /// Create a messaging target. /// - /// @param String userId - /// @param String targetId - /// @param AppwriteEnums.MessagingProviderType providerType - /// @param String identifier - /// @param String providerId - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - targetId: String + /// - providerType: AppwriteEnums.MessagingProviderType + /// - identifier: String + /// - providerId: String (optional) + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Target /// open func createTarget( userId: String, @@ -1842,10 +1897,11 @@ open class Users: Service { /// /// Get a user's push notification target by ID. /// - /// @param String userId - /// @param String targetId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - targetId: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Target /// open func getTarget( userId: String, @@ -1875,13 +1931,14 @@ open class Users: Service { /// /// Update a messaging target. /// - /// @param String userId - /// @param String targetId - /// @param String identifier - /// @param String providerId - /// @param String name - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - targetId: String + /// - identifier: String (optional) + /// - providerId: String (optional) + /// - name: String (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Target /// open func updateTarget( userId: String, @@ -1920,10 +1977,11 @@ open class Users: Service { /// /// Delete a messaging target. /// - /// @param String userId - /// @param String targetId - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - targetId: String + /// - Throws: Exception if the request fails + /// - Returns: Any /// open func deleteTarget( userId: String, @@ -1953,11 +2011,12 @@ open class Users: Service { /// endpoint to complete the login process. /// /// - /// @param String userId - /// @param Int length - /// @param Int expire - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - length: Int (optional) + /// - expire: Int (optional) + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token /// open func createToken( userId: String, @@ -1992,10 +2051,11 @@ open class Users: Service { /// /// Update the user email verification status by its unique ID. /// - /// @param String userId - /// @param Bool emailVerification - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - emailVerification: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateEmailVerification( userId: String, @@ -2029,10 +2089,11 @@ open class Users: Service { /// /// Update the user email verification status by its unique ID. /// - /// @param String userId - /// @param Bool emailVerification - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - emailVerification: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updateEmailVerification( userId: String, @@ -2048,10 +2109,11 @@ open class Users: Service { /// /// Update the user phone verification status by its unique ID. /// - /// @param String userId - /// @param Bool phoneVerification - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - phoneVerification: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePhoneVerification( userId: String, @@ -2085,10 +2147,11 @@ open class Users: Service { /// /// Update the user phone verification status by its unique ID. /// - /// @param String userId - /// @param Bool phoneVerification - /// @throws Exception - /// @return array + /// - Parameters: + /// - userId: String + /// - phoneVerification: Bool + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.User /// open func updatePhoneVerification( userId: String, diff --git a/Sources/AppwriteEnums/BuildRuntime.swift b/Sources/AppwriteEnums/BuildRuntime.swift index 90ca969..dc9b179 100644 --- a/Sources/AppwriteEnums/BuildRuntime.swift +++ b/Sources/AppwriteEnums/BuildRuntime.swift @@ -38,6 +38,7 @@ public enum BuildRuntime: String, CustomStringConvertible { case dart31 = "dart-3.1" case dart33 = "dart-3.3" case dart35 = "dart-3.5" + case dart38 = "dart-3.8" case dotnet60 = "dotnet-6.0" case dotnet70 = "dotnet-7.0" case dotnet80 = "dotnet-8.0" @@ -64,6 +65,7 @@ public enum BuildRuntime: String, CustomStringConvertible { case flutter324 = "flutter-3.24" case flutter327 = "flutter-3.27" case flutter329 = "flutter-3.29" + case flutter332 = "flutter-3.32" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/ImageFormat.swift b/Sources/AppwriteEnums/ImageFormat.swift index 70110ff..c1a6694 100644 --- a/Sources/AppwriteEnums/ImageFormat.swift +++ b/Sources/AppwriteEnums/ImageFormat.swift @@ -7,6 +7,7 @@ public enum ImageFormat: String, CustomStringConvertible { case webp = "webp" case heic = "heic" case avif = "avif" + case gif = "gif" public var description: String { return rawValue diff --git a/Sources/AppwriteEnums/Runtime.swift b/Sources/AppwriteEnums/Runtime.swift index 5a6cccf..a461f31 100644 --- a/Sources/AppwriteEnums/Runtime.swift +++ b/Sources/AppwriteEnums/Runtime.swift @@ -38,6 +38,7 @@ public enum Runtime: String, CustomStringConvertible { case dart31 = "dart-3.1" case dart33 = "dart-3.3" case dart35 = "dart-3.5" + case dart38 = "dart-3.8" case dotnet60 = "dotnet-6.0" case dotnet70 = "dotnet-7.0" case dotnet80 = "dotnet-8.0" @@ -64,6 +65,7 @@ public enum Runtime: String, CustomStringConvertible { case flutter324 = "flutter-3.24" case flutter327 = "flutter-3.27" case flutter329 = "flutter-3.29" + case flutter332 = "flutter-3.32" public var description: String { return rawValue diff --git a/Sources/AppwriteModels/AttributeBoolean.swift b/Sources/AppwriteModels/AttributeBoolean.swift index 31522c2..feb0462 100644 --- a/Sources/AppwriteModels/AttributeBoolean.swift +++ b/Sources/AppwriteModels/AttributeBoolean.swift @@ -114,11 +114,11 @@ open class AttributeBoolean: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + 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 + default: map["default"] as? Bool ) } } diff --git a/Sources/AppwriteModels/AttributeDatetime.swift b/Sources/AppwriteModels/AttributeDatetime.swift index ac80231..6922821 100644 --- a/Sources/AppwriteModels/AttributeDatetime.swift +++ b/Sources/AppwriteModels/AttributeDatetime.swift @@ -123,12 +123,12 @@ open class AttributeDatetime: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + 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 + default: map["default"] as? String ) } } diff --git a/Sources/AppwriteModels/AttributeEmail.swift b/Sources/AppwriteModels/AttributeEmail.swift index 8e57b2c..a8aa6d2 100644 --- a/Sources/AppwriteModels/AttributeEmail.swift +++ b/Sources/AppwriteModels/AttributeEmail.swift @@ -123,12 +123,12 @@ open class AttributeEmail: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + 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 + default: map["default"] as? String ) } } diff --git a/Sources/AppwriteModels/AttributeEnum.swift b/Sources/AppwriteModels/AttributeEnum.swift index e232869..e5f3482 100644 --- a/Sources/AppwriteModels/AttributeEnum.swift +++ b/Sources/AppwriteModels/AttributeEnum.swift @@ -132,13 +132,13 @@ open class AttributeEnum: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + 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 + default: map["default"] as? String ) } } diff --git a/Sources/AppwriteModels/AttributeFloat.swift b/Sources/AppwriteModels/AttributeFloat.swift index 676f317..fceef5f 100644 --- a/Sources/AppwriteModels/AttributeFloat.swift +++ b/Sources/AppwriteModels/AttributeFloat.swift @@ -132,13 +132,13 @@ open class AttributeFloat: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + 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 + default: map["default"] as? Double ) } } diff --git a/Sources/AppwriteModels/AttributeInteger.swift b/Sources/AppwriteModels/AttributeInteger.swift index 06d3a69..acb5d36 100644 --- a/Sources/AppwriteModels/AttributeInteger.swift +++ b/Sources/AppwriteModels/AttributeInteger.swift @@ -132,13 +132,13 @@ open class AttributeInteger: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + 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 + default: map["default"] as? Int ) } } diff --git a/Sources/AppwriteModels/AttributeIp.swift b/Sources/AppwriteModels/AttributeIp.swift index 7904155..47b46de 100644 --- a/Sources/AppwriteModels/AttributeIp.swift +++ b/Sources/AppwriteModels/AttributeIp.swift @@ -123,12 +123,12 @@ open class AttributeIp: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + 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 + default: map["default"] as? String ) } } diff --git a/Sources/AppwriteModels/AttributeRelationship.swift b/Sources/AppwriteModels/AttributeRelationship.swift index a1f8cd7..c7c38d7 100644 --- a/Sources/AppwriteModels/AttributeRelationship.swift +++ b/Sources/AppwriteModels/AttributeRelationship.swift @@ -159,7 +159,7 @@ open class AttributeRelationship: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + required: map["required"] as! Bool, array: map["array"] as? Bool, createdAt: map["$createdAt"] as! String, updatedAt: map["$updatedAt"] as! String, diff --git a/Sources/AppwriteModels/AttributeString.swift b/Sources/AppwriteModels/AttributeString.swift index 9ed9acc..b7da6a8 100644 --- a/Sources/AppwriteModels/AttributeString.swift +++ b/Sources/AppwriteModels/AttributeString.swift @@ -132,12 +132,12 @@ open class AttributeString: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + 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, + default: map["default"] as? String, encrypt: map["encrypt"] as? Bool ) } diff --git a/Sources/AppwriteModels/AttributeUrl.swift b/Sources/AppwriteModels/AttributeUrl.swift index cfbeac5..b45607b 100644 --- a/Sources/AppwriteModels/AttributeUrl.swift +++ b/Sources/AppwriteModels/AttributeUrl.swift @@ -123,12 +123,12 @@ open class AttributeUrl: Codable { type: map["type"] as! String, status: map["status"] as! String, error: map["error"] as! String, - `required`: map["required"] as! Bool, + 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 + default: map["default"] as? String ) } } diff --git a/Sources/AppwriteModels/Document.swift b/Sources/AppwriteModels/Document.swift index 744a03e..f076cc5 100644 --- a/Sources/AppwriteModels/Document.swift +++ b/Sources/AppwriteModels/Document.swift @@ -6,6 +6,7 @@ open class Document: Codable { enum CodingKeys: String, CodingKey { case id = "$id" + case sequence = "$sequence" case collectionId = "$collectionId" case databaseId = "$databaseId" case createdAt = "$createdAt" @@ -17,6 +18,9 @@ open class Document: Codable { /// Document ID. public let id: String + /// Document automatically incrementing ID. + public let sequence: Int + /// Collection ID. public let collectionId: String @@ -37,6 +41,7 @@ open class Document: Codable { init( id: String, + sequence: Int, collectionId: String, databaseId: String, createdAt: String, @@ -45,6 +50,7 @@ open class Document: Codable { data: T ) { self.id = id + self.sequence = sequence self.collectionId = collectionId self.databaseId = databaseId self.createdAt = createdAt @@ -57,6 +63,7 @@ open class Document: Codable { let container = try decoder.container(keyedBy: CodingKeys.self) self.id = try container.decode(String.self, forKey: .id) + self.sequence = try container.decode(Int.self, forKey: .sequence) self.collectionId = try container.decode(String.self, forKey: .collectionId) self.databaseId = try container.decode(String.self, forKey: .databaseId) self.createdAt = try container.decode(String.self, forKey: .createdAt) @@ -69,6 +76,7 @@ open class Document: Codable { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) + try container.encode(sequence, forKey: .sequence) try container.encode(collectionId, forKey: .collectionId) try container.encode(databaseId, forKey: .databaseId) try container.encode(createdAt, forKey: .createdAt) @@ -80,6 +88,7 @@ open class Document: Codable { public func toMap() -> [String: Any] { return [ "$id": id as Any, + "$sequence": sequence as Any, "$collectionId": collectionId as Any, "$databaseId": databaseId as Any, "$createdAt": createdAt as Any, @@ -92,6 +101,7 @@ open class Document: Codable { public static func from(map: [String: Any] ) -> Document { return Document( id: map["$id"] as? String ?? "", + sequence: map["$sequence"] as? Int ?? 0, collectionId: map["$collectionId"] as? String ?? "", databaseId: map["$databaseId"] as? String ?? "", createdAt: map["$createdAt"] as? String ?? "", diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 4ee2104..8fcb1c6 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,6 +2,7 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // Your secret API key .setJWT("") // Your secret JSON Web Token diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..88ba9ae --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.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 databases = Databases(client) + +let document = try await databases.decrementDocumentAttribute( + databaseId: "", + collectionId: "", + documentId: "", + attribute: "", + value: 0, // optional + min: 0 // optional +) + diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..452b200 --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.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 databases = Databases(client) + +let document = try await databases.incrementDocumentAttribute( + databaseId: "", + collectionId: "", + documentId: "", + attribute: "", + value: 0, // optional + max: 0 // optional +) + diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 353cc5c..544f02f 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -10,6 +10,6 @@ let databases = Databases(client) let documentList = try await databases.upsertDocuments( databaseId: "", collectionId: "", - documents: [] // optional + documents: [] ) From f4cd1714c2a69e81e1883adca5db197f9defd2e0 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Jul 2025 16:18:26 +0000 Subject: [PATCH 2/5] chore: regenerate --- README.md | 6 +- Sources/Appwrite/Client.swift | 4 +- Sources/Appwrite/Services/Account.swift | 2 + Sources/Appwrite/Services/Databases.swift | 89 +- Sources/Appwrite/Services/Tables.swift | 2367 +++++++++++++++++ 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 | 124 + 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/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/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-document.md | 1 - docs/examples/databases/create-documents.md | 1 + docs/examples/databases/upsert-document.md | 7 +- docs/examples/databases/upsert-documents.md | 5 +- docs/examples/tables/create-boolean-column.md | 18 + .../examples/tables/create-datetime-column.md | 18 + docs/examples/tables/create-email-column.md | 18 + docs/examples/tables/create-enum-column.md | 19 + docs/examples/tables/create-float-column.md | 20 + docs/examples/tables/create-index.md | 20 + docs/examples/tables/create-integer-column.md | 20 + docs/examples/tables/create-ip-column.md | 18 + .../tables/create-relationship-column.md | 21 + docs/examples/tables/create-row.md | 18 + docs/examples/tables/create-rows.md | 15 + docs/examples/tables/create-string-column.md | 20 + docs/examples/tables/create-url-column.md | 18 + docs/examples/tables/create.md | 18 + docs/examples/tables/decrement-row-column.md | 18 + docs/examples/tables/delete-column.md | 15 + docs/examples/tables/delete-index.md | 15 + docs/examples/tables/delete-row.md | 15 + docs/examples/tables/delete-rows.md | 15 + docs/examples/tables/delete.md | 14 + docs/examples/tables/get-column.md | 15 + docs/examples/tables/get-index.md | 15 + docs/examples/tables/get-row.md | 16 + docs/examples/tables/get.md | 14 + docs/examples/tables/increment-row-column.md | 18 + docs/examples/tables/list-columns.md | 15 + docs/examples/tables/list-indexes.md | 15 + docs/examples/tables/list-rows.md | 15 + docs/examples/tables/list.md | 15 + docs/examples/tables/update-boolean-column.md | 18 + .../examples/tables/update-datetime-column.md | 18 + docs/examples/tables/update-email-column.md | 18 + docs/examples/tables/update-enum-column.md | 19 + docs/examples/tables/update-float-column.md | 20 + docs/examples/tables/update-integer-column.md | 20 + docs/examples/tables/update-ip-column.md | 18 + .../tables/update-relationship-column.md | 18 + docs/examples/tables/update-row.md | 17 + docs/examples/tables/update-rows.md | 16 + docs/examples/tables/update-string-column.md | 19 + docs/examples/tables/update-url-column.md | 18 + docs/examples/tables/update.md | 18 + docs/examples/tables/upsert-row.md | 16 + docs/examples/tables/upsert-rows.md | 14 + 102 files changed, 5230 insertions(+), 71 deletions(-) create mode 100644 Sources/Appwrite/Services/Tables.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/tables/create-boolean-column.md create mode 100644 docs/examples/tables/create-datetime-column.md create mode 100644 docs/examples/tables/create-email-column.md create mode 100644 docs/examples/tables/create-enum-column.md create mode 100644 docs/examples/tables/create-float-column.md create mode 100644 docs/examples/tables/create-index.md create mode 100644 docs/examples/tables/create-integer-column.md create mode 100644 docs/examples/tables/create-ip-column.md create mode 100644 docs/examples/tables/create-relationship-column.md create mode 100644 docs/examples/tables/create-row.md create mode 100644 docs/examples/tables/create-rows.md create mode 100644 docs/examples/tables/create-string-column.md create mode 100644 docs/examples/tables/create-url-column.md create mode 100644 docs/examples/tables/create.md create mode 100644 docs/examples/tables/decrement-row-column.md create mode 100644 docs/examples/tables/delete-column.md create mode 100644 docs/examples/tables/delete-index.md create mode 100644 docs/examples/tables/delete-row.md create mode 100644 docs/examples/tables/delete-rows.md create mode 100644 docs/examples/tables/delete.md create mode 100644 docs/examples/tables/get-column.md create mode 100644 docs/examples/tables/get-index.md create mode 100644 docs/examples/tables/get-row.md create mode 100644 docs/examples/tables/get.md create mode 100644 docs/examples/tables/increment-row-column.md create mode 100644 docs/examples/tables/list-columns.md create mode 100644 docs/examples/tables/list-indexes.md create mode 100644 docs/examples/tables/list-rows.md create mode 100644 docs/examples/tables/list.md create mode 100644 docs/examples/tables/update-boolean-column.md create mode 100644 docs/examples/tables/update-datetime-column.md create mode 100644 docs/examples/tables/update-email-column.md create mode 100644 docs/examples/tables/update-enum-column.md create mode 100644 docs/examples/tables/update-float-column.md create mode 100644 docs/examples/tables/update-integer-column.md create mode 100644 docs/examples/tables/update-ip-column.md create mode 100644 docs/examples/tables/update-relationship-column.md create mode 100644 docs/examples/tables/update-row.md create mode 100644 docs/examples/tables/update-rows.md create mode 100644 docs/examples/tables/update-string-column.md create mode 100644 docs/examples/tables/update-url-column.md create mode 100644 docs/examples/tables/update.md create mode 100644 docs/examples/tables/upsert-row.md create mode 100644 docs/examples/tables/upsert-rows.md diff --git a/README.md b/README.md index 1b70833..2ef5b9e 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/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 2f175f6..33284f7 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -196,6 +196,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 `Tables.list` instead.") open func listCollections( databaseId: String, queries: [String]? = nil, @@ -240,6 +241,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 `Tables.create` instead.") open func createCollection( databaseId: String, collectionId: String, @@ -286,6 +288,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 `Tables.get` instead.") open func getCollection( databaseId: String, collectionId: String @@ -324,6 +327,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 `Tables.update` instead.") open func updateCollection( databaseId: String, collectionId: String, @@ -370,6 +374,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 `Tables.delete` instead.") open func deleteCollection( databaseId: String, collectionId: String @@ -401,6 +406,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 `Tables.listColumns` instead.") open func listAttributes( databaseId: String, collectionId: String, @@ -443,6 +449,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 `Tables.createBooleanColumn` instead.") open func createBooleanAttribute( databaseId: String, collectionId: String, @@ -493,6 +500,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 `Tables.updateBooleanColumn` instead.") open func updateBooleanAttribute( databaseId: String, collectionId: String, @@ -542,6 +550,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 `Tables.createDatetimeColumn` instead.") open func createDatetimeAttribute( databaseId: String, collectionId: String, @@ -592,6 +601,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 `Tables.updateDatetimeColumn` instead.") open func updateDatetimeAttribute( databaseId: String, collectionId: String, @@ -642,6 +652,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 `Tables.createEmailColumn` instead.") open func createEmailAttribute( databaseId: String, collectionId: String, @@ -693,6 +704,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 `Tables.updateEmailColumn` instead.") open func updateEmailAttribute( databaseId: String, collectionId: String, @@ -730,8 +742,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 +757,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 `Tables.createEnumColumn` instead.") open func createEnumAttribute( databaseId: String, collectionId: String, @@ -799,6 +812,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 `Tables.updateEnumColumn` instead.") open func updateEnumAttribute( databaseId: String, collectionId: String, @@ -854,6 +868,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 `Tables.createFloatColumn` instead.") open func createFloatAttribute( databaseId: String, collectionId: String, @@ -911,6 +926,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 `Tables.updateFloatColumn` instead.") open func updateFloatAttribute( databaseId: String, collectionId: String, @@ -968,6 +984,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 `Tables.createIntegerColumn` instead.") open func createIntegerAttribute( databaseId: String, collectionId: String, @@ -1025,6 +1042,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 `Tables.updateIntegerColumn` instead.") open func updateIntegerAttribute( databaseId: String, collectionId: String, @@ -1079,6 +1097,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 `Tables.createIpColumn` instead.") open func createIpAttribute( databaseId: String, collectionId: String, @@ -1130,6 +1149,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 `Tables.updateIpColumn` instead.") open func updateIpAttribute( databaseId: String, collectionId: String, @@ -1183,6 +1203,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 `Tables.createRelationshipColumn` instead.") open func createRelationshipAttribute( databaseId: String, collectionId: String, @@ -1239,6 +1260,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 `Tables.createStringColumn` instead.") open func createStringAttribute( databaseId: String, collectionId: String, @@ -1295,6 +1317,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 `Tables.updateStringColumn` instead.") open func updateStringAttribute( databaseId: String, collectionId: String, @@ -1347,6 +1370,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 `Tables.createUrlColumn` instead.") open func createUrlAttribute( databaseId: String, collectionId: String, @@ -1398,6 +1422,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 `Tables.updateUrlColumn` instead.") open func updateUrlAttribute( databaseId: String, collectionId: String, @@ -1444,6 +1469,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 `Tables.getColumn` instead.") open func getAttribute( databaseId: String, collectionId: String, @@ -1475,6 +1501,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 `Tables.deleteColumn` instead.") open func deleteAttribute( databaseId: String, collectionId: String, @@ -1512,6 +1539,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 `Tables.updateRelationshipColumn` instead.") open func updateRelationshipAttribute( databaseId: String, collectionId: String, @@ -1557,6 +1585,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 `Tables.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -1597,6 +1626,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 `Tables.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -1625,6 +1655,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 `Tables.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -1675,6 +1706,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 `Tables.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -1709,6 +1741,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 `Tables.createRow` instead.") open func createDocuments( databaseId: String, collectionId: String, @@ -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 `Tables.createRow` instead.") open func createDocuments( databaseId: String, collectionId: String, @@ -1779,27 +1813,25 @@ open class Databases: Service { /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. + /// /// /// - Parameters: /// - databaseId: String /// - collectionId: String - /// - documents: [Any] /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Tables.upsertRows` instead.") open func upsertDocuments( databaseId: String, collectionId: String, - documents: [Any], nestedType: T.Type ) async throws -> AppwriteModels.DocumentList { let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents" .replacingOccurrences(of: "{databaseId}", with: databaseId) .replacingOccurrences(of: "{collectionId}", with: collectionId) - let apiParams: [String: Any?] = [ - "documents": documents - ] + let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ "content-type": "application/json" @@ -1827,23 +1859,22 @@ open class Databases: Service { /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. + /// /// /// - Parameters: /// - databaseId: String /// - collectionId: String - /// - documents: [Any] /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Tables.upsertRows` instead.") open func upsertDocuments( databaseId: String, - collectionId: String, - documents: [Any] + collectionId: String ) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> { return try await upsertDocuments( databaseId: databaseId, collectionId: collectionId, - documents: documents, nestedType: [String: AnyCodable].self ) } @@ -1865,6 +1896,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 `Tables.updateRows` instead.") open func updateDocuments( databaseId: String, collectionId: String, @@ -1915,6 +1947,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 `Tables.updateRows` instead.") open func updateDocuments( databaseId: String, collectionId: String, @@ -1945,6 +1978,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 `Tables.deleteRows` instead.") open func deleteDocuments( databaseId: String, collectionId: String, @@ -1991,6 +2025,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 `Tables.deleteRows` instead.") open func deleteDocuments( databaseId: String, collectionId: String, @@ -2016,6 +2051,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 `Tables.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -2059,6 +2095,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 `Tables.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -2088,17 +2125,14 @@ open class Databases: Service { /// - databaseId: String /// - collectionId: String /// - documentId: String - /// - data: Any - /// - permissions: [String] (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, documentId: String, - data: Any, - permissions: [String]? = nil, nestedType: T.Type ) async throws -> AppwriteModels.Document { let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -2106,10 +2140,7 @@ open class Databases: Service { .replacingOccurrences(of: "{collectionId}", with: collectionId) .replacingOccurrences(of: "{documentId}", with: documentId) - let apiParams: [String: Any?] = [ - "data": data, - "permissions": permissions - ] + let apiParams: [String: Any] = [:] let apiHeaders: [String: String] = [ "content-type": "application/json" @@ -2142,24 +2173,19 @@ open class Databases: Service { /// - databaseId: String /// - collectionId: String /// - documentId: String - /// - data: Any - /// - permissions: [String] (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, - documentId: String, - data: Any, - permissions: [String]? = nil + documentId: String ) async throws -> AppwriteModels.Document<[String: AnyCodable]> { return try await upsertDocument( databaseId: databaseId, collectionId: collectionId, documentId: documentId, - data: data, - permissions: permissions, nestedType: [String: AnyCodable].self ) } @@ -2177,6 +2203,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 `Tables.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -2225,6 +2252,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 `Tables.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -2252,6 +2280,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 `Tables.deleteRow` instead.") open func deleteDocument( databaseId: String, collectionId: String, @@ -2288,6 +2317,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 `Tables.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2338,6 +2368,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 `Tables.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2370,6 +2401,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 `Tables.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2420,6 +2452,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 `Tables.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2449,6 +2482,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 `Tables.listIndexes` instead.") open func listIndexes( databaseId: String, collectionId: String, @@ -2493,6 +2527,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 `Tables.createIndex` instead.") open func createIndex( databaseId: String, collectionId: String, @@ -2541,6 +2576,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 `Tables.getIndex` instead.") open func getIndex( databaseId: String, collectionId: String, @@ -2578,6 +2614,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 `Tables.deleteIndex` instead.") open func deleteIndex( databaseId: String, collectionId: String, diff --git a/Sources/Appwrite/Services/Tables.swift b/Sources/Appwrite/Services/Tables.swift new file mode 100644 index 0000000..221a61a --- /dev/null +++ b/Sources/Appwrite/Services/Tables.swift @@ -0,0 +1,2367 @@ +import AsyncHTTPClient +import Foundation +import NIO +import JSONCodable +import AppwriteEnums +import AppwriteModels + +/// The Tables service allows you to create structured tables of rows, query and filter lists of rows +open class Tables: Service { + + /// + /// 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 list( + databaseId: String, + queries: [String]? = nil, + search: String? = nil + ) async throws -> AppwriteModels.TableList { + let apiPath: String = "/databases/{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 create( + databaseId: String, + tableId: String, + name: String, + permissions: [String]? = nil, + rowSecurity: Bool? = nil, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Table { + let apiPath: String = "/databases/{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 get( + databaseId: String, + tableId: String + ) async throws -> AppwriteModels.Table { + let apiPath: String = "/databases/{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 update( + databaseId: String, + tableId: String, + name: String, + permissions: [String]? = nil, + rowSecurity: Bool? = nil, + enabled: Bool? = nil + ) async throws -> AppwriteModels.Table { + let apiPath: String = "/databases/{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 delete( + databaseId: String, + tableId: String + ) async throws -> Any { + let apiPath: String = "/databases/{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 attributes in the collection. + /// + /// - 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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 attributes listed. Your index should include all + /// the attributes 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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func upsertRows( + databaseId: String, + tableId: String, + nestedType: T.Type + ) async throws -> AppwriteModels.RowList { + let apiPath: String = "/databases/{databaseId}/tables/{tableId}/rows" + .replacingOccurrences(of: "{databaseId}", with: databaseId) + .replacingOccurrences(of: "{tableId}", with: tableId) + + let apiParams: [String: Any] = [:] + + 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 + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.RowList + /// + open func upsertRows( + databaseId: String, + tableId: String + ) async throws -> AppwriteModels.RowList<[String: AnyCodable]> { + return try await upsertRows( + databaseId: databaseId, + tableId: tableId, + 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 = "/databases/{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 = "/databases/{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 = "/databases/{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 + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func upsertRow( + databaseId: String, + tableId: String, + rowId: String, + nestedType: T.Type + ) async throws -> AppwriteModels.Row { + let apiPath: String = "/databases/{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" + ] + + 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 + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Row + /// + open func upsertRow( + databaseId: String, + tableId: String, + rowId: String + ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { + return try await upsertRow( + databaseId: databaseId, + tableId: tableId, + rowId: rowId, + 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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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/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..0857a35 --- /dev/null +++ b/Sources/AppwriteModels/ColumnIndex.swift @@ -0,0 +1,124 @@ +import Foundation +import JSONCodable + +/// Index +open class ColumnIndex: Codable { + + enum CodingKeys: String, CodingKey { + case key = "key" + case type = "type" + case status = "status" + case error = "error" + case columns = "columns" + case lengths = "lengths" + case orders = "orders" + case createdAt = "$createdAt" + case updatedAt = "$updatedAt" + } + + /// 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]? + + /// Index creation date in ISO 8601 format. + public let createdAt: String + + /// Index update date in ISO 8601 format. + public let updatedAt: String + + + init( + key: String, + type: String, + status: String, + error: String, + columns: [String], + lengths: [Int], + orders: [String]?, + createdAt: String, + updatedAt: String + ) { + self.key = key + self.type = type + self.status = status + self.error = error + self.columns = columns + 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.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) + 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(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) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(updatedAt, forKey: .updatedAt) + } + + public func toMap() -> [String: Any] { + return [ + "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, + "$createdAt": createdAt as Any, + "$updatedAt": updatedAt as Any + ] + } + + public static func from(map: [String: Any] ) -> ColumnIndex { + return ColumnIndex( + 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], + createdAt: map["$createdAt"] as! String, + updatedAt: map["$updatedAt"] 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/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/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-document.md b/docs/examples/databases/create-document.md index 8fcb1c6..4ee2104 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,7 +2,6 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // Your secret API key .setJWT("") // Your secret JSON Web Token diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 39a58ab..e4f8582 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -2,6 +2,7 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // .setKey("") // Your secret API key let databases = Databases(client) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index e78bd45..9c9684e 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -2,16 +2,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 + .setKey("") // Your secret API key + .setJWT("") // Your secret JSON Web Token let databases = Databases(client) let document = try await databases.upsertDocument( databaseId: "", collectionId: "", - documentId: "", - data: [:], - permissions: ["read("any")"] // optional + documentId: "" ) diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 544f02f..e63b9a3 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -2,14 +2,13 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID + .setAdmin("") // .setKey("") // Your secret API key let databases = Databases(client) let documentList = try await databases.upsertDocuments( databaseId: "", - collectionId: "", - documents: [] + collectionId: "" ) diff --git a/docs/examples/tables/create-boolean-column.md b/docs/examples/tables/create-boolean-column.md new file mode 100644 index 0000000..1b9627a --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnBoolean = try await tables.createBooleanColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: false, // optional + array: false // optional +) + diff --git a/docs/examples/tables/create-datetime-column.md b/docs/examples/tables/create-datetime-column.md new file mode 100644 index 0000000..e002fb8 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnDatetime = try await tables.createDatetimeColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", // optional + array: false // optional +) + diff --git a/docs/examples/tables/create-email-column.md b/docs/examples/tables/create-email-column.md new file mode 100644 index 0000000..338493d --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnEmail = try await tables.createEmailColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "email@example.com", // optional + array: false // optional +) + diff --git a/docs/examples/tables/create-enum-column.md b/docs/examples/tables/create-enum-column.md new file mode 100644 index 0000000..a6a9fff --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnEnum = try await tables.createEnumColumn( + databaseId: "", + tableId: "", + key: "", + elements: [], + required: false, + default: "", // optional + array: false // optional +) + diff --git a/docs/examples/tables/create-float-column.md b/docs/examples/tables/create-float-column.md new file mode 100644 index 0000000..12e4062 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnFloat = try await tables.createFloatColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + min: 0, // optional + max: 0, // optional + default: 0, // optional + array: false // optional +) + diff --git a/docs/examples/tables/create-index.md b/docs/examples/tables/create-index.md new file mode 100644 index 0000000..03dea1a --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnIndex = try await tables.createIndex( + databaseId: "", + tableId: "", + key: "", + type: .key, + columns: [], + orders: [], // optional + lengths: [] // optional +) + diff --git a/docs/examples/tables/create-integer-column.md b/docs/examples/tables/create-integer-column.md new file mode 100644 index 0000000..6c04294 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnInteger = try await tables.createIntegerColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + min: 0, // optional + max: 0, // optional + default: 0, // optional + array: false // optional +) + diff --git a/docs/examples/tables/create-ip-column.md b/docs/examples/tables/create-ip-column.md new file mode 100644 index 0000000..2cd0b27 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnIp = try await tables.createIpColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", // optional + array: false // optional +) + diff --git a/docs/examples/tables/create-relationship-column.md b/docs/examples/tables/create-relationship-column.md new file mode 100644 index 0000000..66b993c --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnRelationship = try await tables.createRelationshipColumn( + databaseId: "", + tableId: "", + relatedTableId: "", + type: .oneToOne, + twoWay: false, // optional + key: "", // optional + twoWayKey: "", // optional + onDelete: .cascade // optional +) + diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md new file mode 100644 index 0000000..a736355 --- /dev/null +++ b/docs/examples/tables/create-row.md @@ -0,0 +1,18 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // Your secret API key + .setJWT("") // Your secret JSON Web Token + +let tables = Tables(client) + +let row = try await tables.createRow( + databaseId: "", + tableId: "", + rowId: "", + data: [:], + permissions: ["read("any")"] // optional +) + diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md new file mode 100644 index 0000000..ee2095f --- /dev/null +++ b/docs/examples/tables/create-rows.md @@ -0,0 +1,15 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // + .setKey("") // Your secret API key + +let tables = Tables(client) + +let rowList = try await tables.createRows( + databaseId: "", + tableId: "", + rows: [] +) + diff --git a/docs/examples/tables/create-string-column.md b/docs/examples/tables/create-string-column.md new file mode 100644 index 0000000..e83ffdf --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnString = try await tables.createStringColumn( + databaseId: "", + tableId: "", + key: "", + size: 1, + required: false, + default: "", // optional + array: false, // optional + encrypt: false // optional +) + diff --git a/docs/examples/tables/create-url-column.md b/docs/examples/tables/create-url-column.md new file mode 100644 index 0000000..150b513 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnUrl = try await tables.createUrlColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "https://example.com", // optional + array: false // optional +) + diff --git a/docs/examples/tables/create.md b/docs/examples/tables/create.md new file mode 100644 index 0000000..0843dfd --- /dev/null +++ b/docs/examples/tables/create.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 tables = Tables(client) + +let table = try await tables.create( + databaseId: "", + tableId: "", + name: "", + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +) + diff --git a/docs/examples/tables/decrement-row-column.md b/docs/examples/tables/decrement-row-column.md new file mode 100644 index 0000000..ef24324 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let row = try await tables.decrementRowColumn( + databaseId: "", + tableId: "", + rowId: "", + column: "", + value: 0, // optional + min: 0 // optional +) + diff --git a/docs/examples/tables/delete-column.md b/docs/examples/tables/delete-column.md new file mode 100644 index 0000000..07f825d --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let result = try await tables.deleteColumn( + databaseId: "", + tableId: "", + key: "" +) + diff --git a/docs/examples/tables/delete-index.md b/docs/examples/tables/delete-index.md new file mode 100644 index 0000000..b6d2e5b --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let result = try await tables.deleteIndex( + databaseId: "", + tableId: "", + key: "" +) + diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md new file mode 100644 index 0000000..92bc387 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let result = try await tables.deleteRow( + databaseId: "", + tableId: "", + rowId: "" +) + diff --git a/docs/examples/tables/delete-rows.md b/docs/examples/tables/delete-rows.md new file mode 100644 index 0000000..d27fbce --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let rowList = try await tables.deleteRows( + databaseId: "", + tableId: "", + queries: [] // optional +) + diff --git a/docs/examples/tables/delete.md b/docs/examples/tables/delete.md new file mode 100644 index 0000000..aefa1d8 --- /dev/null +++ b/docs/examples/tables/delete.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 tables = Tables(client) + +let result = try await tables.delete( + databaseId: "", + tableId: "" +) + diff --git a/docs/examples/tables/get-column.md b/docs/examples/tables/get-column.md new file mode 100644 index 0000000..653f79d --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let result = try await tables.getColumn( + databaseId: "", + tableId: "", + key: "" +) + diff --git a/docs/examples/tables/get-index.md b/docs/examples/tables/get-index.md new file mode 100644 index 0000000..6835f56 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnIndex = try await tables.getIndex( + databaseId: "", + tableId: "", + key: "" +) + diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md new file mode 100644 index 0000000..e2ff10f --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let row = try await tables.getRow( + databaseId: "", + tableId: "", + rowId: "", + queries: [] // optional +) + diff --git a/docs/examples/tables/get.md b/docs/examples/tables/get.md new file mode 100644 index 0000000..610bf42 --- /dev/null +++ b/docs/examples/tables/get.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 tables = Tables(client) + +let table = try await tables.get( + databaseId: "", + tableId: "" +) + diff --git a/docs/examples/tables/increment-row-column.md b/docs/examples/tables/increment-row-column.md new file mode 100644 index 0000000..6ea883d --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let row = try await tables.incrementRowColumn( + databaseId: "", + tableId: "", + rowId: "", + column: "", + value: 0, // optional + max: 0 // optional +) + diff --git a/docs/examples/tables/list-columns.md b/docs/examples/tables/list-columns.md new file mode 100644 index 0000000..88c8613 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnList = try await tables.listColumns( + databaseId: "", + tableId: "", + queries: [] // optional +) + diff --git a/docs/examples/tables/list-indexes.md b/docs/examples/tables/list-indexes.md new file mode 100644 index 0000000..2ea8e99 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnIndexList = try await tables.listIndexes( + databaseId: "", + tableId: "", + queries: [] // optional +) + diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md new file mode 100644 index 0000000..ca2e5b0 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let rowList = try await tables.listRows( + databaseId: "", + tableId: "", + queries: [] // optional +) + diff --git a/docs/examples/tables/list.md b/docs/examples/tables/list.md new file mode 100644 index 0000000..e135b50 --- /dev/null +++ b/docs/examples/tables/list.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 tables = Tables(client) + +let tableList = try await tables.list( + databaseId: "", + queries: [], // optional + search: "" // optional +) + diff --git a/docs/examples/tables/update-boolean-column.md b/docs/examples/tables/update-boolean-column.md new file mode 100644 index 0000000..e0d1ea2 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnBoolean = try await tables.updateBooleanColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: false, + newKey: "" // optional +) + diff --git a/docs/examples/tables/update-datetime-column.md b/docs/examples/tables/update-datetime-column.md new file mode 100644 index 0000000..f09e279 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnDatetime = try await tables.updateDatetimeColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", + newKey: "" // optional +) + diff --git a/docs/examples/tables/update-email-column.md b/docs/examples/tables/update-email-column.md new file mode 100644 index 0000000..f7b8cc4 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnEmail = try await tables.updateEmailColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "email@example.com", + newKey: "" // optional +) + diff --git a/docs/examples/tables/update-enum-column.md b/docs/examples/tables/update-enum-column.md new file mode 100644 index 0000000..776da72 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnEnum = try await tables.updateEnumColumn( + databaseId: "", + tableId: "", + key: "", + elements: [], + required: false, + default: "", + newKey: "" // optional +) + diff --git a/docs/examples/tables/update-float-column.md b/docs/examples/tables/update-float-column.md new file mode 100644 index 0000000..d6cd34c --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnFloat = try await tables.updateFloatColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: 0, + min: 0, // optional + max: 0, // optional + newKey: "" // optional +) + diff --git a/docs/examples/tables/update-integer-column.md b/docs/examples/tables/update-integer-column.md new file mode 100644 index 0000000..e1265ce --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnInteger = try await tables.updateIntegerColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: 0, + min: 0, // optional + max: 0, // optional + newKey: "" // optional +) + diff --git a/docs/examples/tables/update-ip-column.md b/docs/examples/tables/update-ip-column.md new file mode 100644 index 0000000..4f3538b --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnIp = try await tables.updateIpColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", + newKey: "" // optional +) + diff --git a/docs/examples/tables/update-relationship-column.md b/docs/examples/tables/update-relationship-column.md new file mode 100644 index 0000000..74bfd62 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnRelationship = try await tables.updateRelationshipColumn( + databaseId: "", + tableId: "", + key: "", + onDelete: .cascade, // optional + newKey: "" // optional +) + diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md new file mode 100644 index 0000000..7fa81f6 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let row = try await tables.updateRow( + databaseId: "", + tableId: "", + rowId: "", + data: [:], // optional + permissions: ["read("any")"] // optional +) + diff --git a/docs/examples/tables/update-rows.md b/docs/examples/tables/update-rows.md new file mode 100644 index 0000000..d7cd069 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let rowList = try await tables.updateRows( + databaseId: "", + tableId: "", + data: [:], // optional + queries: [] // optional +) + diff --git a/docs/examples/tables/update-string-column.md b/docs/examples/tables/update-string-column.md new file mode 100644 index 0000000..ba14d9a --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnString = try await tables.updateStringColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "", + size: 1, // optional + newKey: "" // optional +) + diff --git a/docs/examples/tables/update-url-column.md b/docs/examples/tables/update-url-column.md new file mode 100644 index 0000000..19015e4 --- /dev/null +++ b/docs/examples/tables/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 tables = Tables(client) + +let columnUrl = try await tables.updateUrlColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: "https://example.com", + newKey: "" // optional +) + diff --git a/docs/examples/tables/update.md b/docs/examples/tables/update.md new file mode 100644 index 0000000..c9840a0 --- /dev/null +++ b/docs/examples/tables/update.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 tables = Tables(client) + +let table = try await tables.update( + databaseId: "", + tableId: "", + name: "", + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +) + diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md new file mode 100644 index 0000000..c5c5b73 --- /dev/null +++ b/docs/examples/tables/upsert-row.md @@ -0,0 +1,16 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // Your secret API key + .setJWT("") // Your secret JSON Web Token + +let tables = Tables(client) + +let row = try await tables.upsertRow( + databaseId: "", + tableId: "", + rowId: "" +) + diff --git a/docs/examples/tables/upsert-rows.md b/docs/examples/tables/upsert-rows.md new file mode 100644 index 0000000..037d927 --- /dev/null +++ b/docs/examples/tables/upsert-rows.md @@ -0,0 +1,14 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // + .setKey("") // Your secret API key + +let tables = Tables(client) + +let rowList = try await tables.upsertRows( + databaseId: "", + tableId: "" +) + From 60ad50bee0d6ddfcad0bb873190537de48433035 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:44:57 +0000 Subject: [PATCH 3/5] chore: regen to 1.7.x --- README.md | 6 +- Sources/Appwrite/Client.swift | 4 +- Sources/Appwrite/Services/Account.swift | 2 - Sources/Appwrite/Services/Databases.swift | 87 +- Sources/Appwrite/Services/Tables.swift | 2367 ----------------- 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 | 124 - 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/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/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-document.md | 3 +- docs/examples/databases/create-documents.md | 2 +- docs/examples/databases/upsert-document.md | 7 +- docs/examples/databases/upsert-documents.md | 5 +- docs/examples/tables/create-boolean-column.md | 18 - .../examples/tables/create-datetime-column.md | 18 - docs/examples/tables/create-email-column.md | 18 - docs/examples/tables/create-enum-column.md | 19 - docs/examples/tables/create-float-column.md | 20 - docs/examples/tables/create-index.md | 20 - docs/examples/tables/create-integer-column.md | 20 - docs/examples/tables/create-ip-column.md | 18 - .../tables/create-relationship-column.md | 21 - docs/examples/tables/create-row.md | 18 - docs/examples/tables/create-rows.md | 15 - docs/examples/tables/create-string-column.md | 20 - docs/examples/tables/create-url-column.md | 18 - docs/examples/tables/create.md | 18 - docs/examples/tables/decrement-row-column.md | 18 - docs/examples/tables/delete-column.md | 15 - docs/examples/tables/delete-index.md | 15 - docs/examples/tables/delete-row.md | 15 - docs/examples/tables/delete-rows.md | 15 - docs/examples/tables/delete.md | 14 - docs/examples/tables/get-column.md | 15 - docs/examples/tables/get-index.md | 15 - docs/examples/tables/get-row.md | 16 - docs/examples/tables/get.md | 14 - docs/examples/tables/increment-row-column.md | 18 - docs/examples/tables/list-columns.md | 15 - docs/examples/tables/list-indexes.md | 15 - docs/examples/tables/list-rows.md | 15 - docs/examples/tables/list.md | 15 - docs/examples/tables/update-boolean-column.md | 18 - .../examples/tables/update-datetime-column.md | 18 - docs/examples/tables/update-email-column.md | 18 - docs/examples/tables/update-enum-column.md | 19 - docs/examples/tables/update-float-column.md | 20 - docs/examples/tables/update-integer-column.md | 20 - docs/examples/tables/update-ip-column.md | 18 - .../tables/update-relationship-column.md | 18 - docs/examples/tables/update-row.md | 17 - docs/examples/tables/update-rows.md | 16 - docs/examples/tables/update-string-column.md | 19 - docs/examples/tables/update-url-column.md | 18 - docs/examples/tables/update.md | 18 - docs/examples/tables/upsert-row.md | 16 - docs/examples/tables/upsert-rows.md | 14 - 102 files changed, 72 insertions(+), 5230 deletions(-) delete mode 100644 Sources/Appwrite/Services/Tables.swift delete mode 100644 Sources/AppwriteModels/ColumnBoolean.swift delete mode 100644 Sources/AppwriteModels/ColumnDatetime.swift delete mode 100644 Sources/AppwriteModels/ColumnEmail.swift delete mode 100644 Sources/AppwriteModels/ColumnEnum.swift delete mode 100644 Sources/AppwriteModels/ColumnFloat.swift delete mode 100644 Sources/AppwriteModels/ColumnIndex.swift delete mode 100644 Sources/AppwriteModels/ColumnIndexList.swift delete mode 100644 Sources/AppwriteModels/ColumnInteger.swift delete mode 100644 Sources/AppwriteModels/ColumnIp.swift delete mode 100644 Sources/AppwriteModels/ColumnList.swift delete mode 100644 Sources/AppwriteModels/ColumnRelationship.swift delete mode 100644 Sources/AppwriteModels/ColumnString.swift delete mode 100644 Sources/AppwriteModels/ColumnUrl.swift delete mode 100644 Sources/AppwriteModels/Row.swift delete mode 100644 Sources/AppwriteModels/RowList.swift delete mode 100644 Sources/AppwriteModels/Table.swift delete mode 100644 Sources/AppwriteModels/TableList.swift delete mode 100644 docs/examples/tables/create-boolean-column.md delete mode 100644 docs/examples/tables/create-datetime-column.md delete mode 100644 docs/examples/tables/create-email-column.md delete mode 100644 docs/examples/tables/create-enum-column.md delete mode 100644 docs/examples/tables/create-float-column.md delete mode 100644 docs/examples/tables/create-index.md delete mode 100644 docs/examples/tables/create-integer-column.md delete mode 100644 docs/examples/tables/create-ip-column.md delete mode 100644 docs/examples/tables/create-relationship-column.md delete mode 100644 docs/examples/tables/create-row.md delete mode 100644 docs/examples/tables/create-rows.md delete mode 100644 docs/examples/tables/create-string-column.md delete mode 100644 docs/examples/tables/create-url-column.md delete mode 100644 docs/examples/tables/create.md delete mode 100644 docs/examples/tables/decrement-row-column.md delete mode 100644 docs/examples/tables/delete-column.md delete mode 100644 docs/examples/tables/delete-index.md delete mode 100644 docs/examples/tables/delete-row.md delete mode 100644 docs/examples/tables/delete-rows.md delete mode 100644 docs/examples/tables/delete.md delete mode 100644 docs/examples/tables/get-column.md delete mode 100644 docs/examples/tables/get-index.md delete mode 100644 docs/examples/tables/get-row.md delete mode 100644 docs/examples/tables/get.md delete mode 100644 docs/examples/tables/increment-row-column.md delete mode 100644 docs/examples/tables/list-columns.md delete mode 100644 docs/examples/tables/list-indexes.md delete mode 100644 docs/examples/tables/list-rows.md delete mode 100644 docs/examples/tables/list.md delete mode 100644 docs/examples/tables/update-boolean-column.md delete mode 100644 docs/examples/tables/update-datetime-column.md delete mode 100644 docs/examples/tables/update-email-column.md delete mode 100644 docs/examples/tables/update-enum-column.md delete mode 100644 docs/examples/tables/update-float-column.md delete mode 100644 docs/examples/tables/update-integer-column.md delete mode 100644 docs/examples/tables/update-ip-column.md delete mode 100644 docs/examples/tables/update-relationship-column.md delete mode 100644 docs/examples/tables/update-row.md delete mode 100644 docs/examples/tables/update-rows.md delete mode 100644 docs/examples/tables/update-string-column.md delete mode 100644 docs/examples/tables/update-url-column.md delete mode 100644 docs/examples/tables/update.md delete mode 100644 docs/examples/tables/upsert-row.md delete mode 100644 docs/examples/tables/upsert-rows.md diff --git a/README.md b/README.md index 2ef5b9e..c7913e3 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.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).** +**This SDK is compatible with Appwrite server version 1.7.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: "11.0.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "10.1.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 1eb5a93..0436599 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": "11.0.0", - "x-appwrite-response-format": "1.8.0" + "x-sdk-version": "10.1.0", + "x-appwrite-response-format": "1.7.0" ] internal var config: [String: String] = [:] diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 810f685..8e93bc4 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -1214,7 +1214,6 @@ 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 @@ -1254,7 +1253,6 @@ 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 33284f7..86e8362 100644 --- a/Sources/Appwrite/Services/Databases.swift +++ b/Sources/Appwrite/Services/Databases.swift @@ -196,7 +196,6 @@ 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 `Tables.list` instead.") open func listCollections( databaseId: String, queries: [String]? = nil, @@ -241,7 +240,6 @@ 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 `Tables.create` instead.") open func createCollection( databaseId: String, collectionId: String, @@ -288,7 +286,6 @@ 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 `Tables.get` instead.") open func getCollection( databaseId: String, collectionId: String @@ -327,7 +324,6 @@ 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 `Tables.update` instead.") open func updateCollection( databaseId: String, collectionId: String, @@ -374,7 +370,6 @@ 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 `Tables.delete` instead.") open func deleteCollection( databaseId: String, collectionId: String @@ -406,7 +401,6 @@ 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 `Tables.listColumns` instead.") open func listAttributes( databaseId: String, collectionId: String, @@ -449,7 +443,6 @@ 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 `Tables.createBooleanColumn` instead.") open func createBooleanAttribute( databaseId: String, collectionId: String, @@ -500,7 +493,6 @@ 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 `Tables.updateBooleanColumn` instead.") open func updateBooleanAttribute( databaseId: String, collectionId: String, @@ -550,7 +542,6 @@ 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 `Tables.createDatetimeColumn` instead.") open func createDatetimeAttribute( databaseId: String, collectionId: String, @@ -601,7 +592,6 @@ 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 `Tables.updateDatetimeColumn` instead.") open func updateDatetimeAttribute( databaseId: String, collectionId: String, @@ -652,7 +642,6 @@ 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 `Tables.createEmailColumn` instead.") open func createEmailAttribute( databaseId: String, collectionId: String, @@ -704,7 +693,6 @@ 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 `Tables.updateEmailColumn` instead.") open func updateEmailAttribute( databaseId: String, collectionId: String, @@ -742,8 +730,8 @@ open class Databases: Service { } /// - /// Create an enum attribute. The `elements` param acts as a white-list of - /// accepted values for this attribute. + /// Create an enumeration attribute. The `elements` param acts as a white-list + /// of accepted values for this attribute. /// /// /// - Parameters: @@ -757,7 +745,6 @@ 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 `Tables.createEnumColumn` instead.") open func createEnumAttribute( databaseId: String, collectionId: String, @@ -812,7 +799,6 @@ 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 `Tables.updateEnumColumn` instead.") open func updateEnumAttribute( databaseId: String, collectionId: String, @@ -868,7 +854,6 @@ 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 `Tables.createFloatColumn` instead.") open func createFloatAttribute( databaseId: String, collectionId: String, @@ -926,7 +911,6 @@ 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 `Tables.updateFloatColumn` instead.") open func updateFloatAttribute( databaseId: String, collectionId: String, @@ -984,7 +968,6 @@ 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 `Tables.createIntegerColumn` instead.") open func createIntegerAttribute( databaseId: String, collectionId: String, @@ -1042,7 +1025,6 @@ 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 `Tables.updateIntegerColumn` instead.") open func updateIntegerAttribute( databaseId: String, collectionId: String, @@ -1097,7 +1079,6 @@ 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 `Tables.createIpColumn` instead.") open func createIpAttribute( databaseId: String, collectionId: String, @@ -1149,7 +1130,6 @@ 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 `Tables.updateIpColumn` instead.") open func updateIpAttribute( databaseId: String, collectionId: String, @@ -1203,7 +1183,6 @@ 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 `Tables.createRelationshipColumn` instead.") open func createRelationshipAttribute( databaseId: String, collectionId: String, @@ -1260,7 +1239,6 @@ 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 `Tables.createStringColumn` instead.") open func createStringAttribute( databaseId: String, collectionId: String, @@ -1317,7 +1295,6 @@ 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 `Tables.updateStringColumn` instead.") open func updateStringAttribute( databaseId: String, collectionId: String, @@ -1370,7 +1347,6 @@ 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 `Tables.createUrlColumn` instead.") open func createUrlAttribute( databaseId: String, collectionId: String, @@ -1422,7 +1398,6 @@ 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 `Tables.updateUrlColumn` instead.") open func updateUrlAttribute( databaseId: String, collectionId: String, @@ -1469,7 +1444,6 @@ 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 `Tables.getColumn` instead.") open func getAttribute( databaseId: String, collectionId: String, @@ -1501,7 +1475,6 @@ 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 `Tables.deleteColumn` instead.") open func deleteAttribute( databaseId: String, collectionId: String, @@ -1539,7 +1512,6 @@ 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 `Tables.updateRelationshipColumn` instead.") open func updateRelationshipAttribute( databaseId: String, collectionId: String, @@ -1585,7 +1557,6 @@ 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 `Tables.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -1626,7 +1597,6 @@ 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 `Tables.listRows` instead.") open func listDocuments( databaseId: String, collectionId: String, @@ -1655,7 +1625,6 @@ 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 `Tables.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -1706,7 +1675,6 @@ 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 `Tables.createRow` instead.") open func createDocument( databaseId: String, collectionId: String, @@ -1741,7 +1709,6 @@ 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 `Tables.createRow` instead.") open func createDocuments( databaseId: String, collectionId: String, @@ -1790,7 +1757,6 @@ 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 `Tables.createRow` instead.") open func createDocuments( databaseId: String, collectionId: String, @@ -1818,20 +1784,23 @@ open class Databases: Service { /// - Parameters: /// - databaseId: String /// - collectionId: String + /// - documents: [Any] /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Tables.upsertRows` instead.") open func upsertDocuments( databaseId: String, collectionId: String, + documents: [Any], nestedType: T.Type ) async throws -> AppwriteModels.DocumentList { let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents" .replacingOccurrences(of: "{databaseId}", with: databaseId) .replacingOccurrences(of: "{collectionId}", with: collectionId) - let apiParams: [String: Any] = [:] + let apiParams: [String: Any?] = [ + "documents": documents + ] let apiHeaders: [String: String] = [ "content-type": "application/json" @@ -1864,17 +1833,19 @@ open class Databases: Service { /// - Parameters: /// - databaseId: String /// - collectionId: String + /// - documents: [Any] /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.DocumentList /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Tables.upsertRows` instead.") open func upsertDocuments( databaseId: String, - collectionId: String + collectionId: String, + documents: [Any] ) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> { return try await upsertDocuments( databaseId: databaseId, collectionId: collectionId, + documents: documents, nestedType: [String: AnyCodable].self ) } @@ -1896,7 +1867,6 @@ 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 `Tables.updateRows` instead.") open func updateDocuments( databaseId: String, collectionId: String, @@ -1947,7 +1917,6 @@ 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 `Tables.updateRows` instead.") open func updateDocuments( databaseId: String, collectionId: String, @@ -1978,7 +1947,6 @@ 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 `Tables.deleteRows` instead.") open func deleteDocuments( databaseId: String, collectionId: String, @@ -2025,7 +1993,6 @@ 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 `Tables.deleteRows` instead.") open func deleteDocuments( databaseId: String, collectionId: String, @@ -2051,7 +2018,6 @@ 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 `Tables.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -2095,7 +2061,6 @@ 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 `Tables.getRow` instead.") open func getDocument( databaseId: String, collectionId: String, @@ -2125,14 +2090,17 @@ open class Databases: Service { /// - databaseId: String /// - collectionId: String /// - documentId: String + /// - data: Any + /// - permissions: [String] (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, documentId: String, + data: Any, + permissions: [String]? = nil, nestedType: T.Type ) async throws -> AppwriteModels.Document { let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -2140,7 +2108,10 @@ open class Databases: Service { .replacingOccurrences(of: "{collectionId}", with: collectionId) .replacingOccurrences(of: "{documentId}", with: documentId) - let apiParams: [String: Any] = [:] + let apiParams: [String: Any?] = [ + "data": data, + "permissions": permissions + ] let apiHeaders: [String: String] = [ "content-type": "application/json" @@ -2173,19 +2144,24 @@ open class Databases: Service { /// - databaseId: String /// - collectionId: String /// - documentId: String + /// - data: Any + /// - permissions: [String] (optional) /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Document /// - @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.") open func upsertDocument( databaseId: String, collectionId: String, - documentId: String + documentId: String, + data: Any, + permissions: [String]? = nil ) async throws -> AppwriteModels.Document<[String: AnyCodable]> { return try await upsertDocument( databaseId: databaseId, collectionId: collectionId, documentId: documentId, + data: data, + permissions: permissions, nestedType: [String: AnyCodable].self ) } @@ -2203,7 +2179,6 @@ 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 `Tables.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -2252,7 +2227,6 @@ 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 `Tables.updateRow` instead.") open func updateDocument( databaseId: String, collectionId: String, @@ -2280,7 +2254,6 @@ 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 `Tables.deleteRow` instead.") open func deleteDocument( databaseId: String, collectionId: String, @@ -2317,7 +2290,6 @@ 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 `Tables.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2368,7 +2340,6 @@ 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 `Tables.decrementRowColumn` instead.") open func decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2401,7 +2372,6 @@ 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 `Tables.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2452,7 +2422,6 @@ 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 `Tables.incrementRowColumn` instead.") open func incrementDocumentAttribute( databaseId: String, collectionId: String, @@ -2482,7 +2451,6 @@ 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 `Tables.listIndexes` instead.") open func listIndexes( databaseId: String, collectionId: String, @@ -2527,7 +2495,6 @@ 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 `Tables.createIndex` instead.") open func createIndex( databaseId: String, collectionId: String, @@ -2576,7 +2543,6 @@ 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 `Tables.getIndex` instead.") open func getIndex( databaseId: String, collectionId: String, @@ -2614,7 +2580,6 @@ 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 `Tables.deleteIndex` instead.") open func deleteIndex( databaseId: String, collectionId: String, diff --git a/Sources/Appwrite/Services/Tables.swift b/Sources/Appwrite/Services/Tables.swift deleted file mode 100644 index 221a61a..0000000 --- a/Sources/Appwrite/Services/Tables.swift +++ /dev/null @@ -1,2367 +0,0 @@ -import AsyncHTTPClient -import Foundation -import NIO -import JSONCodable -import AppwriteEnums -import AppwriteModels - -/// The Tables service allows you to create structured tables of rows, query and filter lists of rows -open class Tables: Service { - - /// - /// 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 list( - databaseId: String, - queries: [String]? = nil, - search: String? = nil - ) async throws -> AppwriteModels.TableList { - let apiPath: String = "/databases/{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 create( - databaseId: String, - tableId: String, - name: String, - permissions: [String]? = nil, - rowSecurity: Bool? = nil, - enabled: Bool? = nil - ) async throws -> AppwriteModels.Table { - let apiPath: String = "/databases/{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 get( - databaseId: String, - tableId: String - ) async throws -> AppwriteModels.Table { - let apiPath: String = "/databases/{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 update( - databaseId: String, - tableId: String, - name: String, - permissions: [String]? = nil, - rowSecurity: Bool? = nil, - enabled: Bool? = nil - ) async throws -> AppwriteModels.Table { - let apiPath: String = "/databases/{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 delete( - databaseId: String, - tableId: String - ) async throws -> Any { - let apiPath: String = "/databases/{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 attributes in the collection. - /// - /// - 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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 attributes listed. Your index should include all - /// the attributes 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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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 - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.RowList - /// - open func upsertRows( - databaseId: String, - tableId: String, - nestedType: T.Type - ) async throws -> AppwriteModels.RowList { - let apiPath: String = "/databases/{databaseId}/tables/{tableId}/rows" - .replacingOccurrences(of: "{databaseId}", with: databaseId) - .replacingOccurrences(of: "{tableId}", with: tableId) - - let apiParams: [String: Any] = [:] - - 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 - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.RowList - /// - open func upsertRows( - databaseId: String, - tableId: String - ) async throws -> AppwriteModels.RowList<[String: AnyCodable]> { - return try await upsertRows( - databaseId: databaseId, - tableId: tableId, - 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 = "/databases/{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 = "/databases/{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 = "/databases/{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 - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.Row - /// - open func upsertRow( - databaseId: String, - tableId: String, - rowId: String, - nestedType: T.Type - ) async throws -> AppwriteModels.Row { - let apiPath: String = "/databases/{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" - ] - - 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 - /// - Throws: Exception if the request fails - /// - Returns: AppwriteModels.Row - /// - open func upsertRow( - databaseId: String, - tableId: String, - rowId: String - ) async throws -> AppwriteModels.Row<[String: AnyCodable]> { - return try await upsertRow( - databaseId: databaseId, - tableId: tableId, - rowId: rowId, - 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 = "/databases/{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 = "/databases/{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 = "/databases/{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 = "/databases/{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/AppwriteModels/BucketList.swift b/Sources/AppwriteModels/BucketList.swift index 89a718e..8fca4e4 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 documents 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..f5f383f 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 documents that matched your query. public let total: Int /// List of collections. diff --git a/Sources/AppwriteModels/ColumnBoolean.swift b/Sources/AppwriteModels/ColumnBoolean.swift deleted file mode 100644 index 84f99b9..0000000 --- a/Sources/AppwriteModels/ColumnBoolean.swift +++ /dev/null @@ -1,124 +0,0 @@ -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 deleted file mode 100644 index 5d5dc37..0000000 --- a/Sources/AppwriteModels/ColumnDatetime.swift +++ /dev/null @@ -1,134 +0,0 @@ -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 deleted file mode 100644 index 8ffc084..0000000 --- a/Sources/AppwriteModels/ColumnEmail.swift +++ /dev/null @@ -1,134 +0,0 @@ -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 deleted file mode 100644 index e9fcbbd..0000000 --- a/Sources/AppwriteModels/ColumnEnum.swift +++ /dev/null @@ -1,144 +0,0 @@ -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 deleted file mode 100644 index 7609ffc..0000000 --- a/Sources/AppwriteModels/ColumnFloat.swift +++ /dev/null @@ -1,144 +0,0 @@ -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 deleted file mode 100644 index 0857a35..0000000 --- a/Sources/AppwriteModels/ColumnIndex.swift +++ /dev/null @@ -1,124 +0,0 @@ -import Foundation -import JSONCodable - -/// Index -open class ColumnIndex: Codable { - - enum CodingKeys: String, CodingKey { - case key = "key" - case type = "type" - case status = "status" - case error = "error" - case columns = "columns" - case lengths = "lengths" - case orders = "orders" - case createdAt = "$createdAt" - case updatedAt = "$updatedAt" - } - - /// 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]? - - /// Index creation date in ISO 8601 format. - public let createdAt: String - - /// Index update date in ISO 8601 format. - public let updatedAt: String - - - init( - key: String, - type: String, - status: String, - error: String, - columns: [String], - lengths: [Int], - orders: [String]?, - createdAt: String, - updatedAt: String - ) { - self.key = key - self.type = type - self.status = status - self.error = error - self.columns = columns - 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.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) - 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(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) - try container.encode(createdAt, forKey: .createdAt) - try container.encode(updatedAt, forKey: .updatedAt) - } - - public func toMap() -> [String: Any] { - return [ - "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, - "$createdAt": createdAt as Any, - "$updatedAt": updatedAt as Any - ] - } - - public static func from(map: [String: Any] ) -> ColumnIndex { - return ColumnIndex( - 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], - createdAt: map["$createdAt"] as! String, - updatedAt: map["$updatedAt"] as! String - ) - } -} diff --git a/Sources/AppwriteModels/ColumnIndexList.swift b/Sources/AppwriteModels/ColumnIndexList.swift deleted file mode 100644 index 5ce8061..0000000 --- a/Sources/AppwriteModels/ColumnIndexList.swift +++ /dev/null @@ -1,54 +0,0 @@ -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 deleted file mode 100644 index 22ba42c..0000000 --- a/Sources/AppwriteModels/ColumnInteger.swift +++ /dev/null @@ -1,144 +0,0 @@ -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 deleted file mode 100644 index d0f358e..0000000 --- a/Sources/AppwriteModels/ColumnIp.swift +++ /dev/null @@ -1,134 +0,0 @@ -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 deleted file mode 100644 index dead6f0..0000000 --- a/Sources/AppwriteModels/ColumnList.swift +++ /dev/null @@ -1,54 +0,0 @@ -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 deleted file mode 100644 index e738c5f..0000000 --- a/Sources/AppwriteModels/ColumnRelationship.swift +++ /dev/null @@ -1,174 +0,0 @@ -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 deleted file mode 100644 index 77f625c..0000000 --- a/Sources/AppwriteModels/ColumnString.swift +++ /dev/null @@ -1,144 +0,0 @@ -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 deleted file mode 100644 index 62aa875..0000000 --- a/Sources/AppwriteModels/ColumnUrl.swift +++ /dev/null @@ -1,134 +0,0 @@ -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 7ebd966..fa9a90f 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 documents 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..865cc19 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 documents 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..1e0dff9 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 documents 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..588cbaa 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 documents 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..e218064 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 documents 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..a129182 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 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..72d43a6 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 documents 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..bec7b76 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 documents 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..7aa2ce7 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 documents 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..c00badb 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 documents 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..6065fad 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 documents 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..2f3ae30 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 documents 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..13c6e4a 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 documents 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..5ef0653 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 documents 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..7ff2d07 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 documents 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..a7b0cd6 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 documents 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..f62fcaa 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 documents 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..6f3bee3 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 documents 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..76fd4eb 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 documents 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..6d894b6 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 documents that matched your query. public let total: Int /// List of tokens. diff --git a/Sources/AppwriteModels/Row.swift b/Sources/AppwriteModels/Row.swift deleted file mode 100644 index 6e94a9e..0000000 --- a/Sources/AppwriteModels/Row.swift +++ /dev/null @@ -1,113 +0,0 @@ -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 deleted file mode 100644 index 8eb7d80..0000000 --- a/Sources/AppwriteModels/RowList.swift +++ /dev/null @@ -1,54 +0,0 @@ -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 36fcdef..ab99ed1 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 documents 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..13b6b3d 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 documents 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..6c37fae 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 documents 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..f2b9766 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 documents 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..2d63f07 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 documents that matched your query. public let total: Int /// List of subscribers. diff --git a/Sources/AppwriteModels/Table.swift b/Sources/AppwriteModels/Table.swift deleted file mode 100644 index 82bdd3d..0000000 --- a/Sources/AppwriteModels/Table.swift +++ /dev/null @@ -1,134 +0,0 @@ -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 deleted file mode 100644 index 50a8bea..0000000 --- a/Sources/AppwriteModels/TableList.swift +++ /dev/null @@ -1,54 +0,0 @@ -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 b28034f..6c9f247 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 documents 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..384d9f6 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 documents 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..66eae2c 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 documents 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..7bf7413 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 documents 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..8345d0b 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 documents that matched your query. public let total: Int /// List of variables. diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 4ee2104..daeaf14 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,9 +2,8 @@ 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 - .setKey("") // Your secret API key - .setJWT("") // Your secret JSON Web Token let databases = Databases(client) diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index e4f8582..2e992d9 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -2,7 +2,7 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // + .setProject("") // Your project ID .setKey("") // Your secret API key let databases = Databases(client) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 9c9684e..e78bd45 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -2,15 +2,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 - .setKey("") // Your secret API key - .setJWT("") // Your secret JSON Web Token let databases = Databases(client) let document = try await databases.upsertDocument( databaseId: "", collectionId: "", - documentId: "" + documentId: "", + data: [:], + permissions: ["read("any")"] // optional ) diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index e63b9a3..544f02f 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -2,13 +2,14 @@ import Appwrite let client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // + .setProject("") // Your project ID .setKey("") // Your secret API key let databases = Databases(client) let documentList = try await databases.upsertDocuments( databaseId: "", - collectionId: "" + collectionId: "", + documents: [] ) diff --git a/docs/examples/tables/create-boolean-column.md b/docs/examples/tables/create-boolean-column.md deleted file mode 100644 index 1b9627a..0000000 --- a/docs/examples/tables/create-boolean-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnBoolean = try await tables.createBooleanColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: false, // optional - array: false // optional -) - diff --git a/docs/examples/tables/create-datetime-column.md b/docs/examples/tables/create-datetime-column.md deleted file mode 100644 index e002fb8..0000000 --- a/docs/examples/tables/create-datetime-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnDatetime = try await tables.createDatetimeColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: "", // optional - array: false // optional -) - diff --git a/docs/examples/tables/create-email-column.md b/docs/examples/tables/create-email-column.md deleted file mode 100644 index 338493d..0000000 --- a/docs/examples/tables/create-email-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnEmail = try await tables.createEmailColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: "email@example.com", // optional - array: false // optional -) - diff --git a/docs/examples/tables/create-enum-column.md b/docs/examples/tables/create-enum-column.md deleted file mode 100644 index a6a9fff..0000000 --- a/docs/examples/tables/create-enum-column.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 tables = Tables(client) - -let columnEnum = try await tables.createEnumColumn( - databaseId: "", - tableId: "", - key: "", - elements: [], - required: false, - default: "", // optional - array: false // optional -) - diff --git a/docs/examples/tables/create-float-column.md b/docs/examples/tables/create-float-column.md deleted file mode 100644 index 12e4062..0000000 --- a/docs/examples/tables/create-float-column.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 tables = Tables(client) - -let columnFloat = try await tables.createFloatColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - min: 0, // optional - max: 0, // optional - default: 0, // optional - array: false // optional -) - diff --git a/docs/examples/tables/create-index.md b/docs/examples/tables/create-index.md deleted file mode 100644 index 03dea1a..0000000 --- a/docs/examples/tables/create-index.md +++ /dev/null @@ -1,20 +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 tables = Tables(client) - -let columnIndex = try await tables.createIndex( - databaseId: "", - tableId: "", - key: "", - type: .key, - columns: [], - orders: [], // optional - lengths: [] // optional -) - diff --git a/docs/examples/tables/create-integer-column.md b/docs/examples/tables/create-integer-column.md deleted file mode 100644 index 6c04294..0000000 --- a/docs/examples/tables/create-integer-column.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 tables = Tables(client) - -let columnInteger = try await tables.createIntegerColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - min: 0, // optional - max: 0, // optional - default: 0, // optional - array: false // optional -) - diff --git a/docs/examples/tables/create-ip-column.md b/docs/examples/tables/create-ip-column.md deleted file mode 100644 index 2cd0b27..0000000 --- a/docs/examples/tables/create-ip-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnIp = try await tables.createIpColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: "", // optional - array: false // optional -) - diff --git a/docs/examples/tables/create-relationship-column.md b/docs/examples/tables/create-relationship-column.md deleted file mode 100644 index 66b993c..0000000 --- a/docs/examples/tables/create-relationship-column.md +++ /dev/null @@ -1,21 +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 tables = Tables(client) - -let columnRelationship = try await tables.createRelationshipColumn( - databaseId: "", - tableId: "", - relatedTableId: "", - type: .oneToOne, - twoWay: false, // optional - key: "", // optional - twoWayKey: "", // optional - onDelete: .cascade // optional -) - diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md deleted file mode 100644 index a736355..0000000 --- a/docs/examples/tables/create-row.md +++ /dev/null @@ -1,18 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // Your secret API key - .setJWT("") // Your secret JSON Web Token - -let tables = Tables(client) - -let row = try await tables.createRow( - databaseId: "", - tableId: "", - rowId: "", - data: [:], - permissions: ["read("any")"] // optional -) - diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md deleted file mode 100644 index ee2095f..0000000 --- a/docs/examples/tables/create-rows.md +++ /dev/null @@ -1,15 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // - .setKey("") // Your secret API key - -let tables = Tables(client) - -let rowList = try await tables.createRows( - databaseId: "", - tableId: "", - rows: [] -) - diff --git a/docs/examples/tables/create-string-column.md b/docs/examples/tables/create-string-column.md deleted file mode 100644 index e83ffdf..0000000 --- a/docs/examples/tables/create-string-column.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 tables = Tables(client) - -let columnString = try await tables.createStringColumn( - databaseId: "", - tableId: "", - key: "", - size: 1, - required: false, - default: "", // optional - array: false, // optional - encrypt: false // optional -) - diff --git a/docs/examples/tables/create-url-column.md b/docs/examples/tables/create-url-column.md deleted file mode 100644 index 150b513..0000000 --- a/docs/examples/tables/create-url-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnUrl = try await tables.createUrlColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: "https://example.com", // optional - array: false // optional -) - diff --git a/docs/examples/tables/create.md b/docs/examples/tables/create.md deleted file mode 100644 index 0843dfd..0000000 --- a/docs/examples/tables/create.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let table = try await tables.create( - databaseId: "", - tableId: "", - name: "", - permissions: ["read("any")"], // optional - rowSecurity: false, // optional - enabled: false // optional -) - diff --git a/docs/examples/tables/decrement-row-column.md b/docs/examples/tables/decrement-row-column.md deleted file mode 100644 index ef24324..0000000 --- a/docs/examples/tables/decrement-row-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let row = try await tables.decrementRowColumn( - databaseId: "", - tableId: "", - rowId: "", - column: "", - value: 0, // optional - min: 0 // optional -) - diff --git a/docs/examples/tables/delete-column.md b/docs/examples/tables/delete-column.md deleted file mode 100644 index 07f825d..0000000 --- a/docs/examples/tables/delete-column.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let result = try await tables.deleteColumn( - databaseId: "", - tableId: "", - key: "" -) - diff --git a/docs/examples/tables/delete-index.md b/docs/examples/tables/delete-index.md deleted file mode 100644 index b6d2e5b..0000000 --- a/docs/examples/tables/delete-index.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let result = try await tables.deleteIndex( - databaseId: "", - tableId: "", - key: "" -) - diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md deleted file mode 100644 index 92bc387..0000000 --- a/docs/examples/tables/delete-row.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let result = try await tables.deleteRow( - databaseId: "", - tableId: "", - rowId: "" -) - diff --git a/docs/examples/tables/delete-rows.md b/docs/examples/tables/delete-rows.md deleted file mode 100644 index d27fbce..0000000 --- a/docs/examples/tables/delete-rows.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let rowList = try await tables.deleteRows( - databaseId: "", - tableId: "", - queries: [] // optional -) - diff --git a/docs/examples/tables/delete.md b/docs/examples/tables/delete.md deleted file mode 100644 index aefa1d8..0000000 --- a/docs/examples/tables/delete.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 tables = Tables(client) - -let result = try await tables.delete( - databaseId: "", - tableId: "" -) - diff --git a/docs/examples/tables/get-column.md b/docs/examples/tables/get-column.md deleted file mode 100644 index 653f79d..0000000 --- a/docs/examples/tables/get-column.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let result = try await tables.getColumn( - databaseId: "", - tableId: "", - key: "" -) - diff --git a/docs/examples/tables/get-index.md b/docs/examples/tables/get-index.md deleted file mode 100644 index 6835f56..0000000 --- a/docs/examples/tables/get-index.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let columnIndex = try await tables.getIndex( - databaseId: "", - tableId: "", - key: "" -) - diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md deleted file mode 100644 index e2ff10f..0000000 --- a/docs/examples/tables/get-row.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 - .setSession("") // The user session to authenticate with - -let tables = Tables(client) - -let row = try await tables.getRow( - databaseId: "", - tableId: "", - rowId: "", - queries: [] // optional -) - diff --git a/docs/examples/tables/get.md b/docs/examples/tables/get.md deleted file mode 100644 index 610bf42..0000000 --- a/docs/examples/tables/get.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 tables = Tables(client) - -let table = try await tables.get( - databaseId: "", - tableId: "" -) - diff --git a/docs/examples/tables/increment-row-column.md b/docs/examples/tables/increment-row-column.md deleted file mode 100644 index 6ea883d..0000000 --- a/docs/examples/tables/increment-row-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let row = try await tables.incrementRowColumn( - databaseId: "", - tableId: "", - rowId: "", - column: "", - value: 0, // optional - max: 0 // optional -) - diff --git a/docs/examples/tables/list-columns.md b/docs/examples/tables/list-columns.md deleted file mode 100644 index 88c8613..0000000 --- a/docs/examples/tables/list-columns.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let columnList = try await tables.listColumns( - databaseId: "", - tableId: "", - queries: [] // optional -) - diff --git a/docs/examples/tables/list-indexes.md b/docs/examples/tables/list-indexes.md deleted file mode 100644 index 2ea8e99..0000000 --- a/docs/examples/tables/list-indexes.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let columnIndexList = try await tables.listIndexes( - databaseId: "", - tableId: "", - queries: [] // optional -) - diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md deleted file mode 100644 index ca2e5b0..0000000 --- a/docs/examples/tables/list-rows.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let rowList = try await tables.listRows( - databaseId: "", - tableId: "", - queries: [] // optional -) - diff --git a/docs/examples/tables/list.md b/docs/examples/tables/list.md deleted file mode 100644 index e135b50..0000000 --- a/docs/examples/tables/list.md +++ /dev/null @@ -1,15 +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 tables = Tables(client) - -let tableList = try await tables.list( - databaseId: "", - queries: [], // optional - search: "" // optional -) - diff --git a/docs/examples/tables/update-boolean-column.md b/docs/examples/tables/update-boolean-column.md deleted file mode 100644 index e0d1ea2..0000000 --- a/docs/examples/tables/update-boolean-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnBoolean = try await tables.updateBooleanColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: false, - newKey: "" // optional -) - diff --git a/docs/examples/tables/update-datetime-column.md b/docs/examples/tables/update-datetime-column.md deleted file mode 100644 index f09e279..0000000 --- a/docs/examples/tables/update-datetime-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnDatetime = try await tables.updateDatetimeColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: "", - newKey: "" // optional -) - diff --git a/docs/examples/tables/update-email-column.md b/docs/examples/tables/update-email-column.md deleted file mode 100644 index f7b8cc4..0000000 --- a/docs/examples/tables/update-email-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnEmail = try await tables.updateEmailColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: "email@example.com", - newKey: "" // optional -) - diff --git a/docs/examples/tables/update-enum-column.md b/docs/examples/tables/update-enum-column.md deleted file mode 100644 index 776da72..0000000 --- a/docs/examples/tables/update-enum-column.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 tables = Tables(client) - -let columnEnum = try await tables.updateEnumColumn( - databaseId: "", - tableId: "", - key: "", - elements: [], - required: false, - default: "", - newKey: "" // optional -) - diff --git a/docs/examples/tables/update-float-column.md b/docs/examples/tables/update-float-column.md deleted file mode 100644 index d6cd34c..0000000 --- a/docs/examples/tables/update-float-column.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 tables = Tables(client) - -let columnFloat = try await tables.updateFloatColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: 0, - min: 0, // optional - max: 0, // optional - newKey: "" // optional -) - diff --git a/docs/examples/tables/update-integer-column.md b/docs/examples/tables/update-integer-column.md deleted file mode 100644 index e1265ce..0000000 --- a/docs/examples/tables/update-integer-column.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 tables = Tables(client) - -let columnInteger = try await tables.updateIntegerColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: 0, - min: 0, // optional - max: 0, // optional - newKey: "" // optional -) - diff --git a/docs/examples/tables/update-ip-column.md b/docs/examples/tables/update-ip-column.md deleted file mode 100644 index 4f3538b..0000000 --- a/docs/examples/tables/update-ip-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnIp = try await tables.updateIpColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: "", - newKey: "" // optional -) - diff --git a/docs/examples/tables/update-relationship-column.md b/docs/examples/tables/update-relationship-column.md deleted file mode 100644 index 74bfd62..0000000 --- a/docs/examples/tables/update-relationship-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnRelationship = try await tables.updateRelationshipColumn( - databaseId: "", - tableId: "", - key: "", - onDelete: .cascade, // optional - newKey: "" // optional -) - diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md deleted file mode 100644 index 7fa81f6..0000000 --- a/docs/examples/tables/update-row.md +++ /dev/null @@ -1,17 +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 tables = Tables(client) - -let row = try await tables.updateRow( - databaseId: "", - tableId: "", - rowId: "", - data: [:], // optional - permissions: ["read("any")"] // optional -) - diff --git a/docs/examples/tables/update-rows.md b/docs/examples/tables/update-rows.md deleted file mode 100644 index d7cd069..0000000 --- a/docs/examples/tables/update-rows.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 tables = Tables(client) - -let rowList = try await tables.updateRows( - databaseId: "", - tableId: "", - data: [:], // optional - queries: [] // optional -) - diff --git a/docs/examples/tables/update-string-column.md b/docs/examples/tables/update-string-column.md deleted file mode 100644 index ba14d9a..0000000 --- a/docs/examples/tables/update-string-column.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 tables = Tables(client) - -let columnString = try await tables.updateStringColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: "", - size: 1, // optional - newKey: "" // optional -) - diff --git a/docs/examples/tables/update-url-column.md b/docs/examples/tables/update-url-column.md deleted file mode 100644 index 19015e4..0000000 --- a/docs/examples/tables/update-url-column.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let columnUrl = try await tables.updateUrlColumn( - databaseId: "", - tableId: "", - key: "", - required: false, - default: "https://example.com", - newKey: "" // optional -) - diff --git a/docs/examples/tables/update.md b/docs/examples/tables/update.md deleted file mode 100644 index c9840a0..0000000 --- a/docs/examples/tables/update.md +++ /dev/null @@ -1,18 +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 tables = Tables(client) - -let table = try await tables.update( - databaseId: "", - tableId: "", - name: "", - permissions: ["read("any")"], // optional - rowSecurity: false, // optional - enabled: false // optional -) - diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md deleted file mode 100644 index c5c5b73..0000000 --- a/docs/examples/tables/upsert-row.md +++ /dev/null @@ -1,16 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // Your secret API key - .setJWT("") // Your secret JSON Web Token - -let tables = Tables(client) - -let row = try await tables.upsertRow( - databaseId: "", - tableId: "", - rowId: "" -) - diff --git a/docs/examples/tables/upsert-rows.md b/docs/examples/tables/upsert-rows.md deleted file mode 100644 index 037d927..0000000 --- a/docs/examples/tables/upsert-rows.md +++ /dev/null @@ -1,14 +0,0 @@ -import Appwrite - -let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // - .setKey("") // Your secret API key - -let tables = Tables(client) - -let rowList = try await tables.upsertRows( - databaseId: "", - tableId: "" -) - From 8ddf3325eaee8b7bec9a6a4c10d321bf38e91bc8 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 08:22:52 +0000 Subject: [PATCH 4/5] chore: add changelog --- CHANGELOG.md | 46 ++++++++++++++++++++++++++++++++++- README.md | 2 +- Sources/Appwrite/Client.swift | 2 +- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4d35e..6cb1cca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,45 @@ -# Change Log \ No newline at end of file +# Change Log + +## 10.2.0 + +* Update sdk to use swift-native doc comments instead of jsdoc styled comments as per [Swift Documentation Comments](https://github.com/swiftlang/swift/blob/main/docs/DocumentationComments.md) +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `gif` support to `ImageFormat` enum +* Add `sequence` support to `Document` model +* Add `dart38` and `flutter332` support to runtime models + +## 10.1.0 + +* Adds `upsertDocument` method +* Adds warnings to bulk operation methods +* Adds the new `encrypt` attribute +* Adds runtimes: `flutter332` and `dart38` +* Fix `select` Queries by updating internal attributes like `id`, `createdAt`, `updatedAt` etc. to be optional in `Document` model. +* Fix `listCollection` errors by updating `attributes` typing +* Fix querying datetime values by properly encoding URLs + +## 10.0.0 + +* Add `` to doc examples due to the new multi region endpoints +* Add doc examples and methods for bulk api transactions: `createDocuments`, `deleteDocuments` etc. +* Add doc examples, class and methods for new `Sites` service +* Add doc examples, class and methods for new `Tokens` service +* Add enums for `BuildRuntime `, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType` +* Update enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329 +* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage +* Add `queries` and `search` params to `listMemberships` method +* Remove `search` param from `listExecutions` method + +## 9.0.0 + +* Fix requests failing by removing `Content-Type` header from `GET` and `HEAD` requests + +## 8.0.0 + +* Remove redundant titles from method descriptions. +* Add `codable` models +* Ensure response attribute in `AppwriteException` is always string + +## 7.0.0 + +* Fix pong response & chunked upload diff --git a/README.md b/README.md index c7913e3..1b70833 100644 --- a/README.md +++ b/README.md @@ -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.1.0"), + .package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "10.2.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 0436599..6a21d52 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -21,7 +21,7 @@ open class Client { "x-sdk-name": "Swift", "x-sdk-platform": "server", "x-sdk-language": "swift", - "x-sdk-version": "10.1.0", + "x-sdk-version": "10.2.0", "x-appwrite-response-format": "1.7.0" ] From 0a0ee5d2dca700223be07aab70251fd56459f598 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 25 Jul 2025 11:45:21 +0000 Subject: [PATCH 5/5] update readme --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/README.md b/README.md index 1b70833..f18bc63 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,63 @@ func main() { } ``` +### Type Safety with Models + +The Appwrite Swift SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a `nestedType` parameter that allows you to specify your custom model type for full type safety. + +```swift +struct Book: Codable { + let name: String + let author: String + let releaseYear: String? + let category: String? + let genre: [String]? + let isCheckedOut: Bool +} + +let databases = Databases(client) + +do { + let documents = try await databases.listDocuments( + databaseId: "your-database-id", + collectionId: "your-collection-id", + nestedType: Book.self // Pass in your custom model type + ) + + for book in documents.documents { + print("Book: \(book.name) by \(book.author)") // Now you have full type safety + } +} catch { + print(error.localizedDescription) +} +``` + +**Tip**: You can use the `appwrite types` command to automatically generate model definitions based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation). + +### Working with Model Methods + +All Appwrite models come with built-in methods for data conversion and manipulation: + +**`toMap()`** - Converts a model instance to a dictionary format, useful for debugging or manual data manipulation: +```swift +let user = try await account.get() +let userMap = user.toMap() +print(userMap) // Prints all user properties as a dictionary +``` + +**`from(map:)`** - Creates a model instance from a dictionary, useful when working with raw data: +```swift +let userData: [String: Any] = ["$id": "123", "name": "John", "email": "john@example.com"] +let user = User.from(map: userData) +``` + +**`encode(to:)`** - Encodes the model to JSON format (part of Swift's Codable protocol), useful for serialization: +```swift +let user = try await account.get() +let jsonData = try JSONEncoder().encode(user) +let jsonString = String(data: jsonData, encoding: .utf8) +``` + ### Error Handling When an error occurs, the Appwrite Swift SDK throws an `AppwriteError` object with `message` and `code` properties. You can handle any errors in a catch block and present the `message` or `localizedDescription` to the user or handle it yourself based on the provided error information. Below is an example.