diff --git a/CHANGELOG.md b/CHANGELOG.md index 3197c21..b5622b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## 31.0.0 + +* Breaking: every service method declares `@Throws(AppwriteException::class)`; Java callers must catch `AppwriteException` +* Added: `account.listMemberships` to list the current user's team memberships +* Added: `createQuery` on `Databases`, `DocumentsDB` and `TablesDB` to send list queries in the request body +* Added: `bundleId` and `environment` params on `account.createPushTarget` and `updatePushTarget` +* Added: `@JvmStatic` on `ID`, `Permission`, `Role`, `Query`, `Operator`, `Channel` and `InputFile` helpers for Java +* Fixed: `row.data` keeps null-valued columns instead of dropping them +* Updated: Java examples catch `AppwriteException` and import `List` and `Map` + ## 30.0.0 * Breaking: requests send `x-appwrite-response-format: 2.5.0`; responses follow the 2.5 shapes diff --git a/README.md b/README.md index 2af8dc6..044266c 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Kotlin DSL (`build.gradle.kts`): ```kotlin dependencies { - implementation("io.appwrite:sdk-for-android:30.0.0") + implementation("io.appwrite:sdk-for-android:31.0.0") } ``` @@ -28,7 +28,7 @@ Groovy (`build.gradle`): ```groovy dependencies { - implementation 'io.appwrite:sdk-for-android:30.0.0' + implementation 'io.appwrite:sdk-for-android:31.0.0' } ``` diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index 4d99edf..91ec66f 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.createAnonymousSession(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.createAnonymousSession( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md index 9e254bd..307af61 100644 --- a/docs/examples/java/account/create-email-password-session.md +++ b/docs/examples/java/account/create-email-password-session.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Account account = new Account(client); -account.createEmailPasswordSession( - "email@example.com", // email - "password", // password - 60L, // duration (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createEmailPasswordSession( + "email@example.com", // email + "password", // password + 60L, // duration (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-email-token.md b/docs/examples/java/account/create-email-token.md index b651783..0895f7f 100644 --- a/docs/examples/java/account/create-email-token.md +++ b/docs/examples/java/account/create-email-token.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Account account = new Account(client); -account.createEmailToken( - "", // userId - "email@example.com", // email - false, // phrase (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createEmailToken( + "", // userId + "email@example.com", // email + false, // phrase (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-email-verification-otp.md b/docs/examples/java/account/create-email-verification-otp.md index 951b4bd..d0b30bc 100644 --- a/docs/examples/java/account/create-email-verification-otp.md +++ b/docs/examples/java/account/create-email-verification-otp.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.createEmailVerificationOTP( - false, // phrase (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createEmailVerificationOTP( + false, // phrase (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-email-verification.md b/docs/examples/java/account/create-email-verification.md index c809947..1173086 100644 --- a/docs/examples/java/account/create-email-verification.md +++ b/docs/examples/java/account/create-email-verification.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.createEmailVerification( - "https://example.com", // url - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createEmailVerification( + "https://example.com", // url + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-id-token-session.md b/docs/examples/java/account/create-id-token-session.md index b7bd83f..6e7aa06 100644 --- a/docs/examples/java/account/create-id-token-session.md +++ b/docs/examples/java/account/create-id-token-session.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; import io.appwrite.enums.IdTokenProvider; @@ -12,21 +13,24 @@ Client client = new Client(context) Account account = new Account(client); -account.createIdTokenSession( - IdTokenProvider.APPLE, // provider - "", // idToken - "", // nonce (optional) - "", // accessToken (optional) - 0L, // accessTokenExpiry (optional) - "", // name (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createIdTokenSession( + IdTokenProvider.APPLE, // provider + "", // idToken + "", // nonce (optional) + "", // accessToken (optional) + 0L, // accessTokenExpiry (optional) + "", // name (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-jwt.md b/docs/examples/java/account/create-jwt.md index c41c572..0044e2f 100644 --- a/docs/examples/java/account/create-jwt.md +++ b/docs/examples/java/account/create-jwt.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.createJWT( - 0L, // duration (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createJWT( + 0L, // duration (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-magic-url-token.md b/docs/examples/java/account/create-magic-url-token.md index e087ea8..c8a0c37 100644 --- a/docs/examples/java/account/create-magic-url-token.md +++ b/docs/examples/java/account/create-magic-url-token.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) Account account = new Account(client); -account.createMagicURLToken( - "", // userId - "email@example.com", // email - "https://example.com", // url (optional) - false, // phrase (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createMagicURLToken( + "", // userId + "email@example.com", // email + "https://example.com", // url (optional) + false, // phrase (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-mfa-authenticator.md b/docs/examples/java/account/create-mfa-authenticator.md index a87f010..11cfcf4 100644 --- a/docs/examples/java/account/create-mfa-authenticator.md +++ b/docs/examples/java/account/create-mfa-authenticator.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; import io.appwrite.enums.AuthenticatorType; @@ -12,16 +13,19 @@ Client client = new Client(context) Account account = new Account(client); -account.createMFAAuthenticator( - AuthenticatorType.TOTP, // type - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createMFAAuthenticator( + AuthenticatorType.TOTP, // type + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-mfa-challenge.md b/docs/examples/java/account/create-mfa-challenge.md index d0e9d5c..d2787aa 100644 --- a/docs/examples/java/account/create-mfa-challenge.md +++ b/docs/examples/java/account/create-mfa-challenge.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; import io.appwrite.enums.AuthenticationFactor; @@ -12,16 +13,19 @@ Client client = new Client(context) Account account = new Account(client); -account.createMFAChallenge( - AuthenticationFactor.EMAIL, // factor - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createMFAChallenge( + AuthenticationFactor.EMAIL, // factor + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-mfa-recovery-codes.md b/docs/examples/java/account/create-mfa-recovery-codes.md index caaa86a..14702ea 100644 --- a/docs/examples/java/account/create-mfa-recovery-codes.md +++ b/docs/examples/java/account/create-mfa-recovery-codes.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.createMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.createMFARecoveryCodes( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-o-auth-2-session.md b/docs/examples/java/account/create-o-auth-2-session.md index f2a07ef..b91d534 100644 --- a/docs/examples/java/account/create-o-auth-2-session.md +++ b/docs/examples/java/account/create-o-auth-2-session.md @@ -3,8 +3,10 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; import io.appwrite.enums.OAuthProvider; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -12,20 +14,24 @@ Client client = new Client(context) Account account = new Account(client); -account.createOAuth2Session( - OAuthProvider.AMAZON, // provider - "https://example.com", // success (optional) - "https://example.com", // failure (optional) - List.of(), // scopes (optional) - "", // state (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createOAuth2Session( + activity, // activity + OAuthProvider.AMAZON, // provider + "https://example.com", // success (optional) + "https://example.com", // failure (optional) + List.of(), // scopes (optional) + "", // state (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-o-auth-2-token.md b/docs/examples/java/account/create-o-auth-2-token.md index 885c066..287ae6b 100644 --- a/docs/examples/java/account/create-o-auth-2-token.md +++ b/docs/examples/java/account/create-o-auth-2-token.md @@ -3,8 +3,10 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; import io.appwrite.enums.OAuthProvider; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -12,20 +14,24 @@ Client client = new Client(context) Account account = new Account(client); -account.createOAuth2Token( - OAuthProvider.AMAZON, // provider - "https://example.com", // success (optional) - "https://example.com", // failure (optional) - List.of(), // scopes (optional) - "", // state (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createOAuth2Token( + activity, // activity + OAuthProvider.AMAZON, // provider + "https://example.com", // success (optional) + "https://example.com", // failure (optional) + List.of(), // scopes (optional) + "", // state (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-passkey-token.md b/docs/examples/java/account/create-passkey-token.md index 12db5fe..358cd2c 100644 --- a/docs/examples/java/account/create-passkey-token.md +++ b/docs/examples/java/account/create-passkey-token.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.createPasskeyToken(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.createPasskeyToken( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-passkey.md b/docs/examples/java/account/create-passkey.md index 39a9a29..a2541df 100644 --- a/docs/examples/java/account/create-passkey.md +++ b/docs/examples/java/account/create-passkey.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.createPasskey( - "", // passkeyId (optional) - "", // name (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createPasskey( + "", // passkeyId (optional) + "", // name (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-phone-token.md b/docs/examples/java/account/create-phone-token.md index a956837..bef46b4 100644 --- a/docs/examples/java/account/create-phone-token.md +++ b/docs/examples/java/account/create-phone-token.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.createPhoneToken( - "", // userId - "+12065550100", // phone - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createPhoneToken( + "", // userId + "+12065550100", // phone + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index db54d3c..03a559c 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.createPhoneVerification(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.createPhoneVerification( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md index 34d903c..dfe5576 100644 --- a/docs/examples/java/account/create-push-target.md +++ b/docs/examples/java/account/create-push-target.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,18 +12,23 @@ Client client = new Client(context) Account account = new Account(client); -account.createPushTarget( - "", // targetId - "", // identifier - "", // providerId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createPushTarget( + "", // targetId + "", // identifier + "", // providerId (optional) + "", // bundleId (optional) + "sandbox", // environment (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-recovery-otp.md b/docs/examples/java/account/create-recovery-otp.md index 66c165b..830ecbc 100644 --- a/docs/examples/java/account/create-recovery-otp.md +++ b/docs/examples/java/account/create-recovery-otp.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.createRecoveryOTP( - "email@example.com", // email - false, // phrase (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createRecoveryOTP( + "email@example.com", // email + false, // phrase (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index acc2230..68c9b13 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.createRecovery( - "email@example.com", // email - "https://example.com", // url - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createRecovery( + "email@example.com", // email + "https://example.com", // url + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-session.md index e9ea8d7..0ef4bb0 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-session.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.createSession( - "", // userId - "", // secret - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createSession( + "", // userId + "", // secret + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index 3c80fbe..272d3e2 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.createVerification( - "https://example.com", // url - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.createVerification( + "https://example.com", // url + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 6a84b3c..70cc63c 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) Account account = new Account(client); -account.create( - "", // userId - "email@example.com", // email - "password", // password - "", // name (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.create( + "", // userId + "email@example.com", // email + "password", // password + "", // name (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/delete-consent-token.md b/docs/examples/java/account/delete-consent-token.md index de7cf32..4242b46 100644 --- a/docs/examples/java/account/delete-consent-token.md +++ b/docs/examples/java/account/delete-consent-token.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.deleteConsentToken( - "", // consentId - "", // tokenId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.deleteConsentToken( + "", // consentId + "", // tokenId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/delete-consent.md b/docs/examples/java/account/delete-consent.md index 84450cc..4e21b6e 100644 --- a/docs/examples/java/account/delete-consent.md +++ b/docs/examples/java/account/delete-consent.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.deleteConsent( - "", // consentId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.deleteConsent( + "", // consentId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index 513de63..782698e 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.deleteIdentity( - "", // identityId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.deleteIdentity( + "", // identityId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/delete-mfa-authenticator.md b/docs/examples/java/account/delete-mfa-authenticator.md index c57eeab..426894e 100644 --- a/docs/examples/java/account/delete-mfa-authenticator.md +++ b/docs/examples/java/account/delete-mfa-authenticator.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; import io.appwrite.enums.AuthenticatorType; @@ -12,16 +13,19 @@ Client client = new Client(context) Account account = new Account(client); -account.deleteMFAAuthenticator( - AuthenticatorType.TOTP, // type - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.deleteMFAAuthenticator( + AuthenticatorType.TOTP, // type + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/delete-passkey.md b/docs/examples/java/account/delete-passkey.md index a59d384..50c83f3 100644 --- a/docs/examples/java/account/delete-passkey.md +++ b/docs/examples/java/account/delete-passkey.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.deletePasskey( - "", // passkeyId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.deletePasskey( + "", // passkeyId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md index a9e6aff..1c9aa4d 100644 --- a/docs/examples/java/account/delete-push-target.md +++ b/docs/examples/java/account/delete-push-target.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.deletePushTarget( - "", // targetId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.deletePushTarget( + "", // targetId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 84a7350..5b51aa8 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.deleteSession( - "", // sessionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.deleteSession( + "", // sessionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index e0dce6c..47a6e7f 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.deleteSessions( - false, // current (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.deleteSessions( + false, // current (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/get-consent-token.md b/docs/examples/java/account/get-consent-token.md index 1395852..8ddbe98 100644 --- a/docs/examples/java/account/get-consent-token.md +++ b/docs/examples/java/account/get-consent-token.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.getConsentToken( - "", // consentId - "", // tokenId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.getConsentToken( + "", // consentId + "", // tokenId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/get-consent.md b/docs/examples/java/account/get-consent.md index 54f2bf2..611ea16 100644 --- a/docs/examples/java/account/get-consent.md +++ b/docs/examples/java/account/get-consent.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.getConsent( - "", // consentId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.getConsent( + "", // consentId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/get-mfa-recovery-codes.md b/docs/examples/java/account/get-mfa-recovery-codes.md index 36814e6..bf28d8f 100644 --- a/docs/examples/java/account/get-mfa-recovery-codes.md +++ b/docs/examples/java/account/get-mfa-recovery-codes.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.getMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.getMFARecoveryCodes( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/get-passkey.md b/docs/examples/java/account/get-passkey.md index 5d988e8..5187175 100644 --- a/docs/examples/java/account/get-passkey.md +++ b/docs/examples/java/account/get-passkey.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.getPasskey( - "", // passkeyId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.getPasskey( + "", // passkeyId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index f951fe9..fb32ea7 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.getPrefs(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.getPrefs( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index 1fb6f1b..335729d 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.getSession( - "", // sessionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.getSession( + "", // sessionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index e452e89..ffea5ed 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.get(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.get( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/list-consent-tokens.md b/docs/examples/java/account/list-consent-tokens.md index 0552b7d..1cf0b72 100644 --- a/docs/examples/java/account/list-consent-tokens.md +++ b/docs/examples/java/account/list-consent-tokens.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Account account = new Account(client); -account.listConsentTokens( - "", // consentId - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.listConsentTokens( + "", // consentId + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/list-consents.md b/docs/examples/java/account/list-consents.md index 5db215f..3645790 100644 --- a/docs/examples/java/account/list-consents.md +++ b/docs/examples/java/account/list-consents.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) Account account = new Account(client); -account.listConsents( - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.listConsents( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index 1222eda..7c20fc2 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) Account account = new Account(client); -account.listIdentities( - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.listIdentities( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/list-memberships.md b/docs/examples/java/account/list-memberships.md new file mode 100644 index 0000000..dc0b67b --- /dev/null +++ b/docs/examples/java/account/list-memberships.md @@ -0,0 +1,32 @@ +```java +import android.util.Log; + +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; +import io.appwrite.services.Account; +import java.util.List; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +try { + account.listMemberships( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} +``` diff --git a/docs/examples/java/account/list-mfa-factors.md b/docs/examples/java/account/list-mfa-factors.md index f0c3e01..7848776 100644 --- a/docs/examples/java/account/list-mfa-factors.md +++ b/docs/examples/java/account/list-mfa-factors.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.listMFAFactors(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.listMFAFactors( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/list-passkeys.md b/docs/examples/java/account/list-passkeys.md index 6b04b1f..36d2b7d 100644 --- a/docs/examples/java/account/list-passkeys.md +++ b/docs/examples/java/account/list-passkeys.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) Account account = new Account(client); -account.listPasskeys( - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.listPasskeys( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index 5ea5062..743a297 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.listSessions( - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.listSessions( + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-email-verification-otp.md b/docs/examples/java/account/update-email-verification-otp.md index d66521c..91005ee 100644 --- a/docs/examples/java/account/update-email-verification-otp.md +++ b/docs/examples/java/account/update-email-verification-otp.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updateEmailVerificationOTP( - "", // userId - "", // secret - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateEmailVerificationOTP( + "", // userId + "", // secret + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-email-verification.md b/docs/examples/java/account/update-email-verification.md index 1c9bc86..a99bf4c 100644 --- a/docs/examples/java/account/update-email-verification.md +++ b/docs/examples/java/account/update-email-verification.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updateEmailVerification( - "", // userId - "", // secret - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateEmailVerification( + "", // userId + "", // secret + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index d077f9f..2eab32e 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updateEmail( - "email@example.com", // email - "password", // password - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateEmail( + "email@example.com", // email + "password", // password + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-magic-url-session.md b/docs/examples/java/account/update-magic-url-session.md index be3e9b0..fc8c9b9 100644 --- a/docs/examples/java/account/update-magic-url-session.md +++ b/docs/examples/java/account/update-magic-url-session.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updateMagicURLSession( - "", // userId - "", // secret - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateMagicURLSession( + "", // userId + "", // secret + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-mfa-authenticator.md b/docs/examples/java/account/update-mfa-authenticator.md index e2b017c..dfe46ab 100644 --- a/docs/examples/java/account/update-mfa-authenticator.md +++ b/docs/examples/java/account/update-mfa-authenticator.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; import io.appwrite.enums.AuthenticatorType; @@ -12,17 +13,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updateMFAAuthenticator( - AuthenticatorType.TOTP, // type - "", // otp - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateMFAAuthenticator( + AuthenticatorType.TOTP, // type + "", // otp + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-mfa-challenge.md b/docs/examples/java/account/update-mfa-challenge.md index 132b299..910f5fd 100644 --- a/docs/examples/java/account/update-mfa-challenge.md +++ b/docs/examples/java/account/update-mfa-challenge.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updateMFAChallenge( - "", // challengeId - "", // otp - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateMFAChallenge( + "", // challengeId + "", // otp + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-mfa-recovery-codes.md b/docs/examples/java/account/update-mfa-recovery-codes.md index 38c2fa9..8855177 100644 --- a/docs/examples/java/account/update-mfa-recovery-codes.md +++ b/docs/examples/java/account/update-mfa-recovery-codes.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.updateMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.updateMFARecoveryCodes( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-mfa.md b/docs/examples/java/account/update-mfa.md index dc9a3d7..61fa037 100644 --- a/docs/examples/java/account/update-mfa.md +++ b/docs/examples/java/account/update-mfa.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.updateMFA( - false, // mfa - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateMFA( + false, // mfa + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index 3aca6d8..547b613 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.updateName( - "", // name - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateName( + "", // name + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-passkey-token.md b/docs/examples/java/account/update-passkey-token.md index 6370aaa..f278a78 100644 --- a/docs/examples/java/account/update-passkey-token.md +++ b/docs/examples/java/account/update-passkey-token.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePasskeyToken( - "", // challengeId - Map.of("a", "b"), // credential - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updatePasskeyToken( + "", // challengeId + Map.of("a", "b"), // credential + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-passkey-verification.md b/docs/examples/java/account/update-passkey-verification.md index 53eed3a..da63835 100644 --- a/docs/examples/java/account/update-passkey-verification.md +++ b/docs/examples/java/account/update-passkey-verification.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePasskeyVerification( - "", // passkeyId - Map.of("a", "b"), // credential - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updatePasskeyVerification( + "", // passkeyId + Map.of("a", "b"), // credential + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-passkey.md b/docs/examples/java/account/update-passkey.md index 3cf1078..fb34998 100644 --- a/docs/examples/java/account/update-passkey.md +++ b/docs/examples/java/account/update-passkey.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePasskey( - "", // passkeyId - "", // name - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updatePasskey( + "", // passkeyId + "", // name + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index c491f4b..2c019fd 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePassword( - "password", // password - "password", // oldPassword (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updatePassword( + "password", // password + "password", // oldPassword (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md index edaa99d..3fd35d6 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/update-phone-session.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePhoneSession( - "", // userId - "", // secret - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updatePhoneSession( + "", // userId + "", // secret + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index b8f19ab..71d3b2f 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePhoneVerification( - "", // userId - "", // secret - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updatePhoneVerification( + "", // userId + "", // secret + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index 6613850..d076a08 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePhone( - "+12065550100", // phone - "password", // password - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updatePhone( + "+12065550100", // phone + "password", // password + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index 819a899..6663094 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,20 +13,23 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePrefs( - Map.of( - "language", "en", - "timezone", "UTC", - "darkTheme", true - ), // prefs - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updatePrefs( + Map.of( + "language", "en", + "timezone", "UTC", + "darkTheme", true + ), // prefs + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md index 1977878..d8b0240 100644 --- a/docs/examples/java/account/update-push-target.md +++ b/docs/examples/java/account/update-push-target.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,22 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePushTarget( - "", // targetId - "", // identifier - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updatePushTarget( + "", // targetId + "", // identifier + "", // bundleId (optional) + "sandbox", // environment (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-recovery-otp.md b/docs/examples/java/account/update-recovery-otp.md index c16df28..6de0bca 100644 --- a/docs/examples/java/account/update-recovery-otp.md +++ b/docs/examples/java/account/update-recovery-otp.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Account account = new Account(client); -account.updateRecoveryOTP( - "", // userId - "", // secret - "password", // password - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateRecoveryOTP( + "", // userId + "", // secret + "password", // password + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index 96741d0..395a39d 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Account account = new Account(client); -account.updateRecovery( - "", // userId - "", // secret - "password", // password - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateRecovery( + "", // userId + "", // secret + "password", // password + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index bf54de4..3bb8d5c 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Account account = new Account(client); -account.updateSession( - "", // sessionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateSession( + "", // sessionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index a0537ae..a640780 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Account account = new Account(client); -account.updateStatus(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + account.updateStatus( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index 2f63c5b..4649237 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Account; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Account account = new Account(client); -account.updateVerification( - "", // userId - "", // secret - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + account.updateVerification( + "", // userId + "", // secret + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/analytics/create-event.md b/docs/examples/java/analytics/create-event.md index e2b8dbe..e94b141 100644 --- a/docs/examples/java/analytics/create-event.md +++ b/docs/examples/java/analytics/create-event.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Analytics; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,28 +13,31 @@ Client client = new Client(context) Analytics analytics = new Analytics(client); -analytics.createEvent( - "", // propertyId - "", // name - "https://example.com", // url - "", // domain (optional) - "", // referrer (optional) - 0L, // screenWidth (optional) - "", // sessionHash (optional) - 0L, // scrollDepth (optional) - 0L, // engagementTime (optional) - List.of(), // props (optional) - "", // userId (optional) - "", // ip (optional) - "", // userAgent (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + analytics.createEvent( + "", // propertyId + "", // name + "https://example.com", // url + "", // domain (optional) + "", // referrer (optional) + 0L, // screenWidth (optional) + "", // sessionHash (optional) + 0L, // scrollDepth (optional) + 0L, // engagementTime (optional) + List.of(), // props (optional) + "", // userId (optional) + "", // ip (optional) + "", // userAgent (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/create-installation-token.md b/docs/examples/java/apps/create-installation-token.md index e46fc2a..aa03579 100644 --- a/docs/examples/java/apps/create-installation-token.md +++ b/docs/examples/java/apps/create-installation-token.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.createInstallationToken( - "", // appId - "", // installationId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.createInstallationToken( + "", // appId + "", // installationId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/create-key.md b/docs/examples/java/apps/create-key.md index 729c98f..cfb7892 100644 --- a/docs/examples/java/apps/create-key.md +++ b/docs/examples/java/apps/create-key.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.createKey( - "", // appId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.createKey( + "", // appId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/create-secret.md b/docs/examples/java/apps/create-secret.md index 8acb44e..0059d14 100644 --- a/docs/examples/java/apps/create-secret.md +++ b/docs/examples/java/apps/create-secret.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.createSecret( - "", // appId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.createSecret( + "", // appId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/create.md b/docs/examples/java/apps/create.md index 88694a9..43beeb0 100644 --- a/docs/examples/java/apps/create.md +++ b/docs/examples/java/apps/create.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,34 +13,37 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.create( - "", // appId - "", // name - List.of(), // redirectUris - "", // description (optional) - "https://example.com", // clientUri (optional) - "https://example.com", // logoUri (optional) - "https://example.com", // privacyPolicyUrl (optional) - "https://example.com", // termsUrl (optional) - List.of(), // contacts (optional) - "", // tagline (optional) - List.of(), // tags (optional) - List.of(), // images (optional) - "https://example.com", // supportUrl (optional) - "https://example.com", // dataDeletionUrl (optional) - List.of(), // postLogoutRedirectUris (optional) - false, // enabled (optional) - "public", // type (optional) - false, // deviceFlow (optional) - "", // teamId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.create( + "", // appId + "", // name + List.of(), // redirectUris + "", // description (optional) + "https://example.com", // clientUri (optional) + "https://example.com", // logoUri (optional) + "https://example.com", // privacyPolicyUrl (optional) + "https://example.com", // termsUrl (optional) + List.of(), // contacts (optional) + "", // tagline (optional) + List.of(), // tags (optional) + List.of(), // images (optional) + "https://example.com", // supportUrl (optional) + "https://example.com", // dataDeletionUrl (optional) + List.of(), // postLogoutRedirectUris (optional) + false, // enabled (optional) + "public", // type (optional) + false, // deviceFlow (optional) + "", // teamId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/delete-installation.md b/docs/examples/java/apps/delete-installation.md index 559ab65..d9e74d1 100644 --- a/docs/examples/java/apps/delete-installation.md +++ b/docs/examples/java/apps/delete-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.deleteInstallation( - "", // appId - "", // installationId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.deleteInstallation( + "", // appId + "", // installationId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/delete-key.md b/docs/examples/java/apps/delete-key.md index 312e0be..c36eeb3 100644 --- a/docs/examples/java/apps/delete-key.md +++ b/docs/examples/java/apps/delete-key.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.deleteKey( - "", // appId - "", // keyId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.deleteKey( + "", // appId + "", // keyId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/delete-secret.md b/docs/examples/java/apps/delete-secret.md index b21fc75..cbf889c 100644 --- a/docs/examples/java/apps/delete-secret.md +++ b/docs/examples/java/apps/delete-secret.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.deleteSecret( - "", // appId - "", // secretId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.deleteSecret( + "", // appId + "", // secretId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/delete-tokens.md b/docs/examples/java/apps/delete-tokens.md index f873873..464eddf 100644 --- a/docs/examples/java/apps/delete-tokens.md +++ b/docs/examples/java/apps/delete-tokens.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.deleteTokens( - "", // appId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.deleteTokens( + "", // appId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/delete.md b/docs/examples/java/apps/delete.md index 0c99520..312cdc8 100644 --- a/docs/examples/java/apps/delete.md +++ b/docs/examples/java/apps/delete.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.delete( - "", // appId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.delete( + "", // appId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/get-installation.md b/docs/examples/java/apps/get-installation.md index f8cf6b5..90ccca2 100644 --- a/docs/examples/java/apps/get-installation.md +++ b/docs/examples/java/apps/get-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.getInstallation( - "", // appId - "", // installationId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.getInstallation( + "", // appId + "", // installationId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/get-key.md b/docs/examples/java/apps/get-key.md index 729ccfa..b2c9652 100644 --- a/docs/examples/java/apps/get-key.md +++ b/docs/examples/java/apps/get-key.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.getKey( - "", // appId - "", // keyId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.getKey( + "", // appId + "", // keyId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/get-secret.md b/docs/examples/java/apps/get-secret.md index f4f3c68..fa0a09a 100644 --- a/docs/examples/java/apps/get-secret.md +++ b/docs/examples/java/apps/get-secret.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.getSecret( - "", // appId - "", // secretId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.getSecret( + "", // appId + "", // secretId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/get.md b/docs/examples/java/apps/get.md index 0b4c537..1d2fff9 100644 --- a/docs/examples/java/apps/get.md +++ b/docs/examples/java/apps/get.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.get( - "", // appId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.get( + "", // appId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/list-installation-scopes.md b/docs/examples/java/apps/list-installation-scopes.md index c09da78..3798301 100644 --- a/docs/examples/java/apps/list-installation-scopes.md +++ b/docs/examples/java/apps/list-installation-scopes.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.listInstallationScopes(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + apps.listInstallationScopes( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/list-installations.md b/docs/examples/java/apps/list-installations.md index f83097e..ec24b88 100644 --- a/docs/examples/java/apps/list-installations.md +++ b/docs/examples/java/apps/list-installations.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.listInstallations( - "", // appId - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.listInstallations( + "", // appId + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/list-keys.md b/docs/examples/java/apps/list-keys.md index 7a87275..0858f05 100644 --- a/docs/examples/java/apps/list-keys.md +++ b/docs/examples/java/apps/list-keys.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.listKeys( - "", // appId - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.listKeys( + "", // appId + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/list-o-auth-2-scopes.md b/docs/examples/java/apps/list-o-auth-2-scopes.md index d96f8c3..3019255 100644 --- a/docs/examples/java/apps/list-o-auth-2-scopes.md +++ b/docs/examples/java/apps/list-o-auth-2-scopes.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.listOAuth2Scopes(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + apps.listOAuth2Scopes( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/list-secrets.md b/docs/examples/java/apps/list-secrets.md index 4d823a7..fe68bd2 100644 --- a/docs/examples/java/apps/list-secrets.md +++ b/docs/examples/java/apps/list-secrets.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.listSecrets( - "", // appId - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.listSecrets( + "", // appId + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/list.md b/docs/examples/java/apps/list.md index 31d80da..e900736 100644 --- a/docs/examples/java/apps/list.md +++ b/docs/examples/java/apps/list.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.list( - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.list( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/update-team.md b/docs/examples/java/apps/update-team.md index 314c672..4e61404 100644 --- a/docs/examples/java/apps/update-team.md +++ b/docs/examples/java/apps/update-team.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.updateTeam( - "", // appId - "", // teamId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.updateTeam( + "", // appId + "", // teamId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/apps/update.md b/docs/examples/java/apps/update.md index e8b51fa..822b1f2 100644 --- a/docs/examples/java/apps/update.md +++ b/docs/examples/java/apps/update.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Apps; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,35 +13,38 @@ Client client = new Client(context) Apps apps = new Apps(client); -apps.update( - "", // appId - "", // name - "", // description (optional) - "https://example.com", // clientUri (optional) - "https://example.com", // logoUri (optional) - "https://example.com", // privacyPolicyUrl (optional) - "https://example.com", // termsUrl (optional) - List.of(), // contacts (optional) - "", // tagline (optional) - List.of(), // tags (optional) - List.of(), // images (optional) - "https://example.com", // supportUrl (optional) - "https://example.com", // dataDeletionUrl (optional) - false, // enabled (optional) - List.of(), // redirectUris (optional) - List.of(), // postLogoutRedirectUris (optional) - "public", // type (optional) - false, // deviceFlow (optional) - List.of(), // installationScopes (optional) - "https://example.com", // installationRedirectUrl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + apps.update( + "", // appId + "", // name + "", // description (optional) + "https://example.com", // clientUri (optional) + "https://example.com", // logoUri (optional) + "https://example.com", // privacyPolicyUrl (optional) + "https://example.com", // termsUrl (optional) + List.of(), // contacts (optional) + "", // tagline (optional) + List.of(), // tags (optional) + List.of(), // images (optional) + "https://example.com", // supportUrl (optional) + "https://example.com", // dataDeletionUrl (optional) + false, // enabled (optional) + List.of(), // redirectUris (optional) + List.of(), // postLogoutRedirectUris (optional) + "public", // type (optional) + false, // deviceFlow (optional) + List.of(), // installationScopes (optional) + "https://example.com", // installationRedirectUrl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/delete-photo.md b/docs/examples/java/avatars/delete-photo.md index cffc010..8887c60 100644 --- a/docs/examples/java/avatars/delete-photo.md +++ b/docs/examples/java/avatars/delete-photo.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.deletePhoto(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + avatars.deletePhoto( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index 626de03..55f2c58 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; import io.appwrite.enums.Browser; @@ -12,19 +13,22 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.getBrowser( - Browser.AVANT_BROWSER, // code - 0L, // width (optional) - 0L, // height (optional) - -1L, // quality (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.getBrowser( + Browser.AVANT_BROWSER, // code + 0L, // width (optional) + 0L, // height (optional) + -1L, // quality (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index f8e114d..0d187ee 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; import io.appwrite.enums.CreditCard; @@ -12,19 +13,22 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.getCreditCard( - CreditCard.AMERICAN_EXPRESS, // code - 0L, // width (optional) - 0L, // height (optional) - -1L, // quality (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.getCreditCard( + CreditCard.AMERICAN_EXPRESS, // code + 0L, // width (optional) + 0L, // height (optional) + -1L, // quality (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index c7bc641..21bcee0 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.getFavicon( - "https://example.com", // url - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.getFavicon( + "https://example.com", // url + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index 0acd391..d07d413 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; import io.appwrite.enums.Flag; @@ -12,19 +13,22 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.getFlag( - Flag.AFGHANISTAN, // code - 0L, // width (optional) - 0L, // height (optional) - -1L, // quality (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.getFlag( + Flag.AFGHANISTAN, // code + 0L, // width (optional) + 0L, // height (optional) + -1L, // quality (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index 38bd4dc..a168bdc 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.getImage( - "https://example.com", // url - 0L, // width (optional) - 0L, // height (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.getImage( + "https://example.com", // url + 0L, // width (optional) + 0L, // height (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index c22358d..84359f4 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.getInitials( - "", // name (optional) - 0L, // width (optional) - 0L, // height (optional) - "FFFFFF", // background (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.getInitials( + "", // name (optional) + 0L, // width (optional) + 0L, // height (optional) + "FFFFFF", // background (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/get-photo.md b/docs/examples/java/avatars/get-photo.md index 04769d1..d6b741d 100644 --- a/docs/examples/java/avatars/get-photo.md +++ b/docs/examples/java/avatars/get-photo.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; Client client = new Client(context) @@ -11,23 +12,26 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.getPhoto( - 0L, // width (optional) - 0L, // height (optional) - 0L, // quality (optional) - "png", // output (optional) - "g", // rating (optional) - "current()", // userId (optional) - "", // emailHash (optional) - "", // name (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.getPhoto( + 0L, // width (optional) + 0L, // height (optional) + 0L, // quality (optional) + "png", // output (optional) + "g", // rating (optional) + "current()", // userId (optional) + "", // emailHash (optional) + "", // name (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/get-qr.md b/docs/examples/java/avatars/get-qr.md index b3bbb6b..95b4a81 100644 --- a/docs/examples/java/avatars/get-qr.md +++ b/docs/examples/java/avatars/get-qr.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.getQR( - "", // text - 1L, // size (optional) - 0L, // margin (optional) - false, // download (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.getQR( + "", // text + 1L, // size (optional) + 0L, // margin (optional) + false, // download (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/get-screenshot.md b/docs/examples/java/avatars/get-screenshot.md index 82454a6..7a10937 100644 --- a/docs/examples/java/avatars/get-screenshot.md +++ b/docs/examples/java/avatars/get-screenshot.md @@ -3,11 +3,14 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Avatars; import io.appwrite.enums.BrowserTheme; import io.appwrite.enums.Timezone; import io.appwrite.enums.BrowserPermission; import io.appwrite.enums.ImageFormat; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -15,37 +18,40 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.getScreenshot( - "https://example.com", // url - Map.of( - "Accept-Language", "en-US,en;q=0.9" - ), // headers (optional) - 1920L, // viewportWidth (optional) - 1080L, // viewportHeight (optional) - 2.0, // scale (optional) - BrowserTheme.LIGHT, // theme (optional) - "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15", // userAgent (optional) - true, // fullpage (optional) - "en-US", // locale (optional) - Timezone.AFRICA_ABIDJAN, // timezone (optional) - 37.7749, // latitude (optional) - -122.4194, // longitude (optional) - 100.0, // accuracy (optional) - true, // touch (optional) - BrowserPermission.GEOLOCATION, // permissions (optional) - 3L, // sleep (optional) - 800L, // width (optional) - 600L, // height (optional) - 85L, // quality (optional) - ImageFormat.JPG, // output (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.getScreenshot( + "https://example.com", // url + Map.of( + "Accept-Language", "en-US,en;q=0.9" + ), // headers (optional) + 1920L, // viewportWidth (optional) + 1080L, // viewportHeight (optional) + 2.0, // scale (optional) + BrowserTheme.DARK, // theme (optional) + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15", // userAgent (optional) + true, // fullpage (optional) + "en-US", // locale (optional) + Timezone.AFRICA_ABIDJAN, // timezone (optional) + 37.7749, // latitude (optional) + -122.4194, // longitude (optional) + 100.0, // accuracy (optional) + true, // touch (optional) + List.of(BrowserPermission.GEOLOCATION, BrowserPermission.NOTIFICATIONS), // permissions (optional) + 3L, // sleep (optional) + 800L, // width (optional) + 600L, // height (optional) + 85L, // quality (optional) + ImageFormat.JPEG, // output (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/avatars/update-photo.md b/docs/examples/java/avatars/update-photo.md index 8c4d6e9..61d981e 100644 --- a/docs/examples/java/avatars/update-photo.md +++ b/docs/examples/java/avatars/update-photo.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.models.InputFile; import io.appwrite.services.Avatars; @@ -12,16 +13,19 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); -avatars.updatePhoto( - InputFile.fromPath("file.png"), // file - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + avatars.updatePhoto( + InputFile.fromPath("file.png"), // file + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 3c64659..ac32bc4 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.Databases; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,27 +16,30 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.createDocument( - "", // databaseId - "", // collectionId - "", // documentId - Map.of( - "username", "walter.obrien", - "email", "walter.obrien@example.com", - "fullName", "Walter O'Brien", - "age", 30, - "isAdmin", false - ), // data - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.createDocument( + "", // databaseId + "", // collectionId + "", // documentId + Map.of( + "username", "walter.obrien", + "email", "walter.obrien@example.com", + "fullName", "Walter O'Brien", + "age", 30, + "isAdmin", false + ), // data + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/create-operations.md b/docs/examples/java/databases/create-operations.md index bbef857..597fc74 100644 --- a/docs/examples/java/databases/create-operations.md +++ b/docs/examples/java/databases/create-operations.md @@ -3,7 +3,10 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,25 +14,28 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.createOperations( - "", // transactionId - List.of(Map.of( - "action", "create", - "databaseId", "", - "collectionId", "", - "documentId", "", - "data", Map.of( - "name", "Walter O'Brien" - ) - )), // operations (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.createOperations( + "", // transactionId + List.of(Map.of( + "action", "create", + "databaseId", "", + "collectionId", "", + "documentId", "", + "data", Map.of( + "name", "Walter O'Brien" + ) + )), // operations (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/create-query.md b/docs/examples/java/databases/create-query.md new file mode 100644 index 0000000..f01db5c --- /dev/null +++ b/docs/examples/java/databases/create-query.md @@ -0,0 +1,36 @@ +```java +import android.util.Log; + +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; +import io.appwrite.services.Databases; +import java.util.List; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +try { + databases.createQuery( + "", // databaseId + "", // collectionId + List.of(), // queries (optional) + "", // transactionId (optional) + false, // total (optional) + 0L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} +``` diff --git a/docs/examples/java/databases/create-transaction.md b/docs/examples/java/databases/create-transaction.md index 616838d..09c8ffa 100644 --- a/docs/examples/java/databases/create-transaction.md +++ b/docs/examples/java/databases/create-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.createTransaction( - 60L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.createTransaction( + 60L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/decrement-document-attribute.md b/docs/examples/java/databases/decrement-document-attribute.md index 682dadd..473366b 100644 --- a/docs/examples/java/databases/decrement-document-attribute.md +++ b/docs/examples/java/databases/decrement-document-attribute.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; Client client = new Client(context) @@ -11,22 +12,25 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.decrementDocumentAttribute( - "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 1.0, // value (optional) - 0.0, // min (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.decrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 1.0, // value (optional) + 0.0, // min (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index ef04ee6..6ed4471 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.deleteDocument( - "", // databaseId - "", // collectionId - "", // documentId - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.deleteDocument( + "", // databaseId + "", // collectionId + "", // documentId + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/delete-transaction.md b/docs/examples/java/databases/delete-transaction.md index 4a2d8f0..5f1d63f 100644 --- a/docs/examples/java/databases/delete-transaction.md +++ b/docs/examples/java/databases/delete-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.deleteTransaction( - "", // transactionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.deleteTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index 106afa2..69855a9 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,20 +13,23 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.getDocument( - "", // databaseId - "", // collectionId - "", // documentId - List.of(), // queries (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.getDocument( + "", // databaseId + "", // collectionId + "", // documentId + List.of(), // queries (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/get-transaction.md b/docs/examples/java/databases/get-transaction.md index b33a4bc..744688e 100644 --- a/docs/examples/java/databases/get-transaction.md +++ b/docs/examples/java/databases/get-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.getTransaction( - "", // transactionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.getTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/increment-document-attribute.md b/docs/examples/java/databases/increment-document-attribute.md index 07dfd55..866ae3c 100644 --- a/docs/examples/java/databases/increment-document-attribute.md +++ b/docs/examples/java/databases/increment-document-attribute.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; Client client = new Client(context) @@ -11,22 +12,25 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.incrementDocumentAttribute( - "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 1.0, // value (optional) - 100.0, // max (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.incrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 1.0, // value (optional) + 100.0, // max (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 8a5a52c..c08d8f4 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,21 +13,24 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.listDocuments( - "", // databaseId - "", // collectionId - List.of(), // queries (optional) - "", // transactionId (optional) - false, // total (optional) - 0L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.listDocuments( + "", // databaseId + "", // collectionId + List.of(), // queries (optional) + "", // transactionId (optional) + false, // total (optional) + 0L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/list-transactions.md b/docs/examples/java/databases/list-transactions.md index 3e7ca13..36fbc33 100644 --- a/docs/examples/java/databases/list-transactions.md +++ b/docs/examples/java/databases/list-transactions.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.listTransactions( - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.listTransactions( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index 40dc7c7..88e3cef 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.Databases; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,27 +16,30 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.updateDocument( - "", // databaseId - "", // collectionId - "", // documentId - Map.of( - "username", "walter.obrien", - "email", "walter.obrien@example.com", - "fullName", "Walter O'Brien", - "age", 33, - "isAdmin", false - ), // data (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.updateDocument( + "", // databaseId + "", // collectionId + "", // documentId + Map.of( + "username", "walter.obrien", + "email", "walter.obrien@example.com", + "fullName", "Walter O'Brien", + "age", 33, + "isAdmin", false + ), // data (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/update-transaction.md b/docs/examples/java/databases/update-transaction.md index dfc4db6..8f486a9 100644 --- a/docs/examples/java/databases/update-transaction.md +++ b/docs/examples/java/databases/update-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Databases; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.updateTransaction( - "", // transactionId - false, // commit (optional) - false, // rollback (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.updateTransaction( + "", // transactionId + false, // commit (optional) + false, // rollback (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/databases/upsert-document.md b/docs/examples/java/databases/upsert-document.md index f5976a9..5194e60 100644 --- a/docs/examples/java/databases/upsert-document.md +++ b/docs/examples/java/databases/upsert-document.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.Databases; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,27 +16,30 @@ Client client = new Client(context) Databases databases = new Databases(client); -databases.upsertDocument( - "", // databaseId - "", // collectionId - "", // documentId - Map.of( - "username", "walter.obrien", - "email", "walter.obrien@example.com", - "fullName", "Walter O'Brien", - "age", 30, - "isAdmin", false - ), // data (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + databases.upsertDocument( + "", // databaseId + "", // collectionId + "", // documentId + Map.of( + "username", "walter.obrien", + "email", "walter.obrien@example.com", + "fullName", "Walter O'Brien", + "age", 30, + "isAdmin", false + ), // data (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/create-document.md b/docs/examples/java/documentsdb/create-document.md index 77f034d..a2cd22e 100644 --- a/docs/examples/java/documentsdb/create-document.md +++ b/docs/examples/java/documentsdb/create-document.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.DocumentsDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,27 +16,30 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.createDocument( - "", // databaseId - "", // collectionId - "", // documentId - Map.of( - "username", "walter.obrien", - "email", "walter.obrien@example.com", - "fullName", "Walter O'Brien", - "age", 30, - "isAdmin", false - ), // data - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.createDocument( + "", // databaseId + "", // collectionId + "", // documentId + Map.of( + "username", "walter.obrien", + "email", "walter.obrien@example.com", + "fullName", "Walter O'Brien", + "age", 30, + "isAdmin", false + ), // data + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/create-documents.md b/docs/examples/java/documentsdb/create-documents.md index ae20335..e0c6f5b 100644 --- a/docs/examples/java/documentsdb/create-documents.md +++ b/docs/examples/java/documentsdb/create-documents.md @@ -3,7 +3,10 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,26 +14,29 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.createDocuments( - "", // databaseId - "", // collectionId - List.of(Map.of( - "$id", "example1", - "username", "walter.obrien", - "email", "walter.obrien@example.com", - "fullName", "Walter O'Brien", - "age", 30, - "isAdmin", false - )), // documents - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.createDocuments( + "", // databaseId + "", // collectionId + List.of(Map.of( + "$id", "example1", + "username", "walter.obrien", + "email", "walter.obrien@example.com", + "fullName", "Walter O'Brien", + "age", 30, + "isAdmin", false + )), // documents + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/create-operations.md b/docs/examples/java/documentsdb/create-operations.md index 961a550..9b81826 100644 --- a/docs/examples/java/documentsdb/create-operations.md +++ b/docs/examples/java/documentsdb/create-operations.md @@ -3,7 +3,10 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,25 +14,28 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.createOperations( - "", // transactionId - List.of(Map.of( - "action", "create", - "databaseId", "", - "collectionId", "", - "documentId", "", - "data", Map.of( - "name", "Walter O'Brien" - ) - )), // operations (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.createOperations( + "", // transactionId + List.of(Map.of( + "action", "create", + "databaseId", "", + "collectionId", "", + "documentId", "", + "data", Map.of( + "name", "Walter O'Brien" + ) + )), // operations (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/create-query.md b/docs/examples/java/documentsdb/create-query.md new file mode 100644 index 0000000..710cff1 --- /dev/null +++ b/docs/examples/java/documentsdb/create-query.md @@ -0,0 +1,36 @@ +```java +import android.util.Log; + +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; +import io.appwrite.services.DocumentsDB; +import java.util.List; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +DocumentsDB documentsDB = new DocumentsDB(client); + +try { + documentsDB.createQuery( + "", // databaseId + "", // collectionId + List.of(), // queries (optional) + "", // transactionId (optional) + false, // total (optional) + 0L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} +``` diff --git a/docs/examples/java/documentsdb/create-transaction.md b/docs/examples/java/documentsdb/create-transaction.md index ac4a96d..fffd080 100644 --- a/docs/examples/java/documentsdb/create-transaction.md +++ b/docs/examples/java/documentsdb/create-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.createTransaction( - 60L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.createTransaction( + 60L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/decrement-document-attribute.md b/docs/examples/java/documentsdb/decrement-document-attribute.md index 9e19095..d2e3707 100644 --- a/docs/examples/java/documentsdb/decrement-document-attribute.md +++ b/docs/examples/java/documentsdb/decrement-document-attribute.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; Client client = new Client(context) @@ -11,22 +12,25 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.decrementDocumentAttribute( - "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 1.0, // value (optional) - 0.0, // min (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.decrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 1.0, // value (optional) + 0.0, // min (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/delete-document.md b/docs/examples/java/documentsdb/delete-document.md index 247a63a..f72562b 100644 --- a/docs/examples/java/documentsdb/delete-document.md +++ b/docs/examples/java/documentsdb/delete-document.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.deleteDocument( - "", // databaseId - "", // collectionId - "", // documentId - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.deleteDocument( + "", // databaseId + "", // collectionId + "", // documentId + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/delete-transaction.md b/docs/examples/java/documentsdb/delete-transaction.md index 0b0a761..d88032a 100644 --- a/docs/examples/java/documentsdb/delete-transaction.md +++ b/docs/examples/java/documentsdb/delete-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.deleteTransaction( - "", // transactionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.deleteTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/get-document.md b/docs/examples/java/documentsdb/get-document.md index 7bd66e1..14f4ecd 100644 --- a/docs/examples/java/documentsdb/get-document.md +++ b/docs/examples/java/documentsdb/get-document.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,20 +13,23 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.getDocument( - "", // databaseId - "", // collectionId - "", // documentId - List.of(), // queries (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.getDocument( + "", // databaseId + "", // collectionId + "", // documentId + List.of(), // queries (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/get-transaction.md b/docs/examples/java/documentsdb/get-transaction.md index 12c4224..5064ce0 100644 --- a/docs/examples/java/documentsdb/get-transaction.md +++ b/docs/examples/java/documentsdb/get-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.getTransaction( - "", // transactionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.getTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/increment-document-attribute.md b/docs/examples/java/documentsdb/increment-document-attribute.md index 470abbf..462ecfc 100644 --- a/docs/examples/java/documentsdb/increment-document-attribute.md +++ b/docs/examples/java/documentsdb/increment-document-attribute.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; Client client = new Client(context) @@ -11,22 +12,25 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.incrementDocumentAttribute( - "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 1.0, // value (optional) - 100.0, // max (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.incrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 1.0, // value (optional) + 100.0, // max (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/list-documents.md b/docs/examples/java/documentsdb/list-documents.md index f6cfe48..4da9d6a 100644 --- a/docs/examples/java/documentsdb/list-documents.md +++ b/docs/examples/java/documentsdb/list-documents.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,21 +13,24 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.listDocuments( - "", // databaseId - "", // collectionId - List.of(), // queries (optional) - "", // transactionId (optional) - false, // total (optional) - 0L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.listDocuments( + "", // databaseId + "", // collectionId + List.of(), // queries (optional) + "", // transactionId (optional) + false, // total (optional) + 0L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/list-transactions.md b/docs/examples/java/documentsdb/list-transactions.md index ab4974a..6a74c22 100644 --- a/docs/examples/java/documentsdb/list-transactions.md +++ b/docs/examples/java/documentsdb/list-transactions.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.listTransactions( - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.listTransactions( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/update-document.md b/docs/examples/java/documentsdb/update-document.md index da8475f..dc574d0 100644 --- a/docs/examples/java/documentsdb/update-document.md +++ b/docs/examples/java/documentsdb/update-document.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.DocumentsDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,21 +16,24 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.updateDocument( - "", // databaseId - "", // collectionId - "", // documentId - Map.of("a", "b"), // data (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.updateDocument( + "", // databaseId + "", // collectionId + "", // documentId + Map.of("a", "b"), // data (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/update-transaction.md b/docs/examples/java/documentsdb/update-transaction.md index 9d95dfc..2d9465e 100644 --- a/docs/examples/java/documentsdb/update-transaction.md +++ b/docs/examples/java/documentsdb/update-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.DocumentsDB; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.updateTransaction( - "", // transactionId - false, // commit (optional) - false, // rollback (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.updateTransaction( + "", // transactionId + false, // commit (optional) + false, // rollback (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/documentsdb/upsert-document.md b/docs/examples/java/documentsdb/upsert-document.md index 82e90a4..2254fe4 100644 --- a/docs/examples/java/documentsdb/upsert-document.md +++ b/docs/examples/java/documentsdb/upsert-document.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.DocumentsDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,21 +16,24 @@ Client client = new Client(context) DocumentsDB documentsDB = new DocumentsDB(client); -documentsDB.upsertDocument( - "", // databaseId - "", // collectionId - "", // documentId - Map.of("a", "b"), // data (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + documentsDB.upsertDocument( + "", // databaseId + "", // collectionId + "", // documentId + Map.of("a", "b"), // data (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 1984020..30365b3 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -3,8 +3,10 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Functions; import io.appwrite.enums.ExecutionMethod; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -12,22 +14,25 @@ Client client = new Client(context) Functions functions = new Functions(client); -functions.createExecution( - "", // functionId - "", // body (optional) - false, // async (optional) - "", // path (optional) - ExecutionMethod.GET, // method (optional) - Map.of("a", "b"), // headers (optional) - "", // scheduledAt (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + functions.createExecution( + "", // functionId + "", // body (optional) + false, // async (optional) + "", // path (optional) + ExecutionMethod.GET, // method (optional) + Map.of("a", "b"), // headers (optional) + "", // scheduledAt (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index 206b407..b6f2f16 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Functions; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Functions functions = new Functions(client); -functions.getExecution( - "", // functionId - "", // executionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + functions.getExecution( + "", // functionId + "", // executionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 3cd974d..9959ee6 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Functions; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Functions functions = new Functions(client); -functions.listExecutions( - "", // functionId - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + functions.listExecutions( + "", // functionId + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index a8488db..5e29e3b 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Graphql; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); -graphql.mutation( - Map.of( - "query", "mutation { accountUpdateName(name: \"Walter\") { name } }" - ), // query - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + graphql.mutation( + Map.of( + "query", "mutation { accountUpdateName(name: \"Walter\") { name } }" + ), // query + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index 58e6363..0d97f96 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Graphql; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); -graphql.query( - Map.of( - "query", "query { localeGet { ip } }" - ), // query - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + graphql.query( + Map.of( + "query", "query { localeGet { ip } }" + ), // query + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index d2c4e4d..756f05f 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Locale; Client client = new Client(context) @@ -11,12 +12,18 @@ Client client = new Client(context) Locale locale = new Locale(client); -locale.get(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } +try { + locale.get( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Log.d("Appwrite", result.toString()); -})); + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/locale/list-codes.md b/docs/examples/java/locale/list-codes.md index 181c1b8..c68b2ec 100644 --- a/docs/examples/java/locale/list-codes.md +++ b/docs/examples/java/locale/list-codes.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Locale; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Locale locale = new Locale(client); -locale.listCodes( - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + locale.listCodes( + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index e8a60fc..21a1b16 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Locale; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Locale locale = new Locale(client); -locale.listContinents( - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + locale.listContinents( + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/locale/list-countries-eu.md b/docs/examples/java/locale/list-countries-eu.md index b6c878f..4464ae8 100644 --- a/docs/examples/java/locale/list-countries-eu.md +++ b/docs/examples/java/locale/list-countries-eu.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Locale; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Locale locale = new Locale(client); -locale.listCountriesEU( - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + locale.listCountriesEU( + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index 3d8bb9e..032e8dd 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Locale; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Locale locale = new Locale(client); -locale.listCountriesPhones( - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + locale.listCountriesPhones( + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index 3238cf2..b1bcb03 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Locale; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Locale locale = new Locale(client); -locale.listCountries( - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + locale.listCountries( + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index 631bb34..b47b3d7 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Locale; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Locale locale = new Locale(client); -locale.listCurrencies( - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + locale.listCurrencies( + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index b000063..b1b4196 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Locale; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Locale locale = new Locale(client); -locale.listLanguages( - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + locale.listLanguages( + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md index 88f9260..94ba429 100644 --- a/docs/examples/java/messaging/create-subscriber.md +++ b/docs/examples/java/messaging/create-subscriber.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Messaging; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Messaging messaging = new Messaging(client); -messaging.createSubscriber( - "", // topicId - "", // subscriberId - "", // targetId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + messaging.createSubscriber( + "", // topicId + "", // subscriberId + "", // targetId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md index 1c012a3..8898a1a 100644 --- a/docs/examples/java/messaging/delete-subscriber.md +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Messaging; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Messaging messaging = new Messaging(client); -messaging.deleteSubscriber( - "", // topicId - "", // subscriberId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + messaging.deleteSubscriber( + "", // topicId + "", // subscriberId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/approve.md b/docs/examples/java/oauth2/approve.md index f2f4a49..370db15 100644 --- a/docs/examples/java/oauth2/approve.md +++ b/docs/examples/java/oauth2/approve.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.approve( - "", // grant_id - "", // authorization_details (optional) - "", // scope (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.approve( + "", // grant_id + "", // authorization_details (optional) + "", // scope (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/authorize-post.md b/docs/examples/java/oauth2/authorize-post.md index 077546f..9ebc66e 100644 --- a/docs/examples/java/oauth2/authorize-post.md +++ b/docs/examples/java/oauth2/authorize-post.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,29 +13,32 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.authorizePost( - "", // client_id (optional) - "https://example.com", // redirect_uri (optional) - "", // response_type (optional) - "", // scope (optional) - "", // state (optional) - "", // nonce (optional) - "", // code_challenge (optional) - "s256", // code_challenge_method (optional) - "", // prompt (optional) - 0L, // max_age (optional) - "", // authorization_details (optional) - List.of(), // resource (optional) - "", // audience (optional) - "", // request_uri (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.authorizePost( + "", // client_id (optional) + "https://example.com", // redirect_uri (optional) + "", // response_type (optional) + "", // scope (optional) + "", // state (optional) + "", // nonce (optional) + "", // code_challenge (optional) + "s256", // code_challenge_method (optional) + "", // prompt (optional) + 0L, // max_age (optional) + "", // authorization_details (optional) + List.of(), // resource (optional) + "", // audience (optional) + "", // request_uri (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/authorize.md b/docs/examples/java/oauth2/authorize.md index d5b72cf..88e23ee 100644 --- a/docs/examples/java/oauth2/authorize.md +++ b/docs/examples/java/oauth2/authorize.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,29 +13,32 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.authorize( - "", // client_id (optional) - "https://example.com", // redirect_uri (optional) - "", // response_type (optional) - "", // scope (optional) - "", // state (optional) - "", // nonce (optional) - "", // code_challenge (optional) - "s256", // code_challenge_method (optional) - "", // prompt (optional) - 0L, // max_age (optional) - "", // authorization_details (optional) - List.of(), // resource (optional) - "", // audience (optional) - "", // request_uri (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.authorize( + "", // client_id (optional) + "https://example.com", // redirect_uri (optional) + "", // response_type (optional) + "", // scope (optional) + "", // state (optional) + "", // nonce (optional) + "", // code_challenge (optional) + "s256", // code_challenge_method (optional) + "", // prompt (optional) + 0L, // max_age (optional) + "", // authorization_details (optional) + List.of(), // resource (optional) + "", // audience (optional) + "", // request_uri (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/create-device-authorization.md b/docs/examples/java/oauth2/create-device-authorization.md index c2fc4ad..dc6391a 100644 --- a/docs/examples/java/oauth2/create-device-authorization.md +++ b/docs/examples/java/oauth2/create-device-authorization.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,20 +13,23 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.createDeviceAuthorization( - "", // client_id (optional) - "", // scope (optional) - "", // authorization_details (optional) - List.of(), // resource (optional) - "", // audience (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.createDeviceAuthorization( + "", // client_id (optional) + "", // scope (optional) + "", // authorization_details (optional) + List.of(), // resource (optional) + "", // audience (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/create-grant.md b/docs/examples/java/oauth2/create-grant.md index a14c388..c794afd 100644 --- a/docs/examples/java/oauth2/create-grant.md +++ b/docs/examples/java/oauth2/create-grant.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.createGrant( - "", // user_code - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.createGrant( + "", // user_code + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/create-par.md b/docs/examples/java/oauth2/create-par.md index e1f14de..7672137 100644 --- a/docs/examples/java/oauth2/create-par.md +++ b/docs/examples/java/oauth2/create-par.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,28 +13,31 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.createPAR( - "", // client_id - "https://example.com", // redirect_uri - "code", // response_type - "", // scope (optional) - "", // state (optional) - "", // nonce (optional) - "", // code_challenge (optional) - "s256", // code_challenge_method (optional) - "", // prompt (optional) - 0L, // max_age (optional) - "", // authorization_details (optional) - List.of(), // resource (optional) - "", // audience (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.createPAR( + "", // client_id + "https://example.com", // redirect_uri + "code", // response_type + "", // scope (optional) + "", // state (optional) + "", // nonce (optional) + "", // code_challenge (optional) + "s256", // code_challenge_method (optional) + "", // prompt (optional) + 0L, // max_age (optional) + "", // authorization_details (optional) + List.of(), // resource (optional) + "", // audience (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/create-token.md b/docs/examples/java/oauth2/create-token.md index 5c808df..787abfd 100644 --- a/docs/examples/java/oauth2/create-token.md +++ b/docs/examples/java/oauth2/create-token.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,25 +13,28 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.createToken( - "", // grant_type - "", // code (optional) - "", // refresh_token (optional) - "", // device_code (optional) - "", // client_id (optional) - "", // client_secret (optional) - "", // code_verifier (optional) - "https://example.com", // redirect_uri (optional) - List.of(), // resource (optional) - "", // audience (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.createToken( + "", // grant_type + "", // code (optional) + "", // refresh_token (optional) + "", // device_code (optional) + "", // client_id (optional) + "", // client_secret (optional) + "", // code_verifier (optional) + "https://example.com", // redirect_uri (optional) + List.of(), // resource (optional) + "", // audience (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/get-grant.md b/docs/examples/java/oauth2/get-grant.md index 1806888..5b2ce5e 100644 --- a/docs/examples/java/oauth2/get-grant.md +++ b/docs/examples/java/oauth2/get-grant.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.getGrant( - "", // grant_id - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.getGrant( + "", // grant_id + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/list-organizations.md b/docs/examples/java/oauth2/list-organizations.md index bbc74a7..2feebf0 100644 --- a/docs/examples/java/oauth2/list-organizations.md +++ b/docs/examples/java/oauth2/list-organizations.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.listOrganizations( - 1L, // limit (optional) - 0L, // offset (optional) - "", // search (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.listOrganizations( + 1L, // limit (optional) + 0L, // offset (optional) + "", // search (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/list-projects.md b/docs/examples/java/oauth2/list-projects.md index 6963583..e6826f1 100644 --- a/docs/examples/java/oauth2/list-projects.md +++ b/docs/examples/java/oauth2/list-projects.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.listProjects( - 1L, // limit (optional) - 0L, // offset (optional) - "", // search (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.listProjects( + 1L, // limit (optional) + 0L, // offset (optional) + "", // search (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/logout-post.md b/docs/examples/java/oauth2/logout-post.md index fefd5e9..bcc756c 100644 --- a/docs/examples/java/oauth2/logout-post.md +++ b/docs/examples/java/oauth2/logout-post.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; Client client = new Client(context) @@ -11,21 +12,24 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.logoutPost( - "", // id_token_hint (optional) - "", // logout_hint (optional) - "", // client_id (optional) - "https://example.com", // post_logout_redirect_uri (optional) - "", // state (optional) - "", // ui_locales (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.logoutPost( + "", // id_token_hint (optional) + "", // logout_hint (optional) + "", // client_id (optional) + "https://example.com", // post_logout_redirect_uri (optional) + "", // state (optional) + "", // ui_locales (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/logout.md b/docs/examples/java/oauth2/logout.md index ca7739a..af1f327 100644 --- a/docs/examples/java/oauth2/logout.md +++ b/docs/examples/java/oauth2/logout.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; Client client = new Client(context) @@ -11,21 +12,24 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.logout( - "", // id_token_hint (optional) - "", // logout_hint (optional) - "", // client_id (optional) - "https://example.com", // post_logout_redirect_uri (optional) - "", // state (optional) - "", // ui_locales (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.logout( + "", // id_token_hint (optional) + "", // logout_hint (optional) + "", // client_id (optional) + "https://example.com", // post_logout_redirect_uri (optional) + "", // state (optional) + "", // ui_locales (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/reject.md b/docs/examples/java/oauth2/reject.md index 90b9b2e..3bfb783 100644 --- a/docs/examples/java/oauth2/reject.md +++ b/docs/examples/java/oauth2/reject.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.reject( - "", // grant_id - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.reject( + "", // grant_id + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/oauth2/revoke.md b/docs/examples/java/oauth2/revoke.md index 0d680eb..19bae68 100644 --- a/docs/examples/java/oauth2/revoke.md +++ b/docs/examples/java/oauth2/revoke.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Oauth2; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) Oauth2 oauth2 = new Oauth2(client); -oauth2.revoke( - "", // token - "access_token", // token_type_hint (optional) - "", // client_id (optional) - "", // client_secret (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + oauth2.revoke( + "", // token + "access_token", // token_type_hint (optional) + "", // client_id (optional) + "", // client_secret (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/organization/create-installation.md b/docs/examples/java/organization/create-installation.md index d4c40fb..19d9a6d 100644 --- a/docs/examples/java/organization/create-installation.md +++ b/docs/examples/java/organization/create-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Organization; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Organization organization = new Organization(client); -organization.createInstallation( - "", // appId - "", // authorizationDetails (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + organization.createInstallation( + "", // appId + "", // authorizationDetails (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/organization/delete-installation.md b/docs/examples/java/organization/delete-installation.md index f1bc871..11583d9 100644 --- a/docs/examples/java/organization/delete-installation.md +++ b/docs/examples/java/organization/delete-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Organization; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Organization organization = new Organization(client); -organization.deleteInstallation( - "", // installationId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + organization.deleteInstallation( + "", // installationId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/organization/get-installation.md b/docs/examples/java/organization/get-installation.md index 20c8779..4354145 100644 --- a/docs/examples/java/organization/get-installation.md +++ b/docs/examples/java/organization/get-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Organization; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Organization organization = new Organization(client); -organization.getInstallation( - "", // installationId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + organization.getInstallation( + "", // installationId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/organization/list-installations.md b/docs/examples/java/organization/list-installations.md index 6fa2c2a..c924c64 100644 --- a/docs/examples/java/organization/list-installations.md +++ b/docs/examples/java/organization/list-installations.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Organization; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) Organization organization = new Organization(client); -organization.listInstallations( - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + organization.listInstallations( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/organization/update-installation.md b/docs/examples/java/organization/update-installation.md index f27fb55..546823f 100644 --- a/docs/examples/java/organization/update-installation.md +++ b/docs/examples/java/organization/update-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Organization; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Organization organization = new Organization(client); -organization.updateInstallation( - "", // installationId - "", // authorizationDetails (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + organization.updateInstallation( + "", // installationId + "", // authorizationDetails (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/presences/delete.md b/docs/examples/java/presences/delete.md index f0f6afa..57596e1 100644 --- a/docs/examples/java/presences/delete.md +++ b/docs/examples/java/presences/delete.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Presences; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Presences presences = new Presences(client); -presences.delete( - "", // presenceId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + presences.delete( + "", // presenceId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/presences/get.md b/docs/examples/java/presences/get.md index 2d2d2ce..e66616c 100644 --- a/docs/examples/java/presences/get.md +++ b/docs/examples/java/presences/get.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Presences; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Presences presences = new Presences(client); -presences.get( - "", // presenceId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + presences.get( + "", // presenceId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/presences/list.md b/docs/examples/java/presences/list.md index c243074..2bf01c6 100644 --- a/docs/examples/java/presences/list.md +++ b/docs/examples/java/presences/list.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Presences; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Presences presences = new Presences(client); -presences.list( - List.of(), // queries (optional) - false, // total (optional) - 0L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + presences.list( + List.of(), // queries (optional) + false, // total (optional) + 0L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/presences/update.md b/docs/examples/java/presences/update.md index 964f3a0..dbf453d 100644 --- a/docs/examples/java/presences/update.md +++ b/docs/examples/java/presences/update.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.Presences; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,21 +16,24 @@ Client client = new Client(context) Presences presences = new Presences(client); -presences.update( - "", // presenceId - "", // status (optional) - "2020-10-15T06:38:00.000+00:00", // expiresAt (optional) - Map.of("a", "b"), // metadata (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - false, // purge (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + presences.update( + "", // presenceId + "", // status (optional) + "2020-10-15T06:38:00.000+00:00", // expiresAt (optional) + Map.of("a", "b"), // metadata (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + false, // purge (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/presences/upsert.md b/docs/examples/java/presences/upsert.md index 2d279b3..a8478a6 100644 --- a/docs/examples/java/presences/upsert.md +++ b/docs/examples/java/presences/upsert.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.Presences; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,20 +16,23 @@ Client client = new Client(context) Presences presences = new Presences(client); -presences.upsert( - "", // presenceId - "", // status - List.of(Permission.read(Role.any())), // permissions (optional) - "2020-10-15T06:38:00.000+00:00", // expiresAt (optional) - Map.of("a", "b"), // metadata (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + presences.upsert( + "", // presenceId + "", // status + List.of(Permission.read(Role.any())), // permissions (optional) + "2020-10-15T06:38:00.000+00:00", // expiresAt (optional) + Map.of("a", "b"), // metadata (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index e441255..5161e18 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -3,10 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.models.InputFile; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.Storage; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -14,20 +16,23 @@ Client client = new Client(context) Storage storage = new Storage(client); -storage.createFile( - "", // bucketId - "", // fileId - InputFile.fromPath("file.png"), // file - List.of(Permission.read(Role.any())), // permissions (optional) - "photos/2026", // folder (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + storage.createFile( + "", // bucketId + "", // fileId + InputFile.fromPath("file.png"), // file + List.of(Permission.read(Role.any())), // permissions (optional) + "photos/2026", // folder (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 67212a7..852b5e3 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Storage; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Storage storage = new Storage(client); -storage.deleteFile( - "", // bucketId - "", // fileId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + storage.deleteFile( + "", // bucketId + "", // fileId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index 88e24ca..04e6609 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Storage; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Storage storage = new Storage(client); -storage.getFileDownload( - "", // bucketId - "", // fileId - "", // token (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + storage.getFileDownload( + "", // bucketId + "", // fileId + "", // token (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 2f1060a..ebd026d 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Storage; import io.appwrite.enums.ImageGravity; import io.appwrite.enums.ImageFormat; @@ -13,29 +14,32 @@ Client client = new Client(context) Storage storage = new Storage(client); -storage.getFilePreview( - "", // bucketId - "", // fileId - 0L, // width (optional) - 0L, // height (optional) - ImageGravity.AUTO, // gravity (optional) - -1L, // quality (optional) - 0L, // borderWidth (optional) - "FFFFFF", // borderColor (optional) - 0L, // borderRadius (optional) - 0.0, // opacity (optional) - -360L, // rotation (optional) - "FFFFFF", // background (optional) - ImageFormat.JPG, // output (optional) - "", // token (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + storage.getFilePreview( + "", // bucketId + "", // fileId + 0L, // width (optional) + 0L, // height (optional) + ImageGravity.AUTO, // gravity (optional) + -1L, // quality (optional) + 0L, // borderWidth (optional) + "FFFFFF", // borderColor (optional) + 0L, // borderRadius (optional) + 0.0, // opacity (optional) + -360L, // rotation (optional) + "FFFFFF", // background (optional) + ImageFormat.JPG, // output (optional) + "", // token (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index c9d1193..8f9af6f 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Storage; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Storage storage = new Storage(client); -storage.getFileView( - "", // bucketId - "", // fileId - "", // token (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + storage.getFileView( + "", // bucketId + "", // fileId + "", // token (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index 1c5cb7a..1d81275 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Storage; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Storage storage = new Storage(client); -storage.getFile( - "", // bucketId - "", // fileId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + storage.getFile( + "", // bucketId + "", // fileId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index b6737bf..5fddb00 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Storage; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,19 +13,22 @@ Client client = new Client(context) Storage storage = new Storage(client); -storage.listFiles( - "", // bucketId - List.of(), // queries (optional) - "", // search (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + storage.listFiles( + "", // bucketId + List.of(), // queries (optional) + "", // search (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 225eaaa..78b0bcd 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -3,9 +3,11 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.Storage; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,19 +15,22 @@ Client client = new Client(context) Storage storage = new Storage(client); -storage.updateFile( - "", // bucketId - "", // fileId - "", // name (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + storage.updateFile( + "", // bucketId + "", // fileId + "", // name (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/create-operations.md b/docs/examples/java/tablesdb/create-operations.md index 86cdfa3..66b6dcb 100644 --- a/docs/examples/java/tablesdb/create-operations.md +++ b/docs/examples/java/tablesdb/create-operations.md @@ -3,7 +3,10 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,25 +14,28 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.createOperations( - "", // transactionId - List.of(Map.of( - "action", "create", - "databaseId", "", - "tableId", "", - "rowId", "", - "data", Map.of( - "name", "Walter O'Brien" - ) - )), // operations (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.createOperations( + "", // transactionId + List.of(Map.of( + "action", "create", + "databaseId", "", + "tableId", "", + "rowId", "", + "data", Map.of( + "name", "Walter O'Brien" + ) + )), // operations (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/create-query.md b/docs/examples/java/tablesdb/create-query.md new file mode 100644 index 0000000..4f9389e --- /dev/null +++ b/docs/examples/java/tablesdb/create-query.md @@ -0,0 +1,36 @@ +```java +import android.util.Log; + +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; +import io.appwrite.services.TablesDB; +import java.util.List; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDB tablesDB = new TablesDB(client); + +try { + tablesDB.createQuery( + "", // databaseId + "", // tableId + List.of(), // queries (optional) + "", // transactionId (optional) + false, // total (optional) + 0L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} +``` diff --git a/docs/examples/java/tablesdb/create-row.md b/docs/examples/java/tablesdb/create-row.md index 4244a24..e414343 100644 --- a/docs/examples/java/tablesdb/create-row.md +++ b/docs/examples/java/tablesdb/create-row.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.TablesDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,27 +16,30 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.createRow( - "", // databaseId - "", // tableId - "", // rowId - Map.of( - "username", "walter.obrien", - "email", "walter.obrien@example.com", - "fullName", "Walter O'Brien", - "age", 30, - "isAdmin", false - ), // data - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.createRow( + "", // databaseId + "", // tableId + "", // rowId + Map.of( + "username", "walter.obrien", + "email", "walter.obrien@example.com", + "fullName", "Walter O'Brien", + "age", 30, + "isAdmin", false + ), // data + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/create-transaction.md b/docs/examples/java/tablesdb/create-transaction.md index 0dab2f0..a9e18f2 100644 --- a/docs/examples/java/tablesdb/create-transaction.md +++ b/docs/examples/java/tablesdb/create-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.createTransaction( - 60L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.createTransaction( + 60L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/decrement-row-column.md b/docs/examples/java/tablesdb/decrement-row-column.md index 2315f16..59006f7 100644 --- a/docs/examples/java/tablesdb/decrement-row-column.md +++ b/docs/examples/java/tablesdb/decrement-row-column.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; Client client = new Client(context) @@ -11,22 +12,25 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.decrementRowColumn( - "", // databaseId - "", // tableId - "", // rowId - "", // column - 1.0, // value (optional) - 0.0, // min (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.decrementRowColumn( + "", // databaseId + "", // tableId + "", // rowId + "", // column + 1.0, // value (optional) + 0.0, // min (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/delete-row.md b/docs/examples/java/tablesdb/delete-row.md index d00cf59..4feb7b4 100644 --- a/docs/examples/java/tablesdb/delete-row.md +++ b/docs/examples/java/tablesdb/delete-row.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.deleteRow( - "", // databaseId - "", // tableId - "", // rowId - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.deleteRow( + "", // databaseId + "", // tableId + "", // rowId + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/delete-transaction.md b/docs/examples/java/tablesdb/delete-transaction.md index f48b50a..4e4e151 100644 --- a/docs/examples/java/tablesdb/delete-transaction.md +++ b/docs/examples/java/tablesdb/delete-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.deleteTransaction( - "", // transactionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.deleteTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/get-row.md b/docs/examples/java/tablesdb/get-row.md index 1eae525..95c8078 100644 --- a/docs/examples/java/tablesdb/get-row.md +++ b/docs/examples/java/tablesdb/get-row.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,20 +13,23 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.getRow( - "", // databaseId - "", // tableId - "", // rowId - List.of(), // queries (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.getRow( + "", // databaseId + "", // tableId + "", // rowId + List.of(), // queries (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/get-transaction.md b/docs/examples/java/tablesdb/get-transaction.md index 861aacb..31472c1 100644 --- a/docs/examples/java/tablesdb/get-transaction.md +++ b/docs/examples/java/tablesdb/get-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.getTransaction( - "", // transactionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.getTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/increment-row-column.md b/docs/examples/java/tablesdb/increment-row-column.md index 2e9b52b..8b08020 100644 --- a/docs/examples/java/tablesdb/increment-row-column.md +++ b/docs/examples/java/tablesdb/increment-row-column.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; Client client = new Client(context) @@ -11,22 +12,25 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.incrementRowColumn( - "", // databaseId - "", // tableId - "", // rowId - "", // column - 1.0, // value (optional) - 100.0, // max (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.incrementRowColumn( + "", // databaseId + "", // tableId + "", // rowId + "", // column + 1.0, // value (optional) + 100.0, // max (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/list-rows.md b/docs/examples/java/tablesdb/list-rows.md index 6d3a0a7..5cf4b5b 100644 --- a/docs/examples/java/tablesdb/list-rows.md +++ b/docs/examples/java/tablesdb/list-rows.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,21 +13,24 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.listRows( - "", // databaseId - "", // tableId - List.of(), // queries (optional) - "", // transactionId (optional) - false, // total (optional) - 0L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.listRows( + "", // databaseId + "", // tableId + List.of(), // queries (optional) + "", // transactionId (optional) + false, // total (optional) + 0L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/list-transactions.md b/docs/examples/java/tablesdb/list-transactions.md index 8a04ad9..1102816 100644 --- a/docs/examples/java/tablesdb/list-transactions.md +++ b/docs/examples/java/tablesdb/list-transactions.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.listTransactions( - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.listTransactions( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/update-row.md b/docs/examples/java/tablesdb/update-row.md index bc3f84c..1f17101 100644 --- a/docs/examples/java/tablesdb/update-row.md +++ b/docs/examples/java/tablesdb/update-row.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.TablesDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,27 +16,30 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.updateRow( - "", // databaseId - "", // tableId - "", // rowId - Map.of( - "username", "walter.obrien", - "email", "walter.obrien@example.com", - "fullName", "Walter O'Brien", - "age", 33, - "isAdmin", false - ), // data (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.updateRow( + "", // databaseId + "", // tableId + "", // rowId + Map.of( + "username", "walter.obrien", + "email", "walter.obrien@example.com", + "fullName", "Walter O'Brien", + "age", 33, + "isAdmin", false + ), // data (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/update-transaction.md b/docs/examples/java/tablesdb/update-transaction.md index 8f362d0..7c7aab9 100644 --- a/docs/examples/java/tablesdb/update-transaction.md +++ b/docs/examples/java/tablesdb/update-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.TablesDB; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.updateTransaction( - "", // transactionId - false, // commit (optional) - false, // rollback (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.updateTransaction( + "", // transactionId + false, // commit (optional) + false, // rollback (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/tablesdb/upsert-row.md b/docs/examples/java/tablesdb/upsert-row.md index 4df4792..18b2460 100644 --- a/docs/examples/java/tablesdb/upsert-row.md +++ b/docs/examples/java/tablesdb/upsert-row.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.TablesDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,27 +16,30 @@ Client client = new Client(context) TablesDB tablesDB = new TablesDB(client); -tablesDB.upsertRow( - "", // databaseId - "", // tableId - "", // rowId - Map.of( - "username", "walter.obrien", - "email", "walter.obrien@example.com", - "fullName", "Walter O'Brien", - "age", 33, - "isAdmin", false - ), // data (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + tablesDB.upsertRow( + "", // databaseId + "", // tableId + "", // rowId + Map.of( + "username", "walter.obrien", + "email", "walter.obrien@example.com", + "fullName", "Walter O'Brien", + "age", 33, + "isAdmin", false + ), // data (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/create-installation.md b/docs/examples/java/teams/create-installation.md index 699f71b..1613cb7 100644 --- a/docs/examples/java/teams/create-installation.md +++ b/docs/examples/java/teams/create-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.createInstallation( - "", // teamId - "", // appId - "", // authorizationDetails (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.createInstallation( + "", // teamId + "", // appId + "", // authorizationDetails (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index b6d23a6..57aa657 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,23 +13,26 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.createMembership( - "", // teamId - List.of("editor"), // roles - "email@example.com", // email (optional) - "", // userId (optional) - "+12065550100", // phone (optional) - "https://example.com", // url (optional) - "", // name (optional) - "", // membershipId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.createMembership( + "", // teamId + List.of("editor"), // roles + "email@example.com", // email (optional) + "", // userId (optional) + "+12065550100", // phone (optional) + "https://example.com", // url (optional) + "", // name (optional) + "", // membershipId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index e9a6800..394cf47 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.create( - "", // teamId - "", // name - List.of(), // roles (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.create( + "", // teamId + "", // name + List.of(), // roles (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/delete-installation.md b/docs/examples/java/teams/delete-installation.md index da5d48f..de77de2 100644 --- a/docs/examples/java/teams/delete-installation.md +++ b/docs/examples/java/teams/delete-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.deleteInstallation( - "", // teamId - "", // installationId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.deleteInstallation( + "", // teamId + "", // installationId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index 3a0482d..6dce8bc 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.deleteMembership( - "", // teamId - "", // membershipId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.deleteMembership( + "", // teamId + "", // membershipId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 06f1867..a4e8766 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.delete( - "", // teamId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.delete( + "", // teamId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/get-installation.md b/docs/examples/java/teams/get-installation.md index 9222d76..8dbde24 100644 --- a/docs/examples/java/teams/get-installation.md +++ b/docs/examples/java/teams/get-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.getInstallation( - "", // teamId - "", // installationId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.getInstallation( + "", // teamId + "", // installationId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index 5018496..e87c990 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.getMembership( - "", // teamId - "", // membershipId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.getMembership( + "", // teamId + "", // membershipId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index c82fce9..1884fde 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.getPrefs( - "", // teamId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.getPrefs( + "", // teamId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index df348f1..c881b86 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.get( - "", // teamId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.get( + "", // teamId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/list-installations.md b/docs/examples/java/teams/list-installations.md index 8aeace5..66173d0 100644 --- a/docs/examples/java/teams/list-installations.md +++ b/docs/examples/java/teams/list-installations.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.listInstallations( - "", // teamId - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.listInstallations( + "", // teamId + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 79aad6d..2ca57ef 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,19 +13,22 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.listMemberships( - "", // teamId - List.of(), // queries (optional) - "", // search (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.listMemberships( + "", // teamId + List.of(), // queries (optional) + "", // search (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index 5d25828..196c6d6 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.list( - List.of(), // queries (optional) - "", // search (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.list( + List.of(), // queries (optional) + "", // search (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/update-installation.md b/docs/examples/java/teams/update-installation.md index cd32a5c..651445b 100644 --- a/docs/examples/java/teams/update-installation.md +++ b/docs/examples/java/teams/update-installation.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.updateInstallation( - "", // teamId - "", // installationId - "", // authorizationDetails (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.updateInstallation( + "", // teamId + "", // installationId + "", // authorizationDetails (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index a6a54df..2705f0f 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.updateMembershipStatus( - "", // teamId - "", // membershipId - "", // userId - "", // secret - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.updateMembershipStatus( + "", // teamId + "", // membershipId + "", // userId + "", // secret + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index c4208a8..1825305 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,18 +13,21 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.updateMembership( - "", // teamId - "", // membershipId - List.of("editor"), // roles - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.updateMembership( + "", // teamId + "", // membershipId + List.of("editor"), // roles + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 1e10410..4496c21 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; Client client = new Client(context) @@ -11,17 +12,20 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.updateName( - "", // teamId - "", // name - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.updateName( + "", // teamId + "", // name + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index 69ed22a..7bc2e97 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.Teams; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.updatePrefs( - "", // teamId - Map.of("a", "b"), // prefs - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + teams.updatePrefs( + "", // teamId + Map.of("a", "b"), // prefs + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/create-document.md b/docs/examples/java/vectorsdb/create-document.md index 8a3d7f9..e7ef887 100644 --- a/docs/examples/java/vectorsdb/create-document.md +++ b/docs/examples/java/vectorsdb/create-document.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.VectorsDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,26 +16,29 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.createDocument( - "", // databaseId - "", // collectionId - "", // documentId - Map.of( - "embeddings", List.of(0.12, -0.55, 0.88, 1.02), - "metadata", Map.of( - "key", "value" - ) - ), // data - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.createDocument( + "", // databaseId + "", // collectionId + "", // documentId + Map.of( + "embeddings", List.of(0.12, -0.55, 0.88, 1.02), + "metadata", Map.of( + "key", "value" + ) + ), // data + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/create-operations.md b/docs/examples/java/vectorsdb/create-operations.md index 8dd6f0b..5aa2bc9 100644 --- a/docs/examples/java/vectorsdb/create-operations.md +++ b/docs/examples/java/vectorsdb/create-operations.md @@ -3,7 +3,10 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,28 +14,31 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.createOperations( - "", // transactionId - List.of(Map.of( - "action", "create", - "databaseId", "", - "collectionId", "", - "documentId", "", - "data", Map.of( - "embeddings", List.of(0.12, -0.55, 0.88, 1.02), - "metadata", Map.of( - "name", "First document" +try { + vectorsDB.createOperations( + "", // transactionId + List.of(Map.of( + "action", "create", + "databaseId", "", + "collectionId", "", + "documentId", "", + "data", Map.of( + "embeddings", List.of(0.12, -0.55, 0.88, 1.02), + "metadata", Map.of( + "name", "First document" + ) ) - ) - )), // operations (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); + )), // operations (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/create-query.md b/docs/examples/java/vectorsdb/create-query.md index 8c79872..2e86644 100644 --- a/docs/examples/java/vectorsdb/create-query.md +++ b/docs/examples/java/vectorsdb/create-query.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,21 +13,24 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.createQuery( - "", // databaseId - "", // collectionId - List.of(), // queries (optional) - "", // transactionId (optional) - false, // total (optional) - 0L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.createQuery( + "", // databaseId + "", // collectionId + List.of(), // queries (optional) + "", // transactionId (optional) + false, // total (optional) + 0L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/create-transaction.md b/docs/examples/java/vectorsdb/create-transaction.md index 916f73c..fbc80c2 100644 --- a/docs/examples/java/vectorsdb/create-transaction.md +++ b/docs/examples/java/vectorsdb/create-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.createTransaction( - 60L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.createTransaction( + 60L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/delete-document.md b/docs/examples/java/vectorsdb/delete-document.md index d806730..be16e90 100644 --- a/docs/examples/java/vectorsdb/delete-document.md +++ b/docs/examples/java/vectorsdb/delete-document.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; Client client = new Client(context) @@ -11,19 +12,22 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.deleteDocument( - "", // databaseId - "", // collectionId - "", // documentId - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.deleteDocument( + "", // databaseId + "", // collectionId + "", // documentId + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/delete-transaction.md b/docs/examples/java/vectorsdb/delete-transaction.md index 04b9c4d..6364f34 100644 --- a/docs/examples/java/vectorsdb/delete-transaction.md +++ b/docs/examples/java/vectorsdb/delete-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.deleteTransaction( - "", // transactionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.deleteTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/get-document.md b/docs/examples/java/vectorsdb/get-document.md index 15ddf82..549a7d8 100644 --- a/docs/examples/java/vectorsdb/get-document.md +++ b/docs/examples/java/vectorsdb/get-document.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,20 +13,23 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.getDocument( - "", // databaseId - "", // collectionId - "", // documentId - List.of(), // queries (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.getDocument( + "", // databaseId + "", // collectionId + "", // documentId + List.of(), // queries (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/get-transaction.md b/docs/examples/java/vectorsdb/get-transaction.md index 987ca6e..e7a7ba1 100644 --- a/docs/examples/java/vectorsdb/get-transaction.md +++ b/docs/examples/java/vectorsdb/get-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; Client client = new Client(context) @@ -11,16 +12,19 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.getTransaction( - "", // transactionId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.getTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/list-documents.md b/docs/examples/java/vectorsdb/list-documents.md index 49689d3..c2c8f10 100644 --- a/docs/examples/java/vectorsdb/list-documents.md +++ b/docs/examples/java/vectorsdb/list-documents.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,21 +13,24 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.listDocuments( - "", // databaseId - "", // collectionId - List.of(), // queries (optional) - "", // transactionId (optional) - false, // total (optional) - 0L, // ttl (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.listDocuments( + "", // databaseId + "", // collectionId + List.of(), // queries (optional) + "", // transactionId (optional) + false, // total (optional) + 0L, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/list-transactions.md b/docs/examples/java/vectorsdb/list-transactions.md index be8905e..a42c190 100644 --- a/docs/examples/java/vectorsdb/list-transactions.md +++ b/docs/examples/java/vectorsdb/list-transactions.md @@ -3,7 +3,9 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; +import java.util.List; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -11,17 +13,20 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.listTransactions( - List.of(), // queries (optional) - false, // total (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.listTransactions( + List.of(), // queries (optional) + false, // total (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/update-document.md b/docs/examples/java/vectorsdb/update-document.md index 4acb5cc..0aa7eb3 100644 --- a/docs/examples/java/vectorsdb/update-document.md +++ b/docs/examples/java/vectorsdb/update-document.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.VectorsDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,21 +16,24 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.updateDocument( - "", // databaseId - "", // collectionId - "", // documentId - Map.of("a", "b"), // data (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.updateDocument( + "", // databaseId + "", // collectionId + "", // documentId + Map.of("a", "b"), // data (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/update-transaction.md b/docs/examples/java/vectorsdb/update-transaction.md index a21aad1..b98a447 100644 --- a/docs/examples/java/vectorsdb/update-transaction.md +++ b/docs/examples/java/vectorsdb/update-transaction.md @@ -3,6 +3,7 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.services.VectorsDB; Client client = new Client(context) @@ -11,18 +12,21 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.updateTransaction( - "", // transactionId - false, // commit (optional) - false, // rollback (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.updateTransaction( + "", // transactionId + false, // commit (optional) + false, // rollback (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/java/vectorsdb/upsert-document.md b/docs/examples/java/vectorsdb/upsert-document.md index 58ac9a9..d0587ce 100644 --- a/docs/examples/java/vectorsdb/upsert-document.md +++ b/docs/examples/java/vectorsdb/upsert-document.md @@ -3,9 +3,12 @@ import android.util.Log; import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.exceptions.AppwriteException; import io.appwrite.Permission; import io.appwrite.Role; import io.appwrite.services.VectorsDB; +import java.util.List; +import java.util.Map; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint @@ -13,21 +16,24 @@ Client client = new Client(context) VectorsDB vectorsDB = new VectorsDB(client); -vectorsDB.upsertDocument( - "", // databaseId - "", // collectionId - "", // documentId - Map.of("a", "b"), // data (optional) - List.of(Permission.read(Role.any())), // permissions (optional) - "", // transactionId (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); +try { + vectorsDB.upsertDocument( + "", // databaseId + "", // collectionId + "", // documentId + Map.of("a", "b"), // data (optional) + List.of(Permission.read(Role.any())), // permissions (optional) + "", // transactionId (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + Log.d("Appwrite", result.toString()); + }) + ); +} catch (AppwriteException e) { + e.printStackTrace(); +} ``` diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md index 22d64cb..92740b6 100644 --- a/docs/examples/kotlin/account/create-push-target.md +++ b/docs/examples/kotlin/account/create-push-target.md @@ -13,5 +13,7 @@ val result = account.createPushTarget( targetId = "", identifier = "", providerId = "", // (optional) + bundleId = "", // (optional) + environment = "sandbox", // (optional) ) ``` diff --git a/docs/examples/kotlin/account/list-memberships.md b/docs/examples/kotlin/account/list-memberships.md new file mode 100644 index 0000000..803cb2e --- /dev/null +++ b/docs/examples/kotlin/account/list-memberships.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.listMemberships( + queries = listOf(), // (optional) + total = false, // (optional) +) +``` diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md index 0e16e2f..5c0fe7f 100644 --- a/docs/examples/kotlin/account/update-push-target.md +++ b/docs/examples/kotlin/account/update-push-target.md @@ -12,5 +12,7 @@ val account = Account(client) val result = account.updatePushTarget( targetId = "", identifier = "", + bundleId = "", // (optional) + environment = "sandbox", // (optional) ) ``` diff --git a/docs/examples/kotlin/databases/create-query.md b/docs/examples/kotlin/databases/create-query.md new file mode 100644 index 0000000..284d35e --- /dev/null +++ b/docs/examples/kotlin/databases/create-query.md @@ -0,0 +1,20 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.createQuery( + databaseId = "", + collectionId = "", + queries = listOf(), // (optional) + transactionId = "", // (optional) + total = false, // (optional) + ttl = 0, // (optional) +) +``` diff --git a/docs/examples/kotlin/documentsdb/create-query.md b/docs/examples/kotlin/documentsdb/create-query.md new file mode 100644 index 0000000..a0fee80 --- /dev/null +++ b/docs/examples/kotlin/documentsdb/create-query.md @@ -0,0 +1,20 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.DocumentsDB + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val documentsDB = DocumentsDB(client) + +val result = documentsDB.createQuery( + databaseId = "", + collectionId = "", + queries = listOf(), // (optional) + transactionId = "", // (optional) + total = false, // (optional) + ttl = 0, // (optional) +) +``` diff --git a/docs/examples/kotlin/tablesdb/create-query.md b/docs/examples/kotlin/tablesdb/create-query.md new file mode 100644 index 0000000..1717ff7 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/create-query.md @@ -0,0 +1,20 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDB = TablesDB(client) + +val result = tablesDB.createQuery( + databaseId = "", + tableId = "", + queries = listOf(), // (optional) + transactionId = "", // (optional) + total = false, // (optional) + ttl = 0, // (optional) +) +``` diff --git a/library/src/main/java/io/appwrite/Channel.kt b/library/src/main/java/io/appwrite/Channel.kt index 26907f2..dbfe1b5 100644 --- a/library/src/main/java/io/appwrite/Channel.kt +++ b/library/src/main/java/io/appwrite/Channel.kt @@ -61,39 +61,55 @@ class Channel private constructor( override fun toString(): String = segments.joinToString(".") companion object { + @JvmStatic fun database(id: String): Channel<_Database> = Channel(listOf("databases", normalize(id))) + @JvmStatic fun tablesdb(id: String): Channel<_TablesDB> = Channel(listOf("tablesdb", normalize(id))) + @JvmStatic fun bucket(id: String): Channel<_Bucket> = Channel(listOf("buckets", normalize(id))) + @JvmStatic fun execution(id: String): Channel<_Execution> = Channel(listOf("executions", normalize(id))) + @JvmStatic fun function(id: String): Channel<_Func> = Channel(listOf("functions", normalize(id))) + @JvmStatic fun team(id: String): Channel<_Team> = Channel(listOf("teams", normalize(id))) + @JvmStatic fun membership(id: String): Channel<_Membership> = Channel(listOf("memberships", normalize(id))) + @JvmStatic fun presence(id: String): Channel<_Presence> = Channel(listOf("presences", normalize(id))) + @JvmStatic fun account(): String = "account" // Global events + @JvmStatic fun documents(): String = "documents" + @JvmStatic fun rows(): String = "rows" + @JvmStatic fun files(): String = "files" + @JvmStatic fun executions(): String = "executions" + @JvmStatic fun teams(): String = "teams" + @JvmStatic fun memberships(): String = "memberships" + @JvmStatic fun presences(): String = "presences" } } diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index ecc12c3..5c85237 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -101,7 +101,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "30.0.0", + "x-sdk-version" to "31.0.0", "x-appwrite-response-format" to "2.5.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/ID.kt b/library/src/main/java/io/appwrite/ID.kt index 93f948f..10be93e 100644 --- a/library/src/main/java/io/appwrite/ID.kt +++ b/library/src/main/java/io/appwrite/ID.kt @@ -19,6 +19,7 @@ class ID { return hexTimestamp } + @JvmStatic fun custom(id: String): String = id @@ -28,6 +29,8 @@ class ID { * @param padding The number of characters to add to the ID * @returns The unique ID */ + @JvmStatic + @JvmOverloads fun unique(padding: Int = 7): String { val baseId = hexTimestamp() val randomPadding = (1..padding) diff --git a/library/src/main/java/io/appwrite/Operator.kt b/library/src/main/java/io/appwrite/Operator.kt index 74ab2cb..c571689 100644 --- a/library/src/main/java/io/appwrite/Operator.kt +++ b/library/src/main/java/io/appwrite/Operator.kt @@ -30,6 +30,8 @@ class Operator( fun toJson(): String = toMap().toJson() companion object { + @JvmStatic + @JvmOverloads fun increment(value: Number = 1, max: Number? = null): String { require(!value.toDouble().isNaN() && !value.toDouble().isInfinite()) { "Value cannot be NaN or Infinity" } max?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Max cannot be NaN or Infinity" } } @@ -38,6 +40,8 @@ class Operator( return Operator("increment", values).toJson() } + @JvmStatic + @JvmOverloads fun decrement(value: Number = 1, min: Number? = null): String { require(!value.toDouble().isNaN() && !value.toDouble().isInfinite()) { "Value cannot be NaN or Infinity" } min?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Min cannot be NaN or Infinity" } } @@ -46,6 +50,8 @@ class Operator( return Operator("decrement", values).toJson() } + @JvmStatic + @JvmOverloads fun multiply(factor: Number, max: Number? = null): String { require(!factor.toDouble().isNaN() && !factor.toDouble().isInfinite()) { "Factor cannot be NaN or Infinity" } max?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Max cannot be NaN or Infinity" } } @@ -54,6 +60,8 @@ class Operator( return Operator("multiply", values).toJson() } + @JvmStatic + @JvmOverloads fun divide(divisor: Number, min: Number? = null): String { require(!divisor.toDouble().isNaN() && !divisor.toDouble().isInfinite()) { "Divisor cannot be NaN or Infinity" } min?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Min cannot be NaN or Infinity" } } @@ -63,12 +71,15 @@ class Operator( return Operator("divide", values).toJson() } + @JvmStatic fun modulo(divisor: Number): String { require(!divisor.toDouble().isNaN() && !divisor.toDouble().isInfinite()) { "Divisor cannot be NaN or Infinity" } require(divisor.toDouble() != 0.0) { "Divisor cannot be zero" } return Operator("modulo", listOf(divisor)).toJson() } + @JvmStatic + @JvmOverloads fun power(exponent: Number, max: Number? = null): String { require(!exponent.toDouble().isNaN() && !exponent.toDouble().isInfinite()) { "Exponent cannot be NaN or Infinity" } max?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Max cannot be NaN or Infinity" } } @@ -77,59 +88,74 @@ class Operator( return Operator("power", values).toJson() } + @JvmStatic fun arrayAppend(values: List): String { return Operator("arrayAppend", values).toJson() } + @JvmStatic fun arrayPrepend(values: List): String { return Operator("arrayPrepend", values).toJson() } + @JvmStatic fun arrayInsert(index: Int, value: Any): String { return Operator("arrayInsert", listOf(index, value)).toJson() } + @JvmStatic fun arrayRemove(value: Any): String { return Operator("arrayRemove", listOf(value)).toJson() } + @JvmStatic fun arrayUnique(): String { return Operator("arrayUnique", emptyList()).toJson() } + @JvmStatic fun arrayIntersect(values: List): String { return Operator("arrayIntersect", values).toJson() } + @JvmStatic fun arrayDiff(values: List): String { return Operator("arrayDiff", values).toJson() } + @JvmStatic + @JvmOverloads fun arrayFilter(condition: Condition, value: Any? = null): String { val values = listOf(condition.value, value) return Operator("arrayFilter", values).toJson() } + @JvmStatic fun stringConcat(value: Any): String { return Operator("stringConcat", listOf(value)).toJson() } + @JvmStatic fun stringReplace(search: String, replace: String): String { return Operator("stringReplace", listOf(search, replace)).toJson() } + @JvmStatic fun toggle(): String { return Operator("toggle", emptyList()).toJson() } + @JvmStatic fun dateAddDays(days: Int): String { return Operator("dateAddDays", listOf(days)).toJson() } + @JvmStatic fun dateSubDays(days: Int): String { return Operator("dateSubDays", listOf(days)).toJson() } + @JvmStatic fun dateSetNow(): String { return Operator("dateSetNow", emptyList()).toJson() } diff --git a/library/src/main/java/io/appwrite/Permission.kt b/library/src/main/java/io/appwrite/Permission.kt index 34d1a48..e4b4390 100644 --- a/library/src/main/java/io/appwrite/Permission.kt +++ b/library/src/main/java/io/appwrite/Permission.kt @@ -12,6 +12,7 @@ class Permission { * @param role The role for which to generate the permission. * @returns The read permission string. */ + @JvmStatic fun read(role: String): String { return "read(\"${role}\")" } @@ -25,6 +26,7 @@ class Permission { * @param role The role for which to generate the permission. * @returns The write permission string. */ + @JvmStatic fun write(role: String): String { return "write(\"${role}\")" } @@ -35,6 +37,7 @@ class Permission { * @param role The role for which to generate the permission. * @returns The create permission string. */ + @JvmStatic fun create(role: String): String { return "create(\"${role}\")" } @@ -45,6 +48,7 @@ class Permission { * @param role The role for which to generate the permission. * @returns The update permission string. */ + @JvmStatic fun update(role: String): String { return "update(\"${role}\")" } @@ -55,6 +59,7 @@ class Permission { * @param role The role for which to generate the permission. * @returns The delete permission string. */ + @JvmStatic fun delete(role: String): String { return "delete(\"${role}\")" } diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index 6be7a6d..5d599c3 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -35,6 +35,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun equal(attribute: String, value: Any) = Query("equal", attribute, parseValue(value)).toJson() /** @@ -44,6 +45,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun notEqual(attribute: String, value: Any) = Query("notEqual", attribute, parseValue(value)).toJson() /** @@ -53,6 +55,7 @@ class Query( * @param pattern The regular expression pattern to match. * @returns The query string. */ + @JvmStatic fun regex(attribute: String, pattern: String) = Query("regex", attribute, parseValue(pattern)).toJson() /** @@ -62,6 +65,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun lessThan(attribute: String, value: Any) = Query("lessThan", attribute, parseValue(value)).toJson() /** @@ -71,6 +75,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun lessThanEqual(attribute: String, value: Any) = Query("lessThanEqual", attribute, parseValue(value)).toJson() /** @@ -80,6 +85,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun greaterThan(attribute: String, value: Any) = Query("greaterThan", attribute, parseValue(value)).toJson() /** @@ -89,6 +95,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun greaterThanEqual(attribute: String, value: Any) = Query("greaterThanEqual", attribute, parseValue(value)).toJson() /** @@ -98,6 +105,7 @@ class Query( * @param value The search value to match against. * @returns The query string. */ + @JvmStatic fun search(attribute: String, value: String) = Query("search", attribute, listOf(value)).toJson() /** @@ -106,6 +114,7 @@ class Query( * @param attribute The attribute to filter on. * @returns The query string. */ + @JvmStatic fun isNull(attribute: String) = Query("isNull", attribute).toJson() /** @@ -114,6 +123,7 @@ class Query( * @param attribute The attribute to filter on. * @returns The query string. */ + @JvmStatic fun isNotNull(attribute: String) = Query("isNotNull", attribute).toJson() /** @@ -122,6 +132,7 @@ class Query( * @param attributes The list of attributes that must exist. * @returns The query string. */ + @JvmStatic fun exists(attributes: List) = Query("exists", null, attributes).toJson() /** @@ -130,6 +141,7 @@ class Query( * @param attributes The list of attributes that must not exist. * @returns The query string. */ + @JvmStatic fun notExists(attributes: List) = Query("notExists", null, attributes).toJson() /** @@ -140,6 +152,7 @@ class Query( * @param end The end value of the range. * @returns The query string. */ + @JvmStatic fun between(attribute: String, start: Any, end: Any) = Query("between", attribute, listOf(start, end)).toJson() /** @@ -149,6 +162,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun startsWith(attribute: String, value: String) = Query("startsWith", attribute, listOf(value)).toJson() /** @@ -158,6 +172,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun endsWith(attribute: String, value: String) = Query("endsWith", attribute, listOf(value)).toJson() /** @@ -166,6 +181,7 @@ class Query( * @param attributes The list of attributes to select. * @returns The query string. */ + @JvmStatic fun select(attributes: List) = Query("select", null, attributes).toJson() /** @@ -174,6 +190,7 @@ class Query( * @param attribute The attribute to sort by. * @returns The query string. */ + @JvmStatic fun orderAsc(attribute: String) = Query("orderAsc", attribute).toJson() /** @@ -182,6 +199,7 @@ class Query( * @param attribute The attribute to sort by. * @returns The query string. */ + @JvmStatic fun orderDesc(attribute: String) = Query("orderDesc", attribute).toJson() /** @@ -189,6 +207,7 @@ class Query( * * @returns The query string. */ + @JvmStatic fun orderRandom() = Query("orderRandom").toJson() /** @@ -197,6 +216,7 @@ class Query( * @param documentId The document ID to use as cursor. * @returns The query string. */ + @JvmStatic fun cursorBefore(documentId: String) = Query("cursorBefore", null, listOf(documentId)).toJson() /** @@ -205,6 +225,7 @@ class Query( * @param documentId The document ID to use as cursor. * @returns The query string. */ + @JvmStatic fun cursorAfter(documentId: String) = Query("cursorAfter", null, listOf(documentId)).toJson() /** @@ -213,6 +234,7 @@ class Query( * @param limit The number of results to return. * @returns The query string. */ + @JvmStatic fun limit(limit: Int) = Query("limit", null, listOf(limit)).toJson() /** @@ -221,6 +243,7 @@ class Query( * @param offset The number of results to skip. * @returns The query string. */ + @JvmStatic fun offset(offset: Int) = Query("offset", null, listOf(offset)).toJson() /** @@ -232,6 +255,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun contains(attribute: String, value: Any) = Query("contains", attribute, parseValue(value)).toJson() /** @@ -243,6 +267,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun containsAny(attribute: String, value: List) = Query("containsAny", attribute, value).toJson() /** @@ -254,6 +279,7 @@ class Query( * @param value The values to match against. * @returns The query string. */ + @JvmStatic fun containsAll(attribute: String, value: List) = Query("containsAll", attribute, value).toJson() /** @@ -263,6 +289,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun notContains(attribute: String, value: Any) = Query("notContains", attribute, parseValue(value)).toJson() /** @@ -272,6 +299,7 @@ class Query( * @param value The search value to match against. * @returns The query string. */ + @JvmStatic fun notSearch(attribute: String, value: String) = Query("notSearch", attribute, listOf(value)).toJson() /** @@ -282,6 +310,7 @@ class Query( * @param end The end value of the range. * @returns The query string. */ + @JvmStatic fun notBetween(attribute: String, start: Any, end: Any) = Query("notBetween", attribute, listOf(start, end)).toJson() /** @@ -291,6 +320,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun notStartsWith(attribute: String, value: String) = Query("notStartsWith", attribute, listOf(value)).toJson() /** @@ -300,6 +330,7 @@ class Query( * @param value The value to compare against. * @returns The query string. */ + @JvmStatic fun notEndsWith(attribute: String, value: String) = Query("notEndsWith", attribute, listOf(value)).toJson() /** @@ -308,6 +339,7 @@ class Query( * @param value The date value to compare against. * @returns The query string. */ + @JvmStatic fun createdBefore(value: String) = lessThan("\$createdAt", value) /** @@ -316,6 +348,7 @@ class Query( * @param value The date value to compare against. * @returns The query string. */ + @JvmStatic fun createdAfter(value: String) = greaterThan("\$createdAt", value) /** @@ -325,6 +358,7 @@ class Query( * @param end The end date value. * @returns The query string. */ + @JvmStatic fun createdBetween(start: String, end: String) = between("\$createdAt", start, end) /** @@ -333,6 +367,7 @@ class Query( * @param value The date value to compare against. * @returns The query string. */ + @JvmStatic fun updatedBefore(value: String) = lessThan("\$updatedAt", value) /** @@ -341,6 +376,7 @@ class Query( * @param value The date value to compare against. * @returns The query string. */ + @JvmStatic fun updatedAfter(value: String) = greaterThan("\$updatedAt", value) /** @@ -350,6 +386,7 @@ class Query( * @param end The end date value. * @returns The query string. */ + @JvmStatic fun updatedBetween(start: String, end: String) = between("\$updatedAt", start, end) /** @@ -358,6 +395,7 @@ class Query( * @param queries The list of query strings to combine. * @returns The query string. */ + @JvmStatic fun or(queries: List) = Query("or", null, queries.map { it.fromJson>() }).toJson() /** @@ -366,6 +404,7 @@ class Query( * @param queries The list of query strings to combine. * @returns The query string. */ + @JvmStatic fun and(queries: List) = Query("and", null, queries.map { it.fromJson>() }).toJson() /** @@ -375,6 +414,7 @@ class Query( * @param queries The list of query strings to match against array elements. * @returns The query string. */ + @JvmStatic fun elemMatch(attribute: String, queries: List) = Query("elemMatch", attribute, queries.map { it.fromJson>() }).toJson() /** @@ -384,6 +424,7 @@ class Query( * @param queries Filter, order, select, and pagination queries applied to related documents. * @returns The query string. */ + @JvmStatic fun relationship(attribute: String, queries: List) = Query("relationship", attribute, queries.map { it.fromJson>() }).toJson() /** @@ -395,6 +436,8 @@ class Query( * @param meters Whether the distance is in meters. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun distanceEqual(attribute: String, values: List, distance: Number, meters: Boolean = true) = Query("distanceEqual", attribute, listOf(listOf(values, distance, meters))).toJson() /** @@ -406,6 +449,8 @@ class Query( * @param meters Whether the distance is in meters. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun distanceNotEqual(attribute: String, values: List, distance: Number, meters: Boolean = true) = Query("distanceNotEqual", attribute, listOf(listOf(values, distance, meters))).toJson() /** @@ -417,6 +462,8 @@ class Query( * @param meters Whether the distance is in meters. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun distanceGreaterThan(attribute: String, values: List, distance: Number, meters: Boolean = true) = Query("distanceGreaterThan", attribute, listOf(listOf(values, distance, meters))).toJson() /** @@ -428,6 +475,8 @@ class Query( * @param meters Whether the distance is in meters. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun distanceLessThan(attribute: String, values: List, distance: Number, meters: Boolean = true) = Query("distanceLessThan", attribute, listOf(listOf(values, distance, meters))).toJson() /** @@ -437,6 +486,7 @@ class Query( * @param vector The query vector. * @returns The query string. */ + @JvmStatic fun vectorDot(attribute: String, vector: List) = Query("vectorDot", attribute, listOf(vector)).toJson() /** @@ -446,6 +496,7 @@ class Query( * @param vector The query vector. * @returns The query string. */ + @JvmStatic fun vectorCosine(attribute: String, vector: List) = Query("vectorCosine", attribute, listOf(vector)).toJson() /** @@ -455,6 +506,7 @@ class Query( * @param vector The query vector. * @returns The query string. */ + @JvmStatic fun vectorEuclidean(attribute: String, vector: List) = Query("vectorEuclidean", attribute, listOf(vector)).toJson() /** @@ -464,6 +516,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun intersects(attribute: String, values: List) = Query("intersects", attribute, listOf(values)).toJson() /** @@ -473,6 +526,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun notIntersects(attribute: String, values: List) = Query("notIntersects", attribute, listOf(values)).toJson() /** @@ -482,6 +536,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun crosses(attribute: String, values: List) = Query("crosses", attribute, listOf(values)).toJson() /** @@ -491,6 +546,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun notCrosses(attribute: String, values: List) = Query("notCrosses", attribute, listOf(values)).toJson() /** @@ -500,6 +556,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun overlaps(attribute: String, values: List) = Query("overlaps", attribute, listOf(values)).toJson() /** @@ -509,6 +566,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun notOverlaps(attribute: String, values: List) = Query("notOverlaps", attribute, listOf(values)).toJson() /** @@ -518,6 +576,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun touches(attribute: String, values: List) = Query("touches", attribute, listOf(values)).toJson() /** @@ -527,6 +586,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun notTouches(attribute: String, values: List) = Query("notTouches", attribute, listOf(values)).toJson() /** @@ -536,6 +596,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun count(attribute: String = "*", alias: String = "") = Query("count", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -545,6 +607,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun countDistinct(attribute: String, alias: String = "") = Query("countDistinct", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -554,6 +618,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun sum(attribute: String, alias: String = "") = Query("sum", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -563,6 +629,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun avg(attribute: String, alias: String = "") = Query("avg", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -572,6 +640,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun min(attribute: String, alias: String = "") = Query("min", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -581,15 +651,19 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun max(attribute: String, alias: String = "") = Query("max", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** - * Standard deviation of [attribute], optionally aliased. + * Population standard deviation of [attribute] (the same as stddevPop), optionally aliased. * * @param attribute The attribute to inspect. * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun stddev(attribute: String, alias: String = "") = Query("stddev", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -599,6 +673,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun stddevPop(attribute: String, alias: String = "") = Query("stddevPop", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -608,15 +684,19 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun stddevSamp(attribute: String, alias: String = "") = Query("stddevSamp", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** - * Variance of [attribute], optionally aliased. + * Population variance of [attribute] (the same as varPop), optionally aliased. * * @param attribute The attribute to inspect. * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun variance(attribute: String, alias: String = "") = Query("variance", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -626,6 +706,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun varPop(attribute: String, alias: String = "") = Query("varPop", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -635,6 +717,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun varSamp(attribute: String, alias: String = "") = Query("varSamp", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -644,6 +728,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun bitAnd(attribute: String, alias: String = "") = Query("bitAnd", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -653,6 +739,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun bitOr(attribute: String, alias: String = "") = Query("bitOr", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -662,6 +750,8 @@ class Query( * @param alias Optional result alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun bitXor(attribute: String, alias: String = "") = Query("bitXor", attribute, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -670,6 +760,7 @@ class Query( * @param attributes Attributes to group by. * @returns The query string. */ + @JvmStatic fun groupBy(attributes: List) = Query("groupBy", null, attributes).toJson() /** @@ -678,6 +769,7 @@ class Query( * @param queries Nested query strings. * @returns The query string. */ + @JvmStatic fun having(queries: List) = Query("having", null, queries.map { it.fromJson>() }).toJson() /** @@ -685,6 +777,7 @@ class Query( * * @returns The query string. */ + @JvmStatic fun distinct() = Query("distinct").toJson() /** @@ -695,27 +788,32 @@ class Query( * @param operator Comparison operator. Defaults to `=`. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun on(left: String, right: String, operator: String = "=") = Query("on", values = listOf(left, operator, right)).toJson() /** - * Inner join. [table] is the joined collection/table ID. + * Inner join. [table] is the joined collection/table ID; without an alias the server names the join after it, if the ID is a valid alias, and otherwise rejects the query. * * @param table Joined table ID. * @param left Left-hand join column. * @param right Right-hand join column. * @param operator Comparison operator. Defaults to `=`. - * @param alias Optional table alias. + * @param alias Optional table alias. Defaults to the table ID when that is a valid alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun join(table: String, left: String, right: String, operator: String = "=", alias: String = "") = joinQuery("join", table, left, right, operator, alias) /** - * Inner join with nested ON queries and no alias. + * Inner join with nested ON queries, named after the table ID when that is a valid alias. * * @param table Joined table ID. * @param on Nested ON queries, including [on]. * @returns The query string. */ + @JvmStatic fun join(table: String, on: List) = nestedJoin("join", table, "", on) /** @@ -726,27 +824,31 @@ class Query( * @param on Nested ON queries, including [on]. * @returns The query string. */ + @JvmStatic fun join(table: String, alias: String, on: List) = nestedJoin("join", table, alias, on) /** - * Left join. [table] is the joined collection/table ID. + * Left join. [table] is the joined collection/table ID; without an alias the server names the join after it, if the ID is a valid alias, and otherwise rejects the query. * * @param table Joined table ID. * @param left Left-hand join column. * @param right Right-hand join column. * @param operator Comparison operator. Defaults to `=`. - * @param alias Optional table alias. + * @param alias Optional table alias. Defaults to the table ID when that is a valid alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun leftJoin(table: String, left: String, right: String, operator: String = "=", alias: String = "") = joinQuery("leftJoin", table, left, right, operator, alias) /** - * Left join with nested ON queries and no alias. + * Left join with nested ON queries, named after the table ID when that is a valid alias. * * @param table Joined table ID. * @param on Nested ON queries, including [on]. * @returns The query string. */ + @JvmStatic fun leftJoin(table: String, on: List) = nestedJoin("leftJoin", table, "", on) /** @@ -757,27 +859,31 @@ class Query( * @param on Nested ON queries, including [on]. * @returns The query string. */ + @JvmStatic fun leftJoin(table: String, alias: String, on: List) = nestedJoin("leftJoin", table, alias, on) /** - * Right join. [table] is the joined collection/table ID. + * Right join. [table] is the joined collection/table ID; without an alias the server names the join after it, if the ID is a valid alias, and otherwise rejects the query. * * @param table Joined table ID. * @param left Left-hand join column. * @param right Right-hand join column. * @param operator Comparison operator. Defaults to `=`. - * @param alias Optional table alias. + * @param alias Optional table alias. Defaults to the table ID when that is a valid alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun rightJoin(table: String, left: String, right: String, operator: String = "=", alias: String = "") = joinQuery("rightJoin", table, left, right, operator, alias) /** - * Right join with nested ON queries and no alias. + * Right join with nested ON queries, named after the table ID when that is a valid alias. * * @param table Joined table ID. * @param on Nested ON queries, including [on]. * @returns The query string. */ + @JvmStatic fun rightJoin(table: String, on: List) = nestedJoin("rightJoin", table, "", on) /** @@ -788,27 +894,31 @@ class Query( * @param on Nested ON queries, including [on]. * @returns The query string. */ + @JvmStatic fun rightJoin(table: String, alias: String, on: List) = nestedJoin("rightJoin", table, alias, on) /** - * Full outer join. [table] is the joined collection/table ID. + * Full outer join. [table] is the joined collection/table ID; without an alias the server names the join after it, if the ID is a valid alias, and otherwise rejects the query. * * @param table Joined table ID. * @param left Left-hand join column. * @param right Right-hand join column. * @param operator Comparison operator. Defaults to `=`. - * @param alias Optional table alias. + * @param alias Optional table alias. Defaults to the table ID when that is a valid alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun fullOuterJoin(table: String, left: String, right: String, operator: String = "=", alias: String = "") = joinQuery("fullOuterJoin", table, left, right, operator, alias) /** - * Full outer join with nested ON queries and no alias. + * Full outer join with nested ON queries, named after the table ID when that is a valid alias. * * @param table Joined table ID. * @param on Nested ON queries, including [on]. * @returns The query string. */ + @JvmStatic fun fullOuterJoin(table: String, on: List) = nestedJoin("fullOuterJoin", table, "", on) /** @@ -819,15 +929,18 @@ class Query( * @param on Nested ON queries, including [on]. * @returns The query string. */ + @JvmStatic fun fullOuterJoin(table: String, alias: String, on: List) = nestedJoin("fullOuterJoin", table, alias, on) /** - * Cross join. [table] is the joined collection/table ID. + * Cross join. [table] is the joined collection/table ID; without an alias the server names the join after it, if the ID is a valid alias, and otherwise rejects the query. * * @param table Joined table ID. - * @param alias Optional table alias. + * @param alias Optional table alias. Defaults to the table ID when that is a valid alias. * @returns The query string. */ + @JvmStatic + @JvmOverloads fun crossJoin(table: String, alias: String = "") = Query("crossJoin", table, if (alias.isNotEmpty()) listOf(alias) else null).toJson() /** @@ -837,6 +950,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun covers(attribute: String, values: List) = Query("covers", attribute, listOf(values)).toJson() /** @@ -846,6 +960,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun notCovers(attribute: String, values: List) = Query("notCovers", attribute, listOf(values)).toJson() /** @@ -855,6 +970,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun spatialEquals(attribute: String, values: List) = Query("spatialEquals", attribute, listOf(values)).toJson() /** @@ -864,6 +980,7 @@ class Query( * @param values The coordinate values. * @returns The query string. */ + @JvmStatic fun notSpatialEquals(attribute: String, values: List) = Query("notSpatialEquals", attribute, listOf(values)).toJson() /** @@ -873,6 +990,8 @@ class Query( * @param perPage Rows per page. Defaults to 25. * @returns Limit and offset query strings. */ + @JvmStatic + @JvmOverloads fun page(page: Int, perPage: Int = 25): List { require(page >= 1) { "Page must be >= 1, got $page" } require(perPage >= 1) { "Per page must be >= 1, got $perPage" } @@ -884,6 +1003,7 @@ class Query( * * @returns A new query builder. */ + @JvmStatic fun builder() = Builder() private fun joinQuery(method: String, table: String, left: String, right: String, operator: String, alias: String): String { diff --git a/library/src/main/java/io/appwrite/Role.kt b/library/src/main/java/io/appwrite/Role.kt index 2348a02..594f38d 100644 --- a/library/src/main/java/io/appwrite/Role.kt +++ b/library/src/main/java/io/appwrite/Role.kt @@ -11,6 +11,7 @@ class Role { * * This includes authenticated and unauthenticated users. */ + @JvmStatic fun any(): String = "any" /** @@ -19,6 +20,8 @@ class Role { * You can optionally pass verified or unverified for * [status] to target specific types of users. */ + @JvmStatic + @JvmOverloads fun user(id: String, status: String = ""): String = if (status.isEmpty()) { "user:$id" } else { @@ -31,6 +34,8 @@ class Role { * You can optionally pass verified or unverified for * [status] to target specific types of users. */ + @JvmStatic + @JvmOverloads fun users(status: String = ""): String = if (status.isEmpty()) { "users" } else { @@ -42,6 +47,7 @@ class Role { * * Authenticated users don't have access to this role. */ + @JvmStatic fun guests(): String = "guests" /** @@ -50,6 +56,8 @@ class Role { * You can optionally pass a role for [role] to target * team members with the specified role. */ + @JvmStatic + @JvmOverloads fun team(id: String, role: String = ""): String = if (role.isEmpty()) { "team:$id" } else { @@ -62,11 +70,13 @@ class Role { * When the member is removed from the team, they will * no longer have access. */ + @JvmStatic fun member(id: String): String = "member:$id" /** * Grants access to a user with the specified label. */ + @JvmStatic fun label(name: String): String = "label:$name" } } diff --git a/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt b/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt index 17b5dc2..aac1cb8 100644 --- a/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt +++ b/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt @@ -41,10 +41,10 @@ inline fun String.fromJson(): T = gson.fromJson(this, T::class.java) fun Any.jsonCast(to: Class): T = - toJson().fromJson(to) + toJsonWithNulls().fromJson(to) inline fun Any.jsonCast(): T = - toJson().fromJson(T::class.java) + toJsonWithNulls().fromJson(T::class.java) fun Any.tryJsonCast(to: Class): T? = try { toJson().fromJson(to) diff --git a/library/src/main/java/io/appwrite/models/InputFile.kt b/library/src/main/java/io/appwrite/models/InputFile.kt index 779da91..e1bcaac 100644 --- a/library/src/main/java/io/appwrite/models/InputFile.kt +++ b/library/src/main/java/io/appwrite/models/InputFile.kt @@ -12,6 +12,7 @@ class InputFile private constructor() { lateinit var data: Any companion object { + @JvmStatic fun fromFile(file: File) = InputFile().apply { path = file.canonicalPath filename = file.name @@ -19,10 +20,13 @@ class InputFile private constructor() { sourceType = "file" } + @JvmStatic fun fromPath(path: String): InputFile = fromFile(File(path)).apply { sourceType = "path" } + @JvmStatic + @JvmOverloads fun fromBytes(bytes: ByteArray, filename: String = "", mimeType: String = "") = InputFile().apply { this.filename = filename this.mimeType = mimeType diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index e6201c4..13fcd0a 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -22,6 +22,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.User] */ + @Throws(AppwriteException::class) suspend fun get( nestedType: Class, ): io.appwrite.models.User { @@ -65,6 +66,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.User] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun create( userId: String, email: String, @@ -130,6 +132,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2ConsentList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listConsents( queries: List? = null, total: Boolean? = null, @@ -163,6 +166,7 @@ class Account(client: Client) : Service(client) { * @param consentId Consent unique ID. * @return [io.appwrite.models.Oauth2Consent] */ + @Throws(AppwriteException::class) suspend fun getConsent( consentId: String, ): io.appwrite.models.Oauth2Consent { @@ -197,6 +201,7 @@ class Account(client: Client) : Service(client) { * @param consentId Consent unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteConsent( consentId: String, ): Any { @@ -230,6 +235,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2ConsentTokenList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listConsentTokens( consentId: String, queries: List? = null, @@ -270,6 +276,7 @@ class Account(client: Client) : Service(client) { * @param tokenId Token unique ID. * @return [io.appwrite.models.Oauth2ConsentToken] */ + @Throws(AppwriteException::class) suspend fun getConsentToken( consentId: String, tokenId: String, @@ -310,6 +317,7 @@ class Account(client: Client) : Service(client) { * @param tokenId Token unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteConsentToken( consentId: String, tokenId: String, @@ -348,6 +356,7 @@ class Account(client: Client) : Service(client) { * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.User] */ + @Throws(AppwriteException::class) suspend fun updateEmail( email: String, password: String, @@ -404,6 +413,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.IdentityList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listIdentities( queries: List? = null, total: Boolean? = null, @@ -437,6 +447,7 @@ class Account(client: Client) : Service(client) { * @param identityId Identity ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteIdentity( identityId: String, ): Any { @@ -468,6 +479,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Jwt] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createJWT( duration: Long? = null, ): io.appwrite.models.Jwt { @@ -494,12 +506,49 @@ class Account(client: Client) : Service(client) { ) } + /** + * Get the team memberships of the currently logged in user. + * + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + * @param total When set to false, the total count returned will be 0 and will not be calculated. + * @return [io.appwrite.models.MembershipList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listMemberships( + queries: List? = null, + total: Boolean? = null, + ): io.appwrite.models.MembershipList { + val apiPath = "/account/memberships" + val apiParams = mutableMapOf( + "queries" to queries, + "total" to total, + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MembershipList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MembershipList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MembershipList::class.java, + converter, + ) + } + /** * Enable or disable MFA on an account. * * @param mfa Enable or disable MFA. * @return [io.appwrite.models.User] */ + @Throws(AppwriteException::class) suspend fun updateMFA( mfa: Boolean, nestedType: Class, @@ -551,6 +600,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAAuthenticator") ) + @Throws(AppwriteException::class) suspend fun createMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): io.appwrite.models.MfaType { @@ -583,6 +633,7 @@ class Account(client: Client) : Service(client) { * @param type Type of authenticator. Must be `totp` * @return [io.appwrite.models.MfaType] */ + @Throws(AppwriteException::class) suspend fun createMFAAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): io.appwrite.models.MfaType { @@ -620,6 +671,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAAuthenticator") ) + @Throws(AppwriteException::class) suspend fun updateMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, otp: String, @@ -678,6 +730,7 @@ class Account(client: Client) : Service(client) { * @param otp Valid verification token. * @return [io.appwrite.models.User] */ + @Throws(AppwriteException::class) suspend fun updateMFAAuthenticator( type: io.appwrite.enums.AuthenticatorType, otp: String, @@ -735,6 +788,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.deleteMFAAuthenticator") ) + @Throws(AppwriteException::class) suspend fun deleteMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): Any { @@ -762,6 +816,7 @@ class Account(client: Client) : Service(client) { * @param type Type of authenticator. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteMFAAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): Any { @@ -793,6 +848,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAChallenge") ) + @Throws(AppwriteException::class) suspend fun createMfaChallenge( factor: io.appwrite.enums.AuthenticationFactor, ): io.appwrite.models.MfaChallenge { @@ -825,6 +881,7 @@ class Account(client: Client) : Service(client) { * @param factor Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`, `custom`. * @return [io.appwrite.models.MfaChallenge] */ + @Throws(AppwriteException::class) suspend fun createMFAChallenge( factor: io.appwrite.enums.AuthenticationFactor, ): io.appwrite.models.MfaChallenge { @@ -862,6 +919,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAChallenge") ) + @Throws(AppwriteException::class) suspend fun updateMfaChallenge( challengeId: String, otp: String, @@ -897,6 +955,7 @@ class Account(client: Client) : Service(client) { * @param otp Valid verification token. * @return [io.appwrite.models.Session] */ + @Throws(AppwriteException::class) suspend fun updateMFAChallenge( challengeId: String, otp: String, @@ -934,6 +993,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.listMFAFactors") ) + @Throws(AppwriteException::class) suspend fun listMfaFactors(): io.appwrite.models.MfaFactors { val apiPath = "/account/mfa/factors" val apiParams = mutableMapOf() @@ -960,6 +1020,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.MfaFactors] */ + @Throws(AppwriteException::class) suspend fun listMFAFactors(): io.appwrite.models.MfaFactors { val apiPath = "/account/mfa/factors" val apiParams = mutableMapOf() @@ -990,6 +1051,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.getMFARecoveryCodes") ) + @Throws(AppwriteException::class) suspend fun getMfaRecoveryCodes(): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf() @@ -1016,6 +1078,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.MfaRecoveryCodes] */ + @Throws(AppwriteException::class) suspend fun getMFARecoveryCodes(): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf() @@ -1046,6 +1109,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.createMFARecoveryCodes") ) + @Throws(AppwriteException::class) suspend fun createMfaRecoveryCodes(): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf() @@ -1073,6 +1137,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.MfaRecoveryCodes] */ + @Throws(AppwriteException::class) suspend fun createMFARecoveryCodes(): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf() @@ -1104,6 +1169,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFARecoveryCodes") ) + @Throws(AppwriteException::class) suspend fun updateMfaRecoveryCodes(): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf() @@ -1131,6 +1197,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.MfaRecoveryCodes] */ + @Throws(AppwriteException::class) suspend fun updateMFARecoveryCodes(): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf() @@ -1159,6 +1226,7 @@ class Account(client: Client) : Service(client) { * @param name User name. Max length: 128 chars. * @return [io.appwrite.models.User] */ + @Throws(AppwriteException::class) suspend fun updateName( name: String, nestedType: Class, @@ -1208,6 +1276,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.PasskeyList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listPasskeys( queries: List? = null, total: Boolean? = null, @@ -1243,6 +1312,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.PasskeyChallenge] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createPasskey( passkeyId: String? = null, name: String? = null, @@ -1277,6 +1347,7 @@ class Account(client: Client) : Service(client) { * @param passkeyId Passkey ID. * @return [io.appwrite.models.Passkey] */ + @Throws(AppwriteException::class) suspend fun getPasskey( passkeyId: String, ): io.appwrite.models.Passkey { @@ -1312,6 +1383,7 @@ class Account(client: Client) : Service(client) { * @param name Passkey name. Max length: 128 chars. * @return [io.appwrite.models.Passkey] */ + @Throws(AppwriteException::class) suspend fun updatePasskey( passkeyId: String, name: String, @@ -1350,6 +1422,7 @@ class Account(client: Client) : Service(client) { * @param passkeyId Passkey ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deletePasskey( passkeyId: String, ): Any { @@ -1381,6 +1454,7 @@ class Account(client: Client) : Service(client) { * @param credential Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. * @return [io.appwrite.models.Passkey] */ + @Throws(AppwriteException::class) suspend fun updatePasskeyVerification( passkeyId: String, credential: Map, @@ -1421,6 +1495,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.User] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updatePassword( password: String, oldPassword: String? = null, @@ -1475,6 +1550,7 @@ class Account(client: Client) : Service(client) { * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.User] */ + @Throws(AppwriteException::class) suspend fun updatePhone( phone: String, password: String, @@ -1526,6 +1602,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.Preferences] */ + @Throws(AppwriteException::class) suspend fun getPrefs( nestedType: Class, ): io.appwrite.models.Preferences { @@ -1565,6 +1642,7 @@ class Account(client: Client) : Service(client) { * @param prefs Prefs key-value JSON object. * @return [io.appwrite.models.User] */ + @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Map, nestedType: Class, @@ -1613,6 +1691,7 @@ class Account(client: Client) : Service(client) { * @param url URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @return [io.appwrite.models.Token] */ + @Throws(AppwriteException::class) suspend fun createRecovery( email: String, url: String, @@ -1646,11 +1725,15 @@ class Account(client: Client) : Service(client) { * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. * + * The new password must satisfy the project's enabled password policies, including custom deny lists. Dictionary entries match the entire password case-sensitively; personal-data terms match substrings case-insensitively. Personal-data validation runs after token verification against the recovered user's ID, name, email, and phone, closing the previous recovery gap for profile-based checks. A rejected password leaves the existing credentials unchanged and the recovery token usable. + * + * * @param userId User ID. * @param secret Valid reset token. * @param password New user password. Must be between 8 and 256 chars. * @return [io.appwrite.models.Token] */ + @Throws(AppwriteException::class) suspend fun updateRecovery( userId: String, secret: String, @@ -1692,6 +1775,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Token] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createRecoveryOTP( email: String, phrase: Boolean? = null, @@ -1723,12 +1807,15 @@ class Account(client: Client) : Service(client) { /** * Use this endpoint to complete the user password recovery process using the 6-digit code that was emailed by [createRecoveryOTP](https://appwrite.io/docs/references/cloud/client-web/account#createRecoveryOTP). Pass the **userId** of the user along with the **secret** code from the email and the new **password** to set. If confirmed, this route will return a 200 status code, the code is consumed and the user's password is updated. * + * The new password must satisfy the project's enabled password policies, including custom deny lists. Dictionary entries match the entire password case-sensitively; personal-data terms match substrings case-insensitively. Personal-data validation runs after token verification against the recovered user's ID, name, email, and phone, closing the previous recovery gap for profile-based checks. A rejected password leaves the existing credentials unchanged and the recovery token usable. + * * * @param userId User ID. * @param secret Valid recovery OTP code. * @param password New user password. Must be between 8 and 256 chars. * @return [io.appwrite.models.Token] */ + @Throws(AppwriteException::class) suspend fun updateRecoveryOTP( userId: String, secret: String, @@ -1766,6 +1853,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.SessionList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listSessions( total: Boolean? = null, ): io.appwrite.models.SessionList { @@ -1798,6 +1886,7 @@ class Account(client: Client) : Service(client) { * @return [Any] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun deleteSessions( current: Boolean? = null, ): Any { @@ -1824,6 +1913,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.Session] */ + @Throws(AppwriteException::class) suspend fun createAnonymousSession(): io.appwrite.models.Session { val apiPath = "/account/sessions/anonymous" val apiParams = mutableMapOf() @@ -1857,6 +1947,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Session] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createEmailPasswordSession( email: String, password: String, @@ -1910,6 +2001,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Session] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createIdTokenSession( provider: io.appwrite.enums.IdTokenProvider, idToken: String, @@ -1957,6 +2049,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.createSession") ) + @Throws(AppwriteException::class) suspend fun updateMagicURLSession( userId: String, secret: String, @@ -2000,6 +2093,7 @@ class Account(client: Client) : Service(client) { * @param state An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createOAuth2Session( activity: ComponentActivity, provider: io.appwrite.enums.OAuthProvider, @@ -2075,6 +2169,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.createSession") ) + @Throws(AppwriteException::class) suspend fun updatePhoneSession( userId: String, secret: String, @@ -2110,6 +2205,7 @@ class Account(client: Client) : Service(client) { * @param secret Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. * @return [io.appwrite.models.Session] */ + @Throws(AppwriteException::class) suspend fun createSession( userId: String, secret: String, @@ -2144,6 +2240,7 @@ class Account(client: Client) : Service(client) { * @param sessionId Session ID. Use the string 'current' to get the current device session. * @return [io.appwrite.models.Session] */ + @Throws(AppwriteException::class) suspend fun getSession( sessionId: String, ): io.appwrite.models.Session { @@ -2178,6 +2275,7 @@ class Account(client: Client) : Service(client) { * @param sessionId Session ID. Use the string 'current' to update the current device session. * @return [io.appwrite.models.Session] */ + @Throws(AppwriteException::class) suspend fun updateSession( sessionId: String, ): io.appwrite.models.Session { @@ -2213,6 +2311,7 @@ class Account(client: Client) : Service(client) { * @param sessionId Session ID. Use the string 'current' to delete the current device session. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteSession( sessionId: String, ): Any { @@ -2242,6 +2341,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.User] */ + @Throws(AppwriteException::class) suspend fun updateStatus( nestedType: Class, ): io.appwrite.models.User { @@ -2282,19 +2382,26 @@ class Account(client: Client) : Service(client) { * @param targetId Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param identifier The target identifier (token, email, phone etc.) * @param providerId Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @param bundleId App bundle ID of the device registering an APNs token. Without `providerId`, routes the target to the enabled APNs provider for this bundle ID and `environment`. + * @param environment APNs environment the token belongs to, `sandbox` or `production`. Used with `bundleId`. * @return [io.appwrite.models.Target] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createPushTarget( targetId: String, identifier: String, providerId: String? = null, + bundleId: String? = null, + environment: String? = null, ): io.appwrite.models.Target { val apiPath = "/account/targets/push" val apiParams = mutableMapOf( "targetId" to targetId, "identifier" to identifier, "providerId" to providerId, + "bundleId" to bundleId, + "environment" to environment, ) val apiHeaders = mutableMapOf( "X-Appwrite-Project" to client.config["project"].orEmpty(), @@ -2320,11 +2427,17 @@ class Account(client: Client) : Service(client) { * * @param targetId Target ID. * @param identifier The target identifier (token, email, phone etc.) + * @param bundleId App bundle ID of the device registering an APNs token. Routes an APNs target to the enabled APNs provider for this bundle ID and `environment`. + * @param environment APNs environment the token belongs to, `sandbox` or `production`. Used with `bundleId`. * @return [io.appwrite.models.Target] */ + @JvmOverloads + @Throws(AppwriteException::class) suspend fun updatePushTarget( targetId: String, identifier: String, + bundleId: String? = null, + environment: String? = null, ): io.appwrite.models.Target { if (targetId.isEmpty()) { throw AppwriteException("Missing required parameter: \"targetId\"") @@ -2334,6 +2447,8 @@ class Account(client: Client) : Service(client) { ) val apiParams = mutableMapOf( "identifier" to identifier, + "bundleId" to bundleId, + "environment" to environment, ) val apiHeaders = mutableMapOf( "X-Appwrite-Project" to client.config["project"].orEmpty(), @@ -2360,6 +2475,7 @@ class Account(client: Client) : Service(client) { * @param targetId Target ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deletePushTarget( targetId: String, ): Any { @@ -2396,6 +2512,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Token] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createEmailToken( userId: String, email: String, @@ -2439,6 +2556,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Token] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createMagicURLToken( userId: String, email: String, @@ -2487,6 +2605,7 @@ class Account(client: Client) : Service(client) { * @param state An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createOAuth2Token( activity: ComponentActivity, provider: io.appwrite.enums.OAuthProvider, @@ -2556,6 +2675,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.PasskeyChallenge] */ + @Throws(AppwriteException::class) suspend fun createPasskeyToken(): io.appwrite.models.PasskeyChallenge { val apiPath = "/account/tokens/passkey" val apiParams = mutableMapOf() @@ -2585,6 +2705,7 @@ class Account(client: Client) : Service(client) { * @param credential Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. * @return [io.appwrite.models.TokenSecret] */ + @Throws(AppwriteException::class) suspend fun updatePasskeyToken( challengeId: String, credential: Map, @@ -2622,6 +2743,7 @@ class Account(client: Client) : Service(client) { * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @return [io.appwrite.models.Token] */ + @Throws(AppwriteException::class) suspend fun createPhoneToken( userId: String, phone: String, @@ -2659,6 +2781,7 @@ class Account(client: Client) : Service(client) { * @param url URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @return [io.appwrite.models.Token] */ + @Throws(AppwriteException::class) suspend fun createEmailVerification( url: String, ): io.appwrite.models.Token { @@ -2698,6 +2821,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.createEmailVerification") ) + @Throws(AppwriteException::class) suspend fun createVerification( url: String, ): io.appwrite.models.Token { @@ -2731,6 +2855,7 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Token] */ + @Throws(AppwriteException::class) suspend fun updateEmailVerification( userId: String, secret: String, @@ -2770,6 +2895,7 @@ class Account(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.", replaceWith = ReplaceWith("io.appwrite.services.Account.updateEmailVerification") ) + @Throws(AppwriteException::class) suspend fun updateVerification( userId: String, secret: String, @@ -2808,6 +2934,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Token] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createEmailVerificationOTP( phrase: Boolean? = null, ): io.appwrite.models.Token { @@ -2842,6 +2969,7 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification OTP code. * @return [io.appwrite.models.Token] */ + @Throws(AppwriteException::class) suspend fun updateEmailVerificationOTP( userId: String, secret: String, @@ -2875,6 +3003,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.Token] */ + @Throws(AppwriteException::class) suspend fun createPhoneVerification(): io.appwrite.models.Token { val apiPath = "/account/verifications/phone" val apiParams = mutableMapOf() @@ -2904,6 +3033,7 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Token] */ + @Throws(AppwriteException::class) suspend fun updatePhoneVerification( userId: String, secret: String, diff --git a/library/src/main/java/io/appwrite/services/Analytics.kt b/library/src/main/java/io/appwrite/services/Analytics.kt index 1949f76..2fe464e 100644 --- a/library/src/main/java/io/appwrite/services/Analytics.kt +++ b/library/src/main/java/io/appwrite/services/Analytics.kt @@ -32,6 +32,7 @@ class Analytics(client: Client) : Service(client) { * @return [Any] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createEvent( propertyId: String, name: String, diff --git a/library/src/main/java/io/appwrite/services/Apps.kt b/library/src/main/java/io/appwrite/services/Apps.kt index 20f0de1..92e6580 100644 --- a/library/src/main/java/io/appwrite/services/Apps.kt +++ b/library/src/main/java/io/appwrite/services/Apps.kt @@ -21,6 +21,7 @@ class Apps(client: Client) : Service(client) { * @return [io.appwrite.models.AppsList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun list( queries: List? = null, total: Boolean? = null, @@ -73,6 +74,7 @@ class Apps(client: Client) : Service(client) { * @return [io.appwrite.models.App] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun create( appId: String, name: String, @@ -140,6 +142,7 @@ class Apps(client: Client) : Service(client) { * * @return [io.appwrite.models.AppScopeList] */ + @Throws(AppwriteException::class) suspend fun listInstallationScopes(): io.appwrite.models.AppScopeList { val apiPath = "/apps/scopes/installations" val apiParams = mutableMapOf() @@ -166,6 +169,7 @@ class Apps(client: Client) : Service(client) { * * @return [io.appwrite.models.AppScopeList] */ + @Throws(AppwriteException::class) suspend fun listOAuth2Scopes(): io.appwrite.models.AppScopeList { val apiPath = "/apps/scopes/oauth2" val apiParams = mutableMapOf() @@ -193,6 +197,7 @@ class Apps(client: Client) : Service(client) { * @param appId Application unique ID. * @return [io.appwrite.models.App] */ + @Throws(AppwriteException::class) suspend fun get( appId: String, ): io.appwrite.models.App { @@ -247,6 +252,7 @@ class Apps(client: Client) : Service(client) { * @return [io.appwrite.models.App] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun update( appId: String, name: String, @@ -321,6 +327,7 @@ class Apps(client: Client) : Service(client) { * @param appId Application unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun delete( appId: String, ): Any { @@ -354,6 +361,7 @@ class Apps(client: Client) : Service(client) { * @return [io.appwrite.models.AppInstallationList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listInstallations( appId: String, queries: List? = null, @@ -394,6 +402,7 @@ class Apps(client: Client) : Service(client) { * @param installationId Installation unique ID. * @return [io.appwrite.models.AppInstallation] */ + @Throws(AppwriteException::class) suspend fun getInstallation( appId: String, installationId: String, @@ -434,6 +443,7 @@ class Apps(client: Client) : Service(client) { * @param installationId Installation unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteInstallation( appId: String, installationId: String, @@ -470,6 +480,7 @@ class Apps(client: Client) : Service(client) { * @param installationId Installation unique ID. * @return [io.appwrite.models.Oauth2Token] */ + @Throws(AppwriteException::class) suspend fun createInstallationToken( appId: String, installationId: String, @@ -513,6 +524,7 @@ class Apps(client: Client) : Service(client) { * @return [io.appwrite.models.AppKeyList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listKeys( appId: String, queries: List? = null, @@ -552,6 +564,7 @@ class Apps(client: Client) : Service(client) { * @param appId Application unique ID. * @return [io.appwrite.models.AppKey] */ + @Throws(AppwriteException::class) suspend fun createKey( appId: String, ): io.appwrite.models.AppKey { @@ -588,6 +601,7 @@ class Apps(client: Client) : Service(client) { * @param keyId App key unique ID. * @return [io.appwrite.models.AppKey] */ + @Throws(AppwriteException::class) suspend fun getKey( appId: String, keyId: String, @@ -628,6 +642,7 @@ class Apps(client: Client) : Service(client) { * @param keyId App key unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteKey( appId: String, keyId: String, @@ -666,6 +681,7 @@ class Apps(client: Client) : Service(client) { * @return [io.appwrite.models.AppSecretList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listSecrets( appId: String, queries: List? = null, @@ -705,6 +721,7 @@ class Apps(client: Client) : Service(client) { * @param appId Application unique ID. * @return [io.appwrite.models.AppSecretPlaintext] */ + @Throws(AppwriteException::class) suspend fun createSecret( appId: String, ): io.appwrite.models.AppSecretPlaintext { @@ -741,6 +758,7 @@ class Apps(client: Client) : Service(client) { * @param secretId Secret unique ID. * @return [io.appwrite.models.AppSecret] */ + @Throws(AppwriteException::class) suspend fun getSecret( appId: String, secretId: String, @@ -781,6 +799,7 @@ class Apps(client: Client) : Service(client) { * @param secretId Secret unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteSecret( appId: String, secretId: String, @@ -817,6 +836,7 @@ class Apps(client: Client) : Service(client) { * @param teamId Team ID of the team to transfer application to. * @return [io.appwrite.models.App] */ + @Throws(AppwriteException::class) suspend fun updateTeam( appId: String, teamId: String, @@ -855,6 +875,7 @@ class Apps(client: Client) : Service(client) { * @param appId Application unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteTokens( appId: String, ): Any { diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 2223223..39257e0 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -27,6 +27,7 @@ class Avatars(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getBrowser( code: io.appwrite.enums.Browser, width: Long? = null, @@ -67,6 +68,7 @@ class Avatars(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getCreditCard( code: io.appwrite.enums.CreditCard, width: Long? = null, @@ -102,6 +104,7 @@ class Avatars(client: Client) : Service(client) { * @param url Website URL which you want to fetch the favicon from. * @return [ByteArray] */ + @Throws(AppwriteException::class) suspend fun getFavicon( url: String, ): ByteArray { @@ -135,6 +138,7 @@ class Avatars(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getFlag( code: io.appwrite.enums.Flag, width: Long? = null, @@ -175,6 +179,7 @@ class Avatars(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getImage( url: String, width: Long? = null, @@ -214,6 +219,7 @@ class Avatars(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getInitials( name: String? = null, width: Long? = null, @@ -256,6 +262,7 @@ class Avatars(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getPhoto( width: Long? = null, height: Long? = null, @@ -296,6 +303,8 @@ class Avatars(client: Client) : Service(client) { * @param file Binary image file of at most 5MB. Allowed file types are png, jpg, jpeg, and webp. * @return [io.appwrite.models.Account] */ + @JvmOverloads + @Throws(AppwriteException::class) suspend fun updatePhoto( file: InputFile, nestedType: Class, @@ -335,6 +344,7 @@ class Avatars(client: Client) : Service(client) { * @param file Binary image file of at most 5MB. Allowed file types are png, jpg, jpeg, and webp. * @return [io.appwrite.models.Account] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePhoto( file: InputFile, @@ -350,6 +360,7 @@ class Avatars(client: Client) : Service(client) { * * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deletePhoto(): Any { val apiPath = "/avatars/photo" val apiParams = mutableMapOf() @@ -378,6 +389,7 @@ class Avatars(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getQR( text: String, size: Long? = null, @@ -434,6 +446,7 @@ class Avatars(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getScreenshot( url: String, headers: Map? = null, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 8b3b821..a5790ea 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -25,6 +25,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.listTransactions") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun listTransactions( queries: List? = null, total: Boolean? = null, @@ -63,6 +64,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createTransaction") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun createTransaction( ttl: Long? = null, ): io.appwrite.models.Transaction { @@ -99,6 +101,7 @@ class Databases(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.", replaceWith = ReplaceWith("io.appwrite.services.TablesDB.getTransaction") ) + @Throws(AppwriteException::class) suspend fun getTransaction( transactionId: String, ): io.appwrite.models.Transaction { @@ -140,6 +143,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.updateTransaction") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateTransaction( transactionId: String, commit: Boolean? = null, @@ -184,6 +188,7 @@ class Databases(client: Client) : Service(client) { message = "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.", replaceWith = ReplaceWith("io.appwrite.services.TablesDB.deleteTransaction") ) + @Throws(AppwriteException::class) suspend fun deleteTransaction( transactionId: String, ): Any { @@ -220,6 +225,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createOperations") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun createOperations( transactionId: String, operations: List>? = null, @@ -255,12 +261,14 @@ class Databases(client: Client) : Service(client) { /** * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. * + * Documents returned by aggregate, groupBy or distinct queries hold only the attributes they select, group or aggregate, typed as a document types them, with a joined attribute named by its join alias (`alias.attribute`). The response omits their `$id`, `$sequence`, `$createdAt`, `$updatedAt`, `$permissions`, `$databaseId` and `$collectionId` unless they select or group it, and those of a right or full join document that no document of this collection matched. SDK document models fill omitted system attributes with empty values. + * * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @param total When set to false, the total count returned will be 0 and will not be calculated. - * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). + * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Lists with join queries are not cached. Must be between 0 and 86400 (24 hours). * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -268,6 +276,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.listRows") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun listDocuments( databaseId: String, collectionId: String, @@ -314,12 +323,14 @@ class Databases(client: Client) : Service(client) { /** * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. * + * Documents returned by aggregate, groupBy or distinct queries hold only the attributes they select, group or aggregate, typed as a document types them, with a joined attribute named by its join alias (`alias.attribute`). The response omits their `$id`, `$sequence`, `$createdAt`, `$updatedAt`, `$permissions`, `$databaseId` and `$collectionId` unless they select or group it, and those of a right or full join document that no document of this collection matched. SDK document models fill omitted system attributes with empty values. + * * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @param total When set to false, the total count returned will be 0 and will not be calculated. - * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). + * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Lists with join queries are not cached. Must be between 0 and 86400 (24 hours). * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -361,6 +372,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createRow") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun createDocument( databaseId: String, collectionId: String, @@ -439,6 +451,103 @@ class Databases(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Get a list of all the user's documents in a given collection using a POST request. This behaves identically to the list documents endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. + * + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. + * @param total When set to false, the total count returned will be 0 and will not be calculated. + * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Lists with join queries are not cached. Must be between 0 and 86400 (24 hours). + * @return [io.appwrite.models.DocumentList] + */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createQuery` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createQuery") + ) + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createQuery( + databaseId: String, + collectionId: String, + queries: List? = null, + transactionId: String? = null, + total: Boolean? = null, + ttl: Long? = null, + nestedType: Class, + ): io.appwrite.models.DocumentList { + if (databaseId.isEmpty()) { + throw AppwriteException("Missing required parameter: \"databaseId\"") + } + if (collectionId.isEmpty()) { + throw AppwriteException("Missing required parameter: \"collectionId\"") + } + val apiPath = ("/databases/{databaseId}/collections/{collectionId}/documents/query" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + ) + val apiParams = mutableMapOf( + "queries" to queries, + "transactionId" to transactionId, + "total" to total, + "ttl" to ttl, + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "content-type" to "application/json", + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Get a list of all the user's documents in a given collection using a POST request. This behaves identically to the list documents endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. + * + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. + * @param total When set to false, the total count returned will be 0 and will not be calculated. + * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Lists with join queries are not cached. Must be between 0 and 86400 (24 hours). + * @return [io.appwrite.models.DocumentList] + */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createQuery` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createQuery") + ) + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createQuery( + databaseId: String, + collectionId: String, + queries: List? = null, + transactionId: String? = null, + total: Boolean? = null, + ttl: Long? = null, + ): io.appwrite.models.DocumentList> = createQuery( + databaseId, + collectionId, + queries, + transactionId, + total, + ttl, + nestedType = classOf(), + ) + /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -454,6 +563,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.getRow") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun getDocument( databaseId: String, collectionId: String, @@ -545,6 +655,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.upsertRow") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun upsertDocument( databaseId: String, collectionId: String, @@ -642,6 +753,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.updateRow") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateDocument( databaseId: String, collectionId: String, @@ -737,6 +849,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.deleteRow") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun deleteDocument( databaseId: String, collectionId: String, @@ -791,6 +904,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.decrementRowColumn") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -897,6 +1011,7 @@ class Databases(client: Client) : Service(client) { replaceWith = ReplaceWith("io.appwrite.services.TablesDB.incrementRowColumn") ) @JvmOverloads + @Throws(AppwriteException::class) suspend fun incrementDocumentAttribute( databaseId: String, collectionId: String, diff --git a/library/src/main/java/io/appwrite/services/DocumentsDB.kt b/library/src/main/java/io/appwrite/services/DocumentsDB.kt index 9c40324..2df650e 100644 --- a/library/src/main/java/io/appwrite/services/DocumentsDB.kt +++ b/library/src/main/java/io/appwrite/services/DocumentsDB.kt @@ -21,6 +21,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.TransactionList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listTransactions( queries: List? = null, total: Boolean? = null, @@ -55,6 +56,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Transaction] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createTransaction( ttl: Long? = null, ): io.appwrite.models.Transaction { @@ -87,6 +89,7 @@ class DocumentsDB(client: Client) : Service(client) { * @param transactionId Transaction ID. * @return [io.appwrite.models.Transaction] */ + @Throws(AppwriteException::class) suspend fun getTransaction( transactionId: String, ): io.appwrite.models.Transaction { @@ -124,6 +127,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Transaction] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateTransaction( transactionId: String, commit: Boolean? = null, @@ -164,6 +168,7 @@ class DocumentsDB(client: Client) : Service(client) { * @param transactionId Transaction ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteTransaction( transactionId: String, ): Any { @@ -196,6 +201,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Transaction] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createOperations( transactionId: String, operations: List>? = null, @@ -240,6 +246,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.DocumentList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listDocuments( databaseId: String, collectionId: String, @@ -325,6 +332,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createDocument( databaseId: String, collectionId: String, @@ -409,6 +417,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.DocumentList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createDocuments( databaseId: String, collectionId: String, @@ -473,6 +482,95 @@ class DocumentsDB(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Get a list of all the user's documents in a given collection using a POST request. This behaves identically to the list documents endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. + * + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. + * @param total When set to false, the total count returned will be 0 and will not be calculated. + * @param ttl TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @return [io.appwrite.models.DocumentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createQuery( + databaseId: String, + collectionId: String, + queries: List? = null, + transactionId: String? = null, + total: Boolean? = null, + ttl: Long? = null, + nestedType: Class, + ): io.appwrite.models.DocumentList { + if (databaseId.isEmpty()) { + throw AppwriteException("Missing required parameter: \"databaseId\"") + } + if (collectionId.isEmpty()) { + throw AppwriteException("Missing required parameter: \"collectionId\"") + } + val apiPath = ("/documentsdb/{databaseId}/collections/{collectionId}/documents/query" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + ) + val apiParams = mutableMapOf( + "queries" to queries, + "transactionId" to transactionId, + "total" to total, + "ttl" to ttl, + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "content-type" to "application/json", + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Get a list of all the user's documents in a given collection using a POST request. This behaves identically to the list documents endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. + * + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. + * @param total When set to false, the total count returned will be 0 and will not be calculated. + * @param ttl TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @return [io.appwrite.models.DocumentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createQuery( + databaseId: String, + collectionId: String, + queries: List? = null, + transactionId: String? = null, + total: Boolean? = null, + ttl: Long? = null, + ): io.appwrite.models.DocumentList> = createQuery( + databaseId, + collectionId, + queries, + transactionId, + total, + ttl, + nestedType = classOf(), + ) + /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -484,6 +582,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getDocument( databaseId: String, collectionId: String, @@ -567,6 +666,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun upsertDocument( databaseId: String, collectionId: String, @@ -656,6 +756,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateDocument( databaseId: String, collectionId: String, @@ -743,6 +844,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [Any] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun deleteDocument( databaseId: String, collectionId: String, @@ -793,6 +895,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun decrementDocumentAttribute( databaseId: String, collectionId: String, @@ -891,6 +994,7 @@ class DocumentsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun incrementDocumentAttribute( databaseId: String, collectionId: String, diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 0417207..c032f12 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -22,6 +22,7 @@ class Functions(client: Client) : Service(client) { * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listExecutions( functionId: String, queries: List? = null, @@ -68,6 +69,7 @@ class Functions(client: Client) : Service(client) { * @return [io.appwrite.models.Execution] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createExecution( functionId: String, body: String? = null, @@ -117,6 +119,7 @@ class Functions(client: Client) : Service(client) { * @param executionId Execution ID. * @return [io.appwrite.models.Execution] */ + @Throws(AppwriteException::class) suspend fun getExecution( functionId: String, executionId: String, diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index dba5986..e6ab555 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -19,6 +19,7 @@ class Graphql(client: Client) : Service(client) { * @param query The query or queries to execute. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun query( query: Map, ): Any { @@ -51,6 +52,7 @@ class Graphql(client: Client) : Service(client) { * @param query The query or queries to execute. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun mutation( query: Map, ): Any { diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index a6eb364..c1b0ba4 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -20,6 +20,7 @@ class Locale(client: Client) : Service(client) { * * @return [io.appwrite.models.Locale] */ + @Throws(AppwriteException::class) suspend fun get(): io.appwrite.models.Locale { val apiPath = "/locale" val apiParams = mutableMapOf() @@ -48,6 +49,7 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.LocaleCodeList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listCodes( total: Boolean? = null, ): io.appwrite.models.LocaleCodeList { @@ -80,6 +82,7 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.ContinentList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listContinents( total: Boolean? = null, ): io.appwrite.models.ContinentList { @@ -112,6 +115,7 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.CountryList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listCountries( total: Boolean? = null, ): io.appwrite.models.CountryList { @@ -144,6 +148,7 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.CountryList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listCountriesEU( total: Boolean? = null, ): io.appwrite.models.CountryList { @@ -176,6 +181,7 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.PhoneList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listCountriesPhones( total: Boolean? = null, ): io.appwrite.models.PhoneList { @@ -208,6 +214,7 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.CurrencyList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listCurrencies( total: Boolean? = null, ): io.appwrite.models.CurrencyList { @@ -240,6 +247,7 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.LanguageList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listLanguages( total: Boolean? = null, ): io.appwrite.models.LanguageList { diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index e0e36b1..b2952d6 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -21,6 +21,7 @@ class Messaging(client: Client) : Service(client) { * @param targetId Target ID. The target ID to link to the specified Topic ID. * @return [io.appwrite.models.Subscriber] */ + @Throws(AppwriteException::class) suspend fun createSubscriber( topicId: String, subscriberId: String, @@ -62,6 +63,7 @@ class Messaging(client: Client) : Service(client) { * @param subscriberId Subscriber ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteSubscriber( topicId: String, subscriberId: String, diff --git a/library/src/main/java/io/appwrite/services/Oauth2.kt b/library/src/main/java/io/appwrite/services/Oauth2.kt index f5cbc3c..20272d8 100644 --- a/library/src/main/java/io/appwrite/services/Oauth2.kt +++ b/library/src/main/java/io/appwrite/services/Oauth2.kt @@ -22,6 +22,7 @@ class Oauth2(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2Approve] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun approve( grantId: String, authorizationDetails: String? = null, @@ -73,6 +74,7 @@ class Oauth2(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2Authorize] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun authorize( clientId: String? = null, redirectUri: String? = null, @@ -145,6 +147,7 @@ class Oauth2(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2Authorize] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun authorizePost( clientId: String? = null, redirectUri: String? = null, @@ -209,6 +212,7 @@ class Oauth2(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2DeviceAuthorization] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createDeviceAuthorization( clientId: String? = null, scope: String? = null, @@ -250,6 +254,7 @@ class Oauth2(client: Client) : Service(client) { * @param userCode User code displayed on the device. * @return [io.appwrite.models.Oauth2Grant] */ + @Throws(AppwriteException::class) suspend fun createGrant( userCode: String, ): io.appwrite.models.Oauth2Grant { @@ -283,6 +288,7 @@ class Oauth2(client: Client) : Service(client) { * @param grantId Grant ID made during authorization, provided to consent screen in URL search params. * @return [io.appwrite.models.Oauth2Grant] */ + @Throws(AppwriteException::class) suspend fun getGrant( grantId: String, ): io.appwrite.models.Oauth2Grant { @@ -323,6 +329,7 @@ class Oauth2(client: Client) : Service(client) { * @return [Any] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun logout( idTokenHint: String? = null, logoutHint: String? = null, @@ -366,6 +373,7 @@ class Oauth2(client: Client) : Service(client) { * @return [Any] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun logoutPost( idTokenHint: String? = null, logoutHint: String? = null, @@ -407,6 +415,7 @@ class Oauth2(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2OrganizationList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listOrganizations( limit: Long? = null, offset: Long? = null, @@ -456,6 +465,7 @@ class Oauth2(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2PAR] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createPAR( clientId: String, redirectUri: String, @@ -516,6 +526,7 @@ class Oauth2(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2ProjectList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listProjects( limit: Long? = null, offset: Long? = null, @@ -552,6 +563,7 @@ class Oauth2(client: Client) : Service(client) { * @param grantId Grant ID made during authorization, provided to consent screen in URL search params. * @return [io.appwrite.models.Oauth2Reject] */ + @Throws(AppwriteException::class) suspend fun reject( grantId: String, ): io.appwrite.models.Oauth2Reject { @@ -589,6 +601,7 @@ class Oauth2(client: Client) : Service(client) { * @return [Any] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun revoke( token: String, tokenTypeHint: String? = null, @@ -633,6 +646,7 @@ class Oauth2(client: Client) : Service(client) { * @return [io.appwrite.models.Oauth2Token] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createToken( grantType: String, code: String? = null, diff --git a/library/src/main/java/io/appwrite/services/Organization.kt b/library/src/main/java/io/appwrite/services/Organization.kt index 00ed08a..c042c48 100644 --- a/library/src/main/java/io/appwrite/services/Organization.kt +++ b/library/src/main/java/io/appwrite/services/Organization.kt @@ -21,6 +21,7 @@ class Organization(client: Client) : Service(client) { * @return [io.appwrite.models.AppInstallationList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listInstallations( queries: List? = null, total: Boolean? = null, @@ -56,6 +57,7 @@ class Organization(client: Client) : Service(client) { * @return [io.appwrite.models.AppInstallation] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createInstallation( appId: String, authorizationDetails: String? = null, @@ -90,6 +92,7 @@ class Organization(client: Client) : Service(client) { * @param installationId Installation unique ID. * @return [io.appwrite.models.AppInstallation] */ + @Throws(AppwriteException::class) suspend fun getInstallation( installationId: String, ): io.appwrite.models.AppInstallation { @@ -126,6 +129,7 @@ class Organization(client: Client) : Service(client) { * @return [io.appwrite.models.AppInstallation] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateInstallation( installationId: String, authorizationDetails: String? = null, @@ -164,6 +168,7 @@ class Organization(client: Client) : Service(client) { * @param installationId Installation unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteInstallation( installationId: String, ): Any { diff --git a/library/src/main/java/io/appwrite/services/Presences.kt b/library/src/main/java/io/appwrite/services/Presences.kt index 31181a0..58b2cac 100644 --- a/library/src/main/java/io/appwrite/services/Presences.kt +++ b/library/src/main/java/io/appwrite/services/Presences.kt @@ -23,6 +23,7 @@ class Presences(client: Client) : Service(client) { * @return [io.appwrite.models.PresenceList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun list( queries: List? = null, total: Boolean? = null, @@ -59,6 +60,7 @@ class Presences(client: Client) : Service(client) { * @param presenceId Presence unique ID. * @return [io.appwrite.models.Presence] */ + @Throws(AppwriteException::class) suspend fun get( presenceId: String, ): io.appwrite.models.Presence { @@ -99,6 +101,7 @@ class Presences(client: Client) : Service(client) { * @return [io.appwrite.models.Presence] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun upsert( presenceId: String, status: String, @@ -150,6 +153,7 @@ class Presences(client: Client) : Service(client) { * @return [io.appwrite.models.Presence] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun update( presenceId: String, status: String? = null, @@ -197,6 +201,7 @@ class Presences(client: Client) : Service(client) { * @param presenceId Presence unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun delete( presenceId: String, ): Any { diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 9f8f45b..f7f88d4 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -25,6 +25,7 @@ class Storage(client: Client) : Service(client) { * @return [io.appwrite.models.FileList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listFiles( bucketId: String, queries: List? = null, @@ -78,6 +79,7 @@ class Storage(client: Client) : Service(client) { * @return [io.appwrite.models.File] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createFile( bucketId: String, fileId: String, @@ -129,6 +131,7 @@ class Storage(client: Client) : Service(client) { * @param fileId File ID. * @return [io.appwrite.models.File] */ + @Throws(AppwriteException::class) suspend fun getFile( bucketId: String, fileId: String, @@ -172,6 +175,7 @@ class Storage(client: Client) : Service(client) { * @return [io.appwrite.models.File] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateFile( bucketId: String, fileId: String, @@ -218,6 +222,7 @@ class Storage(client: Client) : Service(client) { * @param fileId File ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteFile( bucketId: String, fileId: String, @@ -256,6 +261,7 @@ class Storage(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getFileDownload( bucketId: String, fileId: String, @@ -307,6 +313,7 @@ class Storage(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getFilePreview( bucketId: String, fileId: String, @@ -369,6 +376,7 @@ class Storage(client: Client) : Service(client) { * @return [ByteArray] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getFileView( bucketId: String, fileId: String, diff --git a/library/src/main/java/io/appwrite/services/TablesDB.kt b/library/src/main/java/io/appwrite/services/TablesDB.kt index 34217c4..dff3b09 100644 --- a/library/src/main/java/io/appwrite/services/TablesDB.kt +++ b/library/src/main/java/io/appwrite/services/TablesDB.kt @@ -21,6 +21,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.TransactionList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listTransactions( queries: List? = null, total: Boolean? = null, @@ -55,6 +56,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.Transaction] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createTransaction( ttl: Long? = null, ): io.appwrite.models.Transaction { @@ -87,6 +89,7 @@ class TablesDB(client: Client) : Service(client) { * @param transactionId Transaction ID. * @return [io.appwrite.models.Transaction] */ + @Throws(AppwriteException::class) suspend fun getTransaction( transactionId: String, ): io.appwrite.models.Transaction { @@ -124,6 +127,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.Transaction] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateTransaction( transactionId: String, commit: Boolean? = null, @@ -164,6 +168,7 @@ class TablesDB(client: Client) : Service(client) { * @param transactionId Transaction ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteTransaction( transactionId: String, ): Any { @@ -196,6 +201,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.Transaction] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createOperations( transactionId: String, operations: List>? = null, @@ -231,15 +237,18 @@ class TablesDB(client: Client) : Service(client) { /** * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * + * Rows returned by aggregate, groupBy or distinct queries hold only the columns they select, group or aggregate, typed as a row types them, with a joined column named by its join alias (`alias.column`). The response omits their `$id`, `$sequence`, `$createdAt`, `$updatedAt`, `$permissions`, `$databaseId` and `$tableId` unless they select or group it, and those of a right or full join row that no row of this table matched. SDK row models fill omitted system columns with empty values. + * * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @param total When set to false, the total count returned will be 0 and will not be calculated. - * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, table, schema version (columns and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; row writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). + * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, table, schema version (columns and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; row writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Lists with join queries are not cached. Must be between 0 and 86400 (24 hours). * @return [io.appwrite.models.RowList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listRows( databaseId: String, tableId: String, @@ -286,12 +295,14 @@ class TablesDB(client: Client) : Service(client) { /** * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * + * Rows returned by aggregate, groupBy or distinct queries hold only the columns they select, group or aggregate, typed as a row types them, with a joined column named by its join alias (`alias.column`). The response omits their `$id`, `$sequence`, `$createdAt`, `$updatedAt`, `$permissions`, `$databaseId` and `$tableId` unless they select or group it, and those of a right or full join row that no row of this table matched. SDK row models fill omitted system columns with empty values. + * * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @param transactionId Transaction ID to read uncommitted changes within the transaction. * @param total When set to false, the total count returned will be 0 and will not be calculated. - * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, table, schema version (columns and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; row writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). + * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, table, schema version (columns and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; row writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Lists with join queries are not cached. Must be between 0 and 86400 (24 hours). * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -325,6 +336,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.Row] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createRow( databaseId: String, tableId: String, @@ -399,6 +411,95 @@ class TablesDB(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Get a list of all the user's rows in a given table using a POST request. This behaves identically to the list rows endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. + * + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. + * @param total When set to false, the total count returned will be 0 and will not be calculated. + * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, table, schema version (columns and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; row writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Lists with join queries are not cached. Must be between 0 and 86400 (24 hours). + * @return [io.appwrite.models.RowList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createQuery( + databaseId: String, + tableId: String, + queries: List? = null, + transactionId: String? = null, + total: Boolean? = null, + ttl: Long? = null, + nestedType: Class, + ): io.appwrite.models.RowList { + if (databaseId.isEmpty()) { + throw AppwriteException("Missing required parameter: \"databaseId\"") + } + if (tableId.isEmpty()) { + throw AppwriteException("Missing required parameter: \"tableId\"") + } + val apiPath = ("/tablesdb/{databaseId}/tables/{tableId}/rows/query" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + ) + val apiParams = mutableMapOf( + "queries" to queries, + "transactionId" to transactionId, + "total" to total, + "ttl" to ttl, + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "content-type" to "application/json", + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.RowList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.RowList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Get a list of all the user's rows in a given table using a POST request. This behaves identically to the list rows endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. + * + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param transactionId Transaction ID to read uncommitted changes within the transaction. + * @param total When set to false, the total count returned will be 0 and will not be calculated. + * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, table, schema version (columns and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; row writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Lists with join queries are not cached. Must be between 0 and 86400 (24 hours). + * @return [io.appwrite.models.RowList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createQuery( + databaseId: String, + tableId: String, + queries: List? = null, + transactionId: String? = null, + total: Boolean? = null, + ttl: Long? = null, + ): io.appwrite.models.RowList> = createQuery( + databaseId, + tableId, + queries, + transactionId, + total, + ttl, + nestedType = classOf(), + ) + /** * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * @@ -410,6 +511,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.Row] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getRow( databaseId: String, tableId: String, @@ -493,6 +595,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.Row] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun upsertRow( databaseId: String, tableId: String, @@ -582,6 +685,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.Row] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateRow( databaseId: String, tableId: String, @@ -669,6 +773,7 @@ class TablesDB(client: Client) : Service(client) { * @return [Any] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun deleteRow( databaseId: String, tableId: String, @@ -719,6 +824,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.Row] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun decrementRowColumn( databaseId: String, tableId: String, @@ -817,6 +923,7 @@ class TablesDB(client: Client) : Service(client) { * @return [io.appwrite.models.Row] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun incrementRowColumn( databaseId: String, tableId: String, diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 8a4bb87..b989265 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -22,6 +22,7 @@ class Teams(client: Client) : Service(client) { * @return [io.appwrite.models.TeamList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun list( queries: List? = null, search: String? = null, @@ -82,6 +83,7 @@ class Teams(client: Client) : Service(client) { * @return [io.appwrite.models.Team] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun create( teamId: String, name: String, @@ -140,6 +142,7 @@ class Teams(client: Client) : Service(client) { * @param teamId Team ID. * @return [io.appwrite.models.Team] */ + @Throws(AppwriteException::class) suspend fun get( teamId: String, nestedType: Class, @@ -190,6 +193,7 @@ class Teams(client: Client) : Service(client) { * @param name New team name. Max length: 128 chars. * @return [io.appwrite.models.Team] */ + @Throws(AppwriteException::class) suspend fun updateName( teamId: String, name: String, @@ -246,6 +250,7 @@ class Teams(client: Client) : Service(client) { * @param teamId Team ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun delete( teamId: String, ): Any { @@ -279,6 +284,7 @@ class Teams(client: Client) : Service(client) { * @return [io.appwrite.models.AppInstallationList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listInstallations( teamId: String, queries: List? = null, @@ -321,6 +327,7 @@ class Teams(client: Client) : Service(client) { * @return [io.appwrite.models.AppInstallation] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createInstallation( teamId: String, appId: String, @@ -362,6 +369,7 @@ class Teams(client: Client) : Service(client) { * @param installationId Installation unique ID. * @return [io.appwrite.models.AppInstallation] */ + @Throws(AppwriteException::class) suspend fun getInstallation( teamId: String, installationId: String, @@ -404,6 +412,7 @@ class Teams(client: Client) : Service(client) { * @return [io.appwrite.models.AppInstallation] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateInstallation( teamId: String, installationId: String, @@ -448,6 +457,7 @@ class Teams(client: Client) : Service(client) { * @param installationId Installation unique ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteInstallation( teamId: String, installationId: String, @@ -487,6 +497,7 @@ class Teams(client: Client) : Service(client) { * @return [io.appwrite.models.MembershipList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listMemberships( teamId: String, queries: List? = null, @@ -543,6 +554,7 @@ class Teams(client: Client) : Service(client) { * @return [io.appwrite.models.Membership] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createMembership( teamId: String, roles: List, @@ -594,6 +606,7 @@ class Teams(client: Client) : Service(client) { * @param membershipId Membership ID. * @return [io.appwrite.models.Membership] */ + @Throws(AppwriteException::class) suspend fun getMembership( teamId: String, membershipId: String, @@ -636,6 +649,7 @@ class Teams(client: Client) : Service(client) { * @param roles An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. * @return [io.appwrite.models.Membership] */ + @Throws(AppwriteException::class) suspend fun updateMembership( teamId: String, membershipId: String, @@ -680,6 +694,7 @@ class Teams(client: Client) : Service(client) { * @param membershipId Membership ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteMembership( teamId: String, membershipId: String, @@ -721,6 +736,7 @@ class Teams(client: Client) : Service(client) { * @param secret Secret key. * @return [io.appwrite.models.Membership] */ + @Throws(AppwriteException::class) suspend fun updateMembershipStatus( teamId: String, membershipId: String, @@ -766,6 +782,7 @@ class Teams(client: Client) : Service(client) { * @param teamId Team ID. * @return [io.appwrite.models.Preferences] */ + @Throws(AppwriteException::class) suspend fun getPrefs( teamId: String, nestedType: Class, @@ -816,6 +833,7 @@ class Teams(client: Client) : Service(client) { * @param prefs Prefs key-value JSON object. * @return [io.appwrite.models.Preferences] */ + @Throws(AppwriteException::class) suspend fun updatePrefs( teamId: String, prefs: Map, diff --git a/library/src/main/java/io/appwrite/services/VectorsDB.kt b/library/src/main/java/io/appwrite/services/VectorsDB.kt index 9ad46da..cf49961 100644 --- a/library/src/main/java/io/appwrite/services/VectorsDB.kt +++ b/library/src/main/java/io/appwrite/services/VectorsDB.kt @@ -21,6 +21,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.TransactionList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listTransactions( queries: List? = null, total: Boolean? = null, @@ -55,6 +56,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Transaction] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createTransaction( ttl: Long? = null, ): io.appwrite.models.Transaction { @@ -87,6 +89,7 @@ class VectorsDB(client: Client) : Service(client) { * @param transactionId Transaction ID. * @return [io.appwrite.models.Transaction] */ + @Throws(AppwriteException::class) suspend fun getTransaction( transactionId: String, ): io.appwrite.models.Transaction { @@ -124,6 +127,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Transaction] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateTransaction( transactionId: String, commit: Boolean? = null, @@ -164,6 +168,7 @@ class VectorsDB(client: Client) : Service(client) { * @param transactionId Transaction ID. * @return [Any] */ + @Throws(AppwriteException::class) suspend fun deleteTransaction( transactionId: String, ): Any { @@ -196,6 +201,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Transaction] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createOperations( transactionId: String, operations: List>? = null, @@ -240,6 +246,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.DocumentList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun listDocuments( databaseId: String, collectionId: String, @@ -325,6 +332,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createDocument( databaseId: String, collectionId: String, @@ -412,6 +420,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.DocumentList] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun createQuery( databaseId: String, collectionId: String, @@ -498,6 +507,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun getDocument( databaseId: String, collectionId: String, @@ -581,6 +591,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun upsertDocument( databaseId: String, collectionId: String, @@ -670,6 +681,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun updateDocument( databaseId: String, collectionId: String, @@ -757,6 +769,7 @@ class VectorsDB(client: Client) : Service(client) { * @return [Any] */ @JvmOverloads + @Throws(AppwriteException::class) suspend fun deleteDocument( databaseId: String, collectionId: String, diff --git a/library/src/test/java/io/appwrite/JsonCastTest.kt b/library/src/test/java/io/appwrite/JsonCastTest.kt new file mode 100644 index 0000000..3c2935a --- /dev/null +++ b/library/src/test/java/io/appwrite/JsonCastTest.kt @@ -0,0 +1,33 @@ +package io.appwrite + +import io.appwrite.extensions.jsonCast +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test + +class JsonCastTest { + @Test + fun jsonCastKeepsKeysWhoseValueIsNull() { + val cast = mapOf("note" to null, "c.name" to null, "price" to 15L).jsonCast(Map::class.java) + + assertTrue(cast.containsKey("note")) + assertNull(cast["note"]) + assertTrue(cast.containsKey("c.name")) + assertEquals(15L, cast["price"]) + } + + @Test + fun jsonCastKeepsNullsInsideNestedData() { + val response = mapOf( + "\$id" to "o8", + "data" to mapOf("note" to null, "joined" to mapOf("c.name" to null), "customerId" to "c9"), + ) + + val data = response["data"]!!.jsonCast(Map::class.java) + + assertTrue("A null column must stay in the row, not read as unselected", data.containsKey("note")) + assertTrue("An unmatched left join must keep its joined columns as null", (data["joined"] as Map<*, *>).containsKey("c.name")) + assertEquals("c9", data["customerId"]) + } +} diff --git a/library/src/test/java/io/appwrite/QueryTest.kt b/library/src/test/java/io/appwrite/QueryTest.kt index a3662b7..f0a7c3a 100644 --- a/library/src/test/java/io/appwrite/QueryTest.kt +++ b/library/src/test/java/io/appwrite/QueryTest.kt @@ -2,6 +2,7 @@ package io.appwrite import com.google.gson.JsonParser import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test class QueryTest { @@ -105,6 +106,25 @@ class QueryTest { assertEquals("crossJoin", method(Query.crossJoin("orders", "ord"))) } + @Test + fun nestedJoinWithoutAliasLeavesTheAliasToTheServer() { + val json = JsonParser.parseString(Query.join("orders", listOf(Query.on("\$id", "customerId")))).asJsonObject + assertEquals("join", json.get("method").asString) + assertEquals("orders", json.get("attribute").asString) + val values = json.get("values").asJsonArray + assertEquals(1, values.size()) + assertEquals("on", values[0].asJsonObject.get("method").asString) + } + + @Test + fun crossJoinWithoutAliasLeavesTheAliasToTheServer() { + val json = JsonParser.parseString(Query.crossJoin("orders")).asJsonObject + assertEquals("crossJoin", json.get("method").asString) + assertEquals("orders", json.get("attribute").asString) + val values = json.get("values") + assertTrue(values == null || values.isJsonNull || values.asJsonArray.size() == 0) + } + @Test fun on() { assertEquals("on", method(Query.on("\$id", "customerId")))