From 0808589bccf4071e8f6a0c28263c886299b322b2 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 8 Jun 2026 11:20:55 +0530 Subject: [PATCH 1/5] chore: update Android SDK to 25.1.0 --- CHANGELOG.md | 11 +- README.md | 4 +- docs/examples/java/account/update-password.md | 2 +- docs/examples/java/apps/create-secret.md | 24 + docs/examples/java/apps/create.md | 30 ++ docs/examples/java/apps/delete-secret.md | 25 + docs/examples/java/apps/delete-tokens.md | 24 + docs/examples/java/apps/delete.md | 24 + docs/examples/java/apps/get-secret.md | 25 + docs/examples/java/apps/get.md | 24 + docs/examples/java/apps/list-secrets.md | 26 ++ docs/examples/java/apps/list.md | 25 + docs/examples/java/apps/update-team.md | 25 + docs/examples/java/apps/update.md | 29 ++ docs/examples/java/oauth2/approve.md | 26 ++ docs/examples/java/oauth2/authorize.md | 35 ++ docs/examples/java/oauth2/create-grant.md | 25 + docs/examples/java/oauth2/get-grant.md | 25 + docs/examples/java/oauth2/reject.md | 25 + .../kotlin/account/update-password.md | 2 +- docs/examples/kotlin/apps/create-secret.md | 15 + docs/examples/kotlin/apps/create.md | 21 + docs/examples/kotlin/apps/delete-secret.md | 16 + docs/examples/kotlin/apps/delete-tokens.md | 15 + docs/examples/kotlin/apps/delete.md | 15 + docs/examples/kotlin/apps/get-secret.md | 16 + docs/examples/kotlin/apps/get.md | 15 + docs/examples/kotlin/apps/list-secrets.md | 17 + docs/examples/kotlin/apps/list.md | 16 + docs/examples/kotlin/apps/update-team.md | 16 + docs/examples/kotlin/apps/update.md | 20 + docs/examples/kotlin/oauth2/approve.md | 17 + docs/examples/kotlin/oauth2/authorize.md | 26 ++ docs/examples/kotlin/oauth2/create-grant.md | 16 + docs/examples/kotlin/oauth2/get-grant.md | 16 + docs/examples/kotlin/oauth2/reject.md | 16 + library/src/main/java/io/appwrite/Client.kt | 8 +- .../src/main/java/io/appwrite/models/App.kt | 110 +++++ .../main/java/io/appwrite/models/AppSecret.kt | 94 ++++ .../java/io/appwrite/models/AppSecretList.kt | 38 ++ .../io/appwrite/models/AppSecretPlaintext.kt | 94 ++++ .../main/java/io/appwrite/models/AppsList.kt | 38 ++ .../java/io/appwrite/models/Membership.kt | 8 + .../java/io/appwrite/models/Oauth2Approve.kt | 30 ++ .../io/appwrite/models/Oauth2Authorize.kt | 38 ++ .../java/io/appwrite/models/Oauth2Grant.kt | 110 +++++ .../java/io/appwrite/models/Oauth2Reject.kt | 30 ++ .../src/main/java/io/appwrite/models/User.kt | 50 ++ .../main/java/io/appwrite/services/Account.kt | 110 ++++- .../main/java/io/appwrite/services/Apps.kt | 427 ++++++++++++++++++ .../java/io/appwrite/services/Databases.kt | 26 ++ .../java/io/appwrite/services/Functions.kt | 6 + .../main/java/io/appwrite/services/Graphql.kt | 4 + .../main/java/io/appwrite/services/Locale.kt | 16 + .../java/io/appwrite/services/Messaging.kt | 3 + .../main/java/io/appwrite/services/Oauth2.kt | 235 ++++++++++ .../java/io/appwrite/services/Presences.kt | 9 + .../main/java/io/appwrite/services/Storage.kt | 9 + .../java/io/appwrite/services/TablesDB.kt | 26 ++ .../main/java/io/appwrite/services/Teams.kt | 24 + 60 files changed, 2242 insertions(+), 10 deletions(-) create mode 100644 docs/examples/java/apps/create-secret.md create mode 100644 docs/examples/java/apps/create.md create mode 100644 docs/examples/java/apps/delete-secret.md create mode 100644 docs/examples/java/apps/delete-tokens.md create mode 100644 docs/examples/java/apps/delete.md create mode 100644 docs/examples/java/apps/get-secret.md create mode 100644 docs/examples/java/apps/get.md create mode 100644 docs/examples/java/apps/list-secrets.md create mode 100644 docs/examples/java/apps/list.md create mode 100644 docs/examples/java/apps/update-team.md create mode 100644 docs/examples/java/apps/update.md create mode 100644 docs/examples/java/oauth2/approve.md create mode 100644 docs/examples/java/oauth2/authorize.md create mode 100644 docs/examples/java/oauth2/create-grant.md create mode 100644 docs/examples/java/oauth2/get-grant.md create mode 100644 docs/examples/java/oauth2/reject.md create mode 100644 docs/examples/kotlin/apps/create-secret.md create mode 100644 docs/examples/kotlin/apps/create.md create mode 100644 docs/examples/kotlin/apps/delete-secret.md create mode 100644 docs/examples/kotlin/apps/delete-tokens.md create mode 100644 docs/examples/kotlin/apps/delete.md create mode 100644 docs/examples/kotlin/apps/get-secret.md create mode 100644 docs/examples/kotlin/apps/get.md create mode 100644 docs/examples/kotlin/apps/list-secrets.md create mode 100644 docs/examples/kotlin/apps/list.md create mode 100644 docs/examples/kotlin/apps/update-team.md create mode 100644 docs/examples/kotlin/apps/update.md create mode 100644 docs/examples/kotlin/oauth2/approve.md create mode 100644 docs/examples/kotlin/oauth2/authorize.md create mode 100644 docs/examples/kotlin/oauth2/create-grant.md create mode 100644 docs/examples/kotlin/oauth2/get-grant.md create mode 100644 docs/examples/kotlin/oauth2/reject.md create mode 100644 library/src/main/java/io/appwrite/models/App.kt create mode 100644 library/src/main/java/io/appwrite/models/AppSecret.kt create mode 100644 library/src/main/java/io/appwrite/models/AppSecretList.kt create mode 100644 library/src/main/java/io/appwrite/models/AppSecretPlaintext.kt create mode 100644 library/src/main/java/io/appwrite/models/AppsList.kt create mode 100644 library/src/main/java/io/appwrite/models/Oauth2Approve.kt create mode 100644 library/src/main/java/io/appwrite/models/Oauth2Authorize.kt create mode 100644 library/src/main/java/io/appwrite/models/Oauth2Grant.kt create mode 100644 library/src/main/java/io/appwrite/models/Oauth2Reject.kt create mode 100644 library/src/main/java/io/appwrite/services/Apps.kt create mode 100644 library/src/main/java/io/appwrite/services/Oauth2.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index ed8c1769..1440f097 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,19 @@ # Change Log +## 25.1.0 + +* Added: `apps` service with app and secret management methods. +* Added: `oauth2` service with `authorize`, `approve`, `reject`, `createGrant`, and `getGrant`. +* Added: `App`, `AppSecret`, `AppSecretPlaintext`, `AppsList`, and `AppSecretList` models. +* Added: `Oauth2Authorize`, `Oauth2Approve`, `Oauth2Reject`, and `Oauth2Grant` models. +* Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`). +* Added: `Membership.userAccessedAt` field. + ## 25.0.0 * Breaking: `avatars.getScreenshot` `theme` parameter now uses the `BrowserTheme` enum * Breaking: Removed generic type parameters from `presences` service methods -* Added: `BrowserTheme` enum +* Replaced: `BrowserTheme` enum * Updated: `Presence` model is now concrete and adds a `metadata` field ## 24.1.1 diff --git a/README.md b/README.md index fadaf5f7..74bd3178 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:25.0.0") +implementation("io.appwrite:sdk-for-android:25.1.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 25.0.0 + 25.1.0 ``` diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 075a869b..93562d57 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -11,7 +11,7 @@ Account account = new Account(client); account.updatePassword( "", // password - "password", // oldPassword (optional) + "", // oldPassword (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/apps/create-secret.md b/docs/examples/java/apps/create-secret.md new file mode 100644 index 00000000..3cc22697 --- /dev/null +++ b/docs/examples/java/apps/create-secret.md @@ -0,0 +1,24 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Apps apps = new Apps(client); + +apps.createSecret( + "", // appId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/apps/create.md b/docs/examples/java/apps/create.md new file mode 100644 index 00000000..f12f6a1f --- /dev/null +++ b/docs/examples/java/apps/create.md @@ -0,0 +1,30 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Apps apps = new Apps(client); + +apps.create( + "", // appId + "", // name + List.of(), // redirectUris + 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()); + }) +); + +``` diff --git a/docs/examples/java/apps/delete-secret.md b/docs/examples/java/apps/delete-secret.md new file mode 100644 index 00000000..59c74d08 --- /dev/null +++ b/docs/examples/java/apps/delete-secret.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Apps apps = new Apps(client); + +apps.deleteSecret( + "", // appId + "", // secretId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/apps/delete-tokens.md b/docs/examples/java/apps/delete-tokens.md new file mode 100644 index 00000000..d50393bd --- /dev/null +++ b/docs/examples/java/apps/delete-tokens.md @@ -0,0 +1,24 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Apps apps = new Apps(client); + +apps.deleteTokens( + "", // appId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/apps/delete.md b/docs/examples/java/apps/delete.md new file mode 100644 index 00000000..6166e0b3 --- /dev/null +++ b/docs/examples/java/apps/delete.md @@ -0,0 +1,24 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Apps apps = new Apps(client); + +apps.delete( + "", // appId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/apps/get-secret.md b/docs/examples/java/apps/get-secret.md new file mode 100644 index 00000000..bd86dfd4 --- /dev/null +++ b/docs/examples/java/apps/get-secret.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Apps apps = new Apps(client); + +apps.getSecret( + "", // appId + "", // secretId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/apps/get.md b/docs/examples/java/apps/get.md new file mode 100644 index 00000000..b6b2397b --- /dev/null +++ b/docs/examples/java/apps/get.md @@ -0,0 +1,24 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Apps apps = new Apps(client); + +apps.get( + "", // appId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/apps/list-secrets.md b/docs/examples/java/apps/list-secrets.md new file mode 100644 index 00000000..58ca3a9d --- /dev/null +++ b/docs/examples/java/apps/list-secrets.md @@ -0,0 +1,26 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +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()); + }) +); + +``` diff --git a/docs/examples/java/apps/list.md b/docs/examples/java/apps/list.md new file mode 100644 index 00000000..7ac61277 --- /dev/null +++ b/docs/examples/java/apps/list.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +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()); + }) +); + +``` diff --git a/docs/examples/java/apps/update-team.md b/docs/examples/java/apps/update-team.md new file mode 100644 index 00000000..6341e58b --- /dev/null +++ b/docs/examples/java/apps/update-team.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Apps apps = new Apps(client); + +apps.updateTeam( + "", // appId + "", // teamId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/apps/update.md b/docs/examples/java/apps/update.md new file mode 100644 index 00000000..d056455a --- /dev/null +++ b/docs/examples/java/apps/update.md @@ -0,0 +1,29 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Apps; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Apps apps = new Apps(client); + +apps.update( + "", // appId + "", // name + false, // enabled (optional) + List.of(), // redirectUris (optional) + "public", // type (optional) + false, // deviceFlow (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/oauth2/approve.md b/docs/examples/java/oauth2/approve.md new file mode 100644 index 00000000..b736556c --- /dev/null +++ b/docs/examples/java/oauth2/approve.md @@ -0,0 +1,26 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Oauth2; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProjectQuery(""); // Your project ID + +Oauth2 oauth2 = new Oauth2(client); + +oauth2.approve( + "", // project_id + "", // grant_id + "", // authorization_details (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/oauth2/authorize.md b/docs/examples/java/oauth2/authorize.md new file mode 100644 index 00000000..cfa341cd --- /dev/null +++ b/docs/examples/java/oauth2/authorize.md @@ -0,0 +1,35 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Oauth2; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProjectQuery(""); // Your project ID + +Oauth2 oauth2 = new Oauth2(client); + +oauth2.authorize( + "", // project_id + "", // client_id + "https://example.com", // redirect_uri + "code", // response_type + "", // scope + "", // state (optional) + "", // nonce (optional) + "", // code_challenge (optional) + "s256", // code_challenge_method (optional) + "", // prompt (optional) + 0, // max_age (optional) + "", // authorization_details (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/oauth2/create-grant.md b/docs/examples/java/oauth2/create-grant.md new file mode 100644 index 00000000..401396ec --- /dev/null +++ b/docs/examples/java/oauth2/create-grant.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Oauth2; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Oauth2 oauth2 = new Oauth2(client); + +oauth2.createGrant( + "", // project_id + "", // user_code + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/oauth2/get-grant.md b/docs/examples/java/oauth2/get-grant.md new file mode 100644 index 00000000..0a78343a --- /dev/null +++ b/docs/examples/java/oauth2/get-grant.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Oauth2; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Oauth2 oauth2 = new Oauth2(client); + +oauth2.getGrant( + "", // project_id + "", // grant_id + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/java/oauth2/reject.md b/docs/examples/java/oauth2/reject.md new file mode 100644 index 00000000..7c087fdc --- /dev/null +++ b/docs/examples/java/oauth2/reject.md @@ -0,0 +1,25 @@ +```java +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Oauth2; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProjectQuery(""); // Your project ID + +Oauth2 oauth2 = new Oauth2(client); + +oauth2.reject( + "", // project_id + "", // grant_id + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + +``` diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index ce9ae904..dd8a06b8 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -11,6 +11,6 @@ val account = Account(client) val result = account.updatePassword( password = "", - oldPassword = "password", // (optional) + oldPassword = "", // (optional) ) ``` diff --git a/docs/examples/kotlin/apps/create-secret.md b/docs/examples/kotlin/apps/create-secret.md new file mode 100644 index 00000000..d9a4c525 --- /dev/null +++ b/docs/examples/kotlin/apps/create-secret.md @@ -0,0 +1,15 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.createSecret( + appId = "", +) +``` diff --git a/docs/examples/kotlin/apps/create.md b/docs/examples/kotlin/apps/create.md new file mode 100644 index 00000000..ec9f49f5 --- /dev/null +++ b/docs/examples/kotlin/apps/create.md @@ -0,0 +1,21 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.create( + appId = "", + name = "", + redirectUris = listOf(), + enabled = false, // (optional) + type = "public", // (optional) + deviceFlow = false, // (optional) + teamId = "", // (optional) +) +``` diff --git a/docs/examples/kotlin/apps/delete-secret.md b/docs/examples/kotlin/apps/delete-secret.md new file mode 100644 index 00000000..ad22d5e0 --- /dev/null +++ b/docs/examples/kotlin/apps/delete-secret.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.deleteSecret( + appId = "", + secretId = "", +) +``` diff --git a/docs/examples/kotlin/apps/delete-tokens.md b/docs/examples/kotlin/apps/delete-tokens.md new file mode 100644 index 00000000..e8d89009 --- /dev/null +++ b/docs/examples/kotlin/apps/delete-tokens.md @@ -0,0 +1,15 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.deleteTokens( + appId = "", +) +``` diff --git a/docs/examples/kotlin/apps/delete.md b/docs/examples/kotlin/apps/delete.md new file mode 100644 index 00000000..412b55f6 --- /dev/null +++ b/docs/examples/kotlin/apps/delete.md @@ -0,0 +1,15 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.delete( + appId = "", +) +``` diff --git a/docs/examples/kotlin/apps/get-secret.md b/docs/examples/kotlin/apps/get-secret.md new file mode 100644 index 00000000..a76bbe4e --- /dev/null +++ b/docs/examples/kotlin/apps/get-secret.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.getSecret( + appId = "", + secretId = "", +) +``` diff --git a/docs/examples/kotlin/apps/get.md b/docs/examples/kotlin/apps/get.md new file mode 100644 index 00000000..3fc30c71 --- /dev/null +++ b/docs/examples/kotlin/apps/get.md @@ -0,0 +1,15 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.get( + appId = "", +) +``` diff --git a/docs/examples/kotlin/apps/list-secrets.md b/docs/examples/kotlin/apps/list-secrets.md new file mode 100644 index 00000000..aa69cc8c --- /dev/null +++ b/docs/examples/kotlin/apps/list-secrets.md @@ -0,0 +1,17 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.listSecrets( + appId = "", + queries = listOf(), // (optional) + total = false, // (optional) +) +``` diff --git a/docs/examples/kotlin/apps/list.md b/docs/examples/kotlin/apps/list.md new file mode 100644 index 00000000..d2faad48 --- /dev/null +++ b/docs/examples/kotlin/apps/list.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.list( + queries = listOf(), // (optional) + total = false, // (optional) +) +``` diff --git a/docs/examples/kotlin/apps/update-team.md b/docs/examples/kotlin/apps/update-team.md new file mode 100644 index 00000000..b6f69443 --- /dev/null +++ b/docs/examples/kotlin/apps/update-team.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.updateTeam( + appId = "", + teamId = "", +) +``` diff --git a/docs/examples/kotlin/apps/update.md b/docs/examples/kotlin/apps/update.md new file mode 100644 index 00000000..074527ce --- /dev/null +++ b/docs/examples/kotlin/apps/update.md @@ -0,0 +1,20 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Apps + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val apps = Apps(client) + +val result = apps.update( + appId = "", + name = "", + enabled = false, // (optional) + redirectUris = listOf(), // (optional) + type = "public", // (optional) + deviceFlow = false, // (optional) +) +``` diff --git a/docs/examples/kotlin/oauth2/approve.md b/docs/examples/kotlin/oauth2/approve.md new file mode 100644 index 00000000..0fffddec --- /dev/null +++ b/docs/examples/kotlin/oauth2/approve.md @@ -0,0 +1,17 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Oauth2 + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProjectQuery("") // Your project ID + +val oauth2 = Oauth2(client) + +val result = oauth2.approve( + project_id = "", + grant_id = "", + authorization_details = "", // (optional) +) +``` diff --git a/docs/examples/kotlin/oauth2/authorize.md b/docs/examples/kotlin/oauth2/authorize.md new file mode 100644 index 00000000..ade14234 --- /dev/null +++ b/docs/examples/kotlin/oauth2/authorize.md @@ -0,0 +1,26 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Oauth2 + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProjectQuery("") // Your project ID + +val oauth2 = Oauth2(client) + +val result = oauth2.authorize( + project_id = "", + client_id = "", + redirect_uri = "https://example.com", + response_type = "code", + scope = "", + state = "", // (optional) + nonce = "", // (optional) + code_challenge = "", // (optional) + code_challenge_method = "s256", // (optional) + prompt = "", // (optional) + max_age = 0, // (optional) + authorization_details = "", // (optional) +) +``` diff --git a/docs/examples/kotlin/oauth2/create-grant.md b/docs/examples/kotlin/oauth2/create-grant.md new file mode 100644 index 00000000..efc9a273 --- /dev/null +++ b/docs/examples/kotlin/oauth2/create-grant.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Oauth2 + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val oauth2 = Oauth2(client) + +val result = oauth2.createGrant( + project_id = "", + user_code = "", +) +``` diff --git a/docs/examples/kotlin/oauth2/get-grant.md b/docs/examples/kotlin/oauth2/get-grant.md new file mode 100644 index 00000000..b46a6085 --- /dev/null +++ b/docs/examples/kotlin/oauth2/get-grant.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Oauth2 + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val oauth2 = Oauth2(client) + +val result = oauth2.getGrant( + project_id = "", + grant_id = "", +) +``` diff --git a/docs/examples/kotlin/oauth2/reject.md b/docs/examples/kotlin/oauth2/reject.md new file mode 100644 index 00000000..e4e5832c --- /dev/null +++ b/docs/examples/kotlin/oauth2/reject.md @@ -0,0 +1,16 @@ +```kotlin +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Oauth2 + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProjectQuery("") // Your project ID + +val oauth2 = Oauth2(client) + +val result = oauth2.reject( + project_id = "", + grant_id = "", +) +``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index f43ec95a..f51628d0 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -94,7 +94,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "25.0.0", + "x-sdk-version" to "25.1.0", "x-appwrite-response-format" to "1.9.5" ) config = mutableMapOf() @@ -113,7 +113,6 @@ class Client @JvmOverloads constructor( */ fun setProject(value: String): Client { config["project"] = value - addHeader("x-appwrite-project", value) return this } @@ -366,7 +365,10 @@ class Client @JvmOverloads constructor( suspend fun ping(): String { val apiPath = "/ping" val apiParams = mutableMapOf() - val apiHeaders = mutableMapOf("content-type" to "application/json") + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + "X-Appwrite-Project" to config["project"].orEmpty(), + ) return call( "GET", diff --git a/library/src/main/java/io/appwrite/models/App.kt b/library/src/main/java/io/appwrite/models/App.kt new file mode 100644 index 00000000..0a6bfadc --- /dev/null +++ b/library/src/main/java/io/appwrite/models/App.kt @@ -0,0 +1,110 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * App + */ +data class App( + /** + * App ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * App creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * App update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Application name. + */ + @SerializedName("name") + val name: String, + + /** + * List of authorized redirect URIs. These URIs can be used to redirect users after they authenticate. + */ + @SerializedName("redirectUris") + val redirectUris: List, + + /** + * Whether the app is enabled or not. + */ + @SerializedName("enabled") + val enabled: Boolean, + + /** + * OAuth2 client type. `public` for SPAs, mobile, and native apps that cannot keep a client secret (PKCE required); `confidential` for server-side clients that authenticate with a client secret. + */ + @SerializedName("type") + val type: String, + + /** + * Whether this client may use the OAuth2 Device Authorization Grant (RFC 8628). + */ + @SerializedName("deviceFlow") + val deviceFlow: Boolean, + + /** + * ID of team that owns the application, if owned by team. Otherwise, user ID will be used. + */ + @SerializedName("teamId") + val teamId: String, + + /** + * ID of user who owns the application, if owned by user. Otherwise, team ID will be used. + */ + @SerializedName("userId") + val userId: String, + + /** + * List of application secrets. + */ + @SerializedName("secrets") + val secrets: List, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "name" to name as Any, + "redirectUris" to redirectUris as Any, + "enabled" to enabled as Any, + "type" to type as Any, + "deviceFlow" to deviceFlow as Any, + "teamId" to teamId as Any, + "userId" to userId as Any, + "secrets" to secrets.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = App( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + name = map["name"] as String, + redirectUris = map["redirectUris"] as List, + enabled = map["enabled"] as Boolean, + type = map["type"] as String, + deviceFlow = map["deviceFlow"] as Boolean, + teamId = map["teamId"] as String, + userId = map["userId"] as String, + secrets = (map["secrets"] as List>).map { AppSecret.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AppSecret.kt b/library/src/main/java/io/appwrite/models/AppSecret.kt new file mode 100644 index 00000000..a89d8d2e --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AppSecret.kt @@ -0,0 +1,94 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AppSecret + */ +data class AppSecret( + /** + * Secret ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Secret creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Secret update time in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Application ID this secret belongs to. + */ + @SerializedName("appId") + val appId: String, + + /** + * Hashed application client secret. + */ + @SerializedName("secret") + val secret: String, + + /** + * Last few characters of the client secret, used to help identify it. + */ + @SerializedName("hint") + val hint: String, + + /** + * ID of the user who created the secret. + */ + @SerializedName("createdById") + val createdById: String, + + /** + * Name of the user who created the secret. + */ + @SerializedName("createdByName") + val createdByName: String, + + /** + * Time the secret was last used for authentication in ISO 8601 format. Null if never used. + */ + @SerializedName("lastAccessedAt") + var lastAccessedAt: String?, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "appId" to appId as Any, + "secret" to secret as Any, + "hint" to hint as Any, + "createdById" to createdById as Any, + "createdByName" to createdByName as Any, + "lastAccessedAt" to lastAccessedAt as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AppSecret( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + appId = map["appId"] as String, + secret = map["secret"] as String, + hint = map["hint"] as String, + createdById = map["createdById"] as String, + createdByName = map["createdByName"] as String, + lastAccessedAt = map["lastAccessedAt"] as? String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AppSecretList.kt b/library/src/main/java/io/appwrite/models/AppSecretList.kt new file mode 100644 index 00000000..d60cba8a --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AppSecretList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * App secrets list + */ +data class AppSecretList( + /** + * Total number of secrets that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of secrets. + */ + @SerializedName("secrets") + val secrets: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "secrets" to secrets.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AppSecretList( + total = (map["total"] as Number).toLong(), + secrets = (map["secrets"] as List>).map { AppSecret.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AppSecretPlaintext.kt b/library/src/main/java/io/appwrite/models/AppSecretPlaintext.kt new file mode 100644 index 00000000..6a74b807 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AppSecretPlaintext.kt @@ -0,0 +1,94 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AppSecretPlaintext + */ +data class AppSecretPlaintext( + /** + * Secret ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Secret creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Secret update time in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Application ID this secret belongs to. + */ + @SerializedName("appId") + val appId: String, + + /** + * Application client secret. Returned in full only when the secret is created; subsequent reads return a masked value. + */ + @SerializedName("secret") + val secret: String, + + /** + * Last few characters of the client secret, used to help identify it. + */ + @SerializedName("hint") + val hint: String, + + /** + * ID of the user who created the secret. + */ + @SerializedName("createdById") + val createdById: String, + + /** + * Name of the user who created the secret. + */ + @SerializedName("createdByName") + val createdByName: String, + + /** + * Time the secret was last used for authentication in ISO 8601 format. Null if never used. + */ + @SerializedName("lastAccessedAt") + var lastAccessedAt: String?, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "appId" to appId as Any, + "secret" to secret as Any, + "hint" to hint as Any, + "createdById" to createdById as Any, + "createdByName" to createdByName as Any, + "lastAccessedAt" to lastAccessedAt as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AppSecretPlaintext( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + appId = map["appId"] as String, + secret = map["secret"] as String, + hint = map["hint"] as String, + createdById = map["createdById"] as String, + createdByName = map["createdByName"] as String, + lastAccessedAt = map["lastAccessedAt"] as? String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AppsList.kt b/library/src/main/java/io/appwrite/models/AppsList.kt new file mode 100644 index 00000000..74e50fbf --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AppsList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Apps list + */ +data class AppsList( + /** + * Total number of apps that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of apps. + */ + @SerializedName("apps") + val apps: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "apps" to apps.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AppsList( + total = (map["total"] as Number).toLong(), + apps = (map["apps"] as List>).map { App.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index eb13be3b..afcbdf77 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -85,6 +85,12 @@ data class Membership( @SerializedName("mfa") val mfa: Boolean, + /** + * Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + */ + @SerializedName("userAccessedAt") + val userAccessedAt: String, + /** * User list of roles */ @@ -106,6 +112,7 @@ data class Membership( "joined" to joined as Any, "confirm" to confirm as Any, "mfa" to mfa as Any, + "userAccessedAt" to userAccessedAt as Any, "roles" to roles as Any, ) @@ -128,6 +135,7 @@ data class Membership( joined = map["joined"] as String, confirm = map["confirm"] as Boolean, mfa = map["mfa"] as Boolean, + userAccessedAt = map["userAccessedAt"] as String, roles = map["roles"] as List, ) } diff --git a/library/src/main/java/io/appwrite/models/Oauth2Approve.kt b/library/src/main/java/io/appwrite/models/Oauth2Approve.kt new file mode 100644 index 00000000..82dac290 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Oauth2Approve.kt @@ -0,0 +1,30 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * OAuth2 Approve + */ +data class Oauth2Approve( + /** + * URL the end user should be redirected to after the grant is approved, carrying the authorization `code` and/or `id_token` along with the original `state`. + */ + @SerializedName("redirectUrl") + val redirectUrl: String, + +) { + fun toMap(): Map = mapOf( + "redirectUrl" to redirectUrl as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Oauth2Approve( + redirectUrl = map["redirectUrl"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Oauth2Authorize.kt b/library/src/main/java/io/appwrite/models/Oauth2Authorize.kt new file mode 100644 index 00000000..a2770a01 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Oauth2Authorize.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * OAuth2 Authorize + */ +data class Oauth2Authorize( + /** + * OAuth2 grant ID. Set when the user must give explicit consent; pass it to the approve or reject endpoint. Empty when a redirect URL is returned instead. + */ + @SerializedName("grantId") + val grantId: String, + + /** + * URL the end user should be redirected to when the flow can complete without consent. Empty when consent is still required. + */ + @SerializedName("redirectUrl") + val redirectUrl: String, + +) { + fun toMap(): Map = mapOf( + "grantId" to grantId as Any, + "redirectUrl" to redirectUrl as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Oauth2Authorize( + grantId = map["grantId"] as String, + redirectUrl = map["redirectUrl"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Oauth2Grant.kt b/library/src/main/java/io/appwrite/models/Oauth2Grant.kt new file mode 100644 index 00000000..049e7b48 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Oauth2Grant.kt @@ -0,0 +1,110 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * OAuth2 Grant + */ +data class Oauth2Grant( + /** + * Grant ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Grant creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Grant update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * ID of the user the grant belongs to. + */ + @SerializedName("userId") + val userId: String, + + /** + * ID of the OAuth2 client (app) the grant was requested for. + */ + @SerializedName("appId") + val appId: String, + + /** + * Requested OAuth2 scopes the user is being asked to consent to. + */ + @SerializedName("scopes") + val scopes: List, + + /** + * Requested authorization_details the user is being asked to consent to, as a JSON string. Each entry has a `type` plus project-defined fields. + */ + @SerializedName("authorizationDetails") + val authorizationDetails: String, + + /** + * OIDC prompt directive the consent screen should honor. Space-separated list of: login, consent, select_account. + */ + @SerializedName("prompt") + val prompt: String, + + /** + * Redirect URI the user will be sent to after the flow completes. + */ + @SerializedName("redirectUri") + val redirectUri: String, + + /** + * Unix timestamp of when the user last authenticated. + */ + @SerializedName("authTime") + val authTime: Long, + + /** + * Grant expiration time in ISO 8601 format. + */ + @SerializedName("expire") + val expire: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "userId" to userId as Any, + "appId" to appId as Any, + "scopes" to scopes as Any, + "authorizationDetails" to authorizationDetails as Any, + "prompt" to prompt as Any, + "redirectUri" to redirectUri as Any, + "authTime" to authTime as Any, + "expire" to expire as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Oauth2Grant( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + userId = map["userId"] as String, + appId = map["appId"] as String, + scopes = map["scopes"] as List, + authorizationDetails = map["authorizationDetails"] as String, + prompt = map["prompt"] as String, + redirectUri = map["redirectUri"] as String, + authTime = (map["authTime"] as Number).toLong(), + expire = map["expire"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Oauth2Reject.kt b/library/src/main/java/io/appwrite/models/Oauth2Reject.kt new file mode 100644 index 00000000..c291f4e8 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Oauth2Reject.kt @@ -0,0 +1,30 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * OAuth2 Reject + */ +data class Oauth2Reject( + /** + * URL the end user should be redirected to after the grant is rejected, carrying an `access_denied` error. + */ + @SerializedName("redirectUrl") + val redirectUrl: String, + +) { + fun toMap(): Map = mapOf( + "redirectUrl" to redirectUrl as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Oauth2Reject( + redirectUrl = map["redirectUrl"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index a76d61f0..ff66ba72 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -91,6 +91,36 @@ data class User( @SerializedName("emailVerification") val emailVerification: Boolean, + /** + * Canonical form of the user email address. + */ + @SerializedName("emailCanonical") + var emailCanonical: String?, + + /** + * Whether the user email is from a free email provider. + */ + @SerializedName("emailIsFree") + var emailIsFree: Boolean?, + + /** + * Whether the user email is from a disposable email provider. + */ + @SerializedName("emailIsDisposable") + var emailIsDisposable: Boolean?, + + /** + * Whether the user email is from a corporate domain. + */ + @SerializedName("emailIsCorporate") + var emailIsCorporate: Boolean?, + + /** + * Whether the user email is in its canonical form. + */ + @SerializedName("emailIsCanonical") + var emailIsCanonical: Boolean?, + /** * Phone verification status. */ @@ -149,6 +179,11 @@ data class User( "email" to email as Any, "phone" to phone as Any, "emailVerification" to emailVerification as Any, + "emailCanonical" to emailCanonical as Any, + "emailIsFree" to emailIsFree as Any, + "emailIsDisposable" to emailIsDisposable as Any, + "emailIsCorporate" to emailIsCorporate as Any, + "emailIsCanonical" to emailIsCanonical as Any, "phoneVerification" to phoneVerification as Any, "mfa" to mfa as Any, "prefs" to prefs.toMap() as Any, @@ -174,6 +209,11 @@ data class User( email: String, phone: String, emailVerification: Boolean, + emailCanonical: String?, + emailIsFree: Boolean?, + emailIsDisposable: Boolean?, + emailIsCorporate: Boolean?, + emailIsCanonical: Boolean?, phoneVerification: Boolean, mfa: Boolean, prefs: Preferences>, @@ -196,6 +236,11 @@ data class User( email, phone, emailVerification, + emailCanonical, + emailIsFree, + emailIsDisposable, + emailIsCorporate, + emailIsCanonical, phoneVerification, mfa, prefs, @@ -224,6 +269,11 @@ data class User( email = map["email"] as String, phone = map["phone"] as String, emailVerification = map["emailVerification"] as Boolean, + emailCanonical = map["emailCanonical"] as? String, + emailIsFree = map["emailIsFree"] as? Boolean, + emailIsDisposable = map["emailIsDisposable"] as? Boolean, + emailIsCorporate = map["emailIsCorporate"] as? Boolean, + emailIsCanonical = map["emailIsCanonical"] as? Boolean, phoneVerification = map["phoneVerification"] as Boolean, mfa = map["mfa"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map, nestedType), diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 6e2244c3..5f9ee7b4 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -31,6 +31,8 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") @@ -83,7 +85,9 @@ class Account(client: Client) : Service(client) { "name" to name, ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -144,7 +148,9 @@ class Account(client: Client) : Service(client) { "password" to password, ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -198,6 +204,8 @@ class Account(client: Client) : Service(client) { "total" to total, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.IdentityList = { @Suppress("UNCHECKED_CAST") @@ -229,6 +237,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -257,7 +266,9 @@ class Account(client: Client) : Service(client) { "duration" to duration, ) 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.Jwt = { @Suppress("UNCHECKED_CAST") @@ -293,6 +304,8 @@ class Account(client: Client) : Service(client) { "total" to total, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { @Suppress("UNCHECKED_CAST") @@ -325,7 +338,9 @@ class Account(client: Client) : Service(client) { "mfa" to mfa, ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -374,7 +389,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.MfaType = { @Suppress("UNCHECKED_CAST") @@ -406,7 +423,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.MfaType = { @Suppress("UNCHECKED_CAST") @@ -446,7 +465,9 @@ class Account(client: Client) : Service(client) { "otp" to otp, ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -502,7 +523,9 @@ class Account(client: Client) : Service(client) { "otp" to otp, ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -554,6 +577,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -581,6 +605,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -612,7 +637,9 @@ class Account(client: Client) : Service(client) { "factor" to factor, ) 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.MfaChallenge = { @Suppress("UNCHECKED_CAST") @@ -644,7 +671,9 @@ class Account(client: Client) : Service(client) { "factor" to factor, ) 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.MfaChallenge = { @Suppress("UNCHECKED_CAST") @@ -683,7 +712,9 @@ class Account(client: Client) : Service(client) { "otp" to otp, ) 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.Session = { @Suppress("UNCHECKED_CAST") @@ -718,7 +749,9 @@ class Account(client: Client) : Service(client) { "otp" to otp, ) 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.Session = { @Suppress("UNCHECKED_CAST") @@ -751,6 +784,8 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaFactors = { @Suppress("UNCHECKED_CAST") @@ -779,6 +814,8 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaFactors = { @Suppress("UNCHECKED_CAST") @@ -811,6 +848,8 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") @@ -839,6 +878,8 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") @@ -871,7 +912,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") @@ -900,7 +943,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") @@ -933,7 +978,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") @@ -962,7 +1009,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") @@ -995,7 +1044,9 @@ class Account(client: Client) : Service(client) { "name" to name, ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -1029,7 +1080,7 @@ class Account(client: Client) : Service(client) { * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. * * @param password New user password. Must be at least 8 chars. - * @param oldPassword Current user password. Must be at least 8 chars. + * @param oldPassword Current user password. Max length: 256 chars. * @return [io.appwrite.models.User] */ @JvmOverloads @@ -1045,7 +1096,9 @@ class Account(client: Client) : Service(client) { "oldPassword" to oldPassword, ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -1065,7 +1118,7 @@ class Account(client: Client) : Service(client) { * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. * * @param password New user password. Must be at least 8 chars. - * @param oldPassword Current user password. Must be at least 8 chars. + * @param oldPassword Current user password. Max length: 256 chars. * @return [io.appwrite.models.User] */ @JvmOverloads @@ -1098,7 +1151,9 @@ class Account(client: Client) : Service(client) { "password" to password, ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -1144,6 +1199,8 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") @@ -1186,7 +1243,9 @@ class Account(client: Client) : Service(client) { "prefs" to prefs, ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -1234,7 +1293,9 @@ class Account(client: Client) : Service(client) { "url" to url, ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -1274,7 +1335,9 @@ class Account(client: Client) : Service(client) { "password" to password, ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -1303,6 +1366,8 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { @Suppress("UNCHECKED_CAST") @@ -1331,6 +1396,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -1355,7 +1421,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.Session = { @Suppress("UNCHECKED_CAST") @@ -1392,7 +1460,9 @@ class Account(client: Client) : Service(client) { "password" to password, ) 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.Session = { @Suppress("UNCHECKED_CAST") @@ -1431,7 +1501,9 @@ class Account(client: Client) : Service(client) { "secret" to secret, ) 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.Session = { @Suppress("UNCHECKED_CAST") @@ -1547,7 +1619,9 @@ class Account(client: Client) : Service(client) { "secret" to secret, ) 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.Session = { @Suppress("UNCHECKED_CAST") @@ -1582,7 +1656,9 @@ class Account(client: Client) : Service(client) { "secret" to secret, ) 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.Session = { @Suppress("UNCHECKED_CAST") @@ -1614,6 +1690,8 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") @@ -1645,7 +1723,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.Session = { @Suppress("UNCHECKED_CAST") @@ -1677,6 +1757,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -1702,7 +1783,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.User = { @Suppress("UNCHECKED_CAST") @@ -1751,7 +1834,9 @@ class Account(client: Client) : Service(client) { "providerId" to providerId, ) 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.Target = { @Suppress("UNCHECKED_CAST") @@ -1786,7 +1871,9 @@ class Account(client: Client) : Service(client) { "identifier" to identifier, ) 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.Target = { @Suppress("UNCHECKED_CAST") @@ -1818,6 +1905,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -1855,7 +1943,9 @@ class Account(client: Client) : Service(client) { "phrase" to phrase, ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -1900,7 +1990,9 @@ class Account(client: Client) : Service(client) { "phrase" to phrase, ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -2013,7 +2105,9 @@ class Account(client: Client) : Service(client) { "phone" to phone, ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -2048,7 +2142,9 @@ class Account(client: Client) : Service(client) { "url" to url, ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -2087,7 +2183,9 @@ class Account(client: Client) : Service(client) { "url" to url, ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -2122,7 +2220,9 @@ class Account(client: Client) : Service(client) { "secret" to secret, ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -2161,7 +2261,9 @@ class Account(client: Client) : Service(client) { "secret" to secret, ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -2190,7 +2292,9 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) 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.Token = { @Suppress("UNCHECKED_CAST") @@ -2225,7 +2329,9 @@ class Account(client: Client) : Service(client) { "secret" to secret, ) 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.Token = { @Suppress("UNCHECKED_CAST") diff --git a/library/src/main/java/io/appwrite/services/Apps.kt b/library/src/main/java/io/appwrite/services/Apps.kt new file mode 100644 index 00000000..fc463039 --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Apps.kt @@ -0,0 +1,427 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.Service +import io.appwrite.models.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * + */ +class Apps(client: Client) : Service(client) { + + /** + * List applications. + * + * @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 total When set to false, the total count returned will be 0 and will not be calculated. + * @return [io.appwrite.models.AppsList] + */ + @JvmOverloads + suspend fun list( + queries: List? = null, + total: Boolean? = null, + ): io.appwrite.models.AppsList { + val apiPath = "/apps" + + 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.AppsList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.AppsList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.AppsList::class.java, + converter, + ) + } + + + /** + * Create a new application. + * + * @param appId Application 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 name Application name. + * @param redirectUris Redirect URIs (array of valid URLs). + * @param enabled Is application enabled? + * @param type OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. + * @param deviceFlow Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. + * @param teamId Team unique ID. + * @return [io.appwrite.models.App] + */ + @JvmOverloads + suspend fun create( + appId: String, + name: String, + redirectUris: List, + enabled: Boolean? = null, + type: String? = null, + deviceFlow: Boolean? = null, + teamId: String? = null, + ): io.appwrite.models.App { + val apiPath = "/apps" + + val apiParams = mutableMapOf( + "appId" to appId, + "name" to name, + "redirectUris" to redirectUris, + "enabled" to enabled, + "type" to type, + "deviceFlow" to deviceFlow, + "teamId" to teamId, + ) + 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.App = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.App.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.App::class.java, + converter, + ) + } + + + /** + * Get an application by its unique ID. + * + * @param appId Application unique ID. + * @return [io.appwrite.models.App] + */ + suspend fun get( + appId: String, + ): io.appwrite.models.App { + val apiPath = "/apps/{appId}" + .replace("{appId}", appId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.App = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.App.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.App::class.java, + converter, + ) + } + + + /** + * Update an application by its unique ID. + * + * @param appId Application unique ID. + * @param name Application name. + * @param enabled Is application enabled? + * @param redirectUris Redirect URIs (array of valid URLs). + * @param type OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. + * @param deviceFlow Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. + * @return [io.appwrite.models.App] + */ + @JvmOverloads + suspend fun update( + appId: String, + name: String, + enabled: Boolean? = null, + redirectUris: List? = null, + type: String? = null, + deviceFlow: Boolean? = null, + ): io.appwrite.models.App { + val apiPath = "/apps/{appId}" + .replace("{appId}", appId) + + val apiParams = mutableMapOf( + "name" to name, + "enabled" to enabled, + "redirectUris" to redirectUris, + "type" to type, + "deviceFlow" to deviceFlow, + ) + 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.App = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.App.from(map = it as Map) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.App::class.java, + converter, + ) + } + + + /** + * Delete an application by its unique ID. + * + * @param appId Application unique ID. + * @return [Any] + */ + suspend fun delete( + appId: String, + ): Any { + val apiPath = "/apps/{appId}" + .replace("{appId}", appId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "content-type" to "application/json", + "accept" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + + /** + * List client secrets for an application. + * + * @param appId Application unique ID. + * @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 total When set to false, the total count returned will be 0 and will not be calculated. + * @return [io.appwrite.models.AppSecretList] + */ + @JvmOverloads + suspend fun listSecrets( + appId: String, + queries: List? = null, + total: Boolean? = null, + ): io.appwrite.models.AppSecretList { + val apiPath = "/apps/{appId}/secrets" + .replace("{appId}", appId) + + 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.AppSecretList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.AppSecretList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.AppSecretList::class.java, + converter, + ) + } + + + /** + * Create a new client secret for an application. + * + * @param appId Application unique ID. + * @return [io.appwrite.models.AppSecretPlaintext] + */ + suspend fun createSecret( + appId: String, + ): io.appwrite.models.AppSecretPlaintext { + val apiPath = "/apps/{appId}/secrets" + .replace("{appId}", appId) + + val apiParams = mutableMapOf( + ) + 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.AppSecretPlaintext = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.AppSecretPlaintext.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.AppSecretPlaintext::class.java, + converter, + ) + } + + + /** + * Get an application client secret by its unique ID. + * + * @param appId Application unique ID. + * @param secretId Secret unique ID. + * @return [io.appwrite.models.AppSecret] + */ + suspend fun getSecret( + appId: String, + secretId: String, + ): io.appwrite.models.AppSecret { + val apiPath = "/apps/{appId}/secrets/{secretId}" + .replace("{appId}", appId) + .replace("{secretId}", secretId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.AppSecret = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.AppSecret.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.AppSecret::class.java, + converter, + ) + } + + + /** + * Delete an application client secret by its unique ID. + * + * @param appId Application unique ID. + * @param secretId Secret unique ID. + * @return [Any] + */ + suspend fun deleteSecret( + appId: String, + secretId: String, + ): Any { + val apiPath = "/apps/{appId}/secrets/{secretId}" + .replace("{appId}", appId) + .replace("{secretId}", secretId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "content-type" to "application/json", + "accept" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + + /** + * Transfer an application to another team by its unique ID. + * + * @param appId Application unique ID. + * @param teamId Team ID of the team to transfer application to. + * @return [io.appwrite.models.App] + */ + suspend fun updateTeam( + appId: String, + teamId: String, + ): io.appwrite.models.App { + val apiPath = "/apps/{appId}/team" + .replace("{appId}", appId) + + val apiParams = mutableMapOf( + "teamId" to teamId, + ) + 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.App = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.App.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.App::class.java, + converter, + ) + } + + + /** + * Revoke all tokens for an application by its unique ID. + * + * @param appId Application unique ID. + * @return [Any] + */ + suspend fun deleteTokens( + appId: String, + ): Any { + val apiPath = "/apps/{appId}/tokens" + .replace("{appId}", appId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "content-type" to "application/json", + "accept" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + +} diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 2fc95889..ce4e8327 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -30,6 +30,8 @@ class Databases(client: Client) : Service(client) { "queries" to queries, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.TransactionList = { @Suppress("UNCHECKED_CAST") @@ -62,7 +64,9 @@ class Databases(client: Client) : Service(client) { "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.Transaction = { @Suppress("UNCHECKED_CAST") @@ -94,6 +98,8 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Transaction = { @Suppress("UNCHECKED_CAST") @@ -132,7 +138,9 @@ class Databases(client: Client) : Service(client) { "rollback" to rollback, ) 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.Transaction = { @Suppress("UNCHECKED_CAST") @@ -164,6 +172,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -195,7 +204,9 @@ class Databases(client: Client) : Service(client) { "operations" to operations, ) 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.Transaction = { @Suppress("UNCHECKED_CAST") @@ -248,6 +259,8 @@ class Databases(client: Client) : Service(client) { "ttl" to ttl, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { @Suppress("UNCHECKED_CAST") @@ -333,7 +346,9 @@ class Databases(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Document = { @Suppress("UNCHECKED_CAST") @@ -416,6 +431,8 @@ class Databases(client: Client) : Service(client) { "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") @@ -498,7 +515,9 @@ class Databases(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Document = { @Suppress("UNCHECKED_CAST") @@ -584,7 +603,9 @@ class Databases(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Document = { @Suppress("UNCHECKED_CAST") @@ -663,6 +684,7 @@ class Databases(client: Client) : Service(client) { "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -714,7 +736,9 @@ class Databases(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Document = { @Suppress("UNCHECKED_CAST") @@ -806,7 +830,9 @@ class Databases(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Document = { @Suppress("UNCHECKED_CAST") diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 12a5fee5..695b18e4 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -36,6 +36,8 @@ class Functions(client: Client) : Service(client) { "total" to total, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { @Suppress("UNCHECKED_CAST") @@ -86,7 +88,9 @@ class Functions(client: Client) : Service(client) { "scheduledAt" to scheduledAt, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", + "accept" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") @@ -121,6 +125,8 @@ class Functions(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index 1c714748..950366ee 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -29,8 +29,10 @@ class Graphql(client: Client) : Service(client) { "query" to query, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "x-sdk-graphql" to "true", "content-type" to "application/json", + "accept" to "application/json", ) val converter: (Any) -> Any = { it @@ -61,8 +63,10 @@ class Graphql(client: Client) : Service(client) { "query" to query, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "x-sdk-graphql" to "true", "content-type" to "application/json", + "accept" to "application/json", ) val converter: (Any) -> Any = { it diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index d6acb84d..d662ac65 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -28,6 +28,8 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { @Suppress("UNCHECKED_CAST") @@ -56,6 +58,8 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.LocaleCodeList = { @Suppress("UNCHECKED_CAST") @@ -84,6 +88,8 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { @Suppress("UNCHECKED_CAST") @@ -112,6 +118,8 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") @@ -140,6 +148,8 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") @@ -168,6 +178,8 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { @Suppress("UNCHECKED_CAST") @@ -196,6 +208,8 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { @Suppress("UNCHECKED_CAST") @@ -224,6 +238,8 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { @Suppress("UNCHECKED_CAST") diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index ee2444d9..bf0d246a 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -35,7 +35,9 @@ class Messaging(client: Client) : Service(client) { "targetId" to targetId, ) 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.Subscriber = { @Suppress("UNCHECKED_CAST") @@ -70,6 +72,7 @@ class Messaging(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/Oauth2.kt b/library/src/main/java/io/appwrite/services/Oauth2.kt new file mode 100644 index 00000000..16e6680d --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Oauth2.kt @@ -0,0 +1,235 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.Service +import io.appwrite.models.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * + */ +class Oauth2(client: Client) : Service(client) { + + /** + * Approve an OAuth2 grant after the user gives consent. Returns the `redirectUrl` the end user should be sent to. The consent screen may optionally pass enriched `authorization_details` to record the concrete resources the user selected. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param projectId Project ID in which OAuth2 client that created grant during authorization exists. + * @param grantId Grant ID made during authorization, provided to consent screen in URL search params. + * @param authorizationDetails Enriched `authorization_details` the user consented to, replacing what the client requested. Each entry must use a `type` the project accepts. Optional; omit to keep the originally requested details. + * @return [io.appwrite.models.Oauth2Approve] + */ + @JvmOverloads + suspend fun approve( + projectId: String, + grantId: String, + authorizationDetails: String? = null, + ): io.appwrite.models.Oauth2Approve { + val apiPath = "/oauth2/{project_id}/approve" + .replace("{project_id}", projectId) + + "?project=${java.net.URLEncoder.encode(client.config["project"].orEmpty(), "UTF-8")}" + + val apiParams = mutableMapOf( + "grant_id" to grantId, + "authorization_details" to authorizationDetails, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Oauth2Approve = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Oauth2Approve.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Oauth2Approve::class.java, + converter, + ) + } + + + /** + * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param projectId Project ID in which OAuth2 client exists. + * @param clientId OAuth2 client ID. + * @param redirectUri Redirect URI where visitor will be redirected after authorization, whether successful or not. + * @param responseType OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow). + * @param scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. + * @param state OAuth2 state. You receive this back in the redirect URI. + * @param nonce OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + * @param codeChallenge PKCE code challenge. Required when OAuth2 app is public. + * @param codeChallengeMethod PKCE code challenge method. Required when OAuth2 app is public. + * @param prompt OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + * @param maxAge OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param authorizationDetails Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + * @return [io.appwrite.models.Oauth2Authorize] + */ + @JvmOverloads + suspend fun authorize( + projectId: String, + clientId: String, + redirectUri: String, + responseType: String, + scope: String, + state: String? = null, + nonce: String? = null, + codeChallenge: String? = null, + codeChallengeMethod: String? = null, + prompt: String? = null, + maxAge: Long? = null, + authorizationDetails: String? = null, + ): io.appwrite.models.Oauth2Authorize { + val apiPath = "/oauth2/{project_id}/authorize" + .replace("{project_id}", projectId) + + "?project=${java.net.URLEncoder.encode(client.config["project"].orEmpty(), "UTF-8")}" + + val apiParams = mutableMapOf( + "client_id" to clientId, + "redirect_uri" to redirectUri, + "response_type" to responseType, + "scope" to scope, + "state" to state, + "nonce" to nonce, + "code_challenge" to codeChallenge, + "code_challenge_method" to codeChallengeMethod, + "prompt" to prompt, + "max_age" to maxAge, + "authorization_details" to authorizationDetails, + ) + val apiHeaders = mutableMapOf( + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Oauth2Authorize = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Oauth2Authorize.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Oauth2Authorize::class.java, + converter, + ) + } + + + /** + * Exchange a device flow user code for an OAuth2 grant. The authenticated user is bound to the pending grant. Pass the returned grant ID to the get grant endpoint to render the consent screen, then to the approve or reject endpoint to complete the flow. + * + * @param projectId Project ID in which OAuth2 client exists. + * @param userCode User code displayed on the device. + * @return [io.appwrite.models.Oauth2Grant] + */ + suspend fun createGrant( + projectId: String, + userCode: String, + ): io.appwrite.models.Oauth2Grant { + val apiPath = "/oauth2/{project_id}/grants" + .replace("{project_id}", projectId) + + val apiParams = mutableMapOf( + "user_code" to userCode, + ) + 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.Oauth2Grant = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Oauth2Grant.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Oauth2Grant::class.java, + converter, + ) + } + + + /** + * Get an OAuth2 grant by its ID. Used by the consent screen to display the details of the authorization the user is being asked to approve. A grant can only be read by the user it belongs to, or by server SDK. + * + * @param projectId Project ID in which OAuth2 client that created grant during authorization exists. + * @param grantId Grant ID made during authorization, provided to consent screen in URL search params. + * @return [io.appwrite.models.Oauth2Grant] + */ + suspend fun getGrant( + projectId: String, + grantId: String, + ): io.appwrite.models.Oauth2Grant { + val apiPath = "/oauth2/{project_id}/grants/{grant_id}" + .replace("{project_id}", projectId) + .replace("{grant_id}", grantId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Oauth2Grant = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Oauth2Grant.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Oauth2Grant::class.java, + converter, + ) + } + + + /** + * Reject an OAuth2 grant when the user denies consent. Returns the `redirectUrl` the end user should be sent to with an `access_denied` error. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param projectId Project ID in which OAuth2 client that created grant during authorization exists. + * @param grantId Grant ID made during authorization, provided to consent screen in URL search params. + * @return [io.appwrite.models.Oauth2Reject] + */ + suspend fun reject( + projectId: String, + grantId: String, + ): io.appwrite.models.Oauth2Reject { + val apiPath = "/oauth2/{project_id}/reject" + .replace("{project_id}", projectId) + + "?project=${java.net.URLEncoder.encode(client.config["project"].orEmpty(), "UTF-8")}" + + val apiParams = mutableMapOf( + "grant_id" to grantId, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + "accept" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Oauth2Reject = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Oauth2Reject.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Oauth2Reject::class.java, + converter, + ) + } + + +} diff --git a/library/src/main/java/io/appwrite/services/Presences.kt b/library/src/main/java/io/appwrite/services/Presences.kt index 21d234a6..bebcb50e 100644 --- a/library/src/main/java/io/appwrite/services/Presences.kt +++ b/library/src/main/java/io/appwrite/services/Presences.kt @@ -37,6 +37,8 @@ class Presences(client: Client) : Service(client) { "ttl" to ttl, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.PresenceList = { @Suppress("UNCHECKED_CAST") @@ -69,6 +71,8 @@ class Presences(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Presence = { @Suppress("UNCHECKED_CAST") @@ -114,7 +118,9 @@ class Presences(client: Client) : Service(client) { "metadata" to metadata, ) 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.Presence = { @Suppress("UNCHECKED_CAST") @@ -163,7 +169,9 @@ class Presences(client: Client) : Service(client) { "purge" to purge, ) 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.Presence = { @Suppress("UNCHECKED_CAST") @@ -196,6 +204,7 @@ class Presences(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 8276d082..ec073dff 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -41,6 +41,8 @@ class Storage(client: Client) : Service(client) { "total" to total, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { @Suppress("UNCHECKED_CAST") @@ -90,7 +92,9 @@ class Storage(client: Client) : Service(client) { "permissions" to permissions, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "multipart/form-data", + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") @@ -129,6 +133,8 @@ class Storage(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") @@ -170,7 +176,9 @@ class Storage(client: Client) : Service(client) { "permissions" to permissions, ) 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.File = { @Suppress("UNCHECKED_CAST") @@ -205,6 +213,7 @@ class Storage(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/TablesDB.kt b/library/src/main/java/io/appwrite/services/TablesDB.kt index 9c5a955e..8595a4ff 100644 --- a/library/src/main/java/io/appwrite/services/TablesDB.kt +++ b/library/src/main/java/io/appwrite/services/TablesDB.kt @@ -30,6 +30,8 @@ class TablesDB(client: Client) : Service(client) { "queries" to queries, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.TransactionList = { @Suppress("UNCHECKED_CAST") @@ -62,7 +64,9 @@ class TablesDB(client: Client) : Service(client) { "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.Transaction = { @Suppress("UNCHECKED_CAST") @@ -94,6 +98,8 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Transaction = { @Suppress("UNCHECKED_CAST") @@ -132,7 +138,9 @@ class TablesDB(client: Client) : Service(client) { "rollback" to rollback, ) 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.Transaction = { @Suppress("UNCHECKED_CAST") @@ -164,6 +172,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -195,7 +204,9 @@ class TablesDB(client: Client) : Service(client) { "operations" to operations, ) 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.Transaction = { @Suppress("UNCHECKED_CAST") @@ -244,6 +255,8 @@ class TablesDB(client: Client) : Service(client) { "ttl" to ttl, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.RowList = { @Suppress("UNCHECKED_CAST") @@ -321,7 +334,9 @@ class TablesDB(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Row = { @Suppress("UNCHECKED_CAST") @@ -396,6 +411,8 @@ class TablesDB(client: Client) : Service(client) { "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Row = { @Suppress("UNCHECKED_CAST") @@ -470,7 +487,9 @@ class TablesDB(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Row = { @Suppress("UNCHECKED_CAST") @@ -548,7 +567,9 @@ class TablesDB(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Row = { @Suppress("UNCHECKED_CAST") @@ -619,6 +640,7 @@ class TablesDB(client: Client) : Service(client) { "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -666,7 +688,9 @@ class TablesDB(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Row = { @Suppress("UNCHECKED_CAST") @@ -750,7 +774,9 @@ class TablesDB(client: Client) : Service(client) { "transactionId" to transactionId, ) 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.Row = { @Suppress("UNCHECKED_CAST") diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 78019a1d..1ab6c54a 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -37,6 +37,8 @@ class Teams(client: Client) : Service(client) { "total" to total, ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.TeamList = { @Suppress("UNCHECKED_CAST") @@ -96,7 +98,9 @@ class Teams(client: Client) : Service(client) { "roles" to roles, ) 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.Team = { @Suppress("UNCHECKED_CAST") @@ -149,6 +153,8 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @Suppress("UNCHECKED_CAST") @@ -197,7 +203,9 @@ class Teams(client: Client) : Service(client) { "name" to name, ) 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.Team = { @Suppress("UNCHECKED_CAST") @@ -245,6 +253,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -282,6 +291,8 @@ class Teams(client: Client) : Service(client) { "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") @@ -339,7 +350,9 @@ class Teams(client: Client) : Service(client) { "name" to name, ) 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.Membership = { @Suppress("UNCHECKED_CAST") @@ -374,6 +387,8 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") @@ -412,7 +427,9 @@ class Teams(client: Client) : Service(client) { "roles" to roles, ) 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.Membership = { @Suppress("UNCHECKED_CAST") @@ -447,6 +464,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), "content-type" to "application/json", ) return client.call( @@ -486,7 +504,9 @@ class Teams(client: Client) : Service(client) { "secret" to secret, ) 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.Membership = { @Suppress("UNCHECKED_CAST") @@ -519,6 +539,8 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( + "X-Appwrite-Project" to client.config["project"].orEmpty(), + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") @@ -567,7 +589,9 @@ class Teams(client: Client) : Service(client) { "prefs" to prefs, ) 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.Preferences = { @Suppress("UNCHECKED_CAST") From f5ee7e349ba09c84a79bf72e35d73d1b18f74471 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 8 Jun 2026 11:26:24 +0530 Subject: [PATCH 2/5] chore: update Android SDK to 25.1.0 --- CHANGELOG.md | 4 - docs/examples/java/apps/create-secret.md | 24 - docs/examples/java/apps/create.md | 30 -- docs/examples/java/apps/delete-secret.md | 25 - docs/examples/java/apps/delete-tokens.md | 24 - docs/examples/java/apps/delete.md | 24 - docs/examples/java/apps/get-secret.md | 25 - docs/examples/java/apps/get.md | 24 - docs/examples/java/apps/list-secrets.md | 26 -- docs/examples/java/apps/list.md | 25 - docs/examples/java/apps/update-team.md | 25 - docs/examples/java/apps/update.md | 29 -- docs/examples/java/oauth2/approve.md | 26 -- docs/examples/java/oauth2/authorize.md | 35 -- docs/examples/java/oauth2/create-grant.md | 25 - docs/examples/java/oauth2/get-grant.md | 25 - docs/examples/java/oauth2/reject.md | 25 - docs/examples/kotlin/apps/create-secret.md | 15 - docs/examples/kotlin/apps/create.md | 21 - docs/examples/kotlin/apps/delete-secret.md | 16 - docs/examples/kotlin/apps/delete-tokens.md | 15 - docs/examples/kotlin/apps/delete.md | 15 - docs/examples/kotlin/apps/get-secret.md | 16 - docs/examples/kotlin/apps/get.md | 15 - docs/examples/kotlin/apps/list-secrets.md | 17 - docs/examples/kotlin/apps/list.md | 16 - docs/examples/kotlin/apps/update-team.md | 16 - docs/examples/kotlin/apps/update.md | 20 - docs/examples/kotlin/oauth2/approve.md | 17 - docs/examples/kotlin/oauth2/authorize.md | 26 -- docs/examples/kotlin/oauth2/create-grant.md | 16 - docs/examples/kotlin/oauth2/get-grant.md | 16 - docs/examples/kotlin/oauth2/reject.md | 16 - .../src/main/java/io/appwrite/models/App.kt | 110 ----- .../main/java/io/appwrite/models/AppSecret.kt | 94 ---- .../java/io/appwrite/models/AppSecretList.kt | 38 -- .../io/appwrite/models/AppSecretPlaintext.kt | 94 ---- .../main/java/io/appwrite/models/AppsList.kt | 38 -- .../java/io/appwrite/models/Oauth2Approve.kt | 30 -- .../io/appwrite/models/Oauth2Authorize.kt | 38 -- .../java/io/appwrite/models/Oauth2Grant.kt | 110 ----- .../java/io/appwrite/models/Oauth2Reject.kt | 30 -- .../main/java/io/appwrite/services/Apps.kt | 427 ------------------ .../main/java/io/appwrite/services/Oauth2.kt | 235 ---------- 44 files changed, 1938 deletions(-) delete mode 100644 docs/examples/java/apps/create-secret.md delete mode 100644 docs/examples/java/apps/create.md delete mode 100644 docs/examples/java/apps/delete-secret.md delete mode 100644 docs/examples/java/apps/delete-tokens.md delete mode 100644 docs/examples/java/apps/delete.md delete mode 100644 docs/examples/java/apps/get-secret.md delete mode 100644 docs/examples/java/apps/get.md delete mode 100644 docs/examples/java/apps/list-secrets.md delete mode 100644 docs/examples/java/apps/list.md delete mode 100644 docs/examples/java/apps/update-team.md delete mode 100644 docs/examples/java/apps/update.md delete mode 100644 docs/examples/java/oauth2/approve.md delete mode 100644 docs/examples/java/oauth2/authorize.md delete mode 100644 docs/examples/java/oauth2/create-grant.md delete mode 100644 docs/examples/java/oauth2/get-grant.md delete mode 100644 docs/examples/java/oauth2/reject.md delete mode 100644 docs/examples/kotlin/apps/create-secret.md delete mode 100644 docs/examples/kotlin/apps/create.md delete mode 100644 docs/examples/kotlin/apps/delete-secret.md delete mode 100644 docs/examples/kotlin/apps/delete-tokens.md delete mode 100644 docs/examples/kotlin/apps/delete.md delete mode 100644 docs/examples/kotlin/apps/get-secret.md delete mode 100644 docs/examples/kotlin/apps/get.md delete mode 100644 docs/examples/kotlin/apps/list-secrets.md delete mode 100644 docs/examples/kotlin/apps/list.md delete mode 100644 docs/examples/kotlin/apps/update-team.md delete mode 100644 docs/examples/kotlin/apps/update.md delete mode 100644 docs/examples/kotlin/oauth2/approve.md delete mode 100644 docs/examples/kotlin/oauth2/authorize.md delete mode 100644 docs/examples/kotlin/oauth2/create-grant.md delete mode 100644 docs/examples/kotlin/oauth2/get-grant.md delete mode 100644 docs/examples/kotlin/oauth2/reject.md delete mode 100644 library/src/main/java/io/appwrite/models/App.kt delete mode 100644 library/src/main/java/io/appwrite/models/AppSecret.kt delete mode 100644 library/src/main/java/io/appwrite/models/AppSecretList.kt delete mode 100644 library/src/main/java/io/appwrite/models/AppSecretPlaintext.kt delete mode 100644 library/src/main/java/io/appwrite/models/AppsList.kt delete mode 100644 library/src/main/java/io/appwrite/models/Oauth2Approve.kt delete mode 100644 library/src/main/java/io/appwrite/models/Oauth2Authorize.kt delete mode 100644 library/src/main/java/io/appwrite/models/Oauth2Grant.kt delete mode 100644 library/src/main/java/io/appwrite/models/Oauth2Reject.kt delete mode 100644 library/src/main/java/io/appwrite/services/Apps.kt delete mode 100644 library/src/main/java/io/appwrite/services/Oauth2.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 1440f097..f885cd40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,6 @@ ## 25.1.0 -* Added: `apps` service with app and secret management methods. -* Added: `oauth2` service with `authorize`, `approve`, `reject`, `createGrant`, and `getGrant`. -* Added: `App`, `AppSecret`, `AppSecretPlaintext`, `AppsList`, and `AppSecretList` models. -* Added: `Oauth2Authorize`, `Oauth2Approve`, `Oauth2Reject`, and `Oauth2Grant` models. * Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`). * Added: `Membership.userAccessedAt` field. diff --git a/docs/examples/java/apps/create-secret.md b/docs/examples/java/apps/create-secret.md deleted file mode 100644 index 3cc22697..00000000 --- a/docs/examples/java/apps/create-secret.md +++ /dev/null @@ -1,24 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Apps apps = new Apps(client); - -apps.createSecret( - "", // appId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/apps/create.md b/docs/examples/java/apps/create.md deleted file mode 100644 index f12f6a1f..00000000 --- a/docs/examples/java/apps/create.md +++ /dev/null @@ -1,30 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Apps apps = new Apps(client); - -apps.create( - "", // appId - "", // name - List.of(), // redirectUris - 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()); - }) -); - -``` diff --git a/docs/examples/java/apps/delete-secret.md b/docs/examples/java/apps/delete-secret.md deleted file mode 100644 index 59c74d08..00000000 --- a/docs/examples/java/apps/delete-secret.md +++ /dev/null @@ -1,25 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Apps apps = new Apps(client); - -apps.deleteSecret( - "", // appId - "", // secretId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/apps/delete-tokens.md b/docs/examples/java/apps/delete-tokens.md deleted file mode 100644 index d50393bd..00000000 --- a/docs/examples/java/apps/delete-tokens.md +++ /dev/null @@ -1,24 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Apps apps = new Apps(client); - -apps.deleteTokens( - "", // appId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/apps/delete.md b/docs/examples/java/apps/delete.md deleted file mode 100644 index 6166e0b3..00000000 --- a/docs/examples/java/apps/delete.md +++ /dev/null @@ -1,24 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Apps apps = new Apps(client); - -apps.delete( - "", // appId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/apps/get-secret.md b/docs/examples/java/apps/get-secret.md deleted file mode 100644 index bd86dfd4..00000000 --- a/docs/examples/java/apps/get-secret.md +++ /dev/null @@ -1,25 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Apps apps = new Apps(client); - -apps.getSecret( - "", // appId - "", // secretId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/apps/get.md b/docs/examples/java/apps/get.md deleted file mode 100644 index b6b2397b..00000000 --- a/docs/examples/java/apps/get.md +++ /dev/null @@ -1,24 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Apps apps = new Apps(client); - -apps.get( - "", // appId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/apps/list-secrets.md b/docs/examples/java/apps/list-secrets.md deleted file mode 100644 index 58ca3a9d..00000000 --- a/docs/examples/java/apps/list-secrets.md +++ /dev/null @@ -1,26 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -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()); - }) -); - -``` diff --git a/docs/examples/java/apps/list.md b/docs/examples/java/apps/list.md deleted file mode 100644 index 7ac61277..00000000 --- a/docs/examples/java/apps/list.md +++ /dev/null @@ -1,25 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -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()); - }) -); - -``` diff --git a/docs/examples/java/apps/update-team.md b/docs/examples/java/apps/update-team.md deleted file mode 100644 index 6341e58b..00000000 --- a/docs/examples/java/apps/update-team.md +++ /dev/null @@ -1,25 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Apps apps = new Apps(client); - -apps.updateTeam( - "", // appId - "", // teamId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/apps/update.md b/docs/examples/java/apps/update.md deleted file mode 100644 index d056455a..00000000 --- a/docs/examples/java/apps/update.md +++ /dev/null @@ -1,29 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Apps; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Apps apps = new Apps(client); - -apps.update( - "", // appId - "", // name - false, // enabled (optional) - List.of(), // redirectUris (optional) - "public", // type (optional) - false, // deviceFlow (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/oauth2/approve.md b/docs/examples/java/oauth2/approve.md deleted file mode 100644 index b736556c..00000000 --- a/docs/examples/java/oauth2/approve.md +++ /dev/null @@ -1,26 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Oauth2; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProjectQuery(""); // Your project ID - -Oauth2 oauth2 = new Oauth2(client); - -oauth2.approve( - "", // project_id - "", // grant_id - "", // authorization_details (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/oauth2/authorize.md b/docs/examples/java/oauth2/authorize.md deleted file mode 100644 index cfa341cd..00000000 --- a/docs/examples/java/oauth2/authorize.md +++ /dev/null @@ -1,35 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Oauth2; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProjectQuery(""); // Your project ID - -Oauth2 oauth2 = new Oauth2(client); - -oauth2.authorize( - "", // project_id - "", // client_id - "https://example.com", // redirect_uri - "code", // response_type - "", // scope - "", // state (optional) - "", // nonce (optional) - "", // code_challenge (optional) - "s256", // code_challenge_method (optional) - "", // prompt (optional) - 0, // max_age (optional) - "", // authorization_details (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/oauth2/create-grant.md b/docs/examples/java/oauth2/create-grant.md deleted file mode 100644 index 401396ec..00000000 --- a/docs/examples/java/oauth2/create-grant.md +++ /dev/null @@ -1,25 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Oauth2; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Oauth2 oauth2 = new Oauth2(client); - -oauth2.createGrant( - "", // project_id - "", // user_code - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/oauth2/get-grant.md b/docs/examples/java/oauth2/get-grant.md deleted file mode 100644 index 0a78343a..00000000 --- a/docs/examples/java/oauth2/get-grant.md +++ /dev/null @@ -1,25 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Oauth2; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Oauth2 oauth2 = new Oauth2(client); - -oauth2.getGrant( - "", // project_id - "", // grant_id - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/java/oauth2/reject.md b/docs/examples/java/oauth2/reject.md deleted file mode 100644 index 7c087fdc..00000000 --- a/docs/examples/java/oauth2/reject.md +++ /dev/null @@ -1,25 +0,0 @@ -```java -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Oauth2; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProjectQuery(""); // Your project ID - -Oauth2 oauth2 = new Oauth2(client); - -oauth2.reject( - "", // project_id - "", // grant_id - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - -``` diff --git a/docs/examples/kotlin/apps/create-secret.md b/docs/examples/kotlin/apps/create-secret.md deleted file mode 100644 index d9a4c525..00000000 --- a/docs/examples/kotlin/apps/create-secret.md +++ /dev/null @@ -1,15 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.createSecret( - appId = "", -) -``` diff --git a/docs/examples/kotlin/apps/create.md b/docs/examples/kotlin/apps/create.md deleted file mode 100644 index ec9f49f5..00000000 --- a/docs/examples/kotlin/apps/create.md +++ /dev/null @@ -1,21 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.create( - appId = "", - name = "", - redirectUris = listOf(), - enabled = false, // (optional) - type = "public", // (optional) - deviceFlow = false, // (optional) - teamId = "", // (optional) -) -``` diff --git a/docs/examples/kotlin/apps/delete-secret.md b/docs/examples/kotlin/apps/delete-secret.md deleted file mode 100644 index ad22d5e0..00000000 --- a/docs/examples/kotlin/apps/delete-secret.md +++ /dev/null @@ -1,16 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.deleteSecret( - appId = "", - secretId = "", -) -``` diff --git a/docs/examples/kotlin/apps/delete-tokens.md b/docs/examples/kotlin/apps/delete-tokens.md deleted file mode 100644 index e8d89009..00000000 --- a/docs/examples/kotlin/apps/delete-tokens.md +++ /dev/null @@ -1,15 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.deleteTokens( - appId = "", -) -``` diff --git a/docs/examples/kotlin/apps/delete.md b/docs/examples/kotlin/apps/delete.md deleted file mode 100644 index 412b55f6..00000000 --- a/docs/examples/kotlin/apps/delete.md +++ /dev/null @@ -1,15 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.delete( - appId = "", -) -``` diff --git a/docs/examples/kotlin/apps/get-secret.md b/docs/examples/kotlin/apps/get-secret.md deleted file mode 100644 index a76bbe4e..00000000 --- a/docs/examples/kotlin/apps/get-secret.md +++ /dev/null @@ -1,16 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.getSecret( - appId = "", - secretId = "", -) -``` diff --git a/docs/examples/kotlin/apps/get.md b/docs/examples/kotlin/apps/get.md deleted file mode 100644 index 3fc30c71..00000000 --- a/docs/examples/kotlin/apps/get.md +++ /dev/null @@ -1,15 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.get( - appId = "", -) -``` diff --git a/docs/examples/kotlin/apps/list-secrets.md b/docs/examples/kotlin/apps/list-secrets.md deleted file mode 100644 index aa69cc8c..00000000 --- a/docs/examples/kotlin/apps/list-secrets.md +++ /dev/null @@ -1,17 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.listSecrets( - appId = "", - queries = listOf(), // (optional) - total = false, // (optional) -) -``` diff --git a/docs/examples/kotlin/apps/list.md b/docs/examples/kotlin/apps/list.md deleted file mode 100644 index d2faad48..00000000 --- a/docs/examples/kotlin/apps/list.md +++ /dev/null @@ -1,16 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.list( - queries = listOf(), // (optional) - total = false, // (optional) -) -``` diff --git a/docs/examples/kotlin/apps/update-team.md b/docs/examples/kotlin/apps/update-team.md deleted file mode 100644 index b6f69443..00000000 --- a/docs/examples/kotlin/apps/update-team.md +++ /dev/null @@ -1,16 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.updateTeam( - appId = "", - teamId = "", -) -``` diff --git a/docs/examples/kotlin/apps/update.md b/docs/examples/kotlin/apps/update.md deleted file mode 100644 index 074527ce..00000000 --- a/docs/examples/kotlin/apps/update.md +++ /dev/null @@ -1,20 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Apps - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val apps = Apps(client) - -val result = apps.update( - appId = "", - name = "", - enabled = false, // (optional) - redirectUris = listOf(), // (optional) - type = "public", // (optional) - deviceFlow = false, // (optional) -) -``` diff --git a/docs/examples/kotlin/oauth2/approve.md b/docs/examples/kotlin/oauth2/approve.md deleted file mode 100644 index 0fffddec..00000000 --- a/docs/examples/kotlin/oauth2/approve.md +++ /dev/null @@ -1,17 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Oauth2 - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProjectQuery("") // Your project ID - -val oauth2 = Oauth2(client) - -val result = oauth2.approve( - project_id = "", - grant_id = "", - authorization_details = "", // (optional) -) -``` diff --git a/docs/examples/kotlin/oauth2/authorize.md b/docs/examples/kotlin/oauth2/authorize.md deleted file mode 100644 index ade14234..00000000 --- a/docs/examples/kotlin/oauth2/authorize.md +++ /dev/null @@ -1,26 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Oauth2 - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProjectQuery("") // Your project ID - -val oauth2 = Oauth2(client) - -val result = oauth2.authorize( - project_id = "", - client_id = "", - redirect_uri = "https://example.com", - response_type = "code", - scope = "", - state = "", // (optional) - nonce = "", // (optional) - code_challenge = "", // (optional) - code_challenge_method = "s256", // (optional) - prompt = "", // (optional) - max_age = 0, // (optional) - authorization_details = "", // (optional) -) -``` diff --git a/docs/examples/kotlin/oauth2/create-grant.md b/docs/examples/kotlin/oauth2/create-grant.md deleted file mode 100644 index efc9a273..00000000 --- a/docs/examples/kotlin/oauth2/create-grant.md +++ /dev/null @@ -1,16 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Oauth2 - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val oauth2 = Oauth2(client) - -val result = oauth2.createGrant( - project_id = "", - user_code = "", -) -``` diff --git a/docs/examples/kotlin/oauth2/get-grant.md b/docs/examples/kotlin/oauth2/get-grant.md deleted file mode 100644 index b46a6085..00000000 --- a/docs/examples/kotlin/oauth2/get-grant.md +++ /dev/null @@ -1,16 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Oauth2 - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val oauth2 = Oauth2(client) - -val result = oauth2.getGrant( - project_id = "", - grant_id = "", -) -``` diff --git a/docs/examples/kotlin/oauth2/reject.md b/docs/examples/kotlin/oauth2/reject.md deleted file mode 100644 index e4e5832c..00000000 --- a/docs/examples/kotlin/oauth2/reject.md +++ /dev/null @@ -1,16 +0,0 @@ -```kotlin -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Oauth2 - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProjectQuery("") // Your project ID - -val oauth2 = Oauth2(client) - -val result = oauth2.reject( - project_id = "", - grant_id = "", -) -``` diff --git a/library/src/main/java/io/appwrite/models/App.kt b/library/src/main/java/io/appwrite/models/App.kt deleted file mode 100644 index 0a6bfadc..00000000 --- a/library/src/main/java/io/appwrite/models/App.kt +++ /dev/null @@ -1,110 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * App - */ -data class App( - /** - * App ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * App creation time in ISO 8601 format. - */ - @SerializedName("\$createdAt") - val createdAt: String, - - /** - * App update date in ISO 8601 format. - */ - @SerializedName("\$updatedAt") - val updatedAt: String, - - /** - * Application name. - */ - @SerializedName("name") - val name: String, - - /** - * List of authorized redirect URIs. These URIs can be used to redirect users after they authenticate. - */ - @SerializedName("redirectUris") - val redirectUris: List, - - /** - * Whether the app is enabled or not. - */ - @SerializedName("enabled") - val enabled: Boolean, - - /** - * OAuth2 client type. `public` for SPAs, mobile, and native apps that cannot keep a client secret (PKCE required); `confidential` for server-side clients that authenticate with a client secret. - */ - @SerializedName("type") - val type: String, - - /** - * Whether this client may use the OAuth2 Device Authorization Grant (RFC 8628). - */ - @SerializedName("deviceFlow") - val deviceFlow: Boolean, - - /** - * ID of team that owns the application, if owned by team. Otherwise, user ID will be used. - */ - @SerializedName("teamId") - val teamId: String, - - /** - * ID of user who owns the application, if owned by user. Otherwise, team ID will be used. - */ - @SerializedName("userId") - val userId: String, - - /** - * List of application secrets. - */ - @SerializedName("secrets") - val secrets: List, - -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "name" to name as Any, - "redirectUris" to redirectUris as Any, - "enabled" to enabled as Any, - "type" to type as Any, - "deviceFlow" to deviceFlow as Any, - "teamId" to teamId as Any, - "userId" to userId as Any, - "secrets" to secrets.map { it.toMap() } as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = App( - id = map["\$id"] as String, - createdAt = map["\$createdAt"] as String, - updatedAt = map["\$updatedAt"] as String, - name = map["name"] as String, - redirectUris = map["redirectUris"] as List, - enabled = map["enabled"] as Boolean, - type = map["type"] as String, - deviceFlow = map["deviceFlow"] as Boolean, - teamId = map["teamId"] as String, - userId = map["userId"] as String, - secrets = (map["secrets"] as List>).map { AppSecret.from(map = it) }, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AppSecret.kt b/library/src/main/java/io/appwrite/models/AppSecret.kt deleted file mode 100644 index a89d8d2e..00000000 --- a/library/src/main/java/io/appwrite/models/AppSecret.kt +++ /dev/null @@ -1,94 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * AppSecret - */ -data class AppSecret( - /** - * Secret ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * Secret creation time in ISO 8601 format. - */ - @SerializedName("\$createdAt") - val createdAt: String, - - /** - * Secret update time in ISO 8601 format. - */ - @SerializedName("\$updatedAt") - val updatedAt: String, - - /** - * Application ID this secret belongs to. - */ - @SerializedName("appId") - val appId: String, - - /** - * Hashed application client secret. - */ - @SerializedName("secret") - val secret: String, - - /** - * Last few characters of the client secret, used to help identify it. - */ - @SerializedName("hint") - val hint: String, - - /** - * ID of the user who created the secret. - */ - @SerializedName("createdById") - val createdById: String, - - /** - * Name of the user who created the secret. - */ - @SerializedName("createdByName") - val createdByName: String, - - /** - * Time the secret was last used for authentication in ISO 8601 format. Null if never used. - */ - @SerializedName("lastAccessedAt") - var lastAccessedAt: String?, - -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "appId" to appId as Any, - "secret" to secret as Any, - "hint" to hint as Any, - "createdById" to createdById as Any, - "createdByName" to createdByName as Any, - "lastAccessedAt" to lastAccessedAt as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = AppSecret( - id = map["\$id"] as String, - createdAt = map["\$createdAt"] as String, - updatedAt = map["\$updatedAt"] as String, - appId = map["appId"] as String, - secret = map["secret"] as String, - hint = map["hint"] as String, - createdById = map["createdById"] as String, - createdByName = map["createdByName"] as String, - lastAccessedAt = map["lastAccessedAt"] as? String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AppSecretList.kt b/library/src/main/java/io/appwrite/models/AppSecretList.kt deleted file mode 100644 index d60cba8a..00000000 --- a/library/src/main/java/io/appwrite/models/AppSecretList.kt +++ /dev/null @@ -1,38 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * App secrets list - */ -data class AppSecretList( - /** - * Total number of secrets that matched your query. - */ - @SerializedName("total") - val total: Long, - - /** - * List of secrets. - */ - @SerializedName("secrets") - val secrets: List, - -) { - fun toMap(): Map = mapOf( - "total" to total as Any, - "secrets" to secrets.map { it.toMap() } as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = AppSecretList( - total = (map["total"] as Number).toLong(), - secrets = (map["secrets"] as List>).map { AppSecret.from(map = it) }, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AppSecretPlaintext.kt b/library/src/main/java/io/appwrite/models/AppSecretPlaintext.kt deleted file mode 100644 index 6a74b807..00000000 --- a/library/src/main/java/io/appwrite/models/AppSecretPlaintext.kt +++ /dev/null @@ -1,94 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * AppSecretPlaintext - */ -data class AppSecretPlaintext( - /** - * Secret ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * Secret creation time in ISO 8601 format. - */ - @SerializedName("\$createdAt") - val createdAt: String, - - /** - * Secret update time in ISO 8601 format. - */ - @SerializedName("\$updatedAt") - val updatedAt: String, - - /** - * Application ID this secret belongs to. - */ - @SerializedName("appId") - val appId: String, - - /** - * Application client secret. Returned in full only when the secret is created; subsequent reads return a masked value. - */ - @SerializedName("secret") - val secret: String, - - /** - * Last few characters of the client secret, used to help identify it. - */ - @SerializedName("hint") - val hint: String, - - /** - * ID of the user who created the secret. - */ - @SerializedName("createdById") - val createdById: String, - - /** - * Name of the user who created the secret. - */ - @SerializedName("createdByName") - val createdByName: String, - - /** - * Time the secret was last used for authentication in ISO 8601 format. Null if never used. - */ - @SerializedName("lastAccessedAt") - var lastAccessedAt: String?, - -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "appId" to appId as Any, - "secret" to secret as Any, - "hint" to hint as Any, - "createdById" to createdById as Any, - "createdByName" to createdByName as Any, - "lastAccessedAt" to lastAccessedAt as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = AppSecretPlaintext( - id = map["\$id"] as String, - createdAt = map["\$createdAt"] as String, - updatedAt = map["\$updatedAt"] as String, - appId = map["appId"] as String, - secret = map["secret"] as String, - hint = map["hint"] as String, - createdById = map["createdById"] as String, - createdByName = map["createdByName"] as String, - lastAccessedAt = map["lastAccessedAt"] as? String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AppsList.kt b/library/src/main/java/io/appwrite/models/AppsList.kt deleted file mode 100644 index 74e50fbf..00000000 --- a/library/src/main/java/io/appwrite/models/AppsList.kt +++ /dev/null @@ -1,38 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Apps list - */ -data class AppsList( - /** - * Total number of apps that matched your query. - */ - @SerializedName("total") - val total: Long, - - /** - * List of apps. - */ - @SerializedName("apps") - val apps: List, - -) { - fun toMap(): Map = mapOf( - "total" to total as Any, - "apps" to apps.map { it.toMap() } as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = AppsList( - total = (map["total"] as Number).toLong(), - apps = (map["apps"] as List>).map { App.from(map = it) }, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Oauth2Approve.kt b/library/src/main/java/io/appwrite/models/Oauth2Approve.kt deleted file mode 100644 index 82dac290..00000000 --- a/library/src/main/java/io/appwrite/models/Oauth2Approve.kt +++ /dev/null @@ -1,30 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * OAuth2 Approve - */ -data class Oauth2Approve( - /** - * URL the end user should be redirected to after the grant is approved, carrying the authorization `code` and/or `id_token` along with the original `state`. - */ - @SerializedName("redirectUrl") - val redirectUrl: String, - -) { - fun toMap(): Map = mapOf( - "redirectUrl" to redirectUrl as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = Oauth2Approve( - redirectUrl = map["redirectUrl"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Oauth2Authorize.kt b/library/src/main/java/io/appwrite/models/Oauth2Authorize.kt deleted file mode 100644 index a2770a01..00000000 --- a/library/src/main/java/io/appwrite/models/Oauth2Authorize.kt +++ /dev/null @@ -1,38 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * OAuth2 Authorize - */ -data class Oauth2Authorize( - /** - * OAuth2 grant ID. Set when the user must give explicit consent; pass it to the approve or reject endpoint. Empty when a redirect URL is returned instead. - */ - @SerializedName("grantId") - val grantId: String, - - /** - * URL the end user should be redirected to when the flow can complete without consent. Empty when consent is still required. - */ - @SerializedName("redirectUrl") - val redirectUrl: String, - -) { - fun toMap(): Map = mapOf( - "grantId" to grantId as Any, - "redirectUrl" to redirectUrl as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = Oauth2Authorize( - grantId = map["grantId"] as String, - redirectUrl = map["redirectUrl"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Oauth2Grant.kt b/library/src/main/java/io/appwrite/models/Oauth2Grant.kt deleted file mode 100644 index 049e7b48..00000000 --- a/library/src/main/java/io/appwrite/models/Oauth2Grant.kt +++ /dev/null @@ -1,110 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * OAuth2 Grant - */ -data class Oauth2Grant( - /** - * Grant ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * Grant creation time in ISO 8601 format. - */ - @SerializedName("\$createdAt") - val createdAt: String, - - /** - * Grant update date in ISO 8601 format. - */ - @SerializedName("\$updatedAt") - val updatedAt: String, - - /** - * ID of the user the grant belongs to. - */ - @SerializedName("userId") - val userId: String, - - /** - * ID of the OAuth2 client (app) the grant was requested for. - */ - @SerializedName("appId") - val appId: String, - - /** - * Requested OAuth2 scopes the user is being asked to consent to. - */ - @SerializedName("scopes") - val scopes: List, - - /** - * Requested authorization_details the user is being asked to consent to, as a JSON string. Each entry has a `type` plus project-defined fields. - */ - @SerializedName("authorizationDetails") - val authorizationDetails: String, - - /** - * OIDC prompt directive the consent screen should honor. Space-separated list of: login, consent, select_account. - */ - @SerializedName("prompt") - val prompt: String, - - /** - * Redirect URI the user will be sent to after the flow completes. - */ - @SerializedName("redirectUri") - val redirectUri: String, - - /** - * Unix timestamp of when the user last authenticated. - */ - @SerializedName("authTime") - val authTime: Long, - - /** - * Grant expiration time in ISO 8601 format. - */ - @SerializedName("expire") - val expire: String, - -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "userId" to userId as Any, - "appId" to appId as Any, - "scopes" to scopes as Any, - "authorizationDetails" to authorizationDetails as Any, - "prompt" to prompt as Any, - "redirectUri" to redirectUri as Any, - "authTime" to authTime as Any, - "expire" to expire as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = Oauth2Grant( - id = map["\$id"] as String, - createdAt = map["\$createdAt"] as String, - updatedAt = map["\$updatedAt"] as String, - userId = map["userId"] as String, - appId = map["appId"] as String, - scopes = map["scopes"] as List, - authorizationDetails = map["authorizationDetails"] as String, - prompt = map["prompt"] as String, - redirectUri = map["redirectUri"] as String, - authTime = (map["authTime"] as Number).toLong(), - expire = map["expire"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Oauth2Reject.kt b/library/src/main/java/io/appwrite/models/Oauth2Reject.kt deleted file mode 100644 index c291f4e8..00000000 --- a/library/src/main/java/io/appwrite/models/Oauth2Reject.kt +++ /dev/null @@ -1,30 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * OAuth2 Reject - */ -data class Oauth2Reject( - /** - * URL the end user should be redirected to after the grant is rejected, carrying an `access_denied` error. - */ - @SerializedName("redirectUrl") - val redirectUrl: String, - -) { - fun toMap(): Map = mapOf( - "redirectUrl" to redirectUrl as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = Oauth2Reject( - redirectUrl = map["redirectUrl"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Apps.kt b/library/src/main/java/io/appwrite/services/Apps.kt deleted file mode 100644 index fc463039..00000000 --- a/library/src/main/java/io/appwrite/services/Apps.kt +++ /dev/null @@ -1,427 +0,0 @@ -package io.appwrite.services - -import android.net.Uri -import io.appwrite.Client -import io.appwrite.Service -import io.appwrite.models.* -import io.appwrite.exceptions.AppwriteException -import io.appwrite.extensions.classOf -import okhttp3.Cookie -import java.io.File - -/** - * - */ -class Apps(client: Client) : Service(client) { - - /** - * List applications. - * - * @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 total When set to false, the total count returned will be 0 and will not be calculated. - * @return [io.appwrite.models.AppsList] - */ - @JvmOverloads - suspend fun list( - queries: List? = null, - total: Boolean? = null, - ): io.appwrite.models.AppsList { - val apiPath = "/apps" - - 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.AppsList = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.AppsList.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.AppsList::class.java, - converter, - ) - } - - - /** - * Create a new application. - * - * @param appId Application 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 name Application name. - * @param redirectUris Redirect URIs (array of valid URLs). - * @param enabled Is application enabled? - * @param type OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. - * @param deviceFlow Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. - * @param teamId Team unique ID. - * @return [io.appwrite.models.App] - */ - @JvmOverloads - suspend fun create( - appId: String, - name: String, - redirectUris: List, - enabled: Boolean? = null, - type: String? = null, - deviceFlow: Boolean? = null, - teamId: String? = null, - ): io.appwrite.models.App { - val apiPath = "/apps" - - val apiParams = mutableMapOf( - "appId" to appId, - "name" to name, - "redirectUris" to redirectUris, - "enabled" to enabled, - "type" to type, - "deviceFlow" to deviceFlow, - "teamId" to teamId, - ) - 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.App = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.App.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.App::class.java, - converter, - ) - } - - - /** - * Get an application by its unique ID. - * - * @param appId Application unique ID. - * @return [io.appwrite.models.App] - */ - suspend fun get( - appId: String, - ): io.appwrite.models.App { - val apiPath = "/apps/{appId}" - .replace("{appId}", appId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "X-Appwrite-Project" to client.config["project"].orEmpty(), - "accept" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.App = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.App.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.App::class.java, - converter, - ) - } - - - /** - * Update an application by its unique ID. - * - * @param appId Application unique ID. - * @param name Application name. - * @param enabled Is application enabled? - * @param redirectUris Redirect URIs (array of valid URLs). - * @param type OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. - * @param deviceFlow Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. - * @return [io.appwrite.models.App] - */ - @JvmOverloads - suspend fun update( - appId: String, - name: String, - enabled: Boolean? = null, - redirectUris: List? = null, - type: String? = null, - deviceFlow: Boolean? = null, - ): io.appwrite.models.App { - val apiPath = "/apps/{appId}" - .replace("{appId}", appId) - - val apiParams = mutableMapOf( - "name" to name, - "enabled" to enabled, - "redirectUris" to redirectUris, - "type" to type, - "deviceFlow" to deviceFlow, - ) - 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.App = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.App.from(map = it as Map) - } - return client.call( - "PUT", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.App::class.java, - converter, - ) - } - - - /** - * Delete an application by its unique ID. - * - * @param appId Application unique ID. - * @return [Any] - */ - suspend fun delete( - appId: String, - ): Any { - val apiPath = "/apps/{appId}" - .replace("{appId}", appId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "X-Appwrite-Project" to client.config["project"].orEmpty(), - "content-type" to "application/json", - "accept" to "application/json", - ) - return client.call( - "DELETE", - apiPath, - apiHeaders, - apiParams, - responseType = Any::class.java, - ) - } - - - /** - * List client secrets for an application. - * - * @param appId Application unique ID. - * @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 total When set to false, the total count returned will be 0 and will not be calculated. - * @return [io.appwrite.models.AppSecretList] - */ - @JvmOverloads - suspend fun listSecrets( - appId: String, - queries: List? = null, - total: Boolean? = null, - ): io.appwrite.models.AppSecretList { - val apiPath = "/apps/{appId}/secrets" - .replace("{appId}", appId) - - 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.AppSecretList = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.AppSecretList.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.AppSecretList::class.java, - converter, - ) - } - - - /** - * Create a new client secret for an application. - * - * @param appId Application unique ID. - * @return [io.appwrite.models.AppSecretPlaintext] - */ - suspend fun createSecret( - appId: String, - ): io.appwrite.models.AppSecretPlaintext { - val apiPath = "/apps/{appId}/secrets" - .replace("{appId}", appId) - - val apiParams = mutableMapOf( - ) - 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.AppSecretPlaintext = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.AppSecretPlaintext.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.AppSecretPlaintext::class.java, - converter, - ) - } - - - /** - * Get an application client secret by its unique ID. - * - * @param appId Application unique ID. - * @param secretId Secret unique ID. - * @return [io.appwrite.models.AppSecret] - */ - suspend fun getSecret( - appId: String, - secretId: String, - ): io.appwrite.models.AppSecret { - val apiPath = "/apps/{appId}/secrets/{secretId}" - .replace("{appId}", appId) - .replace("{secretId}", secretId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "X-Appwrite-Project" to client.config["project"].orEmpty(), - "accept" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.AppSecret = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.AppSecret.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.AppSecret::class.java, - converter, - ) - } - - - /** - * Delete an application client secret by its unique ID. - * - * @param appId Application unique ID. - * @param secretId Secret unique ID. - * @return [Any] - */ - suspend fun deleteSecret( - appId: String, - secretId: String, - ): Any { - val apiPath = "/apps/{appId}/secrets/{secretId}" - .replace("{appId}", appId) - .replace("{secretId}", secretId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "X-Appwrite-Project" to client.config["project"].orEmpty(), - "content-type" to "application/json", - "accept" to "application/json", - ) - return client.call( - "DELETE", - apiPath, - apiHeaders, - apiParams, - responseType = Any::class.java, - ) - } - - - /** - * Transfer an application to another team by its unique ID. - * - * @param appId Application unique ID. - * @param teamId Team ID of the team to transfer application to. - * @return [io.appwrite.models.App] - */ - suspend fun updateTeam( - appId: String, - teamId: String, - ): io.appwrite.models.App { - val apiPath = "/apps/{appId}/team" - .replace("{appId}", appId) - - val apiParams = mutableMapOf( - "teamId" to teamId, - ) - 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.App = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.App.from(map = it as Map) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.App::class.java, - converter, - ) - } - - - /** - * Revoke all tokens for an application by its unique ID. - * - * @param appId Application unique ID. - * @return [Any] - */ - suspend fun deleteTokens( - appId: String, - ): Any { - val apiPath = "/apps/{appId}/tokens" - .replace("{appId}", appId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "X-Appwrite-Project" to client.config["project"].orEmpty(), - "content-type" to "application/json", - "accept" to "application/json", - ) - return client.call( - "DELETE", - apiPath, - apiHeaders, - apiParams, - responseType = Any::class.java, - ) - } - - -} diff --git a/library/src/main/java/io/appwrite/services/Oauth2.kt b/library/src/main/java/io/appwrite/services/Oauth2.kt deleted file mode 100644 index 16e6680d..00000000 --- a/library/src/main/java/io/appwrite/services/Oauth2.kt +++ /dev/null @@ -1,235 +0,0 @@ -package io.appwrite.services - -import android.net.Uri -import io.appwrite.Client -import io.appwrite.Service -import io.appwrite.models.* -import io.appwrite.exceptions.AppwriteException -import io.appwrite.extensions.classOf -import okhttp3.Cookie -import java.io.File - -/** - * - */ -class Oauth2(client: Client) : Service(client) { - - /** - * Approve an OAuth2 grant after the user gives consent. Returns the `redirectUrl` the end user should be sent to. The consent screen may optionally pass enriched `authorization_details` to record the concrete resources the user selected. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. - * - * @param projectId Project ID in which OAuth2 client that created grant during authorization exists. - * @param grantId Grant ID made during authorization, provided to consent screen in URL search params. - * @param authorizationDetails Enriched `authorization_details` the user consented to, replacing what the client requested. Each entry must use a `type` the project accepts. Optional; omit to keep the originally requested details. - * @return [io.appwrite.models.Oauth2Approve] - */ - @JvmOverloads - suspend fun approve( - projectId: String, - grantId: String, - authorizationDetails: String? = null, - ): io.appwrite.models.Oauth2Approve { - val apiPath = "/oauth2/{project_id}/approve" - .replace("{project_id}", projectId) - + "?project=${java.net.URLEncoder.encode(client.config["project"].orEmpty(), "UTF-8")}" - - val apiParams = mutableMapOf( - "grant_id" to grantId, - "authorization_details" to authorizationDetails, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - "accept" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Oauth2Approve = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Oauth2Approve.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Oauth2Approve::class.java, - converter, - ) - } - - - /** - * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. - * - * @param projectId Project ID in which OAuth2 client exists. - * @param clientId OAuth2 client ID. - * @param redirectUri Redirect URI where visitor will be redirected after authorization, whether successful or not. - * @param responseType OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow). - * @param scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. - * @param state OAuth2 state. You receive this back in the redirect URI. - * @param nonce OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. - * @param codeChallenge PKCE code challenge. Required when OAuth2 app is public. - * @param codeChallengeMethod PKCE code challenge method. Required when OAuth2 app is public. - * @param prompt OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param maxAge OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. - * @param authorizationDetails Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @return [io.appwrite.models.Oauth2Authorize] - */ - @JvmOverloads - suspend fun authorize( - projectId: String, - clientId: String, - redirectUri: String, - responseType: String, - scope: String, - state: String? = null, - nonce: String? = null, - codeChallenge: String? = null, - codeChallengeMethod: String? = null, - prompt: String? = null, - maxAge: Long? = null, - authorizationDetails: String? = null, - ): io.appwrite.models.Oauth2Authorize { - val apiPath = "/oauth2/{project_id}/authorize" - .replace("{project_id}", projectId) - + "?project=${java.net.URLEncoder.encode(client.config["project"].orEmpty(), "UTF-8")}" - - val apiParams = mutableMapOf( - "client_id" to clientId, - "redirect_uri" to redirectUri, - "response_type" to responseType, - "scope" to scope, - "state" to state, - "nonce" to nonce, - "code_challenge" to codeChallenge, - "code_challenge_method" to codeChallengeMethod, - "prompt" to prompt, - "max_age" to maxAge, - "authorization_details" to authorizationDetails, - ) - val apiHeaders = mutableMapOf( - "accept" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Oauth2Authorize = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Oauth2Authorize.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Oauth2Authorize::class.java, - converter, - ) - } - - - /** - * Exchange a device flow user code for an OAuth2 grant. The authenticated user is bound to the pending grant. Pass the returned grant ID to the get grant endpoint to render the consent screen, then to the approve or reject endpoint to complete the flow. - * - * @param projectId Project ID in which OAuth2 client exists. - * @param userCode User code displayed on the device. - * @return [io.appwrite.models.Oauth2Grant] - */ - suspend fun createGrant( - projectId: String, - userCode: String, - ): io.appwrite.models.Oauth2Grant { - val apiPath = "/oauth2/{project_id}/grants" - .replace("{project_id}", projectId) - - val apiParams = mutableMapOf( - "user_code" to userCode, - ) - 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.Oauth2Grant = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Oauth2Grant.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Oauth2Grant::class.java, - converter, - ) - } - - - /** - * Get an OAuth2 grant by its ID. Used by the consent screen to display the details of the authorization the user is being asked to approve. A grant can only be read by the user it belongs to, or by server SDK. - * - * @param projectId Project ID in which OAuth2 client that created grant during authorization exists. - * @param grantId Grant ID made during authorization, provided to consent screen in URL search params. - * @return [io.appwrite.models.Oauth2Grant] - */ - suspend fun getGrant( - projectId: String, - grantId: String, - ): io.appwrite.models.Oauth2Grant { - val apiPath = "/oauth2/{project_id}/grants/{grant_id}" - .replace("{project_id}", projectId) - .replace("{grant_id}", grantId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "X-Appwrite-Project" to client.config["project"].orEmpty(), - "accept" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Oauth2Grant = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Oauth2Grant.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Oauth2Grant::class.java, - converter, - ) - } - - - /** - * Reject an OAuth2 grant when the user denies consent. Returns the `redirectUrl` the end user should be sent to with an `access_denied` error. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. - * - * @param projectId Project ID in which OAuth2 client that created grant during authorization exists. - * @param grantId Grant ID made during authorization, provided to consent screen in URL search params. - * @return [io.appwrite.models.Oauth2Reject] - */ - suspend fun reject( - projectId: String, - grantId: String, - ): io.appwrite.models.Oauth2Reject { - val apiPath = "/oauth2/{project_id}/reject" - .replace("{project_id}", projectId) - + "?project=${java.net.URLEncoder.encode(client.config["project"].orEmpty(), "UTF-8")}" - - val apiParams = mutableMapOf( - "grant_id" to grantId, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - "accept" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Oauth2Reject = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Oauth2Reject.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Oauth2Reject::class.java, - converter, - ) - } - - -} From 97d04e73a6ab581cfe174576fd95dfe58c9a8549 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 8 Jun 2026 11:37:12 +0530 Subject: [PATCH 3/5] docs: add accept header and toString notes to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f885cd40..6b22d7e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`). * Added: `Membership.userAccessedAt` field. +* Updated: Requests now send an explicit `accept` header matching each endpoint's response type. ## 25.0.0 From 244b9409763197c5448e9bf80ed1abaf7f7433f5 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 8 Jun 2026 12:00:02 +0530 Subject: [PATCH 4/5] chore: update Android SDK to 25.1.0 --- .../src/main/java/io/appwrite/services/Functions.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 695b18e4..b5d9436c 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -75,6 +75,7 @@ class Functions(client: Client) : Service(client) { method: io.appwrite.enums.ExecutionMethod? = null, headers: Any? = null, scheduledAt: String? = null, + onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) @@ -89,20 +90,23 @@ class Functions(client: Client) : Service(client) { ) val apiHeaders = mutableMapOf( "X-Appwrite-Project" to client.config["project"].orEmpty(), - "content-type" to "application/json", - "accept" to "multipart/form-data", + "content-type" to "multipart/form-data", + "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } - return client.call( - "POST", + val idParamName: String? = null + return client.chunkedUpload( apiPath, apiHeaders, apiParams, responseType = io.appwrite.models.Execution::class.java, converter, + paramName, + idParamName, + onProgress, ) } From aebe93de3c5c69006cd796aacbed2d053f96b5bd Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 8 Jun 2026 12:53:46 +0530 Subject: [PATCH 5/5] chore: update Android SDK to 25.1.0 --- .../src/main/java/io/appwrite/services/Functions.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index b5d9436c..191c8cc9 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -75,7 +75,6 @@ class Functions(client: Client) : Service(client) { method: io.appwrite.enums.ExecutionMethod? = null, headers: Any? = null, scheduledAt: String? = null, - onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) @@ -90,23 +89,20 @@ class Functions(client: Client) : Service(client) { ) val apiHeaders = mutableMapOf( "X-Appwrite-Project" to client.config["project"].orEmpty(), - "content-type" to "multipart/form-data", + "content-type" to "application/json", "accept" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } - val idParamName: String? = null - return client.chunkedUpload( + return client.call( + "POST", apiPath, apiHeaders, apiParams, responseType = io.appwrite.models.Execution::class.java, converter, - paramName, - idParamName, - onProgress, ) }