diff --git a/README.md b/README.md index e0b45f4..b9997e1 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-kotlin.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-kotlin.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.6.2-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.6.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-kotlin/releases).** +**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-kotlin/releases).** > This is the Kotlin SDK for integrating with Appwrite from your Kotlin server-side code. If you're looking for the Android SDK you should check [appwrite/sdk-for-android](https://github.com/appwrite/sdk-for-android) @@ -39,7 +39,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-kotlin:8.0.0") +implementation("io.appwrite:sdk-for-kotlin:9.0.0") ``` ### Maven @@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-kotlin - 8.0.0 + 9.0.0 ``` diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index c87d5e9..9c3433e 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -14,7 +14,7 @@ avatars.getBrowser( Browser.AVANT_BROWSER, // code 0, // width (optional) 0, // height (optional) - 0, // quality (optional) + -1, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index ddb53a6..6904638 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -14,7 +14,7 @@ avatars.getCreditCard( CreditCard.AMERICAN_EXPRESS, // code 0, // width (optional) 0, // height (optional) - 0, // quality (optional) + -1, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index aadf426..159dcdc 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -14,7 +14,7 @@ avatars.getFlag( Flag.AFGHANISTAN, // code 0, // width (optional) 0, // height (optional) - 0, // quality (optional) + -1, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 5231be3..368b816 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,8 +4,9 @@ import io.appwrite.services.Databases; Client client = new Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - .setSession(""); // The user session to authenticate with + .setSession("") // The user session to authenticate with + .setKey("") // Your secret API key + .setJWT(""); // Your secret JSON Web Token Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/create-documents.md b/docs/examples/java/databases/create-documents.md new file mode 100644 index 0000000..d816af3 --- /dev/null +++ b/docs/examples/java/databases/create-documents.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.createDocuments( + "", // databaseId + "", // collectionId + listOf(), // documents + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/databases/create-index.md b/docs/examples/java/databases/create-index.md index f3faec7..fe2d9bf 100644 --- a/docs/examples/java/databases/create-index.md +++ b/docs/examples/java/databases/create-index.md @@ -17,6 +17,7 @@ databases.createIndex( IndexType.KEY, // type listOf(), // attributes listOf(), // orders (optional) + listOf(), // lengths (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/delete-documents.md b/docs/examples/java/databases/delete-documents.md new file mode 100644 index 0000000..e8394b1 --- /dev/null +++ b/docs/examples/java/databases/delete-documents.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.deleteDocuments( + "", // databaseId + "", // collectionId + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/databases/update-documents.md b/docs/examples/java/databases/update-documents.md new file mode 100644 index 0000000..b4138b4 --- /dev/null +++ b/docs/examples/java/databases/update-documents.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.updateDocuments( + "", // databaseId + "", // collectionId + mapOf( "a" to "b" ), // data (optional) + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/databases/upsert-documents.md b/docs/examples/java/databases/upsert-documents.md new file mode 100644 index 0000000..e2f2a46 --- /dev/null +++ b/docs/examples/java/databases/upsert-documents.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Databases databases = new Databases(client); + +databases.upsertDocuments( + "", // databaseId + "", // collectionId + listOf(), // documents (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/functions/create-build.md b/docs/examples/java/functions/create-duplicate-deployment.md similarity index 94% rename from docs/examples/java/functions/create-build.md rename to docs/examples/java/functions/create-duplicate-deployment.md index a3f6cc5..6b9d9a1 100644 --- a/docs/examples/java/functions/create-build.md +++ b/docs/examples/java/functions/create-duplicate-deployment.md @@ -9,7 +9,7 @@ Client client = new Client() Functions functions = new Functions(client); -functions.createBuild( +functions.createDuplicateDeployment( "", // functionId "", // deploymentId "", // buildId (optional) diff --git a/docs/examples/java/functions/create-template-deployment.md b/docs/examples/java/functions/create-template-deployment.md new file mode 100644 index 0000000..53b5a9a --- /dev/null +++ b/docs/examples/java/functions/create-template-deployment.md @@ -0,0 +1,28 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Functions; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Functions functions = new Functions(client); + +functions.createTemplateDeployment( + "", // functionId + "", // repository + "", // owner + "", // rootDirectory + "", // version + false, // activate (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/functions/create-variable.md b/docs/examples/java/functions/create-variable.md index df2bb8e..70764fb 100644 --- a/docs/examples/java/functions/create-variable.md +++ b/docs/examples/java/functions/create-variable.md @@ -13,6 +13,7 @@ functions.createVariable( "", // functionId "", // key "", // value + false, // secret (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/create-vcs-deployment.md b/docs/examples/java/functions/create-vcs-deployment.md new file mode 100644 index 0000000..9274cd8 --- /dev/null +++ b/docs/examples/java/functions/create-vcs-deployment.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Functions; +import io.appwrite.enums.VCSDeploymentType; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Functions functions = new Functions(client); + +functions.createVcsDeployment( + "", // functionId + VCSDeploymentType.BRANCH, // type + "", // reference + false, // activate (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/functions/create.md b/docs/examples/java/functions/create.md index 7137e40..7187128 100644 --- a/docs/examples/java/functions/create.md +++ b/docs/examples/java/functions/create.md @@ -28,10 +28,6 @@ functions.create( "", // providerBranch (optional) false, // providerSilentMode (optional) "", // providerRootDirectory (optional) - "", // templateRepository (optional) - "", // templateOwner (optional) - "", // templateRootDirectory (optional) - "", // templateVersion (optional) "", // specification (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/functions/get-deployment-download.md b/docs/examples/java/functions/get-deployment-download.md index e2a0748..d522b12 100644 --- a/docs/examples/java/functions/get-deployment-download.md +++ b/docs/examples/java/functions/get-deployment-download.md @@ -12,6 +12,7 @@ Functions functions = new Functions(client); functions.getDeploymentDownload( "", // functionId "", // deploymentId + DeploymentDownloadType.SOURCE, // type (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 7a2ff91..25a9af8 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -12,7 +12,6 @@ Functions functions = new Functions(client); functions.listExecutions( "", // functionId listOf(), // queries (optional) - "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/update-deployment-build.md b/docs/examples/java/functions/update-deployment-status.md similarity index 95% rename from docs/examples/java/functions/update-deployment-build.md rename to docs/examples/java/functions/update-deployment-status.md index 5fc416b..8755fd9 100644 --- a/docs/examples/java/functions/update-deployment-build.md +++ b/docs/examples/java/functions/update-deployment-status.md @@ -9,7 +9,7 @@ Client client = new Client() Functions functions = new Functions(client); -functions.updateDeploymentBuild( +functions.updateDeploymentStatus( "", // functionId "", // deploymentId new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/functions/update-deployment.md b/docs/examples/java/functions/update-function-deployment.md similarity index 94% rename from docs/examples/java/functions/update-deployment.md rename to docs/examples/java/functions/update-function-deployment.md index b83e001..b88e87c 100644 --- a/docs/examples/java/functions/update-deployment.md +++ b/docs/examples/java/functions/update-function-deployment.md @@ -9,7 +9,7 @@ Client client = new Client() Functions functions = new Functions(client); -functions.updateDeployment( +functions.updateFunctionDeployment( "", // functionId "", // deploymentId new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/functions/update-variable.md b/docs/examples/java/functions/update-variable.md index d2bf6db..3a2b281 100644 --- a/docs/examples/java/functions/update-variable.md +++ b/docs/examples/java/functions/update-variable.md @@ -14,6 +14,7 @@ functions.updateVariable( "", // variableId "", // key "", // value (optional) + false, // secret (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/sites/create-deployment.md b/docs/examples/java/sites/create-deployment.md new file mode 100644 index 0000000..f370f80 --- /dev/null +++ b/docs/examples/java/sites/create-deployment.md @@ -0,0 +1,29 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.models.InputFile; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.createDeployment( + "", // siteId + InputFile.fromPath("file.png"), // code + false, // activate + "", // installCommand (optional) + "", // buildCommand (optional) + "", // outputDirectory (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/create-duplicate-deployment.md b/docs/examples/java/sites/create-duplicate-deployment.md new file mode 100644 index 0000000..35e43b8 --- /dev/null +++ b/docs/examples/java/sites/create-duplicate-deployment.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.createDuplicateDeployment( + "", // siteId + "", // deploymentId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/create-template-deployment.md b/docs/examples/java/sites/create-template-deployment.md new file mode 100644 index 0000000..63aba4a --- /dev/null +++ b/docs/examples/java/sites/create-template-deployment.md @@ -0,0 +1,28 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.createTemplateDeployment( + "", // siteId + "", // repository + "", // owner + "", // rootDirectory + "", // version + false, // activate (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/create-variable.md b/docs/examples/java/sites/create-variable.md new file mode 100644 index 0000000..c77bec3 --- /dev/null +++ b/docs/examples/java/sites/create-variable.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.createVariable( + "", // siteId + "", // key + "", // value + false, // secret (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/create-vcs-deployment.md b/docs/examples/java/sites/create-vcs-deployment.md new file mode 100644 index 0000000..754eb26 --- /dev/null +++ b/docs/examples/java/sites/create-vcs-deployment.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; +import io.appwrite.enums.VCSDeploymentType; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.createVcsDeployment( + "", // siteId + VCSDeploymentType.BRANCH, // type + "", // reference + false, // activate (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/create.md b/docs/examples/java/sites/create.md new file mode 100644 index 0000000..19664ec --- /dev/null +++ b/docs/examples/java/sites/create.md @@ -0,0 +1,42 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; +import io.appwrite.enums.Framework; +import io.appwrite.enums.BuildRuntime; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.create( + "", // siteId + "", // name + .ANALOG, // framework + .NODE_14_5, // buildRuntime + false, // enabled (optional) + false, // logging (optional) + 1, // timeout (optional) + "", // installCommand (optional) + "", // buildCommand (optional) + "", // outputDirectory (optional) + .STATIC, // adapter (optional) + "", // installationId (optional) + "", // fallbackFile (optional) + "", // providerRepositoryId (optional) + "", // providerBranch (optional) + false, // providerSilentMode (optional) + "", // providerRootDirectory (optional) + "", // specification (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/delete-deployment.md b/docs/examples/java/sites/delete-deployment.md new file mode 100644 index 0000000..97c08ab --- /dev/null +++ b/docs/examples/java/sites/delete-deployment.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.deleteDeployment( + "", // siteId + "", // deploymentId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/delete-log.md b/docs/examples/java/sites/delete-log.md new file mode 100644 index 0000000..d718937 --- /dev/null +++ b/docs/examples/java/sites/delete-log.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.deleteLog( + "", // siteId + "", // logId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/delete-variable.md b/docs/examples/java/sites/delete-variable.md new file mode 100644 index 0000000..4e2b3ab --- /dev/null +++ b/docs/examples/java/sites/delete-variable.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.deleteVariable( + "", // siteId + "", // variableId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/delete.md b/docs/examples/java/sites/delete.md new file mode 100644 index 0000000..fd07bb2 --- /dev/null +++ b/docs/examples/java/sites/delete.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.delete( + "", // siteId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/get-deployment-download.md b/docs/examples/java/sites/get-deployment-download.md new file mode 100644 index 0000000..5875c72 --- /dev/null +++ b/docs/examples/java/sites/get-deployment-download.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.getDeploymentDownload( + "", // siteId + "", // deploymentId + DeploymentDownloadType.SOURCE, // type (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/get-deployment.md b/docs/examples/java/sites/get-deployment.md new file mode 100644 index 0000000..6af859b --- /dev/null +++ b/docs/examples/java/sites/get-deployment.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.getDeployment( + "", // siteId + "", // deploymentId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/get-log.md b/docs/examples/java/sites/get-log.md new file mode 100644 index 0000000..d33f2a6 --- /dev/null +++ b/docs/examples/java/sites/get-log.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.getLog( + "", // siteId + "", // logId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/get-variable.md b/docs/examples/java/sites/get-variable.md new file mode 100644 index 0000000..1c8df0c --- /dev/null +++ b/docs/examples/java/sites/get-variable.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.getVariable( + "", // siteId + "", // variableId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/get.md b/docs/examples/java/sites/get.md new file mode 100644 index 0000000..660cad3 --- /dev/null +++ b/docs/examples/java/sites/get.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.get( + "", // siteId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/list-deployments.md b/docs/examples/java/sites/list-deployments.md new file mode 100644 index 0000000..8bcec54 --- /dev/null +++ b/docs/examples/java/sites/list-deployments.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.listDeployments( + "", // siteId + listOf(), // queries (optional) + "", // search (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/list-frameworks.md b/docs/examples/java/sites/list-frameworks.md new file mode 100644 index 0000000..df59717 --- /dev/null +++ b/docs/examples/java/sites/list-frameworks.md @@ -0,0 +1,19 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.listFrameworks(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); +})); diff --git a/docs/examples/java/sites/list-logs.md b/docs/examples/java/sites/list-logs.md new file mode 100644 index 0000000..3532882 --- /dev/null +++ b/docs/examples/java/sites/list-logs.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.listLogs( + "", // siteId + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/list-specifications.md b/docs/examples/java/sites/list-specifications.md new file mode 100644 index 0000000..caad732 --- /dev/null +++ b/docs/examples/java/sites/list-specifications.md @@ -0,0 +1,19 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.listSpecifications(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); +})); diff --git a/docs/examples/java/sites/list-variables.md b/docs/examples/java/sites/list-variables.md new file mode 100644 index 0000000..f2a38b7 --- /dev/null +++ b/docs/examples/java/sites/list-variables.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.listVariables( + "", // siteId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/list.md b/docs/examples/java/sites/list.md new file mode 100644 index 0000000..39a1c06 --- /dev/null +++ b/docs/examples/java/sites/list.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.list( + listOf(), // queries (optional) + "", // search (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/update-deployment-status.md b/docs/examples/java/sites/update-deployment-status.md new file mode 100644 index 0000000..8dc3041 --- /dev/null +++ b/docs/examples/java/sites/update-deployment-status.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.updateDeploymentStatus( + "", // siteId + "", // deploymentId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/update-site-deployment.md b/docs/examples/java/sites/update-site-deployment.md new file mode 100644 index 0000000..edbda7c --- /dev/null +++ b/docs/examples/java/sites/update-site-deployment.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.updateSiteDeployment( + "", // siteId + "", // deploymentId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/update-variable.md b/docs/examples/java/sites/update-variable.md new file mode 100644 index 0000000..9735ae3 --- /dev/null +++ b/docs/examples/java/sites/update-variable.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.updateVariable( + "", // siteId + "", // variableId + "", // key + "", // value (optional) + false, // secret (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/sites/update.md b/docs/examples/java/sites/update.md new file mode 100644 index 0000000..9a8b577 --- /dev/null +++ b/docs/examples/java/sites/update.md @@ -0,0 +1,41 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Sites; +import io.appwrite.enums.Framework; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Sites sites = new Sites(client); + +sites.update( + "", // siteId + "", // name + .ANALOG, // framework + false, // enabled (optional) + false, // logging (optional) + 1, // timeout (optional) + "", // installCommand (optional) + "", // buildCommand (optional) + "", // outputDirectory (optional) + .NODE_14_5, // buildRuntime (optional) + .STATIC, // adapter (optional) + "", // fallbackFile (optional) + "", // installationId (optional) + "", // providerRepositoryId (optional) + "", // providerBranch (optional) + false, // providerSilentMode (optional) + "", // providerRootDirectory (optional) + "", // specification (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index d0399f9..edda260 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -12,6 +12,7 @@ Storage storage = new Storage(client); storage.getFileDownload( "", // bucketId "", // fileId + "", // token (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index dd7c09d..1a0ab59 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -15,7 +15,7 @@ storage.getFilePreview( 0, // width (optional) 0, // height (optional) ImageGravity.CENTER, // gravity (optional) - 0, // quality (optional) + -1, // quality (optional) 0, // borderWidth (optional) "", // borderColor (optional) 0, // borderRadius (optional) @@ -23,6 +23,7 @@ storage.getFilePreview( -360, // rotation (optional) "", // background (optional) ImageFormat.JPG, // output (optional) + "", // token (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 1de4ae0..178e507 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -12,6 +12,7 @@ Storage storage = new Storage(client); storage.getFileView( "", // bucketId "", // fileId + "", // token (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tokens/create-file-token.md b/docs/examples/java/tokens/create-file-token.md new file mode 100644 index 0000000..6996641 --- /dev/null +++ b/docs/examples/java/tokens/create-file-token.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tokens; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Tokens tokens = new Tokens(client); + +tokens.createFileToken( + "", // bucketId + "", // fileId + "", // expire (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tokens/delete.md b/docs/examples/java/tokens/delete.md new file mode 100644 index 0000000..bf1874d --- /dev/null +++ b/docs/examples/java/tokens/delete.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tokens; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Tokens tokens = new Tokens(client); + +tokens.delete( + "", // tokenId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tokens/get.md b/docs/examples/java/tokens/get.md new file mode 100644 index 0000000..c55563c --- /dev/null +++ b/docs/examples/java/tokens/get.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tokens; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Tokens tokens = new Tokens(client); + +tokens.get( + "", // tokenId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tokens/list.md b/docs/examples/java/tokens/list.md new file mode 100644 index 0000000..a59e9f5 --- /dev/null +++ b/docs/examples/java/tokens/list.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tokens; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Tokens tokens = new Tokens(client); + +tokens.list( + "", // bucketId + "", // fileId + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/tokens/update.md b/docs/examples/java/tokens/update.md new file mode 100644 index 0000000..2a44f2d --- /dev/null +++ b/docs/examples/java/tokens/update.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tokens; + +Client client = new Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey(""); // Your secret API key + +Tokens tokens = new Tokens(client); + +tokens.update( + "", // tokenId + "", // expire (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/java/users/list-memberships.md b/docs/examples/java/users/list-memberships.md index dc03be2..d0cee13 100644 --- a/docs/examples/java/users/list-memberships.md +++ b/docs/examples/java/users/list-memberships.md @@ -11,6 +11,8 @@ Users users = new Users(client); users.listMemberships( "", // userId + listOf(), // queries (optional) + "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index e9b95c9..f289205 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -14,5 +14,5 @@ val result = avatars.getBrowser( code = Browser.AVANT_BROWSER, width = 0, // optional height = 0, // optional - quality = 0 // optional + quality = -1 // optional ) diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 8554dbd..1fd00a2 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -14,5 +14,5 @@ val result = avatars.getCreditCard( code = CreditCard.AMERICAN_EXPRESS, width = 0, // optional height = 0, // optional - quality = 0 // optional + quality = -1 // optional ) diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index 011a729..a16aefc 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -14,5 +14,5 @@ val result = avatars.getFlag( code = Flag.AFGHANISTAN, width = 0, // optional height = 0, // optional - quality = 0 // optional + quality = -1 // optional ) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 695fdbd..93da01e 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,8 +4,9 @@ import io.appwrite.services.Databases val client = Client() .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID .setSession("") // The user session to authenticate with + .setKey("") // Your secret API key + .setJWT("") // Your secret JSON Web Token val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/create-documents.md b/docs/examples/kotlin/databases/create-documents.md new file mode 100644 index 0000000..01692c6 --- /dev/null +++ b/docs/examples/kotlin/databases/create-documents.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.createDocuments( + databaseId = "", + collectionId = "", + documents = listOf() +) diff --git a/docs/examples/kotlin/databases/create-index.md b/docs/examples/kotlin/databases/create-index.md index 7ada0f7..da777ac 100644 --- a/docs/examples/kotlin/databases/create-index.md +++ b/docs/examples/kotlin/databases/create-index.md @@ -16,5 +16,6 @@ val response = databases.createIndex( key = "", type = IndexType.KEY, attributes = listOf(), - orders = listOf() // optional + orders = listOf(), // optional + lengths = listOf() // optional ) diff --git a/docs/examples/kotlin/databases/delete-documents.md b/docs/examples/kotlin/databases/delete-documents.md new file mode 100644 index 0000000..c4caa63 --- /dev/null +++ b/docs/examples/kotlin/databases/delete-documents.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.deleteDocuments( + databaseId = "", + collectionId = "", + queries = listOf() // optional +) diff --git a/docs/examples/kotlin/databases/update-documents.md b/docs/examples/kotlin/databases/update-documents.md new file mode 100644 index 0000000..9d6c2b5 --- /dev/null +++ b/docs/examples/kotlin/databases/update-documents.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.updateDocuments( + databaseId = "", + collectionId = "", + data = mapOf( "a" to "b" ), // optional + queries = listOf() // optional +) diff --git a/docs/examples/kotlin/databases/upsert-documents.md b/docs/examples/kotlin/databases/upsert-documents.md new file mode 100644 index 0000000..7459b38 --- /dev/null +++ b/docs/examples/kotlin/databases/upsert-documents.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val databases = Databases(client) + +val response = databases.upsertDocuments( + databaseId = "", + collectionId = "", + documents = listOf() // optional +) diff --git a/docs/examples/kotlin/functions/create-build.md b/docs/examples/kotlin/functions/create-duplicate-deployment.md similarity index 90% rename from docs/examples/kotlin/functions/create-build.md rename to docs/examples/kotlin/functions/create-duplicate-deployment.md index f835d93..a3395f1 100644 --- a/docs/examples/kotlin/functions/create-build.md +++ b/docs/examples/kotlin/functions/create-duplicate-deployment.md @@ -9,7 +9,7 @@ val client = Client() val functions = Functions(client) -val response = functions.createBuild( +val response = functions.createDuplicateDeployment( functionId = "", deploymentId = "", buildId = "" // optional diff --git a/docs/examples/kotlin/functions/create-template-deployment.md b/docs/examples/kotlin/functions/create-template-deployment.md new file mode 100644 index 0000000..90c311e --- /dev/null +++ b/docs/examples/kotlin/functions/create-template-deployment.md @@ -0,0 +1,19 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Functions + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val functions = Functions(client) + +val response = functions.createTemplateDeployment( + functionId = "", + repository = "", + owner = "", + rootDirectory = "", + version = "", + activate = false // optional +) diff --git a/docs/examples/kotlin/functions/create-variable.md b/docs/examples/kotlin/functions/create-variable.md index 5dff26f..061bc20 100644 --- a/docs/examples/kotlin/functions/create-variable.md +++ b/docs/examples/kotlin/functions/create-variable.md @@ -12,5 +12,6 @@ val functions = Functions(client) val response = functions.createVariable( functionId = "", key = "", - value = "" + value = "", + secret = false // optional ) diff --git a/docs/examples/kotlin/functions/create-vcs-deployment.md b/docs/examples/kotlin/functions/create-vcs-deployment.md new file mode 100644 index 0000000..08bb5a3 --- /dev/null +++ b/docs/examples/kotlin/functions/create-vcs-deployment.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Functions +import io.appwrite.enums.VCSDeploymentType + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val functions = Functions(client) + +val response = functions.createVcsDeployment( + functionId = "", + type = VCSDeploymentType.BRANCH, + reference = "", + activate = false // optional +) diff --git a/docs/examples/kotlin/functions/create.md b/docs/examples/kotlin/functions/create.md index 7278878..c0ea4de 100644 --- a/docs/examples/kotlin/functions/create.md +++ b/docs/examples/kotlin/functions/create.md @@ -28,9 +28,5 @@ val response = functions.create( providerBranch = "", // optional providerSilentMode = false, // optional providerRootDirectory = "", // optional - templateRepository = "", // optional - templateOwner = "", // optional - templateRootDirectory = "", // optional - templateVersion = "", // optional specification = "" // optional ) diff --git a/docs/examples/kotlin/functions/get-deployment-download.md b/docs/examples/kotlin/functions/get-deployment-download.md index 5e9558e..634cfae 100644 --- a/docs/examples/kotlin/functions/get-deployment-download.md +++ b/docs/examples/kotlin/functions/get-deployment-download.md @@ -11,5 +11,6 @@ val functions = Functions(client) val result = functions.getDeploymentDownload( functionId = "", - deploymentId = "" + deploymentId = "", + type = "source" // optional ) diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index 9f85f67..926719c 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -11,6 +11,5 @@ val functions = Functions(client) val response = functions.listExecutions( functionId = "", - queries = listOf(), // optional - search = "" // optional + queries = listOf() // optional ) diff --git a/docs/examples/kotlin/functions/update-deployment-build.md b/docs/examples/kotlin/functions/update-deployment-status.md similarity index 89% rename from docs/examples/kotlin/functions/update-deployment-build.md rename to docs/examples/kotlin/functions/update-deployment-status.md index 839bbe6..0e6e9c0 100644 --- a/docs/examples/kotlin/functions/update-deployment-build.md +++ b/docs/examples/kotlin/functions/update-deployment-status.md @@ -9,7 +9,7 @@ val client = Client() val functions = Functions(client) -val response = functions.updateDeploymentBuild( +val response = functions.updateDeploymentStatus( functionId = "", deploymentId = "" ) diff --git a/docs/examples/kotlin/functions/update-deployment.md b/docs/examples/kotlin/functions/update-function-deployment.md similarity index 89% rename from docs/examples/kotlin/functions/update-deployment.md rename to docs/examples/kotlin/functions/update-function-deployment.md index cf020d6..a975e07 100644 --- a/docs/examples/kotlin/functions/update-deployment.md +++ b/docs/examples/kotlin/functions/update-function-deployment.md @@ -9,7 +9,7 @@ val client = Client() val functions = Functions(client) -val response = functions.updateDeployment( +val response = functions.updateFunctionDeployment( functionId = "", deploymentId = "" ) diff --git a/docs/examples/kotlin/functions/update-variable.md b/docs/examples/kotlin/functions/update-variable.md index ed6e4ff..106b340 100644 --- a/docs/examples/kotlin/functions/update-variable.md +++ b/docs/examples/kotlin/functions/update-variable.md @@ -13,5 +13,6 @@ val response = functions.updateVariable( functionId = "", variableId = "", key = "", - value = "" // optional + value = "", // optional + secret = false // optional ) diff --git a/docs/examples/kotlin/sites/create-deployment.md b/docs/examples/kotlin/sites/create-deployment.md new file mode 100644 index 0000000..ba2c24d --- /dev/null +++ b/docs/examples/kotlin/sites/create-deployment.md @@ -0,0 +1,20 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.models.InputFile +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.createDeployment( + siteId = "", + code = InputFile.fromPath("file.png"), + activate = false, + installCommand = "", // optional + buildCommand = "", // optional + outputDirectory = "" // optional +) diff --git a/docs/examples/kotlin/sites/create-duplicate-deployment.md b/docs/examples/kotlin/sites/create-duplicate-deployment.md new file mode 100644 index 0000000..06a3ce8 --- /dev/null +++ b/docs/examples/kotlin/sites/create-duplicate-deployment.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.createDuplicateDeployment( + siteId = "", + deploymentId = "" +) diff --git a/docs/examples/kotlin/sites/create-template-deployment.md b/docs/examples/kotlin/sites/create-template-deployment.md new file mode 100644 index 0000000..bf246be --- /dev/null +++ b/docs/examples/kotlin/sites/create-template-deployment.md @@ -0,0 +1,19 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.createTemplateDeployment( + siteId = "", + repository = "", + owner = "", + rootDirectory = "", + version = "", + activate = false // optional +) diff --git a/docs/examples/kotlin/sites/create-variable.md b/docs/examples/kotlin/sites/create-variable.md new file mode 100644 index 0000000..6eb4666 --- /dev/null +++ b/docs/examples/kotlin/sites/create-variable.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.createVariable( + siteId = "", + key = "", + value = "", + secret = false // optional +) diff --git a/docs/examples/kotlin/sites/create-vcs-deployment.md b/docs/examples/kotlin/sites/create-vcs-deployment.md new file mode 100644 index 0000000..141cf3e --- /dev/null +++ b/docs/examples/kotlin/sites/create-vcs-deployment.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites +import io.appwrite.enums.VCSDeploymentType + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.createVcsDeployment( + siteId = "", + type = VCSDeploymentType.BRANCH, + reference = "", + activate = false // optional +) diff --git a/docs/examples/kotlin/sites/create.md b/docs/examples/kotlin/sites/create.md new file mode 100644 index 0000000..a5e9719 --- /dev/null +++ b/docs/examples/kotlin/sites/create.md @@ -0,0 +1,33 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites +import io.appwrite.enums.Framework +import io.appwrite.enums.BuildRuntime + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.create( + siteId = "", + name = "", + framework = .ANALOG, + buildRuntime = .NODE_14_5, + enabled = false, // optional + logging = false, // optional + timeout = 1, // optional + installCommand = "", // optional + buildCommand = "", // optional + outputDirectory = "", // optional + adapter = "static", // optional + installationId = "", // optional + fallbackFile = "", // optional + providerRepositoryId = "", // optional + providerBranch = "", // optional + providerSilentMode = false, // optional + providerRootDirectory = "", // optional + specification = "" // optional +) diff --git a/docs/examples/kotlin/sites/delete-deployment.md b/docs/examples/kotlin/sites/delete-deployment.md new file mode 100644 index 0000000..6d73918 --- /dev/null +++ b/docs/examples/kotlin/sites/delete-deployment.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.deleteDeployment( + siteId = "", + deploymentId = "" +) diff --git a/docs/examples/kotlin/sites/delete-log.md b/docs/examples/kotlin/sites/delete-log.md new file mode 100644 index 0000000..c7d7b77 --- /dev/null +++ b/docs/examples/kotlin/sites/delete-log.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.deleteLog( + siteId = "", + logId = "" +) diff --git a/docs/examples/kotlin/sites/delete-variable.md b/docs/examples/kotlin/sites/delete-variable.md new file mode 100644 index 0000000..7859a8a --- /dev/null +++ b/docs/examples/kotlin/sites/delete-variable.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.deleteVariable( + siteId = "", + variableId = "" +) diff --git a/docs/examples/kotlin/sites/delete.md b/docs/examples/kotlin/sites/delete.md new file mode 100644 index 0000000..369b614 --- /dev/null +++ b/docs/examples/kotlin/sites/delete.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.delete( + siteId = "" +) diff --git a/docs/examples/kotlin/sites/get-deployment-download.md b/docs/examples/kotlin/sites/get-deployment-download.md new file mode 100644 index 0000000..8432476 --- /dev/null +++ b/docs/examples/kotlin/sites/get-deployment-download.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val result = sites.getDeploymentDownload( + siteId = "", + deploymentId = "", + type = "source" // optional +) diff --git a/docs/examples/kotlin/sites/get-deployment.md b/docs/examples/kotlin/sites/get-deployment.md new file mode 100644 index 0000000..f2a33a4 --- /dev/null +++ b/docs/examples/kotlin/sites/get-deployment.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.getDeployment( + siteId = "", + deploymentId = "" +) diff --git a/docs/examples/kotlin/sites/get-log.md b/docs/examples/kotlin/sites/get-log.md new file mode 100644 index 0000000..ff46f77 --- /dev/null +++ b/docs/examples/kotlin/sites/get-log.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.getLog( + siteId = "", + logId = "" +) diff --git a/docs/examples/kotlin/sites/get-variable.md b/docs/examples/kotlin/sites/get-variable.md new file mode 100644 index 0000000..ccab666 --- /dev/null +++ b/docs/examples/kotlin/sites/get-variable.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.getVariable( + siteId = "", + variableId = "" +) diff --git a/docs/examples/kotlin/sites/get.md b/docs/examples/kotlin/sites/get.md new file mode 100644 index 0000000..7ced974 --- /dev/null +++ b/docs/examples/kotlin/sites/get.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.get( + siteId = "" +) diff --git a/docs/examples/kotlin/sites/list-deployments.md b/docs/examples/kotlin/sites/list-deployments.md new file mode 100644 index 0000000..6bc29cc --- /dev/null +++ b/docs/examples/kotlin/sites/list-deployments.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.listDeployments( + siteId = "", + queries = listOf(), // optional + search = "" // optional +) diff --git a/docs/examples/kotlin/sites/list-frameworks.md b/docs/examples/kotlin/sites/list-frameworks.md new file mode 100644 index 0000000..cf02b75 --- /dev/null +++ b/docs/examples/kotlin/sites/list-frameworks.md @@ -0,0 +1,12 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.listFrameworks() diff --git a/docs/examples/kotlin/sites/list-logs.md b/docs/examples/kotlin/sites/list-logs.md new file mode 100644 index 0000000..d7979de --- /dev/null +++ b/docs/examples/kotlin/sites/list-logs.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.listLogs( + siteId = "", + queries = listOf() // optional +) diff --git a/docs/examples/kotlin/sites/list-specifications.md b/docs/examples/kotlin/sites/list-specifications.md new file mode 100644 index 0000000..56e8640 --- /dev/null +++ b/docs/examples/kotlin/sites/list-specifications.md @@ -0,0 +1,12 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.listSpecifications() diff --git a/docs/examples/kotlin/sites/list-variables.md b/docs/examples/kotlin/sites/list-variables.md new file mode 100644 index 0000000..70ec497 --- /dev/null +++ b/docs/examples/kotlin/sites/list-variables.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.listVariables( + siteId = "" +) diff --git a/docs/examples/kotlin/sites/list.md b/docs/examples/kotlin/sites/list.md new file mode 100644 index 0000000..26e9651 --- /dev/null +++ b/docs/examples/kotlin/sites/list.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.list( + queries = listOf(), // optional + search = "" // optional +) diff --git a/docs/examples/kotlin/sites/update-deployment-status.md b/docs/examples/kotlin/sites/update-deployment-status.md new file mode 100644 index 0000000..585fc32 --- /dev/null +++ b/docs/examples/kotlin/sites/update-deployment-status.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.updateDeploymentStatus( + siteId = "", + deploymentId = "" +) diff --git a/docs/examples/kotlin/sites/update-site-deployment.md b/docs/examples/kotlin/sites/update-site-deployment.md new file mode 100644 index 0000000..fb9bb72 --- /dev/null +++ b/docs/examples/kotlin/sites/update-site-deployment.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.updateSiteDeployment( + siteId = "", + deploymentId = "" +) diff --git a/docs/examples/kotlin/sites/update-variable.md b/docs/examples/kotlin/sites/update-variable.md new file mode 100644 index 0000000..b32c278 --- /dev/null +++ b/docs/examples/kotlin/sites/update-variable.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.updateVariable( + siteId = "", + variableId = "", + key = "", + value = "", // optional + secret = false // optional +) diff --git a/docs/examples/kotlin/sites/update.md b/docs/examples/kotlin/sites/update.md new file mode 100644 index 0000000..4b4a938 --- /dev/null +++ b/docs/examples/kotlin/sites/update.md @@ -0,0 +1,32 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Sites +import io.appwrite.enums.Framework + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val sites = Sites(client) + +val response = sites.update( + siteId = "", + name = "", + framework = .ANALOG, + enabled = false, // optional + logging = false, // optional + timeout = 1, // optional + installCommand = "", // optional + buildCommand = "", // optional + outputDirectory = "", // optional + buildRuntime = "node-14.5", // optional + adapter = "static", // optional + fallbackFile = "", // optional + installationId = "", // optional + providerRepositoryId = "", // optional + providerBranch = "", // optional + providerSilentMode = false, // optional + providerRootDirectory = "", // optional + specification = "" // optional +) diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index f3422f9..c14c966 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -11,5 +11,6 @@ val storage = Storage(client) val result = storage.getFileDownload( bucketId = "", - fileId = "" + fileId = "", + token = "" // optional ) diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 8c37ce8..45122de 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -15,12 +15,13 @@ val result = storage.getFilePreview( width = 0, // optional height = 0, // optional gravity = "center", // optional - quality = 0, // optional + quality = -1, // optional borderWidth = 0, // optional borderColor = "", // optional borderRadius = 0, // optional opacity = 0, // optional rotation = -360, // optional background = "", // optional - output = "jpg" // optional + output = "jpg", // optional + token = "" // optional ) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index cf8cde3..fec1ec7 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -11,5 +11,6 @@ val storage = Storage(client) val result = storage.getFileView( bucketId = "", - fileId = "" + fileId = "", + token = "" // optional ) diff --git a/docs/examples/kotlin/tokens/create-file-token.md b/docs/examples/kotlin/tokens/create-file-token.md new file mode 100644 index 0000000..63d8fc3 --- /dev/null +++ b/docs/examples/kotlin/tokens/create-file-token.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tokens + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tokens = Tokens(client) + +val response = tokens.createFileToken( + bucketId = "", + fileId = "", + expire = "" // optional +) diff --git a/docs/examples/kotlin/tokens/delete.md b/docs/examples/kotlin/tokens/delete.md new file mode 100644 index 0000000..1831bc6 --- /dev/null +++ b/docs/examples/kotlin/tokens/delete.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tokens + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tokens = Tokens(client) + +val response = tokens.delete( + tokenId = "" +) diff --git a/docs/examples/kotlin/tokens/get.md b/docs/examples/kotlin/tokens/get.md new file mode 100644 index 0000000..70a47c2 --- /dev/null +++ b/docs/examples/kotlin/tokens/get.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tokens + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tokens = Tokens(client) + +val response = tokens.get( + tokenId = "" +) diff --git a/docs/examples/kotlin/tokens/list.md b/docs/examples/kotlin/tokens/list.md new file mode 100644 index 0000000..6975790 --- /dev/null +++ b/docs/examples/kotlin/tokens/list.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tokens + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tokens = Tokens(client) + +val response = tokens.list( + bucketId = "", + fileId = "", + queries = listOf() // optional +) diff --git a/docs/examples/kotlin/tokens/update.md b/docs/examples/kotlin/tokens/update.md new file mode 100644 index 0000000..045ddaa --- /dev/null +++ b/docs/examples/kotlin/tokens/update.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tokens + +val client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + .setKey("") // Your secret API key + +val tokens = Tokens(client) + +val response = tokens.update( + tokenId = "", + expire = "" // optional +) diff --git a/docs/examples/kotlin/users/list-memberships.md b/docs/examples/kotlin/users/list-memberships.md index 528b69c..7df13df 100644 --- a/docs/examples/kotlin/users/list-memberships.md +++ b/docs/examples/kotlin/users/list-memberships.md @@ -10,5 +10,7 @@ val client = Client() val users = Users(client) val response = users.listMemberships( - userId = "" + userId = "", + queries = listOf(), // optional + search = "" // optional ) diff --git a/src/main/kotlin/io/appwrite/Client.kt b/src/main/kotlin/io/appwrite/Client.kt index 2f5a476..c7824ef 100644 --- a/src/main/kotlin/io/appwrite/Client.kt +++ b/src/main/kotlin/io/appwrite/Client.kt @@ -58,12 +58,12 @@ class Client @JvmOverloads constructor( init { headers = mutableMapOf( "content-type" to "application/json", - "user-agent" to "AppwriteKotlinSDK/8.0.0 ${System.getProperty("http.agent")}", + "user-agent" to "AppwriteKotlinSDK/9.0.0 ${System.getProperty("http.agent")}", "x-sdk-name" to "Kotlin", "x-sdk-platform" to "server", "x-sdk-language" to "kotlin", - "x-sdk-version" to "8.0.0", - "x-appwrite-response-format" to "1.6.0", + "x-sdk-version" to "9.0.0", + "x-appwrite-response-format" to "1.7.0", ) config = mutableMapOf() diff --git a/src/main/kotlin/io/appwrite/enums/Adapter.kt b/src/main/kotlin/io/appwrite/enums/Adapter.kt new file mode 100644 index 0000000..3f38345 --- /dev/null +++ b/src/main/kotlin/io/appwrite/enums/Adapter.kt @@ -0,0 +1,12 @@ +package io.appwrite.enums + +import com.google.gson.annotations.SerializedName + +enum class Adapter(val value: String) { + @SerializedName("static") + STATIC("static"), + @SerializedName("ssr") + SSR("ssr"); + + override fun toString() = value +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/enums/BuildRuntime.kt b/src/main/kotlin/io/appwrite/enums/BuildRuntime.kt new file mode 100644 index 0000000..71d857d --- /dev/null +++ b/src/main/kotlin/io/appwrite/enums/BuildRuntime.kt @@ -0,0 +1,134 @@ +package io.appwrite.enums + +import com.google.gson.annotations.SerializedName + +enum class BuildRuntime(val value: String) { + @SerializedName("node-14.5") + NODE_14_5("node-14.5"), + @SerializedName("node-16.0") + NODE_16_0("node-16.0"), + @SerializedName("node-18.0") + NODE_18_0("node-18.0"), + @SerializedName("node-19.0") + NODE_19_0("node-19.0"), + @SerializedName("node-20.0") + NODE_20_0("node-20.0"), + @SerializedName("node-21.0") + NODE_21_0("node-21.0"), + @SerializedName("node-22") + NODE_22("node-22"), + @SerializedName("php-8.0") + PHP_8_0("php-8.0"), + @SerializedName("php-8.1") + PHP_8_1("php-8.1"), + @SerializedName("php-8.2") + PHP_8_2("php-8.2"), + @SerializedName("php-8.3") + PHP_8_3("php-8.3"), + @SerializedName("ruby-3.0") + RUBY_3_0("ruby-3.0"), + @SerializedName("ruby-3.1") + RUBY_3_1("ruby-3.1"), + @SerializedName("ruby-3.2") + RUBY_3_2("ruby-3.2"), + @SerializedName("ruby-3.3") + RUBY_3_3("ruby-3.3"), + @SerializedName("python-3.8") + PYTHON_3_8("python-3.8"), + @SerializedName("python-3.9") + PYTHON_3_9("python-3.9"), + @SerializedName("python-3.10") + PYTHON_3_10("python-3.10"), + @SerializedName("python-3.11") + PYTHON_3_11("python-3.11"), + @SerializedName("python-3.12") + PYTHON_3_12("python-3.12"), + @SerializedName("python-ml-3.11") + PYTHON_ML_3_11("python-ml-3.11"), + @SerializedName("python-ml-3.12") + PYTHON_ML_3_12("python-ml-3.12"), + @SerializedName("deno-1.21") + DENO_1_21("deno-1.21"), + @SerializedName("deno-1.24") + DENO_1_24("deno-1.24"), + @SerializedName("deno-1.35") + DENO_1_35("deno-1.35"), + @SerializedName("deno-1.40") + DENO_1_40("deno-1.40"), + @SerializedName("deno-1.46") + DENO_1_46("deno-1.46"), + @SerializedName("deno-2.0") + DENO_2_0("deno-2.0"), + @SerializedName("dart-2.15") + DART_2_15("dart-2.15"), + @SerializedName("dart-2.16") + DART_2_16("dart-2.16"), + @SerializedName("dart-2.17") + DART_2_17("dart-2.17"), + @SerializedName("dart-2.18") + DART_2_18("dart-2.18"), + @SerializedName("dart-2.19") + DART_2_19("dart-2.19"), + @SerializedName("dart-3.0") + DART_3_0("dart-3.0"), + @SerializedName("dart-3.1") + DART_3_1("dart-3.1"), + @SerializedName("dart-3.3") + DART_3_3("dart-3.3"), + @SerializedName("dart-3.5") + DART_3_5("dart-3.5"), + @SerializedName("dotnet-6.0") + DOTNET_6_0("dotnet-6.0"), + @SerializedName("dotnet-7.0") + DOTNET_7_0("dotnet-7.0"), + @SerializedName("dotnet-8.0") + DOTNET_8_0("dotnet-8.0"), + @SerializedName("java-8.0") + JAVA_8_0("java-8.0"), + @SerializedName("java-11.0") + JAVA_11_0("java-11.0"), + @SerializedName("java-17.0") + JAVA_17_0("java-17.0"), + @SerializedName("java-18.0") + JAVA_18_0("java-18.0"), + @SerializedName("java-21.0") + JAVA_21_0("java-21.0"), + @SerializedName("java-22") + JAVA_22("java-22"), + @SerializedName("swift-5.5") + SWIFT_5_5("swift-5.5"), + @SerializedName("swift-5.8") + SWIFT_5_8("swift-5.8"), + @SerializedName("swift-5.9") + SWIFT_5_9("swift-5.9"), + @SerializedName("swift-5.10") + SWIFT_5_10("swift-5.10"), + @SerializedName("kotlin-1.6") + KOTLIN_1_6("kotlin-1.6"), + @SerializedName("kotlin-1.8") + KOTLIN_1_8("kotlin-1.8"), + @SerializedName("kotlin-1.9") + KOTLIN_1_9("kotlin-1.9"), + @SerializedName("kotlin-2.0") + KOTLIN_2_0("kotlin-2.0"), + @SerializedName("cpp-17") + CPP_17("cpp-17"), + @SerializedName("cpp-20") + CPP_20("cpp-20"), + @SerializedName("bun-1.0") + BUN_1_0("bun-1.0"), + @SerializedName("bun-1.1") + BUN_1_1("bun-1.1"), + @SerializedName("go-1.23") + GO_1_23("go-1.23"), + @SerializedName("static-1") + STATIC_1("static-1"), + @SerializedName("flutter-3.24") + FLUTTER_3_24("flutter-3.24"), + @SerializedName("flutter-3.27") + FLUTTER_3_27("flutter-3.27"), + @SerializedName("flutter-3.29") + FLUTTER_3_29("flutter-3.29"); + + override fun toString() = value +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/enums/DeploymentDownloadType.kt b/src/main/kotlin/io/appwrite/enums/DeploymentDownloadType.kt new file mode 100644 index 0000000..ab75880 --- /dev/null +++ b/src/main/kotlin/io/appwrite/enums/DeploymentDownloadType.kt @@ -0,0 +1,12 @@ +package io.appwrite.enums + +import com.google.gson.annotations.SerializedName + +enum class DeploymentDownloadType(val value: String) { + @SerializedName("source") + SOURCE("source"), + @SerializedName("output") + OUTPUT("output"); + + override fun toString() = value +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/enums/Framework.kt b/src/main/kotlin/io/appwrite/enums/Framework.kt new file mode 100644 index 0000000..4087d6b --- /dev/null +++ b/src/main/kotlin/io/appwrite/enums/Framework.kt @@ -0,0 +1,36 @@ +package io.appwrite.enums + +import com.google.gson.annotations.SerializedName + +enum class Framework(val value: String) { + @SerializedName("analog") + ANALOG("analog"), + @SerializedName("angular") + ANGULAR("angular"), + @SerializedName("nextjs") + NEXTJS("nextjs"), + @SerializedName("react") + REACT("react"), + @SerializedName("nuxt") + NUXT("nuxt"), + @SerializedName("vue") + VUE("vue"), + @SerializedName("sveltekit") + SVELTEKIT("sveltekit"), + @SerializedName("astro") + ASTRO("astro"), + @SerializedName("remix") + REMIX("remix"), + @SerializedName("lynx") + LYNX("lynx"), + @SerializedName("flutter") + FLUTTER("flutter"), + @SerializedName("react-native") + REACT_NATIVE("react-native"), + @SerializedName("vite") + VITE("vite"), + @SerializedName("other") + OTHER("other"); + + override fun toString() = value +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/enums/ImageFormat.kt b/src/main/kotlin/io/appwrite/enums/ImageFormat.kt index 7249f2a..c3dea06 100644 --- a/src/main/kotlin/io/appwrite/enums/ImageFormat.kt +++ b/src/main/kotlin/io/appwrite/enums/ImageFormat.kt @@ -7,8 +7,6 @@ enum class ImageFormat(val value: String) { JPG("jpg"), @SerializedName("jpeg") JPEG("jpeg"), - @SerializedName("gif") - GIF("gif"), @SerializedName("png") PNG("png"), @SerializedName("webp") diff --git a/src/main/kotlin/io/appwrite/enums/Runtime.kt b/src/main/kotlin/io/appwrite/enums/Runtime.kt index c19f52b..dd65f3e 100644 --- a/src/main/kotlin/io/appwrite/enums/Runtime.kt +++ b/src/main/kotlin/io/appwrite/enums/Runtime.kt @@ -45,6 +45,8 @@ enum class Runtime(val value: String) { PYTHON_3_12("python-3.12"), @SerializedName("python-ml-3.11") PYTHON_ML_3_11("python-ml-3.11"), + @SerializedName("python-ml-3.12") + PYTHON_ML_3_12("python-ml-3.12"), @SerializedName("deno-1.21") DENO_1_21("deno-1.21"), @SerializedName("deno-1.24") @@ -65,6 +67,8 @@ enum class Runtime(val value: String) { DART_2_17("dart-2.17"), @SerializedName("dart-2.18") DART_2_18("dart-2.18"), + @SerializedName("dart-2.19") + DART_2_19("dart-2.19"), @SerializedName("dart-3.0") DART_3_0("dart-3.0"), @SerializedName("dart-3.1") @@ -120,7 +124,11 @@ enum class Runtime(val value: String) { @SerializedName("static-1") STATIC_1("static-1"), @SerializedName("flutter-3.24") - FLUTTER_3_24("flutter-3.24"); + FLUTTER_3_24("flutter-3.24"), + @SerializedName("flutter-3.27") + FLUTTER_3_27("flutter-3.27"), + @SerializedName("flutter-3.29") + FLUTTER_3_29("flutter-3.29"); override fun toString() = value } \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/enums/VCSDeploymentType.kt b/src/main/kotlin/io/appwrite/enums/VCSDeploymentType.kt new file mode 100644 index 0000000..ef7147b --- /dev/null +++ b/src/main/kotlin/io/appwrite/enums/VCSDeploymentType.kt @@ -0,0 +1,14 @@ +package io.appwrite.enums + +import com.google.gson.annotations.SerializedName + +enum class VCSDeploymentType(val value: String) { + @SerializedName("branch") + BRANCH("branch"), + @SerializedName("commit") + COMMIT("commit"), + @SerializedName("tag") + TAG("tag"); + + override fun toString() = value +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/Build.kt b/src/main/kotlin/io/appwrite/models/Build.kt deleted file mode 100644 index 4f4c470..0000000 --- a/src/main/kotlin/io/appwrite/models/Build.kt +++ /dev/null @@ -1,94 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Build - */ -data class Build( - /** - * Build ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * The deployment that created this build. - */ - @SerializedName("deploymentId") - val deploymentId: String, - - /** - * The build status. There are a few different types and each one means something different. \nFailed - The deployment build has failed. More details can usually be found in buildStderr\nReady - The deployment build was successful and the deployment is ready to be deployed\nProcessing - The deployment is currently waiting to have a build triggered\nBuilding - The deployment is currently being built - */ - @SerializedName("status") - val status: String, - - /** - * The stdout of the build. - */ - @SerializedName("stdout") - val stdout: String, - - /** - * The stderr of the build. - */ - @SerializedName("stderr") - val stderr: String, - - /** - * The deployment creation date in ISO 8601 format. - */ - @SerializedName("startTime") - val startTime: String, - - /** - * The time the build was finished in ISO 8601 format. - */ - @SerializedName("endTime") - val endTime: String, - - /** - * The build duration in seconds. - */ - @SerializedName("duration") - val duration: Long, - - /** - * The code size in bytes. - */ - @SerializedName("size") - val size: Long, - -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "deploymentId" to deploymentId as Any, - "status" to status as Any, - "stdout" to stdout as Any, - "stderr" to stderr as Any, - "startTime" to startTime as Any, - "endTime" to endTime as Any, - "duration" to duration as Any, - "size" to size as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = Build( - id = map["\$id"] as String, - deploymentId = map["deploymentId"] as String, - status = map["status"] as String, - stdout = map["stdout"] as String, - stderr = map["stderr"] as String, - startTime = map["startTime"] as String, - endTime = map["endTime"] as String, - duration = (map["duration"] as Number).toLong(), - size = (map["size"] as Number).toLong(), - ) - } -} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/Deployment.kt b/src/main/kotlin/io/appwrite/models/Deployment.kt index 20db30b..17ee770 100644 --- a/src/main/kotlin/io/appwrite/models/Deployment.kt +++ b/src/main/kotlin/io/appwrite/models/Deployment.kt @@ -52,8 +52,8 @@ data class Deployment( /** * The code size in bytes. */ - @SerializedName("size") - val size: Long, + @SerializedName("sourceSize") + val sourceSize: Long, /** * The build output size in bytes. @@ -61,6 +61,12 @@ data class Deployment( @SerializedName("buildSize") val buildSize: Long, + /** + * The total size in bytes (source and build output). + */ + @SerializedName("totalSize") + val totalSize: Long, + /** * The current build ID. */ @@ -74,7 +80,19 @@ data class Deployment( val activate: Boolean, /** - * The deployment status. Possible values are "processing", "building", "waiting", "ready", and "failed". + * Screenshot with light theme preference file ID. + */ + @SerializedName("screenshotLight") + val screenshotLight: String, + + /** + * Screenshot with dark theme preference file ID. + */ + @SerializedName("screenshotDark") + val screenshotDark: String, + + /** + * The deployment status. Possible values are "waiting", "processing", "building", "ready", and "failed". */ @SerializedName("status") val status: String, @@ -88,8 +106,8 @@ data class Deployment( /** * The current build time in seconds. */ - @SerializedName("buildTime") - val buildTime: Long, + @SerializedName("buildDuration") + val buildDuration: Long, /** * The name of the vcs provider repository @@ -160,13 +178,16 @@ data class Deployment( "resourceId" to resourceId as Any, "resourceType" to resourceType as Any, "entrypoint" to entrypoint as Any, - "size" to size as Any, + "sourceSize" to sourceSize as Any, "buildSize" to buildSize as Any, + "totalSize" to totalSize as Any, "buildId" to buildId as Any, "activate" to activate as Any, + "screenshotLight" to screenshotLight as Any, + "screenshotDark" to screenshotDark as Any, "status" to status as Any, "buildLogs" to buildLogs as Any, - "buildTime" to buildTime as Any, + "buildDuration" to buildDuration as Any, "providerRepositoryName" to providerRepositoryName as Any, "providerRepositoryOwner" to providerRepositoryOwner as Any, "providerRepositoryUrl" to providerRepositoryUrl as Any, @@ -192,13 +213,16 @@ data class Deployment( resourceId = map["resourceId"] as String, resourceType = map["resourceType"] as String, entrypoint = map["entrypoint"] as String, - size = (map["size"] as Number).toLong(), + sourceSize = (map["sourceSize"] as Number).toLong(), buildSize = (map["buildSize"] as Number).toLong(), + totalSize = (map["totalSize"] as Number).toLong(), buildId = map["buildId"] as String, activate = map["activate"] as Boolean, + screenshotLight = map["screenshotLight"] as String, + screenshotDark = map["screenshotDark"] as String, status = map["status"] as String, buildLogs = map["buildLogs"] as String, - buildTime = (map["buildTime"] as Number).toLong(), + buildDuration = (map["buildDuration"] as Number).toLong(), providerRepositoryName = map["providerRepositoryName"] as String, providerRepositoryOwner = map["providerRepositoryOwner"] as String, providerRepositoryUrl = map["providerRepositoryUrl"] as String, diff --git a/src/main/kotlin/io/appwrite/models/Execution.kt b/src/main/kotlin/io/appwrite/models/Execution.kt index 1b6226a..216e146 100644 --- a/src/main/kotlin/io/appwrite/models/Execution.kt +++ b/src/main/kotlin/io/appwrite/models/Execution.kt @@ -98,7 +98,7 @@ data class Execution( val errors: String, /** - * Function execution duration in seconds. + * Resource(function/site) execution duration in seconds. */ @SerializedName("duration") val duration: Double, diff --git a/src/main/kotlin/io/appwrite/models/Framework.kt b/src/main/kotlin/io/appwrite/models/Framework.kt new file mode 100644 index 0000000..c57b2ae --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/Framework.kt @@ -0,0 +1,62 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Framework + */ +data class Framework( + /** + * Framework key. + */ + @SerializedName("key") + val key: String, + + /** + * Framework Name. + */ + @SerializedName("name") + val name: String, + + /** + * Default runtime version. + */ + @SerializedName("buildRuntime") + val buildRuntime: String, + + /** + * List of supported runtime versions. + */ + @SerializedName("runtimes") + val runtimes: List, + + /** + * List of supported adapters. + */ + @SerializedName("adapters") + val adapters: List, + +) { + fun toMap(): Map = mapOf( + "key" to key as Any, + "name" to name as Any, + "buildRuntime" to buildRuntime as Any, + "runtimes" to runtimes as Any, + "adapters" to adapters.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Framework( + key = map["key"] as String, + name = map["name"] as String, + buildRuntime = map["buildRuntime"] as String, + runtimes = map["runtimes"] as List, + adapters = (map["adapters"] as List>).map { FrameworkAdapter.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/FrameworkAdapter.kt b/src/main/kotlin/io/appwrite/models/FrameworkAdapter.kt new file mode 100644 index 0000000..5f6c688 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/FrameworkAdapter.kt @@ -0,0 +1,62 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Framework Adapter + */ +data class FrameworkAdapter( + /** + * Adapter key. + */ + @SerializedName("key") + val key: String, + + /** + * Default command to download dependencies. + */ + @SerializedName("installCommand") + val installCommand: String, + + /** + * Default command to build site into output directory. + */ + @SerializedName("buildCommand") + val buildCommand: String, + + /** + * Default output directory of build. + */ + @SerializedName("outputDirectory") + val outputDirectory: String, + + /** + * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + */ + @SerializedName("fallbackFile") + val fallbackFile: String, + +) { + fun toMap(): Map = mapOf( + "key" to key as Any, + "installCommand" to installCommand as Any, + "buildCommand" to buildCommand as Any, + "outputDirectory" to outputDirectory as Any, + "fallbackFile" to fallbackFile as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = FrameworkAdapter( + key = map["key"] as String, + installCommand = map["installCommand"] as String, + buildCommand = map["buildCommand"] as String, + outputDirectory = map["outputDirectory"] as String, + fallbackFile = map["fallbackFile"] as String, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/FrameworkList.kt b/src/main/kotlin/io/appwrite/models/FrameworkList.kt new file mode 100644 index 0000000..41532c8 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/FrameworkList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Frameworks List + */ +data class FrameworkList( + /** + * Total number of frameworks documents that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of frameworks. + */ + @SerializedName("frameworks") + val frameworks: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "frameworks" to frameworks.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = FrameworkList( + total = (map["total"] as Number).toLong(), + frameworks = (map["frameworks"] as List>).map { Framework.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/Function.kt b/src/main/kotlin/io/appwrite/models/Function.kt index bb1b50e..f6c20e4 100644 --- a/src/main/kotlin/io/appwrite/models/Function.kt +++ b/src/main/kotlin/io/appwrite/models/Function.kt @@ -50,13 +50,13 @@ data class Function( val live: Boolean, /** - * Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project. + * When disabled, executions will exclude logs and errors, and will be slightly faster. */ @SerializedName("logging") val logging: Boolean, /** - * Function execution runtime. + * Function execution and build runtime. */ @SerializedName("runtime") val runtime: String, @@ -64,8 +64,32 @@ data class Function( /** * Function's active deployment ID. */ - @SerializedName("deployment") - val deployment: String, + @SerializedName("deploymentId") + val deploymentId: String, + + /** + * Active deployment creation date in ISO 8601 format. + */ + @SerializedName("deploymentCreatedAt") + val deploymentCreatedAt: String, + + /** + * Function's latest deployment ID. + */ + @SerializedName("latestDeploymentId") + val latestDeploymentId: String, + + /** + * Latest deployment creation date in ISO 8601 format. + */ + @SerializedName("latestDeploymentCreatedAt") + val latestDeploymentCreatedAt: String, + + /** + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + */ + @SerializedName("latestDeploymentStatus") + val latestDeploymentStatus: String, /** * Allowed permission scopes. @@ -162,7 +186,11 @@ data class Function( "live" to live as Any, "logging" to logging as Any, "runtime" to runtime as Any, - "deployment" to deployment as Any, + "deploymentId" to deploymentId as Any, + "deploymentCreatedAt" to deploymentCreatedAt as Any, + "latestDeploymentId" to latestDeploymentId as Any, + "latestDeploymentCreatedAt" to latestDeploymentCreatedAt as Any, + "latestDeploymentStatus" to latestDeploymentStatus as Any, "scopes" to scopes as Any, "vars" to vars.map { it.toMap() } as Any, "events" to events as Any, @@ -194,7 +222,11 @@ data class Function( live = map["live"] as Boolean, logging = map["logging"] as Boolean, runtime = map["runtime"] as String, - deployment = map["deployment"] as String, + deploymentId = map["deploymentId"] as String, + deploymentCreatedAt = map["deploymentCreatedAt"] as String, + latestDeploymentId = map["latestDeploymentId"] as String, + latestDeploymentCreatedAt = map["latestDeploymentCreatedAt"] as String, + latestDeploymentStatus = map["latestDeploymentStatus"] as String, scopes = map["scopes"] as List, vars = (map["vars"] as List>).map { Variable.from(map = it) }, events = map["events"] as List, diff --git a/src/main/kotlin/io/appwrite/models/Index.kt b/src/main/kotlin/io/appwrite/models/Index.kt index c45e25f..a368c13 100644 --- a/src/main/kotlin/io/appwrite/models/Index.kt +++ b/src/main/kotlin/io/appwrite/models/Index.kt @@ -37,6 +37,12 @@ data class Index( @SerializedName("attributes") val attributes: List, + /** + * Index attributes length. + */ + @SerializedName("lengths") + val lengths: List, + /** * Index orders. */ @@ -62,6 +68,7 @@ data class Index( "status" to status as Any, "error" to error as Any, "attributes" to attributes as Any, + "lengths" to lengths as Any, "orders" to orders as Any, "\$createdAt" to createdAt as Any, "\$updatedAt" to updatedAt as Any, @@ -78,6 +85,7 @@ data class Index( status = map["status"] as String, error = map["error"] as String, attributes = map["attributes"] as List, + lengths = map["lengths"] as List, orders = map["orders"] as? List?, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, diff --git a/src/main/kotlin/io/appwrite/models/ResourceToken.kt b/src/main/kotlin/io/appwrite/models/ResourceToken.kt new file mode 100644 index 0000000..06466a1 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/ResourceToken.kt @@ -0,0 +1,78 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * ResourceToken + */ +data class ResourceToken( + /** + * Token ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Token creation date in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Resource ID. + */ + @SerializedName("resourceId") + val resourceId: String, + + /** + * Resource type. + */ + @SerializedName("resourceType") + val resourceType: String, + + /** + * Token expiration date in ISO 8601 format. + */ + @SerializedName("expire") + val expire: String, + + /** + * JWT encoded string. + */ + @SerializedName("secret") + val secret: String, + + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + @SerializedName("accessedAt") + val accessedAt: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "resourceId" to resourceId as Any, + "resourceType" to resourceType as Any, + "expire" to expire as Any, + "secret" to secret as Any, + "accessedAt" to accessedAt as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = ResourceToken( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + resourceId = map["resourceId"] as String, + resourceType = map["resourceType"] as String, + expire = map["expire"] as String, + secret = map["secret"] as String, + accessedAt = map["accessedAt"] as String, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/ResourceTokenList.kt b/src/main/kotlin/io/appwrite/models/ResourceTokenList.kt new file mode 100644 index 0000000..bb9e6d7 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/ResourceTokenList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Resource Tokens List + */ +data class ResourceTokenList( + /** + * Total number of tokens documents that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of tokens. + */ + @SerializedName("tokens") + val tokens: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "tokens" to tokens.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = ResourceTokenList( + total = (map["total"] as Number).toLong(), + tokens = (map["tokens"] as List>).map { ResourceToken.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/Site.kt b/src/main/kotlin/io/appwrite/models/Site.kt new file mode 100644 index 0000000..d3de7b0 --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/Site.kt @@ -0,0 +1,254 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Site + */ +data class Site( + /** + * Site ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Site creation date in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Site update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Site name. + */ + @SerializedName("name") + val name: String, + + /** + * Site enabled. + */ + @SerializedName("enabled") + val enabled: Boolean, + + /** + * Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration. + */ + @SerializedName("live") + val live: Boolean, + + /** + * When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + */ + @SerializedName("logging") + val logging: Boolean, + + /** + * Site framework. + */ + @SerializedName("framework") + val framework: String, + + /** + * Site's active deployment ID. + */ + @SerializedName("deploymentId") + val deploymentId: String, + + /** + * Active deployment creation date in ISO 8601 format. + */ + @SerializedName("deploymentCreatedAt") + val deploymentCreatedAt: String, + + /** + * Screenshot of active deployment with light theme preference file ID. + */ + @SerializedName("deploymentScreenshotLight") + val deploymentScreenshotLight: String, + + /** + * Screenshot of active deployment with dark theme preference file ID. + */ + @SerializedName("deploymentScreenshotDark") + val deploymentScreenshotDark: String, + + /** + * Site's latest deployment ID. + */ + @SerializedName("latestDeploymentId") + val latestDeploymentId: String, + + /** + * Latest deployment creation date in ISO 8601 format. + */ + @SerializedName("latestDeploymentCreatedAt") + val latestDeploymentCreatedAt: String, + + /** + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + */ + @SerializedName("latestDeploymentStatus") + val latestDeploymentStatus: String, + + /** + * Site variables. + */ + @SerializedName("vars") + val vars: List, + + /** + * Site request timeout in seconds. + */ + @SerializedName("timeout") + val timeout: Long, + + /** + * The install command used to install the site dependencies. + */ + @SerializedName("installCommand") + val installCommand: String, + + /** + * The build command used to build the site. + */ + @SerializedName("buildCommand") + val buildCommand: String, + + /** + * The directory where the site build output is located. + */ + @SerializedName("outputDirectory") + val outputDirectory: String, + + /** + * Site VCS (Version Control System) installation id. + */ + @SerializedName("installationId") + val installationId: String, + + /** + * VCS (Version Control System) Repository ID + */ + @SerializedName("providerRepositoryId") + val providerRepositoryId: String, + + /** + * VCS (Version Control System) branch name + */ + @SerializedName("providerBranch") + val providerBranch: String, + + /** + * Path to site in VCS (Version Control System) repository + */ + @SerializedName("providerRootDirectory") + val providerRootDirectory: String, + + /** + * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + */ + @SerializedName("providerSilentMode") + val providerSilentMode: Boolean, + + /** + * Machine specification for builds and executions. + */ + @SerializedName("specification") + val specification: String, + + /** + * Site build runtime. + */ + @SerializedName("buildRuntime") + val buildRuntime: String, + + /** + * Site framework adapter. + */ + @SerializedName("adapter") + val adapter: String, + + /** + * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + */ + @SerializedName("fallbackFile") + val fallbackFile: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "name" to name as Any, + "enabled" to enabled as Any, + "live" to live as Any, + "logging" to logging as Any, + "framework" to framework as Any, + "deploymentId" to deploymentId as Any, + "deploymentCreatedAt" to deploymentCreatedAt as Any, + "deploymentScreenshotLight" to deploymentScreenshotLight as Any, + "deploymentScreenshotDark" to deploymentScreenshotDark as Any, + "latestDeploymentId" to latestDeploymentId as Any, + "latestDeploymentCreatedAt" to latestDeploymentCreatedAt as Any, + "latestDeploymentStatus" to latestDeploymentStatus as Any, + "vars" to vars.map { it.toMap() } as Any, + "timeout" to timeout as Any, + "installCommand" to installCommand as Any, + "buildCommand" to buildCommand as Any, + "outputDirectory" to outputDirectory as Any, + "installationId" to installationId as Any, + "providerRepositoryId" to providerRepositoryId as Any, + "providerBranch" to providerBranch as Any, + "providerRootDirectory" to providerRootDirectory as Any, + "providerSilentMode" to providerSilentMode as Any, + "specification" to specification as Any, + "buildRuntime" to buildRuntime as Any, + "adapter" to adapter as Any, + "fallbackFile" to fallbackFile as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Site( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + name = map["name"] as String, + enabled = map["enabled"] as Boolean, + live = map["live"] as Boolean, + logging = map["logging"] as Boolean, + framework = map["framework"] as String, + deploymentId = map["deploymentId"] as String, + deploymentCreatedAt = map["deploymentCreatedAt"] as String, + deploymentScreenshotLight = map["deploymentScreenshotLight"] as String, + deploymentScreenshotDark = map["deploymentScreenshotDark"] as String, + latestDeploymentId = map["latestDeploymentId"] as String, + latestDeploymentCreatedAt = map["latestDeploymentCreatedAt"] as String, + latestDeploymentStatus = map["latestDeploymentStatus"] as String, + vars = (map["vars"] as List>).map { Variable.from(map = it) }, + timeout = (map["timeout"] as Number).toLong(), + installCommand = map["installCommand"] as String, + buildCommand = map["buildCommand"] as String, + outputDirectory = map["outputDirectory"] as String, + installationId = map["installationId"] as String, + providerRepositoryId = map["providerRepositoryId"] as String, + providerBranch = map["providerBranch"] as String, + providerRootDirectory = map["providerRootDirectory"] as String, + providerSilentMode = map["providerSilentMode"] as Boolean, + specification = map["specification"] as String, + buildRuntime = map["buildRuntime"] as String, + adapter = map["adapter"] as String, + fallbackFile = map["fallbackFile"] as String, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/SiteList.kt b/src/main/kotlin/io/appwrite/models/SiteList.kt new file mode 100644 index 0000000..15ecc7f --- /dev/null +++ b/src/main/kotlin/io/appwrite/models/SiteList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Sites List + */ +data class SiteList( + /** + * Total number of sites documents that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of sites. + */ + @SerializedName("sites") + val sites: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "sites" to sites.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = SiteList( + total = (map["total"] as Number).toLong(), + sites = (map["sites"] as List>).map { Site.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/models/Variable.kt b/src/main/kotlin/io/appwrite/models/Variable.kt index 99a7696..47518f1 100644 --- a/src/main/kotlin/io/appwrite/models/Variable.kt +++ b/src/main/kotlin/io/appwrite/models/Variable.kt @@ -37,6 +37,12 @@ data class Variable( @SerializedName("value") val value: String, + /** + * Variable secret flag. Secret variables can only be updated or deleted, but never read. + */ + @SerializedName("secret") + val secret: Boolean, + /** * Service to which the variable belongs. Possible values are "project", "function" */ @@ -56,6 +62,7 @@ data class Variable( "\$updatedAt" to updatedAt as Any, "key" to key as Any, "value" to value as Any, + "secret" to secret as Any, "resourceType" to resourceType as Any, "resourceId" to resourceId as Any, ) @@ -71,6 +78,7 @@ data class Variable( updatedAt = map["\$updatedAt"] as String, key = map["key"] as String, value = map["value"] as String, + secret = map["secret"] as Boolean, resourceType = map["resourceType"] as String, resourceId = map["resourceId"] as String, ) diff --git a/src/main/kotlin/io/appwrite/services/Avatars.kt b/src/main/kotlin/io/appwrite/services/Avatars.kt index 1739600..e6f4673 100644 --- a/src/main/kotlin/io/appwrite/services/Avatars.kt +++ b/src/main/kotlin/io/appwrite/services/Avatars.kt @@ -21,7 +21,7 @@ class Avatars(client: Client) : Service(client) { * @param code Browser Code. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. * @param height Image height. Pass an integer between 0 to 2000. Defaults to 100. - * @param quality Image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @return [ByteArray] */ @JvmOverloads @@ -56,7 +56,7 @@ class Avatars(client: Client) : Service(client) { * @param code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. * @param height Image height. Pass an integer between 0 to 2000. Defaults to 100. - * @param quality Image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @return [ByteArray] */ @JvmOverloads @@ -116,7 +116,7 @@ class Avatars(client: Client) : Service(client) { * @param code Country Code. ISO Alpha-2 country code format. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. * @param height Image height. Pass an integer between 0 to 2000. Defaults to 100. - * @param quality Image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @return [ByteArray] */ @JvmOverloads diff --git a/src/main/kotlin/io/appwrite/services/Databases.kt b/src/main/kotlin/io/appwrite/services/Databases.kt index 32685cc..143e829 100644 --- a/src/main/kotlin/io/appwrite/services/Databases.kt +++ b/src/main/kotlin/io/appwrite/services/Databases.kt @@ -1589,6 +1589,250 @@ class Databases(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + @Throws(AppwriteException::class) + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + nestedType: Class, + ): io.appwrite.models.DocumentList { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + + val apiParams = mutableMapOf( + "documents" to documents, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + @Throws(AppwriteException::class) + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + ): io.appwrite.models.DocumentList> = createDocuments( + databaseId, + collectionId, + documents, + nestedType = classOf(), + ) + + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documents Array of document data as JSON objects. May contain partial documents. + * @return [io.appwrite.models.DocumentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun upsertDocuments( + databaseId: String, + collectionId: String, + documents: List? = null, + nestedType: Class, + ): io.appwrite.models.DocumentList { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + + val apiParams = mutableMapOf( + "documents" to documents, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documents Array of document data as JSON objects. May contain partial documents. + * @return [io.appwrite.models.DocumentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun upsertDocuments( + databaseId: String, + collectionId: String, + documents: List? = null, + ): io.appwrite.models.DocumentList> = upsertDocuments( + databaseId, + collectionId, + documents, + nestedType = classOf(), + ) + + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param data Document data as JSON object. Include only attribute and value pairs to be updated. + * @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. + * @return [io.appwrite.models.DocumentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateDocuments( + databaseId: String, + collectionId: String, + data: Any? = null, + queries: List? = null, + nestedType: Class, + ): io.appwrite.models.DocumentList { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + + val apiParams = mutableMapOf( + "data" to data, + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param data Document data as JSON object. Include only attribute and value pairs to be updated. + * @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. + * @return [io.appwrite.models.DocumentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateDocuments( + databaseId: String, + collectionId: String, + data: Any? = null, + queries: List? = null, + ): io.appwrite.models.DocumentList> = updateDocuments( + databaseId, + collectionId, + data, + queries, + nestedType = classOf(), + ) + + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.DocumentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteDocuments( + databaseId: String, + collectionId: String, + queries: List? = null, + nestedType: Class, + ): io.appwrite.models.DocumentList { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.DocumentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteDocuments( + databaseId: String, + collectionId: String, + queries: List? = null, + ): io.appwrite.models.DocumentList> = deleteDocuments( + databaseId, + collectionId, + queries, + nestedType = classOf(), + ) + /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -1805,6 +2049,7 @@ class Databases(client: Client) : Service(client) { * @param type Index type. * @param attributes Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. * @param orders Array of index orders. Maximum of 100 orders are allowed. + * @param lengths Length of index. Maximum of 100 * @return [io.appwrite.models.Index] */ @JvmOverloads @@ -1816,6 +2061,7 @@ class Databases(client: Client) : Service(client) { type: io.appwrite.enums.IndexType, attributes: List, orders: List? = null, + lengths: List? = null, ): io.appwrite.models.Index { val apiPath = "/databases/{databaseId}/collections/{collectionId}/indexes" .replace("{databaseId}", databaseId) @@ -1826,6 +2072,7 @@ class Databases(client: Client) : Service(client) { "type" to type, "attributes" to attributes, "orders" to orders, + "lengths" to lengths, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", diff --git a/src/main/kotlin/io/appwrite/services/Functions.kt b/src/main/kotlin/io/appwrite/services/Functions.kt index 124d410..8e09dc9 100644 --- a/src/main/kotlin/io/appwrite/services/Functions.kt +++ b/src/main/kotlin/io/appwrite/services/Functions.kt @@ -18,7 +18,7 @@ class Functions(client: Client) : Service(client) { /** * Get a list of all the project's functions. You can use the query params to filter your results. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.FunctionList] */ @@ -60,7 +60,7 @@ class Functions(client: Client) : Service(client) { * @param schedule Schedule CRON syntax. * @param timeout Function maximum execution time in seconds. * @param enabled Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. - * @param logging Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project. + * @param logging When disabled, executions will exclude logs and errors, and will be slightly faster. * @param entrypoint Entrypoint File. This path is relative to the "providerRootDirectory". * @param commands Build Commands. * @param scopes List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. @@ -69,10 +69,6 @@ class Functions(client: Client) : Service(client) { * @param providerBranch Production branch for the repo linked to the function. * @param providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param providerRootDirectory Path to function code in the linked repo. - * @param templateRepository Repository name of the template. - * @param templateOwner The name of the owner of the template. - * @param templateRootDirectory Path to function code in the template repo. - * @param templateVersion Version (tag) for the repo linked to the function template. * @param specification Runtime specification for the function and builds. * @return [io.appwrite.models.Function] */ @@ -96,10 +92,6 @@ class Functions(client: Client) : Service(client) { providerBranch: String? = null, providerSilentMode: Boolean? = null, providerRootDirectory: String? = null, - templateRepository: String? = null, - templateOwner: String? = null, - templateRootDirectory: String? = null, - templateVersion: String? = null, specification: String? = null, ): io.appwrite.models.Function { val apiPath = "/functions" @@ -122,10 +114,6 @@ class Functions(client: Client) : Service(client) { "providerBranch" to providerBranch, "providerSilentMode" to providerSilentMode, "providerRootDirectory" to providerRootDirectory, - "templateRepository" to templateRepository, - "templateOwner" to templateOwner, - "templateRootDirectory" to templateRootDirectory, - "templateVersion" to templateVersion, "specification" to specification, ) val apiHeaders = mutableMapOf( @@ -239,7 +227,7 @@ class Functions(client: Client) : Service(client) { * @param schedule Schedule CRON syntax. * @param timeout Maximum execution time in seconds. * @param enabled Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. - * @param logging Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project. + * @param logging When disabled, executions will exclude logs and errors, and will be slightly faster. * @param entrypoint Entrypoint File. This path is relative to the "providerRootDirectory". * @param commands Build Commands. * @param scopes List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. @@ -339,10 +327,44 @@ class Functions(client: Client) : Service(client) { } /** - * Get a list of all the project's code deployments. You can use the query params to filter your results. + * Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. * * @param functionId Function 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. You may filter on the following attributes: size, buildId, activate, entrypoint, commands, type, size + * @param deploymentId Deployment ID. + * @return [io.appwrite.models.Function] + */ + @Throws(AppwriteException::class) + suspend fun updateFunctionDeployment( + functionId: String, + deploymentId: String, + ): io.appwrite.models.Function { + val apiPath = "/functions/{functionId}/deployment" + .replace("{functionId}", functionId) + + val apiParams = mutableMapOf( + "deploymentId" to deploymentId, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Function = { + io.appwrite.models.Function.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Function::class.java, + converter, + ) + } + + /** + * Get a list of all the function's code deployments. You can use the query params to filter your results. + * + * @param functionId Function 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. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.DeploymentList] */ @@ -425,30 +447,35 @@ class Functions(client: Client) : Service(client) { } /** - * Get a code deployment by its unique ID. + * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. * * @param functionId Function ID. * @param deploymentId Deployment ID. + * @param buildId Build unique ID. * @return [io.appwrite.models.Deployment] */ + @JvmOverloads @Throws(AppwriteException::class) - suspend fun getDeployment( + suspend fun createDuplicateDeployment( functionId: String, deploymentId: String, + buildId: String? = null, ): io.appwrite.models.Deployment { - val apiPath = "/functions/{functionId}/deployments/{deploymentId}" + val apiPath = "/functions/{functionId}/deployments/duplicate" .replace("{functionId}", functionId) - .replace("{deploymentId}", deploymentId) val apiParams = mutableMapOf( + "deploymentId" to deploymentId, + "buildId" to buildId, ) val apiHeaders = mutableMapOf( + "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Deployment = { io.appwrite.models.Deployment.from(map = it as Map) } return client.call( - "GET", + "POST", apiPath, apiHeaders, apiParams, @@ -458,116 +485,139 @@ class Functions(client: Client) : Service(client) { } /** - * Update the function code deployment ID using the unique function ID. Use this endpoint to switch the code deployment that should be executed by the execution endpoint. + * Create a deployment based on a template.Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details. * * @param functionId Function ID. - * @param deploymentId Deployment ID. - * @return [io.appwrite.models.Function] + * @param repository Repository name of the template. + * @param owner The name of the owner of the template. + * @param rootDirectory Path to function code in the template repo. + * @param version Version (tag) for the repo linked to the function template. + * @param activate Automatically activate the deployment when it is finished building. + * @return [io.appwrite.models.Deployment] */ + @JvmOverloads @Throws(AppwriteException::class) - suspend fun updateDeployment( + suspend fun createTemplateDeployment( functionId: String, - deploymentId: String, - ): io.appwrite.models.Function { - val apiPath = "/functions/{functionId}/deployments/{deploymentId}" + repository: String, + owner: String, + rootDirectory: String, + version: String, + activate: Boolean? = null, + ): io.appwrite.models.Deployment { + val apiPath = "/functions/{functionId}/deployments/template" .replace("{functionId}", functionId) - .replace("{deploymentId}", deploymentId) val apiParams = mutableMapOf( + "repository" to repository, + "owner" to owner, + "rootDirectory" to rootDirectory, + "version" to version, + "activate" to activate, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Function = { - io.appwrite.models.Function.from(map = it as Map) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) } return client.call( - "PATCH", + "POST", apiPath, apiHeaders, apiParams, - responseType = io.appwrite.models.Function::class.java, + responseType = io.appwrite.models.Deployment::class.java, converter, ) } /** - * Delete a code deployment by its unique ID. + * Create a deployment when a function is connected to VCS.This endpoint lets you create deployment from a branch, commit, or a tag. * * @param functionId Function ID. - * @param deploymentId Deployment ID. - * @return [Any] + * @param type Type of reference passed. Allowed values are: branch, commit + * @param reference VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param activate Automatically activate the deployment when it is finished building. + * @return [io.appwrite.models.Deployment] */ + @JvmOverloads @Throws(AppwriteException::class) - suspend fun deleteDeployment( + suspend fun createVcsDeployment( functionId: String, - deploymentId: String, - ): Any { - val apiPath = "/functions/{functionId}/deployments/{deploymentId}" + type: io.appwrite.enums.VCSDeploymentType, + reference: String, + activate: Boolean? = null, + ): io.appwrite.models.Deployment { + val apiPath = "/functions/{functionId}/deployments/vcs" .replace("{functionId}", functionId) - .replace("{deploymentId}", deploymentId) val apiParams = mutableMapOf( + "type" to type, + "reference" to reference, + "activate" to activate, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", ) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) + } return client.call( - "DELETE", + "POST", apiPath, apiHeaders, apiParams, - responseType = Any::class.java, + responseType = io.appwrite.models.Deployment::class.java, + converter, ) } /** - * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * Get a function deployment by its unique ID. * * @param functionId Function ID. * @param deploymentId Deployment ID. - * @param buildId Build unique ID. - * @return [Any] + * @return [io.appwrite.models.Deployment] */ - @JvmOverloads @Throws(AppwriteException::class) - suspend fun createBuild( + suspend fun getDeployment( functionId: String, deploymentId: String, - buildId: String? = null, - ): Any { - val apiPath = "/functions/{functionId}/deployments/{deploymentId}/build" + ): io.appwrite.models.Deployment { + val apiPath = "/functions/{functionId}/deployments/{deploymentId}" .replace("{functionId}", functionId) .replace("{deploymentId}", deploymentId) val apiParams = mutableMapOf( - "buildId" to buildId, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) + } return client.call( - "POST", + "GET", apiPath, apiHeaders, apiParams, - responseType = Any::class.java, + responseType = io.appwrite.models.Deployment::class.java, + converter, ) } /** - * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * Delete a code deployment by its unique ID. * * @param functionId Function ID. * @param deploymentId Deployment ID. - * @return [io.appwrite.models.Build] + * @return [Any] */ @Throws(AppwriteException::class) - suspend fun updateDeploymentBuild( + suspend fun deleteDeployment( functionId: String, deploymentId: String, - ): io.appwrite.models.Build { - val apiPath = "/functions/{functionId}/deployments/{deploymentId}/build" + ): Any { + val apiPath = "/functions/{functionId}/deployments/{deploymentId}" .replace("{functionId}", functionId) .replace("{deploymentId}", deploymentId) @@ -576,36 +626,36 @@ class Functions(client: Client) : Service(client) { val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Build = { - io.appwrite.models.Build.from(map = it as Map) - } return client.call( - "PATCH", + "DELETE", apiPath, apiHeaders, apiParams, - responseType = io.appwrite.models.Build::class.java, - converter, + responseType = Any::class.java, ) } /** - * Get a Deployment's contents by its unique ID. This endpoint supports range requests for partial or streaming file download. + * Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * * @param functionId Function ID. * @param deploymentId Deployment ID. + * @param type Deployment file to download. Can be: "source", "output". * @return [ByteArray] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun getDeploymentDownload( functionId: String, deploymentId: String, + type: io.appwrite.enums.DeploymentDownloadType? = null, ): ByteArray { val apiPath = "/functions/{functionId}/deployments/{deploymentId}/download" .replace("{functionId}", functionId) .replace("{deploymentId}", deploymentId) val apiParams = mutableMapOf( + "type" to type, ) val apiHeaders = mutableMapOf( ) @@ -617,12 +667,45 @@ class Functions(client: Client) : Service(client) { ) } + /** + * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * + * @param functionId Function ID. + * @param deploymentId Deployment ID. + * @return [io.appwrite.models.Deployment] + */ + @Throws(AppwriteException::class) + suspend fun updateDeploymentStatus( + functionId: String, + deploymentId: String, + ): io.appwrite.models.Deployment { + val apiPath = "/functions/{functionId}/deployments/{deploymentId}/status" + .replace("{functionId}", functionId) + .replace("{deploymentId}", deploymentId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Deployment::class.java, + converter, + ) + } + /** * Get a list of all the current user function execution logs. You can use the query params to filter your results. * * @param functionId Function 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. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId - * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads @@ -630,14 +713,12 @@ class Functions(client: Client) : Service(client) { suspend fun listExecutions( functionId: String, queries: List? = null, - search: String? = null, ): io.appwrite.models.ExecutionList { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val apiParams = mutableMapOf( "queries" to queries, - "search" to search, ) val apiHeaders = mutableMapOf( ) @@ -803,13 +884,16 @@ class Functions(client: Client) : Service(client) { * @param functionId Function unique ID. * @param key Variable key. Max length: 255 chars. * @param value Variable value. Max length: 8192 chars. + * @param secret Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @return [io.appwrite.models.Variable] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun createVariable( functionId: String, key: String, value: String, + secret: Boolean? = null, ): io.appwrite.models.Variable { val apiPath = "/functions/{functionId}/variables" .replace("{functionId}", functionId) @@ -817,6 +901,7 @@ class Functions(client: Client) : Service(client) { val apiParams = mutableMapOf( "key" to key, "value" to value, + "secret" to secret, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -874,6 +959,7 @@ class Functions(client: Client) : Service(client) { * @param variableId Variable unique ID. * @param key Variable key. Max length: 255 chars. * @param value Variable value. Max length: 8192 chars. + * @param secret Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @return [io.appwrite.models.Variable] */ @JvmOverloads @@ -883,6 +969,7 @@ class Functions(client: Client) : Service(client) { variableId: String, key: String, value: String? = null, + secret: Boolean? = null, ): io.appwrite.models.Variable { val apiPath = "/functions/{functionId}/variables/{variableId}" .replace("{functionId}", functionId) @@ -891,6 +978,7 @@ class Functions(client: Client) : Service(client) { val apiParams = mutableMapOf( "key" to key, "value" to value, + "secret" to secret, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", diff --git a/src/main/kotlin/io/appwrite/services/Sites.kt b/src/main/kotlin/io/appwrite/services/Sites.kt new file mode 100644 index 0000000..07aff05 --- /dev/null +++ b/src/main/kotlin/io/appwrite/services/Sites.kt @@ -0,0 +1,978 @@ +package io.appwrite.services + +import io.appwrite.Client +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrl +import java.io.File + +/** + * The Sites Service allows you view, create and manage your web applications. +**/ +class Sites(client: Client) : Service(client) { + + /** + * Get a list of all the project's sites. You can use the query params to filter your results. + * + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, framework, deploymentId, buildCommand, installCommand, outputDirectory, installationId + * @param search Search term to filter your list results. Max length: 256 chars. + * @return [io.appwrite.models.SiteList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun list( + queries: List? = null, + search: String? = null, + ): io.appwrite.models.SiteList { + val apiPath = "/sites" + + val apiParams = mutableMapOf( + "queries" to queries, + "search" to search, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.SiteList = { + io.appwrite.models.SiteList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.SiteList::class.java, + converter, + ) + } + + /** + * Create a new site. + * + * @param siteId Site 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 Site name. Max length: 128 chars. + * @param framework Sites framework. + * @param buildRuntime Runtime to use during build step. + * @param enabled Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param logging When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param timeout Maximum request time in seconds. + * @param installCommand Install Command. + * @param buildCommand Build Command. + * @param outputDirectory Output Directory for site. + * @param adapter Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param installationId Appwrite Installation ID for VCS (Version Control System) deployment. + * @param fallbackFile Fallback file for single page application sites. + * @param providerRepositoryId Repository ID of the repo linked to the site. + * @param providerBranch Production branch for the repo linked to the site. + * @param providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param providerRootDirectory Path to site code in the linked repo. + * @param specification Framework specification for the site and builds. + * @return [io.appwrite.models.Site] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun create( + siteId: String, + name: String, + framework: io.appwrite.enums.Framework, + buildRuntime: io.appwrite.enums.BuildRuntime, + enabled: Boolean? = null, + logging: Boolean? = null, + timeout: Long? = null, + installCommand: String? = null, + buildCommand: String? = null, + outputDirectory: String? = null, + adapter: io.appwrite.enums.Adapter? = null, + installationId: String? = null, + fallbackFile: String? = null, + providerRepositoryId: String? = null, + providerBranch: String? = null, + providerSilentMode: Boolean? = null, + providerRootDirectory: String? = null, + specification: String? = null, + ): io.appwrite.models.Site { + val apiPath = "/sites" + + val apiParams = mutableMapOf( + "siteId" to siteId, + "name" to name, + "framework" to framework, + "enabled" to enabled, + "logging" to logging, + "timeout" to timeout, + "installCommand" to installCommand, + "buildCommand" to buildCommand, + "outputDirectory" to outputDirectory, + "buildRuntime" to buildRuntime, + "adapter" to adapter, + "installationId" to installationId, + "fallbackFile" to fallbackFile, + "providerRepositoryId" to providerRepositoryId, + "providerBranch" to providerBranch, + "providerSilentMode" to providerSilentMode, + "providerRootDirectory" to providerRootDirectory, + "specification" to specification, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Site = { + io.appwrite.models.Site.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Site::class.java, + converter, + ) + } + + /** + * Get a list of all frameworks that are currently available on the server instance. + * + * @return [io.appwrite.models.FrameworkList] + */ + @Throws(AppwriteException::class) + suspend fun listFrameworks( + ): io.appwrite.models.FrameworkList { + val apiPath = "/sites/frameworks" + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.FrameworkList = { + io.appwrite.models.FrameworkList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.FrameworkList::class.java, + converter, + ) + } + + /** + * List allowed site specifications for this instance. + * + * @return [io.appwrite.models.SpecificationList] + */ + @Throws(AppwriteException::class) + suspend fun listSpecifications( + ): io.appwrite.models.SpecificationList { + val apiPath = "/sites/specifications" + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.SpecificationList = { + io.appwrite.models.SpecificationList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.SpecificationList::class.java, + converter, + ) + } + + /** + * Get a site by its unique ID. + * + * @param siteId Site ID. + * @return [io.appwrite.models.Site] + */ + @Throws(AppwriteException::class) + suspend fun get( + siteId: String, + ): io.appwrite.models.Site { + val apiPath = "/sites/{siteId}" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Site = { + io.appwrite.models.Site.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Site::class.java, + converter, + ) + } + + /** + * Update site by its unique ID. + * + * @param siteId Site ID. + * @param name Site name. Max length: 128 chars. + * @param framework Sites framework. + * @param enabled Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param logging When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param timeout Maximum request time in seconds. + * @param installCommand Install Command. + * @param buildCommand Build Command. + * @param outputDirectory Output Directory for site. + * @param buildRuntime Runtime to use during build step. + * @param adapter Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param fallbackFile Fallback file for single page application sites. + * @param installationId Appwrite Installation ID for VCS (Version Control System) deployment. + * @param providerRepositoryId Repository ID of the repo linked to the site. + * @param providerBranch Production branch for the repo linked to the site. + * @param providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param providerRootDirectory Path to site code in the linked repo. + * @param specification Framework specification for the site and builds. + * @return [io.appwrite.models.Site] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun update( + siteId: String, + name: String, + framework: io.appwrite.enums.Framework, + enabled: Boolean? = null, + logging: Boolean? = null, + timeout: Long? = null, + installCommand: String? = null, + buildCommand: String? = null, + outputDirectory: String? = null, + buildRuntime: io.appwrite.enums.BuildRuntime? = null, + adapter: io.appwrite.enums.Adapter? = null, + fallbackFile: String? = null, + installationId: String? = null, + providerRepositoryId: String? = null, + providerBranch: String? = null, + providerSilentMode: Boolean? = null, + providerRootDirectory: String? = null, + specification: String? = null, + ): io.appwrite.models.Site { + val apiPath = "/sites/{siteId}" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + "name" to name, + "framework" to framework, + "enabled" to enabled, + "logging" to logging, + "timeout" to timeout, + "installCommand" to installCommand, + "buildCommand" to buildCommand, + "outputDirectory" to outputDirectory, + "buildRuntime" to buildRuntime, + "adapter" to adapter, + "fallbackFile" to fallbackFile, + "installationId" to installationId, + "providerRepositoryId" to providerRepositoryId, + "providerBranch" to providerBranch, + "providerSilentMode" to providerSilentMode, + "providerRootDirectory" to providerRootDirectory, + "specification" to specification, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Site = { + io.appwrite.models.Site.from(map = it as Map) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Site::class.java, + converter, + ) + } + + /** + * Delete a site by its unique ID. + * + * @param siteId Site ID. + * @return [Any] + */ + @Throws(AppwriteException::class) + suspend fun delete( + siteId: String, + ): Any { + val apiPath = "/sites/{siteId}" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + /** + * Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. + * + * @param siteId Site ID. + * @param deploymentId Deployment ID. + * @return [io.appwrite.models.Site] + */ + @Throws(AppwriteException::class) + suspend fun updateSiteDeployment( + siteId: String, + deploymentId: String, + ): io.appwrite.models.Site { + val apiPath = "/sites/{siteId}/deployment" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + "deploymentId" to deploymentId, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Site = { + io.appwrite.models.Site.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Site::class.java, + converter, + ) + } + + /** + * Get a list of all the site's code deployments. You can use the query params to filter your results. + * + * @param siteId Site 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. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + * @param search Search term to filter your list results. Max length: 256 chars. + * @return [io.appwrite.models.DeploymentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listDeployments( + siteId: String, + queries: List? = null, + search: String? = null, + ): io.appwrite.models.DeploymentList { + val apiPath = "/sites/{siteId}/deployments" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + "queries" to queries, + "search" to search, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.DeploymentList = { + io.appwrite.models.DeploymentList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.DeploymentList::class.java, + converter, + ) + } + + /** + * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the function's deployment to use your new deployment ID. + * + * @param siteId Site ID. + * @param code Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + * @param activate Automatically activate the deployment when it is finished building. + * @param installCommand Install Commands. + * @param buildCommand Build Commands. + * @param outputDirectory Output Directory. + * @return [io.appwrite.models.Deployment] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createDeployment( + siteId: String, + code: InputFile, + activate: Boolean, + installCommand: String? = null, + buildCommand: String? = null, + outputDirectory: String? = null, + onProgress: ((UploadProgress) -> Unit)? = null + ): io.appwrite.models.Deployment { + val apiPath = "/sites/{siteId}/deployments" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + "installCommand" to installCommand, + "buildCommand" to buildCommand, + "outputDirectory" to outputDirectory, + "code" to code, + "activate" to activate, + ) + val apiHeaders = mutableMapOf( + "content-type" to "multipart/form-data", + ) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) + } + val idParamName: String? = null + val paramName = "code" + return client.chunkedUpload( + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Deployment::class.java, + converter, + paramName, + idParamName, + onProgress, + ) + } + + /** + * Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * + * @param siteId Site ID. + * @param deploymentId Deployment ID. + * @return [io.appwrite.models.Deployment] + */ + @Throws(AppwriteException::class) + suspend fun createDuplicateDeployment( + siteId: String, + deploymentId: String, + ): io.appwrite.models.Deployment { + val apiPath = "/sites/{siteId}/deployments/duplicate" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + "deploymentId" to deploymentId, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Deployment::class.java, + converter, + ) + } + + /** + * Create a deployment based on a template.Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details. + * + * @param siteId Site ID. + * @param repository Repository name of the template. + * @param owner The name of the owner of the template. + * @param rootDirectory Path to site code in the template repo. + * @param version Version (tag) for the repo linked to the site template. + * @param activate Automatically activate the deployment when it is finished building. + * @return [io.appwrite.models.Deployment] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createTemplateDeployment( + siteId: String, + repository: String, + owner: String, + rootDirectory: String, + version: String, + activate: Boolean? = null, + ): io.appwrite.models.Deployment { + val apiPath = "/sites/{siteId}/deployments/template" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + "repository" to repository, + "owner" to owner, + "rootDirectory" to rootDirectory, + "version" to version, + "activate" to activate, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Deployment::class.java, + converter, + ) + } + + /** + * Create a deployment when a site is connected to VCS.This endpoint lets you create deployment from a branch, commit, or a tag. + * + * @param siteId Site ID. + * @param type Type of reference passed. Allowed values are: branch, commit + * @param reference VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param activate Automatically activate the deployment when it is finished building. + * @return [io.appwrite.models.Deployment] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createVcsDeployment( + siteId: String, + type: io.appwrite.enums.VCSDeploymentType, + reference: String, + activate: Boolean? = null, + ): io.appwrite.models.Deployment { + val apiPath = "/sites/{siteId}/deployments/vcs" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + "type" to type, + "reference" to reference, + "activate" to activate, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Deployment::class.java, + converter, + ) + } + + /** + * Get a site deployment by its unique ID. + * + * @param siteId Site ID. + * @param deploymentId Deployment ID. + * @return [io.appwrite.models.Deployment] + */ + @Throws(AppwriteException::class) + suspend fun getDeployment( + siteId: String, + deploymentId: String, + ): io.appwrite.models.Deployment { + val apiPath = "/sites/{siteId}/deployments/{deploymentId}" + .replace("{siteId}", siteId) + .replace("{deploymentId}", deploymentId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Deployment::class.java, + converter, + ) + } + + /** + * Delete a site deployment by its unique ID. + * + * @param siteId Site ID. + * @param deploymentId Deployment ID. + * @return [Any] + */ + @Throws(AppwriteException::class) + suspend fun deleteDeployment( + siteId: String, + deploymentId: String, + ): Any { + val apiPath = "/sites/{siteId}/deployments/{deploymentId}" + .replace("{siteId}", siteId) + .replace("{deploymentId}", deploymentId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + /** + * Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. + * + * @param siteId Site ID. + * @param deploymentId Deployment ID. + * @param type Deployment file to download. Can be: "source", "output". + * @return [ByteArray] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getDeploymentDownload( + siteId: String, + deploymentId: String, + type: io.appwrite.enums.DeploymentDownloadType? = null, + ): ByteArray { + val apiPath = "/sites/{siteId}/deployments/{deploymentId}/download" + .replace("{siteId}", siteId) + .replace("{deploymentId}", deploymentId) + + val apiParams = mutableMapOf( + "type" to type, + ) + val apiHeaders = mutableMapOf( + ) + return client.call( + "GET", + apiPath, + params = apiParams, + responseType = ByteArray::class.java + ) + } + + /** + * Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * + * @param siteId Site ID. + * @param deploymentId Deployment ID. + * @return [io.appwrite.models.Deployment] + */ + @Throws(AppwriteException::class) + suspend fun updateDeploymentStatus( + siteId: String, + deploymentId: String, + ): io.appwrite.models.Deployment { + val apiPath = "/sites/{siteId}/deployments/{deploymentId}/status" + .replace("{siteId}", siteId) + .replace("{deploymentId}", deploymentId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Deployment = { + io.appwrite.models.Deployment.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Deployment::class.java, + converter, + ) + } + + /** + * Get a list of all site logs. You can use the query params to filter your results. + * + * @param siteId Site 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. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + * @return [io.appwrite.models.ExecutionList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listLogs( + siteId: String, + queries: List? = null, + ): io.appwrite.models.ExecutionList { + val apiPath = "/sites/{siteId}/logs" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.ExecutionList = { + io.appwrite.models.ExecutionList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.ExecutionList::class.java, + converter, + ) + } + + /** + * Get a site request log by its unique ID. + * + * @param siteId Site ID. + * @param logId Log ID. + * @return [io.appwrite.models.Execution] + */ + @Throws(AppwriteException::class) + suspend fun getLog( + siteId: String, + logId: String, + ): io.appwrite.models.Execution { + val apiPath = "/sites/{siteId}/logs/{logId}" + .replace("{siteId}", siteId) + .replace("{logId}", logId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Execution = { + io.appwrite.models.Execution.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Execution::class.java, + converter, + ) + } + + /** + * Delete a site log by its unique ID. + * + * @param siteId Site ID. + * @param logId Log ID. + * @return [Any] + */ + @Throws(AppwriteException::class) + suspend fun deleteLog( + siteId: String, + logId: String, + ): Any { + val apiPath = "/sites/{siteId}/logs/{logId}" + .replace("{siteId}", siteId) + .replace("{logId}", logId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + /** + * Get a list of all variables of a specific site. + * + * @param siteId Site unique ID. + * @return [io.appwrite.models.VariableList] + */ + @Throws(AppwriteException::class) + suspend fun listVariables( + siteId: String, + ): io.appwrite.models.VariableList { + val apiPath = "/sites/{siteId}/variables" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.VariableList = { + io.appwrite.models.VariableList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.VariableList::class.java, + converter, + ) + } + + /** + * Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. + * + * @param siteId Site unique ID. + * @param key Variable key. Max length: 255 chars. + * @param value Variable value. Max length: 8192 chars. + * @param secret Secret variables can be updated or deleted, but only sites can read them during build and runtime. + * @return [io.appwrite.models.Variable] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createVariable( + siteId: String, + key: String, + value: String, + secret: Boolean? = null, + ): io.appwrite.models.Variable { + val apiPath = "/sites/{siteId}/variables" + .replace("{siteId}", siteId) + + val apiParams = mutableMapOf( + "key" to key, + "value" to value, + "secret" to secret, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Variable = { + io.appwrite.models.Variable.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Variable::class.java, + converter, + ) + } + + /** + * Get a variable by its unique ID. + * + * @param siteId Site unique ID. + * @param variableId Variable unique ID. + * @return [io.appwrite.models.Variable] + */ + @Throws(AppwriteException::class) + suspend fun getVariable( + siteId: String, + variableId: String, + ): io.appwrite.models.Variable { + val apiPath = "/sites/{siteId}/variables/{variableId}" + .replace("{siteId}", siteId) + .replace("{variableId}", variableId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Variable = { + io.appwrite.models.Variable.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Variable::class.java, + converter, + ) + } + + /** + * Update variable by its unique ID. + * + * @param siteId Site unique ID. + * @param variableId Variable unique ID. + * @param key Variable key. Max length: 255 chars. + * @param value Variable value. Max length: 8192 chars. + * @param secret Secret variables can be updated or deleted, but only sites can read them during build and runtime. + * @return [io.appwrite.models.Variable] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateVariable( + siteId: String, + variableId: String, + key: String, + value: String? = null, + secret: Boolean? = null, + ): io.appwrite.models.Variable { + val apiPath = "/sites/{siteId}/variables/{variableId}" + .replace("{siteId}", siteId) + .replace("{variableId}", variableId) + + val apiParams = mutableMapOf( + "key" to key, + "value" to value, + "secret" to secret, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Variable = { + io.appwrite.models.Variable.from(map = it as Map) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Variable::class.java, + converter, + ) + } + + /** + * Delete a variable by its unique ID. + * + * @param siteId Site unique ID. + * @param variableId Variable unique ID. + * @return [Any] + */ + @Throws(AppwriteException::class) + suspend fun deleteVariable( + siteId: String, + variableId: String, + ): Any { + val apiPath = "/sites/{siteId}/variables/{variableId}" + .replace("{siteId}", siteId) + .replace("{variableId}", variableId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/services/Storage.kt b/src/main/kotlin/io/appwrite/services/Storage.kt index 825e9f4..f319359 100644 --- a/src/main/kotlin/io/appwrite/services/Storage.kt +++ b/src/main/kotlin/io/appwrite/services/Storage.kt @@ -416,18 +416,22 @@ class Storage(client: Client) : Service(client) { * * @param bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. + * @param token File token for accessing this file. * @return [ByteArray] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileDownload( bucketId: String, fileId: String, + token: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/download" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( + "token" to token, ) val apiHeaders = mutableMapOf( ) @@ -447,7 +451,7 @@ class Storage(client: Client) : Service(client) { * @param width Resize preview image width, Pass an integer between 0 to 4000. * @param height Resize preview image height, Pass an integer between 0 to 4000. * @param gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right - * @param quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param quality Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @param borderWidth Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. * @param borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix. * @param borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000. @@ -455,6 +459,7 @@ class Storage(client: Client) : Service(client) { * @param rotation Preview image rotation in degrees. Pass an integer between -360 and 360. * @param background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. * @param output Output format type (jpeg, jpg, png, gif and webp). + * @param token File token for accessing this file. * @return [ByteArray] */ @JvmOverloads @@ -473,6 +478,7 @@ class Storage(client: Client) : Service(client) { rotation: Long? = null, background: String? = null, output: io.appwrite.enums.ImageFormat? = null, + token: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) @@ -490,6 +496,7 @@ class Storage(client: Client) : Service(client) { "rotation" to rotation, "background" to background, "output" to output, + "token" to token, ) val apiHeaders = mutableMapOf( ) @@ -506,18 +513,22 @@ class Storage(client: Client) : Service(client) { * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. + * @param token File token for accessing this file. * @return [ByteArray] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileView( bucketId: String, fileId: String, + token: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/view" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( + "token" to token, ) val apiHeaders = mutableMapOf( ) diff --git a/src/main/kotlin/io/appwrite/services/Teams.kt b/src/main/kotlin/io/appwrite/services/Teams.kt index 4762622..9d601ab 100644 --- a/src/main/kotlin/io/appwrite/services/Teams.kt +++ b/src/main/kotlin/io/appwrite/services/Teams.kt @@ -254,7 +254,7 @@ class Teams(client: Client) : Service(client) { * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @param teamId Team 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. You may filter on the following attributes: userId, teamId, invited, joined, confirm + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.MembershipList] */ diff --git a/src/main/kotlin/io/appwrite/services/Tokens.kt b/src/main/kotlin/io/appwrite/services/Tokens.kt new file mode 100644 index 0000000..059595a --- /dev/null +++ b/src/main/kotlin/io/appwrite/services/Tokens.kt @@ -0,0 +1,183 @@ +package io.appwrite.services + +import io.appwrite.Client +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * +**/ +class Tokens(client: Client) : Service(client) { + + /** + * List all the tokens created for a specific file or bucket. You can use the query params to filter your results. + * + * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param fileId File 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. You may filter on the following attributes: expire + * @return [io.appwrite.models.ResourceTokenList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun list( + bucketId: String, + fileId: String, + queries: List? = null, + ): io.appwrite.models.ResourceTokenList { + val apiPath = "/tokens/buckets/{bucketId}/files/{fileId}" + .replace("{bucketId}", bucketId) + .replace("{fileId}", fileId) + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.ResourceTokenList = { + io.appwrite.models.ResourceTokenList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.ResourceTokenList::class.java, + converter, + ) + } + + /** + * Create a new token. A token is linked to a file. Token can be passed as a header or request get parameter. + * + * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param fileId File unique ID. + * @param expire Token expiry date + * @return [io.appwrite.models.ResourceToken] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createFileToken( + bucketId: String, + fileId: String, + expire: String? = null, + ): io.appwrite.models.ResourceToken { + val apiPath = "/tokens/buckets/{bucketId}/files/{fileId}" + .replace("{bucketId}", bucketId) + .replace("{fileId}", fileId) + + val apiParams = mutableMapOf( + "expire" to expire, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.ResourceToken = { + io.appwrite.models.ResourceToken.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.ResourceToken::class.java, + converter, + ) + } + + /** + * Get a token by its unique ID. + * + * @param tokenId Token ID. + * @return [io.appwrite.models.ResourceToken] + */ + @Throws(AppwriteException::class) + suspend fun get( + tokenId: String, + ): io.appwrite.models.ResourceToken { + val apiPath = "/tokens/{tokenId}" + .replace("{tokenId}", tokenId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.ResourceToken = { + io.appwrite.models.ResourceToken.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.ResourceToken::class.java, + converter, + ) + } + + /** + * Update a token by its unique ID. Use this endpoint to update a token's expiry date. + * + * @param tokenId Token unique ID. + * @param expire File token expiry date + * @return [io.appwrite.models.ResourceToken] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun update( + tokenId: String, + expire: String? = null, + ): io.appwrite.models.ResourceToken { + val apiPath = "/tokens/{tokenId}" + .replace("{tokenId}", tokenId) + + val apiParams = mutableMapOf( + "expire" to expire, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.ResourceToken = { + io.appwrite.models.ResourceToken.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.ResourceToken::class.java, + converter, + ) + } + + /** + * Delete a token by its unique ID. + * + * @param tokenId Token ID. + * @return [Any] + */ + @Throws(AppwriteException::class) + suspend fun delete( + tokenId: String, + ): Any { + val apiPath = "/tokens/{tokenId}" + .replace("{tokenId}", tokenId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/io/appwrite/services/Users.kt b/src/main/kotlin/io/appwrite/services/Users.kt index d2005af..c98fd79 100644 --- a/src/main/kotlin/io/appwrite/services/Users.kt +++ b/src/main/kotlin/io/appwrite/services/Users.kt @@ -967,16 +967,23 @@ class Users(client: Client) : Service(client) { * Get the user membership list by its unique ID. * * @param userId User 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. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.MembershipList] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun listMemberships( userId: String, + queries: List? = null, + search: String? = null, ): io.appwrite.models.MembershipList { val apiPath = "/users/{userId}/memberships" .replace("{userId}", userId) val apiParams = mutableMapOf( + "queries" to queries, + "search" to search, ) val apiHeaders = mutableMapOf( )