diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e68affe --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +**/bin +**/obj +**/.DS_Store +**/.vs diff --git a/LICENSE b/LICENSE index d73a6e9..47cfdfb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification, 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index 1c08a16..9cf624e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite .NET SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-dotnet.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.3.2-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) -[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io) +[![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 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dotnet/releases).** +**This SDK is compatible with Appwrite server version 1.3.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dotnet/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the .NET SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -17,17 +17,17 @@ Appwrite is an open-source backend as a service server that abstract and simplif Add this reference to your project's `.csproj` file: ```xml - + ``` You can install packages from the command line: ```powershell # Package Manager -Install-Package Appwrite -Version 0.3.0 +Install-Package Appwrite -Version 0.4.0 # or .NET CLI -dotnet add package Appwrite --version 0.3.0 +dotnet add package Appwrite --version 0.4.0 ``` @@ -35,51 +35,47 @@ dotnet add package Appwrite --version 0.3.0 ## Getting Started ### Initialize & Make API Request -Once you add the dependencies, its extremely easy to get started with the SDK; All you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example: +Once you have installed the package, it is extremely easy to get started with the SDK; all you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example: ```csharp using Appwrite; -static async Task Main(string[] args) -{ - var client = Client(); +var client = new Client() + .SetEndpoint("http://cloud.appwrite.io/v1") // Make sure your endpoint is accessible + .SetProject("5ff3379a01d25") // Your project ID + .SetKey("cd868db89") // Your secret API key + .SetSelfSigned(); // Use only on dev mode with a self-signed SSL cert - client - .setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible - .setProject('5ff3379a01d25') // Your project ID - .setKey('cd868c7af8bdc893b4...93b7535db89') - .setSelfSigned() // Use only on dev mode with a self-signed SSL cert - ; +var users = new Users(client); - var users = Users(client); +var user = await users.Create( + userId: ID.Unique(), + email: "email@example.com", + password: "password", + name: "name"); - try { - var request = await users.create('email@example.com', 'password', 'name'); - var response = await request.Content.ReadAsStringAsync(); - Console.WriteLine(response); - } catch (AppwriteException e) { - Console.WriteLine(e.Message); - } -} +Console.WriteLine(user.ToMap()); ``` ### Error Handling -The Appwrite .NET SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example. +The Appwrite .NET SDK raises an `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example. ```csharp -var users = Users(client); +var users = new Users(client); try { - var request = await users.create('email@example.com', 'password', 'name'); - var response = await request.Content.ReadAsStringAsync(); - Console.WriteLine(response); + var user = await users.Create( + userId: ID.Unique(), + email: "email@example.com", + password: "password", + name: "name"); } catch (AppwriteException e) { - Console.WriteLine(e.Message); + Console.WriteLine(e.Message); } ``` ### Learn more -You can use following resources to learn more and get help +You can use the following resources to learn more and get help - 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) - 📜 [Appwrite Docs](https://appwrite.io/docs) - 💬 [Discord Community](https://appwrite.io/discord) diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md new file mode 100644 index 0000000..32e8ea1 --- /dev/null +++ b/docs/examples/account/create-phone-verification.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Token result = await account.CreatePhoneVerification(); \ No newline at end of file diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index 7752d55..20cdd7e 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.CreateRecovery("email@example.com", "https://example.com"); +Token result = await account.CreateRecovery( + email: "email@example.com", + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index 39f0a97..4a103ef 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.CreateVerification("https://example.com"); +Token result = await account.CreateVerification( + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index be205da..fe61cef 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.DeleteSession("[SESSION_ID]"); +await account.DeleteSession( + sessionId: "[SESSION_ID]"); \ No newline at end of file diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index 481a358..8c37060 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.DeleteSessions(); +await account.DeleteSessions(); \ No newline at end of file diff --git a/docs/examples/account/delete.md b/docs/examples/account/delete.md deleted file mode 100644 index 02d2e42..0000000 --- a/docs/examples/account/delete.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; - -Account account = new Account(client); - -HttpResponseMessage result = await account.Delete(); diff --git a/docs/examples/account/get-logs.md b/docs/examples/account/get-logs.md deleted file mode 100644 index c209904..0000000 --- a/docs/examples/account/get-logs.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; - -Account account = new Account(client); - -HttpResponseMessage result = await account.GetLogs(); diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index 9d8bc74..6d7d9ea 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.GetPrefs(); +Preferences result = await account.GetPrefs(); \ No newline at end of file diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index ed03cb4..4d2e716 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.GetSession("[SESSION_ID]"); +Session result = await account.GetSession( + sessionId: "[SESSION_ID]"); \ No newline at end of file diff --git a/docs/examples/account/get-sessions.md b/docs/examples/account/get-sessions.md deleted file mode 100644 index 5de1229..0000000 --- a/docs/examples/account/get-sessions.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; - -Account account = new Account(client); - -HttpResponseMessage result = await account.GetSessions(); diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index faa62f8..9853c6a 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.Get(); +User result = await account.Get(); \ No newline at end of file diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md new file mode 100644 index 0000000..9f4712e --- /dev/null +++ b/docs/examples/account/list-logs.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +LogList result = await account.ListLogs(); \ No newline at end of file diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md new file mode 100644 index 0000000..232319e --- /dev/null +++ b/docs/examples/account/list-sessions.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +SessionList result = await account.ListSessions(); \ No newline at end of file diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index 9860148..1208095 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.UpdateEmail("email@example.com", "password"); +User result = await account.UpdateEmail( + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index d0de774..f8dfbf5 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.UpdateName("[NAME]"); +User result = await account.UpdateName( + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 9eba542..1a0e586 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.UpdatePassword("password"); +User result = await account.UpdatePassword( + password: ""); \ No newline at end of file diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md new file mode 100644 index 0000000..fafcea7 --- /dev/null +++ b/docs/examples/account/update-phone-verification.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Token result = await account.UpdatePhoneVerification( + userId: "[USER_ID]", + secret: "[SECRET]"); \ No newline at end of file diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md new file mode 100644 index 0000000..ccea754 --- /dev/null +++ b/docs/examples/account/update-phone.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +User result = await account.UpdatePhone( + phone: "+12065550100", + password: "password"); \ No newline at end of file diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index c9d3f16..040815b 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.UpdatePrefs([object]); +User result = await account.UpdatePrefs( + prefs: [object]); \ No newline at end of file diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 83c7588..07f09f7 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -1,13 +1,15 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.UpdateRecovery("[USER_ID]", "[SECRET]", "password", "password"); +Token result = await account.UpdateRecovery( + userId: "[USER_ID]", + secret: "[SECRET]", + password: "password", + passwordAgain: "password"); \ No newline at end of file diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md new file mode 100644 index 0000000..7c2443a --- /dev/null +++ b/docs/examples/account/update-session.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +Session result = await account.UpdateSession( + sessionId: "[SESSION_ID]"); \ No newline at end of file diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md new file mode 100644 index 0000000..0233b5d --- /dev/null +++ b/docs/examples/account/update-status.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var account = new Account(client); + +User result = await account.UpdateStatus(); \ No newline at end of file diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 88ef9b0..23c3a99 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var account = new Account(client); -Account account = new Account(client); - -HttpResponseMessage result = await account.UpdateVerification("[USER_ID]", "[SECRET]"); +Token result = await account.UpdateVerification( + userId: "[USER_ID]", + secret: "[SECRET]"); \ No newline at end of file diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index ebfa129..4150d3a 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var avatars = new Avatars(client); -Avatars avatars = new Avatars(client); - -string result = await avatars.GetBrowser("aa"); +byte[] result = await avatars.GetBrowser( + code: "aa"); \ No newline at end of file diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index 5eb207c..47cd89c 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var avatars = new Avatars(client); -Avatars avatars = new Avatars(client); - -string result = await avatars.GetCreditCard("amex"); +byte[] result = await avatars.GetCreditCard( + code: "amex"); \ No newline at end of file diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 7035838..0711dd3 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var avatars = new Avatars(client); -Avatars avatars = new Avatars(client); - -string result = await avatars.GetFavicon("https://example.com"); +byte[] result = await avatars.GetFavicon( + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index ec6b971..9c19d1a 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var avatars = new Avatars(client); -Avatars avatars = new Avatars(client); - -string result = await avatars.GetFlag("af"); +byte[] result = await avatars.GetFlag( + code: "af"); \ No newline at end of file diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 4217579..a5888ad 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var avatars = new Avatars(client); -Avatars avatars = new Avatars(client); - -string result = await avatars.GetImage("https://example.com"); +byte[] result = await avatars.GetImage( + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 5f47fba..c037de2 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var avatars = new Avatars(client); -Avatars avatars = new Avatars(client); - -string result = await avatars.GetInitials(); +byte[] result = await avatars.GetInitials(); \ No newline at end of file diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md index 69ae088..ff2634d 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-q-r.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var avatars = new Avatars(client); -Avatars avatars = new Avatars(client); - -string result = await avatars.GetQR("[TEXT]"); +byte[] result = await avatars.GetQR( + text: "[TEXT]"); \ No newline at end of file diff --git a/docs/examples/database/create-collection.md b/docs/examples/database/create-collection.md deleted file mode 100644 index 2154074..0000000 --- a/docs/examples/database/create-collection.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.CreateCollection("[NAME]", [List], [List], [List]); diff --git a/docs/examples/database/create-document.md b/docs/examples/database/create-document.md deleted file mode 100644 index 561d457..0000000 --- a/docs/examples/database/create-document.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.CreateDocument("[COLLECTION_ID]", [object]); diff --git a/docs/examples/database/delete-collection.md b/docs/examples/database/delete-collection.md deleted file mode 100644 index 9abdd5c..0000000 --- a/docs/examples/database/delete-collection.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.DeleteCollection("[COLLECTION_ID]"); diff --git a/docs/examples/database/delete-document.md b/docs/examples/database/delete-document.md deleted file mode 100644 index 18389e1..0000000 --- a/docs/examples/database/delete-document.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.DeleteDocument("[COLLECTION_ID]", "[DOCUMENT_ID]"); diff --git a/docs/examples/database/get-collection.md b/docs/examples/database/get-collection.md deleted file mode 100644 index 4d917a7..0000000 --- a/docs/examples/database/get-collection.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.GetCollection("[COLLECTION_ID]"); diff --git a/docs/examples/database/get-document.md b/docs/examples/database/get-document.md deleted file mode 100644 index 5eb0a37..0000000 --- a/docs/examples/database/get-document.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.GetDocument("[COLLECTION_ID]", "[DOCUMENT_ID]"); diff --git a/docs/examples/database/list-collections.md b/docs/examples/database/list-collections.md deleted file mode 100644 index edde1a3..0000000 --- a/docs/examples/database/list-collections.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.ListCollections(); diff --git a/docs/examples/database/list-documents.md b/docs/examples/database/list-documents.md deleted file mode 100644 index 9ccb247..0000000 --- a/docs/examples/database/list-documents.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.ListDocuments("[COLLECTION_ID]"); diff --git a/docs/examples/database/update-collection.md b/docs/examples/database/update-collection.md deleted file mode 100644 index d6e9c58..0000000 --- a/docs/examples/database/update-collection.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.UpdateCollection("[COLLECTION_ID]", "[NAME]"); diff --git a/docs/examples/database/update-document.md b/docs/examples/database/update-document.md deleted file mode 100644 index 7689065..0000000 --- a/docs/examples/database/update-document.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Database database = new Database(client); - -HttpResponseMessage result = await database.UpdateDocument("[COLLECTION_ID]", "[DOCUMENT_ID]", [object]); diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md new file mode 100644 index 0000000..b29a7fa --- /dev/null +++ b/docs/examples/databases/create-boolean-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeBoolean result = await databases.CreateBooleanAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md new file mode 100644 index 0000000..fa0bf3b --- /dev/null +++ b/docs/examples/databases/create-collection.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Collection result = await databases.CreateCollection( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md new file mode 100644 index 0000000..c44cc40 --- /dev/null +++ b/docs/examples/databases/create-datetime-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeDatetime result = await databases.CreateDatetimeAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md new file mode 100644 index 0000000..01532a3 --- /dev/null +++ b/docs/examples/databases/create-document.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Document result = await databases.CreateDocument( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + documentId: "[DOCUMENT_ID]", + data: [object]); \ No newline at end of file diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md new file mode 100644 index 0000000..7724160 --- /dev/null +++ b/docs/examples/databases/create-email-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeEmail result = await databases.CreateEmailAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md new file mode 100644 index 0000000..239d09d --- /dev/null +++ b/docs/examples/databases/create-enum-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeEnum result = await databases.CreateEnumAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + elements: new List {}, + required: false); \ No newline at end of file diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md new file mode 100644 index 0000000..382d4ad --- /dev/null +++ b/docs/examples/databases/create-float-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeFloat result = await databases.CreateFloatAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md new file mode 100644 index 0000000..7cf5f50 --- /dev/null +++ b/docs/examples/databases/create-index.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Index result = await databases.CreateIndex( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + type: "key", + attributes: new List {}); \ No newline at end of file diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md new file mode 100644 index 0000000..d3b95a7 --- /dev/null +++ b/docs/examples/databases/create-integer-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeInteger result = await databases.CreateIntegerAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md new file mode 100644 index 0000000..4fd8de1 --- /dev/null +++ b/docs/examples/databases/create-ip-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeIp result = await databases.CreateIpAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md new file mode 100644 index 0000000..036211a --- /dev/null +++ b/docs/examples/databases/create-relationship-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeRelationship result = await databases.CreateRelationshipAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + relatedCollectionId: "[RELATED_COLLECTION_ID]", + type: "oneToOne"); \ No newline at end of file diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md new file mode 100644 index 0000000..af1f9e4 --- /dev/null +++ b/docs/examples/databases/create-string-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeString result = await databases.CreateStringAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + size: 1, + required: false); \ No newline at end of file diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md new file mode 100644 index 0000000..d0d43e9 --- /dev/null +++ b/docs/examples/databases/create-url-attribute.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeUrl result = await databases.CreateUrlAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false); \ No newline at end of file diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md new file mode 100644 index 0000000..c1e62ca --- /dev/null +++ b/docs/examples/databases/create.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Database result = await databases.Create( + databaseId: "[DATABASE_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md new file mode 100644 index 0000000..b79abd9 --- /dev/null +++ b/docs/examples/databases/delete-attribute.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.DeleteAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md new file mode 100644 index 0000000..1530e33 --- /dev/null +++ b/docs/examples/databases/delete-collection.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.DeleteCollection( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md new file mode 100644 index 0000000..d20281e --- /dev/null +++ b/docs/examples/databases/delete-document.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.DeleteDocument( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + documentId: "[DOCUMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md new file mode 100644 index 0000000..3045ba9 --- /dev/null +++ b/docs/examples/databases/delete-index.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.DeleteIndex( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md new file mode 100644 index 0000000..c367cc4 --- /dev/null +++ b/docs/examples/databases/delete.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +await databases.Delete( + databaseId: "[DATABASE_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md new file mode 100644 index 0000000..16671ec --- /dev/null +++ b/docs/examples/databases/get-attribute.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + + result = await databases.GetAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md new file mode 100644 index 0000000..2b9702c --- /dev/null +++ b/docs/examples/databases/get-collection.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Collection result = await databases.GetCollection( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md new file mode 100644 index 0000000..7ceccde --- /dev/null +++ b/docs/examples/databases/get-document.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Document result = await databases.GetDocument( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + documentId: "[DOCUMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md new file mode 100644 index 0000000..ed04b74 --- /dev/null +++ b/docs/examples/databases/get-index.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Index result = await databases.GetIndex( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md new file mode 100644 index 0000000..975b00c --- /dev/null +++ b/docs/examples/databases/get.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Database result = await databases.Get( + databaseId: "[DATABASE_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md new file mode 100644 index 0000000..15c1c75 --- /dev/null +++ b/docs/examples/databases/list-attributes.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeList result = await databases.ListAttributes( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md new file mode 100644 index 0000000..1e2e545 --- /dev/null +++ b/docs/examples/databases/list-collections.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +CollectionList result = await databases.ListCollections( + databaseId: "[DATABASE_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md new file mode 100644 index 0000000..0445238 --- /dev/null +++ b/docs/examples/databases/list-documents.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +DocumentList result = await databases.ListDocuments( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md new file mode 100644 index 0000000..0505d19 --- /dev/null +++ b/docs/examples/databases/list-indexes.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +IndexList result = await databases.ListIndexes( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md new file mode 100644 index 0000000..baee085 --- /dev/null +++ b/docs/examples/databases/list.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +DatabaseList result = await databases.List(); \ No newline at end of file diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md new file mode 100644 index 0000000..8e185d7 --- /dev/null +++ b/docs/examples/databases/update-boolean-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeBoolean result = await databases.UpdateBooleanAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: false); \ No newline at end of file diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md new file mode 100644 index 0000000..5744767 --- /dev/null +++ b/docs/examples/databases/update-collection.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Collection result = await databases.UpdateCollection( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md new file mode 100644 index 0000000..6d02e2b --- /dev/null +++ b/docs/examples/databases/update-datetime-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeDatetime result = await databases.UpdateDatetimeAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: ""); \ No newline at end of file diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md new file mode 100644 index 0000000..48fee0d --- /dev/null +++ b/docs/examples/databases/update-document.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Document result = await databases.UpdateDocument( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + documentId: "[DOCUMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md new file mode 100644 index 0000000..0664760 --- /dev/null +++ b/docs/examples/databases/update-email-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeEmail result = await databases.UpdateEmailAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: "email@example.com"); \ No newline at end of file diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md new file mode 100644 index 0000000..65362c0 --- /dev/null +++ b/docs/examples/databases/update-enum-attribute.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeEnum result = await databases.UpdateEnumAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + elements: new List {}, + required: false, + default: "[DEFAULT]"); \ No newline at end of file diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md new file mode 100644 index 0000000..2950bd0 --- /dev/null +++ b/docs/examples/databases/update-float-attribute.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeFloat result = await databases.UpdateFloatAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + min: 0, + max: 0, + default: 0); \ No newline at end of file diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md new file mode 100644 index 0000000..880d1cc --- /dev/null +++ b/docs/examples/databases/update-integer-attribute.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeInteger result = await databases.UpdateIntegerAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + min: 0, + max: 0, + default: 0); \ No newline at end of file diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md new file mode 100644 index 0000000..70fd773 --- /dev/null +++ b/docs/examples/databases/update-ip-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeIp result = await databases.UpdateIpAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: ""); \ No newline at end of file diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md new file mode 100644 index 0000000..e4917ef --- /dev/null +++ b/docs/examples/databases/update-relationship-attribute.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeRelationship result = await databases.UpdateRelationshipAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: ""); \ No newline at end of file diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md new file mode 100644 index 0000000..4744bf5 --- /dev/null +++ b/docs/examples/databases/update-string-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeString result = await databases.UpdateStringAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: "[DEFAULT]"); \ No newline at end of file diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md new file mode 100644 index 0000000..cb04a5d --- /dev/null +++ b/docs/examples/databases/update-url-attribute.md @@ -0,0 +1,16 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +AttributeUrl result = await databases.UpdateUrlAttribute( + databaseId: "[DATABASE_ID]", + collectionId: "[COLLECTION_ID]", + key: "", + required: false, + default: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md new file mode 100644 index 0000000..db07b7a --- /dev/null +++ b/docs/examples/databases/update.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var databases = new Databases(client); + +Database result = await databases.Update( + databaseId: "[DATABASE_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/functions/create-build.md b/docs/examples/functions/create-build.md new file mode 100644 index 0000000..6d62298 --- /dev/null +++ b/docs/examples/functions/create-build.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + + result = await functions.CreateBuild( + functionId: "[FUNCTION_ID]", + deploymentId: "[DEPLOYMENT_ID]", + buildId: "[BUILD_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md new file mode 100644 index 0000000..5463ee4 --- /dev/null +++ b/docs/examples/functions/create-deployment.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Deployment result = await functions.CreateDeployment( + functionId: "[FUNCTION_ID]", + entrypoint: "[ENTRYPOINT]", + code: InputFile.FromPath("./path-to-files/image.jpg"), + activate: false); \ No newline at end of file diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 4844317..9c015f8 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var functions = new Functions(client); -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.CreateExecution("[FUNCTION_ID]"); +Execution result = await functions.CreateExecution( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/create-tag.md b/docs/examples/functions/create-tag.md deleted file mode 100644 index 39e7461..0000000 --- a/docs/examples/functions/create-tag.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.CreateTag("[FUNCTION_ID]", "[COMMAND]", new File("./path-to-files/image.jpg")); diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md new file mode 100644 index 0000000..e5df30d --- /dev/null +++ b/docs/examples/functions/create-variable.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Variable result = await functions.CreateVariable( + functionId: "[FUNCTION_ID]", + key: "[KEY]", + value: "[VALUE]"); \ No newline at end of file diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 7c264a4..3f189b0 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -1,13 +1,14 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var functions = new Functions(client); -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.Create("[NAME]", [List], "java-11.0"); +Function result = await functions.Create( + functionId: "[FUNCTION_ID]", + name: "[NAME]", + runtime: "node-14.5"); \ No newline at end of file diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md new file mode 100644 index 0000000..f52515b --- /dev/null +++ b/docs/examples/functions/delete-deployment.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +await functions.DeleteDeployment( + functionId: "[FUNCTION_ID]", + deploymentId: "[DEPLOYMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/delete-tag.md b/docs/examples/functions/delete-tag.md deleted file mode 100644 index 859a9e8..0000000 --- a/docs/examples/functions/delete-tag.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.DeleteTag("[FUNCTION_ID]", "[TAG_ID]"); diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md new file mode 100644 index 0000000..d9fb356 --- /dev/null +++ b/docs/examples/functions/delete-variable.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +await functions.DeleteVariable( + functionId: "[FUNCTION_ID]", + variableId: "[VARIABLE_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index e7ef51f..265ebc3 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var functions = new Functions(client); -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.Delete("[FUNCTION_ID]"); +await functions.Delete( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md new file mode 100644 index 0000000..65d8431 --- /dev/null +++ b/docs/examples/functions/get-deployment.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Deployment result = await functions.GetDeployment( + functionId: "[FUNCTION_ID]", + deploymentId: "[DEPLOYMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index f18a8fb..f46f9d5 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var functions = new Functions(client); -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.GetExecution("[FUNCTION_ID]", "[EXECUTION_ID]"); +Execution result = await functions.GetExecution( + functionId: "[FUNCTION_ID]", + executionId: "[EXECUTION_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/get-tag.md b/docs/examples/functions/get-tag.md deleted file mode 100644 index 900864a..0000000 --- a/docs/examples/functions/get-tag.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.GetTag("[FUNCTION_ID]", "[TAG_ID]"); diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md new file mode 100644 index 0000000..a90ff4f --- /dev/null +++ b/docs/examples/functions/get-variable.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Variable result = await functions.GetVariable( + functionId: "[FUNCTION_ID]", + variableId: "[VARIABLE_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index a92fa25..0cbec8a 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var functions = new Functions(client); -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.Get("[FUNCTION_ID]"); +Function result = await functions.Get( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md new file mode 100644 index 0000000..d277204 --- /dev/null +++ b/docs/examples/functions/list-deployments.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +DeploymentList result = await functions.ListDeployments( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index b9a86ce..0797af5 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var functions = new Functions(client); -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.ListExecutions("[FUNCTION_ID]"); +ExecutionList result = await functions.ListExecutions( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md new file mode 100644 index 0000000..9f2edf4 --- /dev/null +++ b/docs/examples/functions/list-runtimes.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +RuntimeList result = await functions.ListRuntimes(); \ No newline at end of file diff --git a/docs/examples/functions/list-tags.md b/docs/examples/functions/list-tags.md deleted file mode 100644 index ec1b872..0000000 --- a/docs/examples/functions/list-tags.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.ListTags("[FUNCTION_ID]"); diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md new file mode 100644 index 0000000..f1336f6 --- /dev/null +++ b/docs/examples/functions/list-variables.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +VariableList result = await functions.ListVariables( + functionId: "[FUNCTION_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index 1b76f19..ba78467 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var functions = new Functions(client); -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.List(); +FunctionList result = await functions.List(); \ No newline at end of file diff --git a/docs/examples/functions/update-deployment.md b/docs/examples/functions/update-deployment.md new file mode 100644 index 0000000..1c8498f --- /dev/null +++ b/docs/examples/functions/update-deployment.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Function result = await functions.UpdateDeployment( + functionId: "[FUNCTION_ID]", + deploymentId: "[DEPLOYMENT_ID]"); \ No newline at end of file diff --git a/docs/examples/functions/update-tag.md b/docs/examples/functions/update-tag.md deleted file mode 100644 index b42ef93..0000000 --- a/docs/examples/functions/update-tag.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.UpdateTag("[FUNCTION_ID]", "[TAG]"); diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md new file mode 100644 index 0000000..ad60d97 --- /dev/null +++ b/docs/examples/functions/update-variable.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var functions = new Functions(client); + +Variable result = await functions.UpdateVariable( + functionId: "[FUNCTION_ID]", + variableId: "[VARIABLE_ID]", + key: "[KEY]"); \ No newline at end of file diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 53db3ed..02bfc73 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var functions = new Functions(client); -Functions functions = new Functions(client); - -HttpResponseMessage result = await functions.Update("[FUNCTION_ID]", "[NAME]", [List]); +Function result = await functions.Update( + functionId: "[FUNCTION_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md new file mode 100644 index 0000000..ba79658 --- /dev/null +++ b/docs/examples/graphql/mutation.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var graphql = new Graphql(client); + +Any result = await graphql.Mutation( + query: [object]); \ No newline at end of file diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md new file mode 100644 index 0000000..e271058 --- /dev/null +++ b/docs/examples/graphql/query.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var graphql = new Graphql(client); + +Any result = await graphql.Query( + query: [object]); \ No newline at end of file diff --git a/docs/examples/health/get-anti-virus.md b/docs/examples/health/get-anti-virus.md deleted file mode 100644 index b8fcdd6..0000000 --- a/docs/examples/health/get-anti-virus.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Health health = new Health(client); - -HttpResponseMessage result = await health.GetAntiVirus(); diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md new file mode 100644 index 0000000..f133c3d --- /dev/null +++ b/docs/examples/health/get-antivirus.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var health = new Health(client); + +HealthAntivirus result = await health.GetAntivirus(); \ No newline at end of file diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md index 9f864ee..4c3b827 100644 --- a/docs/examples/health/get-cache.md +++ b/docs/examples/health/get-cache.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var health = new Health(client); -Health health = new Health(client); - -HttpResponseMessage result = await health.GetCache(); +HealthStatus result = await health.GetCache(); \ No newline at end of file diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-d-b.md index 458f31c..d49218f 100644 --- a/docs/examples/health/get-d-b.md +++ b/docs/examples/health/get-d-b.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var health = new Health(client); -Health health = new Health(client); - -HttpResponseMessage result = await health.GetDB(); +HealthStatus result = await health.GetDB(); \ No newline at end of file diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md index 56d182f..4e4c042 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/health/get-queue-certificates.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var health = new Health(client); -Health health = new Health(client); - -HttpResponseMessage result = await health.GetQueueCertificates(); +HealthQueue result = await health.GetQueueCertificates(); \ No newline at end of file diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md index adbba7a..1f12061 100644 --- a/docs/examples/health/get-queue-functions.md +++ b/docs/examples/health/get-queue-functions.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var health = new Health(client); -Health health = new Health(client); - -HttpResponseMessage result = await health.GetQueueFunctions(); +HealthQueue result = await health.GetQueueFunctions(); \ No newline at end of file diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md index 75173bb..68d6dac 100644 --- a/docs/examples/health/get-queue-logs.md +++ b/docs/examples/health/get-queue-logs.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var health = new Health(client); -Health health = new Health(client); - -HttpResponseMessage result = await health.GetQueueLogs(); +HealthQueue result = await health.GetQueueLogs(); \ No newline at end of file diff --git a/docs/examples/health/get-queue-tasks.md b/docs/examples/health/get-queue-tasks.md deleted file mode 100644 index 6df301b..0000000 --- a/docs/examples/health/get-queue-tasks.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Health health = new Health(client); - -HttpResponseMessage result = await health.GetQueueTasks(); diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md deleted file mode 100644 index 2ea5c91..0000000 --- a/docs/examples/health/get-queue-usage.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Health health = new Health(client); - -HttpResponseMessage result = await health.GetQueueUsage(); diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md index b3d9ccd..12fb20d 100644 --- a/docs/examples/health/get-queue-webhooks.md +++ b/docs/examples/health/get-queue-webhooks.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var health = new Health(client); -Health health = new Health(client); - -HttpResponseMessage result = await health.GetQueueWebhooks(); +HealthQueue result = await health.GetQueueWebhooks(); \ No newline at end of file diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md index d68bc1d..3412c03 100644 --- a/docs/examples/health/get-storage-local.md +++ b/docs/examples/health/get-storage-local.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var health = new Health(client); -Health health = new Health(client); - -HttpResponseMessage result = await health.GetStorageLocal(); +HealthStatus result = await health.GetStorageLocal(); \ No newline at end of file diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md index 7a0711c..d50d15b 100644 --- a/docs/examples/health/get-time.md +++ b/docs/examples/health/get-time.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var health = new Health(client); -Health health = new Health(client); - -HttpResponseMessage result = await health.GetTime(); +HealthTime result = await health.GetTime(); \ No newline at end of file diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md index f05c8ef..dac4a12 100644 --- a/docs/examples/health/get.md +++ b/docs/examples/health/get.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var health = new Health(client); -Health health = new Health(client); - -HttpResponseMessage result = await health.Get(); +HealthStatus result = await health.Get(); \ No newline at end of file diff --git a/docs/examples/locale/get-continents.md b/docs/examples/locale/get-continents.md deleted file mode 100644 index 600bfcd..0000000 --- a/docs/examples/locale/get-continents.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Locale locale = new Locale(client); - -HttpResponseMessage result = await locale.GetContinents(); diff --git a/docs/examples/locale/get-countries-e-u.md b/docs/examples/locale/get-countries-e-u.md deleted file mode 100644 index 2ba4e22..0000000 --- a/docs/examples/locale/get-countries-e-u.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Locale locale = new Locale(client); - -HttpResponseMessage result = await locale.GetCountriesEU(); diff --git a/docs/examples/locale/get-countries-phones.md b/docs/examples/locale/get-countries-phones.md deleted file mode 100644 index 2630aef..0000000 --- a/docs/examples/locale/get-countries-phones.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Locale locale = new Locale(client); - -HttpResponseMessage result = await locale.GetCountriesPhones(); diff --git a/docs/examples/locale/get-countries.md b/docs/examples/locale/get-countries.md deleted file mode 100644 index 46b14de..0000000 --- a/docs/examples/locale/get-countries.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Locale locale = new Locale(client); - -HttpResponseMessage result = await locale.GetCountries(); diff --git a/docs/examples/locale/get-currencies.md b/docs/examples/locale/get-currencies.md deleted file mode 100644 index daecdcf..0000000 --- a/docs/examples/locale/get-currencies.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Locale locale = new Locale(client); - -HttpResponseMessage result = await locale.GetCurrencies(); diff --git a/docs/examples/locale/get-languages.md b/docs/examples/locale/get-languages.md deleted file mode 100644 index ba00b2a..0000000 --- a/docs/examples/locale/get-languages.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Locale locale = new Locale(client); - -HttpResponseMessage result = await locale.GetLanguages(); diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index 7b10a28..da5866a 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var locale = new Locale(client); -Locale locale = new Locale(client); - -HttpResponseMessage result = await locale.Get(); +Locale result = await locale.Get(); \ No newline at end of file diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md new file mode 100644 index 0000000..94f5dce --- /dev/null +++ b/docs/examples/locale/list-continents.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +ContinentList result = await locale.ListContinents(); \ No newline at end of file diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md new file mode 100644 index 0000000..49bee6c --- /dev/null +++ b/docs/examples/locale/list-countries-e-u.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +CountryList result = await locale.ListCountriesEU(); \ No newline at end of file diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md new file mode 100644 index 0000000..1a2b578 --- /dev/null +++ b/docs/examples/locale/list-countries-phones.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +PhoneList result = await locale.ListCountriesPhones(); \ No newline at end of file diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md new file mode 100644 index 0000000..4036ba3 --- /dev/null +++ b/docs/examples/locale/list-countries.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +CountryList result = await locale.ListCountries(); \ No newline at end of file diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md new file mode 100644 index 0000000..338a7b4 --- /dev/null +++ b/docs/examples/locale/list-currencies.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +CurrencyList result = await locale.ListCurrencies(); \ No newline at end of file diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md new file mode 100644 index 0000000..ce75f8c --- /dev/null +++ b/docs/examples/locale/list-languages.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var locale = new Locale(client); + +LanguageList result = await locale.ListLanguages(); \ No newline at end of file diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md new file mode 100644 index 0000000..ce3857f --- /dev/null +++ b/docs/examples/storage/create-bucket.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +Bucket result = await storage.CreateBucket( + bucketId: "[BUCKET_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 5930f88..ed042bb 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,13 +1,14 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var storage = new Storage(client); -Storage storage = new Storage(client); - -HttpResponseMessage result = await storage.CreateFile(new File("./path-to-files/image.jpg")); +File result = await storage.CreateFile( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]", + file: InputFile.FromPath("./path-to-files/image.jpg")); \ No newline at end of file diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md new file mode 100644 index 0000000..bf2c393 --- /dev/null +++ b/docs/examples/storage/delete-bucket.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +await storage.DeleteBucket( + bucketId: "[BUCKET_ID]"); \ No newline at end of file diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 5a91ecb..c66b581 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var storage = new Storage(client); -Storage storage = new Storage(client); - -HttpResponseMessage result = await storage.DeleteFile("[FILE_ID]"); +await storage.DeleteFile( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md new file mode 100644 index 0000000..37d6c21 --- /dev/null +++ b/docs/examples/storage/get-bucket.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +Bucket result = await storage.GetBucket( + bucketId: "[BUCKET_ID]"); \ No newline at end of file diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 0a93cef..6907347 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var storage = new Storage(client); -Storage storage = new Storage(client); - -string result = await storage.GetFileDownload("[FILE_ID]"); +byte[] result = await storage.GetFileDownload( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index e89ca27..8d63fc8 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var storage = new Storage(client); -Storage storage = new Storage(client); - -string result = await storage.GetFilePreview("[FILE_ID]"); +byte[] result = await storage.GetFilePreview( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index e3fe690..bdeb1b9 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var storage = new Storage(client); -Storage storage = new Storage(client); - -string result = await storage.GetFileView("[FILE_ID]"); +byte[] result = await storage.GetFileView( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index 1e090bb..9b0c29e 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var storage = new Storage(client); -Storage storage = new Storage(client); - -HttpResponseMessage result = await storage.GetFile("[FILE_ID]"); +File result = await storage.GetFile( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md new file mode 100644 index 0000000..869571a --- /dev/null +++ b/docs/examples/storage/list-buckets.md @@ -0,0 +1,11 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +BucketList result = await storage.ListBuckets(); \ No newline at end of file diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index bee452d..7010825 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var storage = new Storage(client); -Storage storage = new Storage(client); - -HttpResponseMessage result = await storage.ListFiles(); +FileList result = await storage.ListFiles( + bucketId: "[BUCKET_ID]"); \ No newline at end of file diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md new file mode 100644 index 0000000..f05ca9c --- /dev/null +++ b/docs/examples/storage/update-bucket.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var storage = new Storage(client); + +Bucket result = await storage.UpdateBucket( + bucketId: "[BUCKET_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index a4b87be..d2246ad 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var storage = new Storage(client); -Storage storage = new Storage(client); - -HttpResponseMessage result = await storage.UpdateFile("[FILE_ID]", [List], [List]); +File result = await storage.UpdateFile( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]"); \ No newline at end of file diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 34f34dc..75abdfa 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -1,13 +1,14 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var teams = new Teams(client); -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.CreateMembership("[TEAM_ID]", "email@example.com", [List], "https://example.com"); +Membership result = await teams.CreateMembership( + teamId: "[TEAM_ID]", + roles: new List {}, + url: "https://example.com"); \ No newline at end of file diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index ad325dd..bac3d72 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var teams = new Teams(client); -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.Create("[NAME]"); +Team result = await teams.Create( + teamId: "[TEAM_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index a50061b..60cb7ea 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var teams = new Teams(client); -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.DeleteMembership("[TEAM_ID]", "[MEMBERSHIP_ID]"); +await teams.DeleteMembership( + teamId: "[TEAM_ID]", + membershipId: "[MEMBERSHIP_ID]"); \ No newline at end of file diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index 26b780f..2b72528 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var teams = new Teams(client); -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.Delete("[TEAM_ID]"); +await teams.Delete( + teamId: "[TEAM_ID]"); \ No newline at end of file diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md new file mode 100644 index 0000000..7873a24 --- /dev/null +++ b/docs/examples/teams/get-membership.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +Membership result = await teams.GetMembership( + teamId: "[TEAM_ID]", + membershipId: "[MEMBERSHIP_ID]"); \ No newline at end of file diff --git a/docs/examples/teams/get-memberships.md b/docs/examples/teams/get-memberships.md deleted file mode 100644 index 8897efa..0000000 --- a/docs/examples/teams/get-memberships.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.GetMemberships("[TEAM_ID]"); diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md new file mode 100644 index 0000000..487461c --- /dev/null +++ b/docs/examples/teams/get-prefs.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var teams = new Teams(client); + +Preferences result = await teams.GetPrefs( + teamId: "[TEAM_ID]"); \ No newline at end of file diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index 78a3d0c..32bebaf 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var teams = new Teams(client); -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.Get("[TEAM_ID]"); +Team result = await teams.Get( + teamId: "[TEAM_ID]"); \ No newline at end of file diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md new file mode 100644 index 0000000..3ea7cb5 --- /dev/null +++ b/docs/examples/teams/list-memberships.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +MembershipList result = await teams.ListMemberships( + teamId: "[TEAM_ID]"); \ No newline at end of file diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index b93ba90..db4cd34 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var teams = new Teams(client); -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.List(); +TeamList result = await teams.List(); \ No newline at end of file diff --git a/docs/examples/teams/update-membership-roles.md b/docs/examples/teams/update-membership-roles.md index 17ab5e3..1c2fada 100644 --- a/docs/examples/teams/update-membership-roles.md +++ b/docs/examples/teams/update-membership-roles.md @@ -1,13 +1,14 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var teams = new Teams(client); -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.UpdateMembershipRoles("[TEAM_ID]", "[MEMBERSHIP_ID]", [List]); +Membership result = await teams.UpdateMembershipRoles( + teamId: "[TEAM_ID]", + membershipId: "[MEMBERSHIP_ID]", + roles: new List {}); \ No newline at end of file diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index ab47f8a..eaff766 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -1,13 +1,15 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token -; +var teams = new Teams(client); -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.UpdateMembershipStatus("[TEAM_ID]", "[MEMBERSHIP_ID]", "[USER_ID]", "[SECRET]"); +Membership result = await teams.UpdateMembershipStatus( + teamId: "[TEAM_ID]", + membershipId: "[MEMBERSHIP_ID]", + userId: "[USER_ID]", + secret: "[SECRET]"); \ No newline at end of file diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md new file mode 100644 index 0000000..ca72222 --- /dev/null +++ b/docs/examples/teams/update-name.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var teams = new Teams(client); + +Team result = await teams.UpdateName( + teamId: "[TEAM_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md new file mode 100644 index 0000000..7a51248 --- /dev/null +++ b/docs/examples/teams/update-prefs.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token + +var teams = new Teams(client); + +Preferences result = await teams.UpdatePrefs( + teamId: "[TEAM_ID]", + prefs: [object]); \ No newline at end of file diff --git a/docs/examples/teams/update.md b/docs/examples/teams/update.md deleted file mode 100644 index 481c987..0000000 --- a/docs/examples/teams/update.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Teams teams = new Teams(client); - -HttpResponseMessage result = await teams.Update("[TEAM_ID]", "[NAME]"); diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon2user.md new file mode 100644 index 0000000..5bd89a2 --- /dev/null +++ b/docs/examples/users/create-argon2user.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateArgon2User( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md new file mode 100644 index 0000000..aef0d9e --- /dev/null +++ b/docs/examples/users/create-bcrypt-user.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateBcryptUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-m-d5user.md new file mode 100644 index 0000000..e537124 --- /dev/null +++ b/docs/examples/users/create-m-d5user.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateMD5User( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-p-h-pass-user.md new file mode 100644 index 0000000..f7a0d24 --- /dev/null +++ b/docs/examples/users/create-p-h-pass-user.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreatePHPassUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md new file mode 100644 index 0000000..c504ec7 --- /dev/null +++ b/docs/examples/users/create-s-h-a-user.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateSHAUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password"); \ No newline at end of file diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md new file mode 100644 index 0000000..af04bbc --- /dev/null +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateScryptModifiedUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password", + passwordSalt: "[PASSWORD_SALT]", + passwordSaltSeparator: "[PASSWORD_SALT_SEPARATOR]", + passwordSignerKey: "[PASSWORD_SIGNER_KEY]"); \ No newline at end of file diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md new file mode 100644 index 0000000..3a95de5 --- /dev/null +++ b/docs/examples/users/create-scrypt-user.md @@ -0,0 +1,19 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.CreateScryptUser( + userId: "[USER_ID]", + email: "email@example.com", + password: "password", + passwordSalt: "[PASSWORD_SALT]", + passwordCpu: 0, + passwordMemory: 0, + passwordParallel: 0, + passwordLength: 0); \ No newline at end of file diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 3c3e7d2..2ed0671 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var users = new Users(client); -Users users = new Users(client); - -HttpResponseMessage result = await users.Create("email@example.com", "password"); +User result = await users.Create( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index 2fcf7db..d656c67 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var users = new Users(client); -Users users = new Users(client); - -HttpResponseMessage result = await users.DeleteSession("[USER_ID]", "[SESSION_ID]"); +await users.DeleteSession( + userId: "[USER_ID]", + sessionId: "[SESSION_ID]"); \ No newline at end of file diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index b3b9f05..ca15eb9 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var users = new Users(client); -Users users = new Users(client); - -HttpResponseMessage result = await users.DeleteSessions("[USER_ID]"); +await users.DeleteSessions( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index b0eb7ef..e3552fd 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var users = new Users(client); -Users users = new Users(client); - -HttpResponseMessage result = await users.Delete("[USER_ID]"); +await users.Delete( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/users/get-logs.md b/docs/examples/users/get-logs.md deleted file mode 100644 index ca352b4..0000000 --- a/docs/examples/users/get-logs.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Users users = new Users(client); - -HttpResponseMessage result = await users.GetLogs("[USER_ID]"); diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index 2e673a5..695601b 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var users = new Users(client); -Users users = new Users(client); - -HttpResponseMessage result = await users.GetPrefs("[USER_ID]"); +Preferences result = await users.GetPrefs( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/users/get-sessions.md b/docs/examples/users/get-sessions.md deleted file mode 100644 index 63e9844..0000000 --- a/docs/examples/users/get-sessions.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Users users = new Users(client); - -HttpResponseMessage result = await users.GetSessions("[USER_ID]"); diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index 2448a98..90411a6 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -1,13 +1,12 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var users = new Users(client); -Users users = new Users(client); - -HttpResponseMessage result = await users.Get("[USER_ID]"); +User result = await users.Get( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md new file mode 100644 index 0000000..c42a767 --- /dev/null +++ b/docs/examples/users/list-logs.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +LogList result = await users.ListLogs( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md new file mode 100644 index 0000000..0a76062 --- /dev/null +++ b/docs/examples/users/list-memberships.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +MembershipList result = await users.ListMemberships( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md new file mode 100644 index 0000000..43fcb7a --- /dev/null +++ b/docs/examples/users/list-sessions.md @@ -0,0 +1,12 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +SessionList result = await users.ListSessions( + userId: "[USER_ID]"); \ No newline at end of file diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 06a036d..7bba5b7 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -1,13 +1,11 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var users = new Users(client); -Users users = new Users(client); - -HttpResponseMessage result = await users.List(); +UserList result = await users.List(); \ No newline at end of file diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md new file mode 100644 index 0000000..14d7a41 --- /dev/null +++ b/docs/examples/users/update-email-verification.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdateEmailVerification( + userId: "[USER_ID]", + emailVerification: false); \ No newline at end of file diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md new file mode 100644 index 0000000..dd2e1e3 --- /dev/null +++ b/docs/examples/users/update-email.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdateEmail( + userId: "[USER_ID]", + email: "email@example.com"); \ No newline at end of file diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md new file mode 100644 index 0000000..01e3654 --- /dev/null +++ b/docs/examples/users/update-name.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdateName( + userId: "[USER_ID]", + name: "[NAME]"); \ No newline at end of file diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md new file mode 100644 index 0000000..b8ad2c5 --- /dev/null +++ b/docs/examples/users/update-password.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdatePassword( + userId: "[USER_ID]", + password: ""); \ No newline at end of file diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md new file mode 100644 index 0000000..afddc55 --- /dev/null +++ b/docs/examples/users/update-phone-verification.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdatePhoneVerification( + userId: "[USER_ID]", + phoneVerification: false); \ No newline at end of file diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md new file mode 100644 index 0000000..f556b73 --- /dev/null +++ b/docs/examples/users/update-phone.md @@ -0,0 +1,13 @@ +using Appwrite; +using Appwrite.Models; + +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key + +var users = new Users(client); + +User result = await users.UpdatePhone( + userId: "[USER_ID]", + number: "+12065550100"); \ No newline at end of file diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index 01f481b..8d3f10e 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var users = new Users(client); -Users users = new Users(client); - -HttpResponseMessage result = await users.UpdatePrefs("[USER_ID]", [object]); +Preferences result = await users.UpdatePrefs( + userId: "[USER_ID]", + prefs: [object]); \ No newline at end of file diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index de625dd..c2d1336 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -1,13 +1,13 @@ using Appwrite; +using Appwrite.Models; -Client client = new Client(); +var client = new Client() + .SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("5df5acd0d48c2") // Your project ID + .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; +var users = new Users(client); -Users users = new Users(client); - -HttpResponseMessage result = await users.UpdateStatus("[USER_ID]", 1); +User result = await users.UpdateStatus( + userId: "[USER_ID]", + status: false); \ No newline at end of file diff --git a/docs/examples/users/update-verification.md b/docs/examples/users/update-verification.md deleted file mode 100644 index 127cdc9..0000000 --- a/docs/examples/users/update-verification.md +++ /dev/null @@ -1,13 +0,0 @@ -using Appwrite; - -Client client = new Client(); - -client - .SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .SetProject("5df5acd0d48c2") // Your project ID - .SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key -; - -Users users = new Users(client); - -HttpResponseMessage result = await users.UpdateVerification("[USER_ID]", false); diff --git a/io/appwrite/src/Appwrite/Client.cs b/io/appwrite/src/Appwrite/Client.cs deleted file mode 100644 index f5282bc..0000000 --- a/io/appwrite/src/Appwrite/Client.cs +++ /dev/null @@ -1,200 +0,0 @@ -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Text; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Client - { - private readonly HttpClient http; - private readonly Dictionary headers; - private readonly Dictionary config; - private string endPoint; - private bool selfSigned; - - public Client() : this("https://appwrite.io/v1", false, new HttpClient()) - { - } - - public Client(string endPoint, bool selfSigned, HttpClient http) - { - this.endPoint = endPoint; - this.selfSigned = selfSigned; - this.headers = new Dictionary() - { - { "content-type", "application/json" }, - { "x-sdk-version", "appwrite:dotnet:0.3.0" }, - { "X-Appwrite-Response-Format", "0.9.0" } - }; - this.config = new Dictionary(); - this.http = http; - } - - public Client SetSelfSigned(bool selfSigned) - { - this.selfSigned = selfSigned; - return this; - } - - public Client SetEndPoint(string endPoint) - { - this.endPoint = endPoint; - return this; - } - - public string GetEndPoint() - { - return endPoint; - } - - public Dictionary GetConfig() - { - return config; - } - - /// Your project ID - public Client SetProject(string value) { - config.Add("project", value); - AddHeader("X-Appwrite-Project", value); - return this; - } - - /// Your secret API key - public Client SetKey(string value) { - config.Add("key", value); - AddHeader("X-Appwrite-Key", value); - return this; - } - - /// Your secret JSON Web Token - public Client SetJWT(string value) { - config.Add("jWT", value); - AddHeader("X-Appwrite-JWT", value); - return this; - } - - public Client SetLocale(string value) { - config.Add("locale", value); - AddHeader("X-Appwrite-Locale", value); - return this; - } - - public Client AddHeader(String key, String value) - { - headers.Add(key, value); - return this; - } - - public async Task Call(string method, string path, Dictionary headers, Dictionary parameters) - { - if (selfSigned) - { - ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; - } - - bool methodGet = "GET".Equals(method, StringComparison.InvariantCultureIgnoreCase); - - string queryString = methodGet ? "?" + parameters.ToQueryString() : string.Empty; - - HttpRequestMessage request = new HttpRequestMessage(new HttpMethod(method), endPoint + path + queryString); - - if ("multipart/form-data".Equals(headers["content-type"], StringComparison.InvariantCultureIgnoreCase)) - { - MultipartFormDataContent form = new MultipartFormDataContent(); - - foreach (var parameter in parameters) - { - if (parameter.Key == "file") - { - FileInfo fi = parameters["file"] as FileInfo; - - var file = File.ReadAllBytes(fi.FullName); - - form.Add(new ByteArrayContent(file, 0, file.Length), "file", fi.Name); - } - else if (parameter.Value is IEnumerable) - { - List list = new List((IEnumerable) parameter.Value); - for (int index = 0; index < list.Count; index++) - { - form.Add(new StringContent(list[index].ToString()), $"{parameter.Key}[{index}]"); - } - } - else - { - form.Add(new StringContent(parameter.Value.ToString()), parameter.Key); - } - } - request.Content = form; - - } - else if (!methodGet) - { - string body = parameters.ToJson(); - - request.Content = new StringContent(body, Encoding.UTF8, "application/json"); - } - - foreach (var header in this.headers) - { - if (header.Key.Equals("content-type", StringComparison.InvariantCultureIgnoreCase)) - { - http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(header.Value)); - } - else - { - if (http.DefaultRequestHeaders.Contains(header.Key)) { - http.DefaultRequestHeaders.Remove(header.Key); - } - http.DefaultRequestHeaders.Add(header.Key, header.Value); - } - } - - foreach (var header in headers) - { - if (header.Key.Equals("content-type", StringComparison.InvariantCultureIgnoreCase)) - { - request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header.Value)); - } - else - { - if (request.Headers.Contains(header.Key)) { - request.Headers.Remove(header.Key); - } - request.Headers.Add(header.Key, header.Value); - } - } - try - { - var httpResponseMessage = await http.SendAsync(request); - var code = (int) httpResponseMessage.StatusCode; - var response = await httpResponseMessage.Content.ReadAsStringAsync(); - - if (code >= 400) { - var message = response.ToString(); - var isJson = httpResponseMessage.Content.Headers.GetValues("Content-Type").FirstOrDefault().Contains("application/json"); - - if (isJson) { - message = (JObject.Parse(message))["message"].ToString(); - } - - throw new AppwriteException(message, code, response.ToString()); - } - - return httpResponseMessage; - } - catch (System.Exception e) - { - throw new AppwriteException(e.Message, e); - } - - } - } -} diff --git a/io/appwrite/src/Appwrite/Helpers/ExtensionMethods.cs b/io/appwrite/src/Appwrite/Helpers/ExtensionMethods.cs deleted file mode 100644 index d0bcbc8..0000000 --- a/io/appwrite/src/Appwrite/Helpers/ExtensionMethods.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Serialization; -using System; -using System.Collections.Generic; - -namespace Appwrite -{ - public static class ExtensionMethods - { - public static string ToJson(this Dictionary dict) - { - var settings = new JsonSerializerSettings - { - ContractResolver = new CamelCasePropertyNamesContractResolver(), - Converters = new List { new StringEnumConverter() } - }; - - return JsonConvert.SerializeObject(dict, settings); - } - - public static string ToQueryString(this Dictionary parameters) - { - List query = new List(); - - foreach (KeyValuePair parameter in parameters) - { - if (parameter.Value != null) - { - if (parameter.Value is List) - { - foreach(object entry in (dynamic) parameter.Value) - { - query.Add(parameter.Key + "[]=" + Uri.EscapeUriString(entry.ToString())); - } - } - else - { - query.Add(parameter.Key + "=" + Uri.EscapeUriString(parameter.Value.ToString())); - } - } - } - return string.Join("&", query); - } - } -} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Models/Rule.cs b/io/appwrite/src/Appwrite/Models/Rule.cs deleted file mode 100644 index c6ad8d3..0000000 --- a/io/appwrite/src/Appwrite/Models/Rule.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Appwrite -{ - public class Rule - { - public string Label { get; set; } - public string Key { get; set; } - public string Type { get; set; } - public string Default { get; set; } - public bool Required { get; set; } - public bool Array { get; set; } - } -} diff --git a/io/appwrite/src/Appwrite/Services/Account.cs b/io/appwrite/src/Appwrite/Services/Account.cs deleted file mode 100644 index 29569f2..0000000 --- a/io/appwrite/src/Appwrite/Services/Account.cs +++ /dev/null @@ -1,430 +0,0 @@ - -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Account : Service - { - public Account(Client client) : base(client) { } - - /// - /// Get Account - /// - /// Get currently logged in user data as JSON object. - /// - /// - public async Task Get() - { - string path = "/account"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Delete Account - /// - /// Delete a currently logged in user account. Behind the scene, the user - /// record is not deleted but permanently blocked from any access. This is done - /// to avoid deleted accounts being overtaken by new users with the same email - /// address. Any user-related resources like documents or storage files should - /// be deleted separately. - /// - /// - public async Task Delete() - { - string path = "/account"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// Update Account Email - /// - /// Update currently logged in user account email address. After changing user - /// address, user confirmation status is being reset and a new confirmation - /// mail is sent. For security measures, user password is required to complete - /// this request. - /// This endpoint can also be used to convert an anonymous account to a normal - /// one, by passing an email address and a new password. - /// - /// - public async Task UpdateEmail(string email, string password) - { - string path = "/account/email"; - - Dictionary parameters = new Dictionary() - { - { "email", email }, - { "password", password } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - - /// - /// Get Account Logs - /// - /// Get currently logged in user list of latest security activity logs. Each - /// log returns user IP address, location and date and time of log. - /// - /// - public async Task GetLogs() - { - string path = "/account/logs"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Update Account Name - /// - /// Update currently logged in user account name. - /// - /// - public async Task UpdateName(string name) - { - string path = "/account/name"; - - Dictionary parameters = new Dictionary() - { - { "name", name } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - - /// - /// Update Account Password - /// - /// Update currently logged in user password. For validation, user is required - /// to pass in the new password, and the old password. For users created with - /// OAuth and Team Invites, oldPassword is optional. - /// - /// - public async Task UpdatePassword(string password, string oldPassword = "") - { - string path = "/account/password"; - - Dictionary parameters = new Dictionary() - { - { "password", password }, - { "oldPassword", oldPassword } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - - /// - /// Get Account Preferences - /// - /// Get currently logged in user preferences as a key-value object. - /// - /// - public async Task GetPrefs() - { - string path = "/account/prefs"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Update Account Preferences - /// - /// Update currently logged in user account preferences. You can pass only the - /// specific settings you wish to update. - /// - /// - public async Task UpdatePrefs(object prefs) - { - string path = "/account/prefs"; - - Dictionary parameters = new Dictionary() - { - { "prefs", prefs } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - - /// - /// Create Password Recovery - /// - /// Sends the user an email with a temporary secret key for password reset. - /// When the user clicks the confirmation link he is redirected back to your - /// app password reset URL with the secret key and email address values - /// attached to the URL query string. Use the query string params to submit a - /// request to the [PUT - /// /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to - /// complete the process. The verification link sent to the user's email - /// address is valid for 1 hour. - /// - /// - public async Task CreateRecovery(string email, string url) - { - string path = "/account/recovery"; - - Dictionary parameters = new Dictionary() - { - { "email", email }, - { "url", url } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Complete Password Recovery - /// - /// Use this endpoint to complete the user account password reset. Both the - /// **userId** and **secret** arguments will be passed as query parameters to - /// the redirect URL you have provided when sending your request to the [POST - /// /account/recovery](/docs/client/account#accountCreateRecovery) endpoint. - /// - /// Please note that in order to avoid a [Redirect - /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - /// the only valid redirect URLs are the ones from domains you have set when - /// adding your platforms in the console interface. - /// - /// - public async Task UpdateRecovery(string userId, string secret, string password, string passwordAgain) - { - string path = "/account/recovery"; - - Dictionary parameters = new Dictionary() - { - { "userId", userId }, - { "secret", secret }, - { "password", password }, - { "passwordAgain", passwordAgain } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PUT", path, headers, parameters); - } - - /// - /// Get Account Sessions - /// - /// Get currently logged in user list of active sessions across different - /// devices. - /// - /// - public async Task GetSessions() - { - string path = "/account/sessions"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Delete All Account Sessions - /// - /// Delete all sessions from the user account and remove any sessions cookies - /// from the end client. - /// - /// - public async Task DeleteSessions() - { - string path = "/account/sessions"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// Get Session By ID - /// - /// Use this endpoint to get a logged in user's session using a Session ID. - /// Inputting 'current' will return the current session being used. - /// - /// - public async Task GetSession(string sessionId) - { - string path = "/account/sessions/{sessionId}".Replace("{sessionId}", sessionId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Delete Account Session - /// - /// Use this endpoint to log out the currently logged in user from all their - /// account sessions across all of their different devices. When using the - /// option id argument, only the session unique ID provider will be deleted. - /// - /// - public async Task DeleteSession(string sessionId) - { - string path = "/account/sessions/{sessionId}".Replace("{sessionId}", sessionId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// Create Email Verification - /// - /// Use this endpoint to send a verification message to your user email address - /// to confirm they are the valid owners of that address. Both the **userId** - /// and **secret** arguments will be passed as query parameters to the URL you - /// have provided to be attached to the verification email. The provided URL - /// should redirect the user back to your app and allow you to complete the - /// verification process by verifying both the **userId** and **secret** - /// parameters. Learn more about how to [complete the verification - /// process](/docs/client/account#accountUpdateVerification). The verification - /// link sent to the user's email address is valid for 7 days. - /// - /// Please note that in order to avoid a [Redirect - /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), - /// the only valid redirect URLs are the ones from domains you have set when - /// adding your platforms in the console interface. - /// - /// - /// - public async Task CreateVerification(string url) - { - string path = "/account/verification"; - - Dictionary parameters = new Dictionary() - { - { "url", url } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Complete Email Verification - /// - /// Use this endpoint to complete the user email verification process. Use both - /// the **userId** and **secret** parameters that were attached to your app URL - /// to verify the user email ownership. If confirmed this route will return a - /// 200 status code. - /// - /// - public async Task UpdateVerification(string userId, string secret) - { - string path = "/account/verification"; - - Dictionary parameters = new Dictionary() - { - { "userId", userId }, - { "secret", secret } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PUT", path, headers, parameters); - } - }; -} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Services/Avatars.cs b/io/appwrite/src/Appwrite/Services/Avatars.cs deleted file mode 100644 index 9a07de6..0000000 --- a/io/appwrite/src/Appwrite/Services/Avatars.cs +++ /dev/null @@ -1,190 +0,0 @@ - -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Avatars : Service - { - public Avatars(Client client) : base(client) { } - - /// - /// Get Browser Icon - /// - /// You can use this endpoint to show different browser icons to your users. - /// The code argument receives the browser code as it appears in your user - /// /account/sessions endpoint. Use width, height and quality arguments to - /// change the output settings. - /// - /// - public string GetBrowser(string code, int? width = 100, int? height = 100, int? quality = 100) - { - string path = "/avatars/browsers/{code}".Replace("{code}", code); - - Dictionary parameters = new Dictionary() - { - { "width", width }, - { "height", height }, - { "quality", quality }, - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - - /// - /// Get Credit Card Icon - /// - /// The credit card endpoint will return you the icon of the credit card - /// provider you need. Use width, height and quality arguments to change the - /// output settings. - /// - /// - public string GetCreditCard(string code, int? width = 100, int? height = 100, int? quality = 100) - { - string path = "/avatars/credit-cards/{code}".Replace("{code}", code); - - Dictionary parameters = new Dictionary() - { - { "width", width }, - { "height", height }, - { "quality", quality }, - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - - /// - /// Get Favicon - /// - /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote - /// website URL. - /// - /// - /// - public string GetFavicon(string url) - { - string path = "/avatars/favicon"; - - Dictionary parameters = new Dictionary() - { - { "url", url }, - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - - /// - /// Get Country Flag - /// - /// You can use this endpoint to show different country flags icons to your - /// users. The code argument receives the 2 letter country code. Use width, - /// height and quality arguments to change the output settings. - /// - /// - public string GetFlag(string code, int? width = 100, int? height = 100, int? quality = 100) - { - string path = "/avatars/flags/{code}".Replace("{code}", code); - - Dictionary parameters = new Dictionary() - { - { "width", width }, - { "height", height }, - { "quality", quality }, - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - - /// - /// Get Image from URL - /// - /// Use this endpoint to fetch a remote image URL and crop it to any image size - /// you want. This endpoint is very useful if you need to crop and display - /// remote images in your app or in case you want to make sure a 3rd party - /// image is properly served using a TLS protocol. - /// - /// - public string GetImage(string url, int? width = 400, int? height = 400) - { - string path = "/avatars/image"; - - Dictionary parameters = new Dictionary() - { - { "url", url }, - { "width", width }, - { "height", height }, - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - - /// - /// Get User Initials - /// - /// Use this endpoint to show your user initials avatar icon on your website or - /// app. By default, this route will try to print your logged-in user name or - /// email initials. You can also overwrite the user name if you pass the 'name' - /// parameter. If no name is given and no user is logged, an empty avatar will - /// be returned. - /// - /// You can use the color and background params to change the avatar colors. By - /// default, a random theme will be selected. The random theme will persist for - /// the user's initials when reloading the same theme will always return for - /// the same initials. - /// - /// - public string GetInitials(string name = "", int? width = 500, int? height = 500, string color = "", string background = "") - { - string path = "/avatars/initials"; - - Dictionary parameters = new Dictionary() - { - { "name", name }, - { "width", width }, - { "height", height }, - { "color", color }, - { "background", background }, - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - - /// - /// Get QR Code - /// - /// Converts a given plain text to a QR code image. You can use the query - /// parameters to change the size and style of the resulting image. - /// - /// - public string GetQR(string text, int? size = 400, int? margin = 1, bool? download = false) - { - string path = "/avatars/qr"; - - Dictionary parameters = new Dictionary() - { - { "text", text }, - { "size", size }, - { "margin", margin }, - { "download", download }, - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - }; -} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Services/Database.cs b/io/appwrite/src/Appwrite/Services/Database.cs deleted file mode 100644 index 6fe53f4..0000000 --- a/io/appwrite/src/Appwrite/Services/Database.cs +++ /dev/null @@ -1,276 +0,0 @@ - -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Database : Service - { - public Database(Client client) : base(client) { } - - /// - /// List Collections - /// - /// Get a list of all the user collections. You can use the query params to - /// filter your results. On admin mode, this endpoint will return a list of all - /// of the project's collections. [Learn more about different API - /// modes](/docs/admin). - /// - /// - public async Task ListCollections(string search = "", int? limit = 25, int? offset = 0, OrderType orderType = OrderType.ASC) - { - string path = "/database/collections"; - - Dictionary parameters = new Dictionary() - { - { "search", search }, - { "limit", limit }, - { "offset", offset }, - { "orderType", orderType.ToString() } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Create Collection - /// - /// Create a new Collection. - /// - /// - public async Task CreateCollection(string name, List read, List write, List rules) - { - string path = "/database/collections"; - - Dictionary parameters = new Dictionary() - { - { "name", name }, - { "read", read }, - { "write", write }, - { "rules", rules } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Get Collection - /// - /// Get a collection by its unique ID. This endpoint response returns a JSON - /// object with the collection metadata. - /// - /// - public async Task GetCollection(string collectionId) - { - string path = "/database/collections/{collectionId}".Replace("{collectionId}", collectionId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Update Collection - /// - /// Update a collection by its unique ID. - /// - /// - public async Task UpdateCollection(string collectionId, string name, List read = null, List write = null, List rules = null) - { - string path = "/database/collections/{collectionId}".Replace("{collectionId}", collectionId); - - Dictionary parameters = new Dictionary() - { - { "name", name }, - { "read", read }, - { "write", write }, - { "rules", rules } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PUT", path, headers, parameters); - } - - /// - /// Delete Collection - /// - /// Delete a collection by its unique ID. Only users with write permissions - /// have access to delete this resource. - /// - /// - public async Task DeleteCollection(string collectionId) - { - string path = "/database/collections/{collectionId}".Replace("{collectionId}", collectionId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// List Documents - /// - /// Get a list of all the user documents. You can use the query params to - /// filter your results. On admin mode, this endpoint will return a list of all - /// of the project's documents. [Learn more about different API - /// modes](/docs/admin). - /// - /// - public async Task ListDocuments(string collectionId, List filters = null, int? limit = 25, int? offset = 0, string orderField = "", OrderType orderType = OrderType.ASC, string orderCast = "string", string search = "") - { - string path = "/database/collections/{collectionId}/documents".Replace("{collectionId}", collectionId); - - Dictionary parameters = new Dictionary() - { - { "filters", filters }, - { "limit", limit }, - { "offset", offset }, - { "orderField", orderField }, - { "orderType", orderType.ToString() }, - { "orderCast", orderCast }, - { "search", search } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Create Document - /// - /// Create a new Document. Before using this route, you should create a new - /// collection resource using either a [server - /// integration](/docs/server/database#databaseCreateCollection) API or - /// directly from your database console. - /// - /// - public async Task CreateDocument(string collectionId, object data, List read = null, List write = null, string parentDocument = "", string parentProperty = "", string parentPropertyType = "assign") - { - string path = "/database/collections/{collectionId}/documents".Replace("{collectionId}", collectionId); - - Dictionary parameters = new Dictionary() - { - { "data", data }, - { "read", read }, - { "write", write }, - { "parentDocument", parentDocument }, - { "parentProperty", parentProperty }, - { "parentPropertyType", parentPropertyType } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Get Document - /// - /// Get a document by its unique ID. This endpoint response returns a JSON - /// object with the document data. - /// - /// - public async Task GetDocument(string collectionId, string documentId) - { - string path = "/database/collections/{collectionId}/documents/{documentId}".Replace("{collectionId}", collectionId).Replace("{documentId}", documentId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Update Document - /// - /// Update a document by its unique ID. Using the patch method you can pass - /// only specific fields that will get updated. - /// - /// - public async Task UpdateDocument(string collectionId, string documentId, object data, List read = null, List write = null) - { - string path = "/database/collections/{collectionId}/documents/{documentId}".Replace("{collectionId}", collectionId).Replace("{documentId}", documentId); - - Dictionary parameters = new Dictionary() - { - { "data", data }, - { "read", read }, - { "write", write } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - - /// - /// Delete Document - /// - /// Delete a document by its unique ID. This endpoint deletes only the parent - /// documents, its attributes and relations to other documents. Child documents - /// **will not** be deleted. - /// - /// - public async Task DeleteDocument(string collectionId, string documentId) - { - string path = "/database/collections/{collectionId}/documents/{documentId}".Replace("{collectionId}", collectionId).Replace("{documentId}", documentId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - }; -} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Services/Functions.cs b/io/appwrite/src/Appwrite/Services/Functions.cs deleted file mode 100644 index df35e6a..0000000 --- a/io/appwrite/src/Appwrite/Services/Functions.cs +++ /dev/null @@ -1,349 +0,0 @@ - -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Functions : Service - { - public Functions(Client client) : base(client) { } - - /// - /// List Functions - /// - /// Get a list of all the project's functions. You can use the query params to - /// filter your results. - /// - /// - public async Task List(string search = "", int? limit = 25, int? offset = 0, OrderType orderType = OrderType.ASC) - { - string path = "/functions"; - - Dictionary parameters = new Dictionary() - { - { "search", search }, - { "limit", limit }, - { "offset", offset }, - { "orderType", orderType.ToString() } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Create Function - /// - /// Create a new function. You can pass a list of - /// [permissions](/docs/permissions) to allow different project users or team - /// with access to execute the function using the client API. - /// - /// - public async Task Create(string name, List execute, string runtime, object vars = null, List events = null, string schedule = "", int? timeout = 15) - { - string path = "/functions"; - - Dictionary parameters = new Dictionary() - { - { "name", name }, - { "execute", execute }, - { "runtime", runtime }, - { "vars", vars }, - { "events", events }, - { "schedule", schedule }, - { "timeout", timeout } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Get Function - /// - /// Get a function by its unique ID. - /// - /// - public async Task Get(string functionId) - { - string path = "/functions/{functionId}".Replace("{functionId}", functionId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Update Function - /// - /// Update function by its unique ID. - /// - /// - public async Task Update(string functionId, string name, List execute, object vars = null, List events = null, string schedule = "", int? timeout = 15) - { - string path = "/functions/{functionId}".Replace("{functionId}", functionId); - - Dictionary parameters = new Dictionary() - { - { "name", name }, - { "execute", execute }, - { "vars", vars }, - { "events", events }, - { "schedule", schedule }, - { "timeout", timeout } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PUT", path, headers, parameters); - } - - /// - /// Delete Function - /// - /// Delete a function by its unique ID. - /// - /// - public async Task Delete(string functionId) - { - string path = "/functions/{functionId}".Replace("{functionId}", functionId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// List Executions - /// - /// Get a list of all the current user function execution logs. You can use the - /// query params to filter your results. On admin mode, this endpoint will - /// return a list of all of the project's executions. [Learn more about - /// different API modes](/docs/admin). - /// - /// - public async Task ListExecutions(string functionId, string search = "", int? limit = 25, int? offset = 0, OrderType orderType = OrderType.ASC) - { - string path = "/functions/{functionId}/executions".Replace("{functionId}", functionId); - - Dictionary parameters = new Dictionary() - { - { "search", search }, - { "limit", limit }, - { "offset", offset }, - { "orderType", orderType.ToString() } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Create Execution - /// - /// Trigger a function execution. The returned object will return you the - /// current execution status. You can ping the `Get Execution` endpoint to get - /// updates on the current execution status. Once this endpoint is called, your - /// function execution process will start asynchronously. - /// - /// - public async Task CreateExecution(string functionId, string data = "") - { - string path = "/functions/{functionId}/executions".Replace("{functionId}", functionId); - - Dictionary parameters = new Dictionary() - { - { "data", data } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Get Execution - /// - /// Get a function execution log by its unique ID. - /// - /// - public async Task GetExecution(string functionId, string executionId) - { - string path = "/functions/{functionId}/executions/{executionId}".Replace("{functionId}", functionId).Replace("{executionId}", executionId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Update Function Tag - /// - /// Update the function code tag ID using the unique function ID. Use this - /// endpoint to switch the code tag that should be executed by the execution - /// endpoint. - /// - /// - public async Task UpdateTag(string functionId, string tag) - { - string path = "/functions/{functionId}/tag".Replace("{functionId}", functionId); - - Dictionary parameters = new Dictionary() - { - { "tag", tag } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - - /// - /// List Tags - /// - /// Get a list of all the project's code tags. You can use the query params to - /// filter your results. - /// - /// - public async Task ListTags(string functionId, string search = "", int? limit = 25, int? offset = 0, OrderType orderType = OrderType.ASC) - { - string path = "/functions/{functionId}/tags".Replace("{functionId}", functionId); - - Dictionary parameters = new Dictionary() - { - { "search", search }, - { "limit", limit }, - { "offset", offset }, - { "orderType", orderType.ToString() } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Create Tag - /// - /// Create a new function code tag. Use this endpoint to upload a new version - /// of your code function. To execute your newly uploaded code, you'll need to - /// update the function's tag to use your new tag UID. - /// - /// This endpoint accepts a tar.gz file compressed with your code. Make sure to - /// include any dependencies your code has within the compressed file. You can - /// learn more about code packaging in the [Appwrite Cloud Functions - /// tutorial](/docs/functions). - /// - /// Use the "command" param to set the entry point used to execute your code. - /// - /// - public async Task CreateTag(string functionId, string command, FileInfo code) - { - string path = "/functions/{functionId}/tags".Replace("{functionId}", functionId); - - Dictionary parameters = new Dictionary() - { - { "command", command }, - { "code", code } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "multipart/form-data" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Get Tag - /// - /// Get a code tag by its unique ID. - /// - /// - public async Task GetTag(string functionId, string tagId) - { - string path = "/functions/{functionId}/tags/{tagId}".Replace("{functionId}", functionId).Replace("{tagId}", tagId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Delete Tag - /// - /// Delete a code tag by its unique ID. - /// - /// - public async Task DeleteTag(string functionId, string tagId) - { - string path = "/functions/{functionId}/tags/{tagId}".Replace("{functionId}", functionId).Replace("{tagId}", tagId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - }; -} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Services/Health.cs b/io/appwrite/src/Appwrite/Services/Health.cs deleted file mode 100644 index e18c026..0000000 --- a/io/appwrite/src/Appwrite/Services/Health.cs +++ /dev/null @@ -1,287 +0,0 @@ - -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Health : Service - { - public Health(Client client) : base(client) { } - - /// - /// Get HTTP - /// - /// Check the Appwrite HTTP server is up and responsive. - /// - /// - public async Task Get() - { - string path = "/health"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Anti virus - /// - /// Check the Appwrite Anti Virus server is up and connection is successful. - /// - /// - public async Task GetAntiVirus() - { - string path = "/health/anti-virus"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Cache - /// - /// Check the Appwrite in-memory cache server is up and connection is - /// successful. - /// - /// - public async Task GetCache() - { - string path = "/health/cache"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get DB - /// - /// Check the Appwrite database server is up and connection is successful. - /// - /// - public async Task GetDB() - { - string path = "/health/db"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Certificate Queue - /// - /// Get the number of certificates that are waiting to be issued against - /// [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - /// server. - /// - /// - public async Task GetQueueCertificates() - { - string path = "/health/queue/certificates"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Functions Queue - /// - public async Task GetQueueFunctions() - { - string path = "/health/queue/functions"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Logs Queue - /// - /// Get the number of logs that are waiting to be processed in the Appwrite - /// internal queue server. - /// - /// - public async Task GetQueueLogs() - { - string path = "/health/queue/logs"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Tasks Queue - /// - /// Get the number of tasks that are waiting to be processed in the Appwrite - /// internal queue server. - /// - /// - public async Task GetQueueTasks() - { - string path = "/health/queue/tasks"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Usage Queue - /// - /// Get the number of usage stats that are waiting to be processed in the - /// Appwrite internal queue server. - /// - /// - public async Task GetQueueUsage() - { - string path = "/health/queue/usage"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Webhooks Queue - /// - /// Get the number of webhooks that are waiting to be processed in the Appwrite - /// internal queue server. - /// - /// - public async Task GetQueueWebhooks() - { - string path = "/health/queue/webhooks"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Local Storage - /// - /// Check the Appwrite local storage device is up and connection is successful. - /// - /// - public async Task GetStorageLocal() - { - string path = "/health/storage/local"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get Time - /// - /// Check the Appwrite server time is synced with Google remote NTP server. We - /// use this technology to smoothly handle leap seconds with no disruptive - /// events. The [Network Time - /// Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - /// used by hundreds of millions of computers and devices to synchronize their - /// clocks over the Internet. If your computer sets its own clock, it likely - /// uses NTP. - /// - /// - public async Task GetTime() - { - string path = "/health/time"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - }; -} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Services/Locale.cs b/io/appwrite/src/Appwrite/Services/Locale.cs deleted file mode 100644 index 506ac59..0000000 --- a/io/appwrite/src/Appwrite/Services/Locale.cs +++ /dev/null @@ -1,179 +0,0 @@ - -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Locale : Service - { - public Locale(Client client) : base(client) { } - - /// - /// Get User Locale - /// - /// Get the current user location based on IP. Returns an object with user - /// country code, country name, continent name, continent code, ip address and - /// suggested currency. You can use the locale header to get the data in a - /// supported language. - /// - /// ([IP Geolocation by DB-IP](https://db-ip.com)) - /// - /// - public async Task Get() - { - string path = "/locale"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// List Continents - /// - /// List of all continents. You can use the locale header to get the data in a - /// supported language. - /// - /// - public async Task GetContinents() - { - string path = "/locale/continents"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// List Countries - /// - /// List of all countries. You can use the locale header to get the data in a - /// supported language. - /// - /// - public async Task GetCountries() - { - string path = "/locale/countries"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// List EU Countries - /// - /// List of all countries that are currently members of the EU. You can use the - /// locale header to get the data in a supported language. - /// - /// - public async Task GetCountriesEU() - { - string path = "/locale/countries/eu"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// List Countries Phone Codes - /// - /// List of all countries phone codes. You can use the locale header to get the - /// data in a supported language. - /// - /// - public async Task GetCountriesPhones() - { - string path = "/locale/countries/phones"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// List Currencies - /// - /// List of all currencies, including currency symbol, name, plural, and - /// decimal digits for all major and minor currencies. You can use the locale - /// header to get the data in a supported language. - /// - /// - public async Task GetCurrencies() - { - string path = "/locale/currencies"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// List Languages - /// - /// List of all languages classified by ISO 639-1 including 2-letter code, name - /// in English, and name in the respective language. - /// - /// - public async Task GetLanguages() - { - string path = "/locale/languages"; - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - }; -} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Services/Storage.cs b/io/appwrite/src/Appwrite/Services/Storage.cs deleted file mode 100644 index 0ce7023..0000000 --- a/io/appwrite/src/Appwrite/Services/Storage.cs +++ /dev/null @@ -1,214 +0,0 @@ - -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Storage : Service - { - public Storage(Client client) : base(client) { } - - /// - /// List Files - /// - /// Get a list of all the user files. You can use the query params to filter - /// your results. On admin mode, this endpoint will return a list of all of the - /// project's files. [Learn more about different API modes](/docs/admin). - /// - /// - public async Task ListFiles(string search = "", int? limit = 25, int? offset = 0, OrderType orderType = OrderType.ASC) - { - string path = "/storage/files"; - - Dictionary parameters = new Dictionary() - { - { "search", search }, - { "limit", limit }, - { "offset", offset }, - { "orderType", orderType.ToString() } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Create File - /// - /// Create a new file. The user who creates the file will automatically be - /// assigned to read and write access unless he has passed custom values for - /// read and write arguments. - /// - /// - public async Task CreateFile(FileInfo file, List read = null, List write = null) - { - string path = "/storage/files"; - - Dictionary parameters = new Dictionary() - { - { "file", file }, - { "read", read }, - { "write", write } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "multipart/form-data" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Get File - /// - /// Get a file by its unique ID. This endpoint response returns a JSON object - /// with the file metadata. - /// - /// - public async Task GetFile(string fileId) - { - string path = "/storage/files/{fileId}".Replace("{fileId}", fileId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Update File - /// - /// Update a file by its unique ID. Only users with write permissions have - /// access to update this resource. - /// - /// - public async Task UpdateFile(string fileId, List read, List write) - { - string path = "/storage/files/{fileId}".Replace("{fileId}", fileId); - - Dictionary parameters = new Dictionary() - { - { "read", read }, - { "write", write } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PUT", path, headers, parameters); - } - - /// - /// Delete File - /// - /// Delete a file by its unique ID. Only users with write permissions have - /// access to delete this resource. - /// - /// - public async Task DeleteFile(string fileId) - { - string path = "/storage/files/{fileId}".Replace("{fileId}", fileId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// Get File for Download - /// - /// Get a file 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. - /// - /// - public string GetFileDownload(string fileId) - { - string path = "/storage/files/{fileId}/download".Replace("{fileId}", fileId); - - Dictionary parameters = new Dictionary() - { - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - - /// - /// Get File Preview - /// - /// Get a file preview image. Currently, this method supports preview for image - /// files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - /// and spreadsheets, will return the file icon image. You can also pass query - /// string arguments for cutting and resizing your preview image. - /// - /// - public string GetFilePreview(string fileId, int? width = 0, int? height = 0, string gravity = "center", int? quality = 100, int? borderWidth = 0, string borderColor = "", int? borderRadius = 0, number opacity = , int? rotation = 0, string background = "", string output = "") - { - string path = "/storage/files/{fileId}/preview".Replace("{fileId}", fileId); - - Dictionary parameters = new Dictionary() - { - { "width", width }, - { "height", height }, - { "gravity", gravity }, - { "quality", quality }, - { "borderWidth", borderWidth }, - { "borderColor", borderColor }, - { "borderRadius", borderRadius }, - { "opacity", opacity }, - { "rotation", rotation }, - { "background", background }, - { "output", output }, - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - - /// - /// Get File for View - /// - /// Get a file content by its unique ID. This endpoint is similar to the - /// download method but returns with no 'Content-Disposition: attachment' - /// header. - /// - /// - public string GetFileView(string fileId) - { - string path = "/storage/files/{fileId}/view".Replace("{fileId}", fileId); - - Dictionary parameters = new Dictionary() - { - }; - // { "project", _client.GetConfig().get("project") }, - // { "key", _client.GetConfig().get("key") } - - return _client.GetEndPoint() + path + "?" + parameters.ToQueryString(); - } - }; -} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Services/Teams.cs b/io/appwrite/src/Appwrite/Services/Teams.cs deleted file mode 100644 index ce5a855..0000000 --- a/io/appwrite/src/Appwrite/Services/Teams.cs +++ /dev/null @@ -1,274 +0,0 @@ - -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Teams : Service - { - public Teams(Client client) : base(client) { } - - /// - /// List Teams - /// - /// Get a list of all the current user teams. You can use the query params to - /// filter your results. On admin mode, this endpoint will return a list of all - /// of the project's teams. [Learn more about different API - /// modes](/docs/admin). - /// - /// - public async Task List(string search = "", int? limit = 25, int? offset = 0, OrderType orderType = OrderType.ASC) - { - string path = "/teams"; - - Dictionary parameters = new Dictionary() - { - { "search", search }, - { "limit", limit }, - { "offset", offset }, - { "orderType", orderType.ToString() } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Create Team - /// - /// Create a new team. The user who creates the team will automatically be - /// assigned as the owner of the team. The team owner can invite new members, - /// who will be able add new owners and update or delete the team from your - /// project. - /// - /// - public async Task Create(string name, List roles = null) - { - string path = "/teams"; - - Dictionary parameters = new Dictionary() - { - { "name", name }, - { "roles", roles } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Get Team - /// - /// Get a team by its unique ID. All team members have read access for this - /// resource. - /// - /// - public async Task Get(string teamId) - { - string path = "/teams/{teamId}".Replace("{teamId}", teamId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Update Team - /// - /// Update a team by its unique ID. Only team owners have write access for this - /// resource. - /// - /// - public async Task Update(string teamId, string name) - { - string path = "/teams/{teamId}".Replace("{teamId}", teamId); - - Dictionary parameters = new Dictionary() - { - { "name", name } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PUT", path, headers, parameters); - } - - /// - /// Delete Team - /// - /// Delete a team by its unique ID. Only team owners have write access for this - /// resource. - /// - /// - public async Task Delete(string teamId) - { - string path = "/teams/{teamId}".Replace("{teamId}", teamId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// Get Team Memberships - /// - /// Get a team members by the team unique ID. All team members have read access - /// for this list of resources. - /// - /// - public async Task GetMemberships(string teamId, string search = "", int? limit = 25, int? offset = 0, OrderType orderType = OrderType.ASC) - { - string path = "/teams/{teamId}/memberships".Replace("{teamId}", teamId); - - Dictionary parameters = new Dictionary() - { - { "search", search }, - { "limit", limit }, - { "offset", offset }, - { "orderType", orderType.ToString() } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Create Team Membership - /// - /// Use this endpoint to invite a new member to join your team. An email with a - /// link to join the team will be sent to the new member email address if the - /// member doesn't exist in the project it will be created automatically. - /// - /// Use the 'URL' parameter to redirect the user from the invitation email back - /// to your app. When the user is redirected, use the [Update Team Membership - /// Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow - /// the user to accept the invitation to the team. - /// - /// Please note that in order to avoid a [Redirect - /// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - /// the only valid redirect URL's are the once from domains you have set when - /// added your platforms in the console interface. - /// - /// - public async Task CreateMembership(string teamId, string email, List roles, string url, string name = "") - { - string path = "/teams/{teamId}/memberships".Replace("{teamId}", teamId); - - Dictionary parameters = new Dictionary() - { - { "email", email }, - { "name", name }, - { "roles", roles }, - { "url", url } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Update Membership Roles - /// - public async Task UpdateMembershipRoles(string teamId, string membershipId, List roles) - { - string path = "/teams/{teamId}/memberships/{membershipId}".Replace("{teamId}", teamId).Replace("{membershipId}", membershipId); - - Dictionary parameters = new Dictionary() - { - { "roles", roles } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - - /// - /// Delete Team Membership - /// - /// This endpoint allows a user to leave a team or for a team owner to delete - /// the membership of any other team member. You can also use this endpoint to - /// delete a user membership even if it is not accepted. - /// - /// - public async Task DeleteMembership(string teamId, string membershipId) - { - string path = "/teams/{teamId}/memberships/{membershipId}".Replace("{teamId}", teamId).Replace("{membershipId}", membershipId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// Update Team Membership Status - /// - /// Use this endpoint to allow a user to accept an invitation to join a team - /// after being redirected back to your app from the invitation email recieved - /// by the user. - /// - /// - public async Task UpdateMembershipStatus(string teamId, string membershipId, string userId, string secret) - { - string path = "/teams/{teamId}/memberships/{membershipId}/status".Replace("{teamId}", teamId).Replace("{membershipId}", membershipId); - - Dictionary parameters = new Dictionary() - { - { "userId", userId }, - { "secret", secret } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - }; -} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Services/Users.cs b/io/appwrite/src/Appwrite/Services/Users.cs deleted file mode 100644 index 22227c5..0000000 --- a/io/appwrite/src/Appwrite/Services/Users.cs +++ /dev/null @@ -1,289 +0,0 @@ - -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace Appwrite -{ - public class Users : Service - { - public Users(Client client) : base(client) { } - - /// - /// List Users - /// - /// Get a list of all the project's users. You can use the query params to - /// filter your results. - /// - /// - public async Task List(string search = "", int? limit = 25, int? offset = 0, OrderType orderType = OrderType.ASC) - { - string path = "/users"; - - Dictionary parameters = new Dictionary() - { - { "search", search }, - { "limit", limit }, - { "offset", offset }, - { "orderType", orderType.ToString() } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Create User - /// - /// Create a new user. - /// - /// - public async Task Create(string email, string password, string name = "") - { - string path = "/users"; - - Dictionary parameters = new Dictionary() - { - { "email", email }, - { "password", password }, - { "name", name } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("POST", path, headers, parameters); - } - - /// - /// Get User - /// - /// Get a user by its unique ID. - /// - /// - public async Task Get(string userId) - { - string path = "/users/{userId}".Replace("{userId}", userId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Delete User - /// - /// Delete a user by its unique ID. - /// - /// - public async Task Delete(string userId) - { - string path = "/users/{userId}".Replace("{userId}", userId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// Get User Logs - /// - /// Get a user activity logs list by its unique ID. - /// - /// - public async Task GetLogs(string userId) - { - string path = "/users/{userId}/logs".Replace("{userId}", userId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Get User Preferences - /// - /// Get the user preferences by its unique ID. - /// - /// - public async Task GetPrefs(string userId) - { - string path = "/users/{userId}/prefs".Replace("{userId}", userId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Update User Preferences - /// - /// Update the user preferences by its unique ID. You can pass only the - /// specific settings you wish to update. - /// - /// - public async Task UpdatePrefs(string userId, object prefs) - { - string path = "/users/{userId}/prefs".Replace("{userId}", userId); - - Dictionary parameters = new Dictionary() - { - { "prefs", prefs } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - - /// - /// Get User Sessions - /// - /// Get the user sessions list by its unique ID. - /// - /// - public async Task GetSessions(string userId) - { - string path = "/users/{userId}/sessions".Replace("{userId}", userId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("GET", path, headers, parameters); - } - - /// - /// Delete User Sessions - /// - /// Delete all user's sessions by using the user's unique ID. - /// - /// - public async Task DeleteSessions(string userId) - { - string path = "/users/{userId}/sessions".Replace("{userId}", userId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// Delete User Session - /// - /// Delete a user sessions by its unique ID. - /// - /// - public async Task DeleteSession(string userId, string sessionId) - { - string path = "/users/{userId}/sessions/{sessionId}".Replace("{userId}", userId).Replace("{sessionId}", sessionId); - - Dictionary parameters = new Dictionary() - { - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("DELETE", path, headers, parameters); - } - - /// - /// Update User Status - /// - /// Update the user status by its unique ID. - /// - /// - public async Task UpdateStatus(string userId, int status) - { - string path = "/users/{userId}/status".Replace("{userId}", userId); - - Dictionary parameters = new Dictionary() - { - { "status", status } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - - /// - /// Update Email Verification - /// - /// Update the user email verification status by its unique ID. - /// - /// - public async Task UpdateVerification(string userId, bool emailVerification) - { - string path = "/users/{userId}/verification".Replace("{userId}", userId); - - Dictionary parameters = new Dictionary() - { - { "emailVerification", emailVerification } - }; - - Dictionary headers = new Dictionary() - { - { "content-type", "application/json" } - }; - - return await _client.Call("PATCH", path, headers, parameters); - } - }; -} \ No newline at end of file diff --git a/src/Appwrite/Appwrite.csproj b/src/Appwrite/Appwrite.csproj index 2a3e0d5..8562b0f 100644 --- a/src/Appwrite/Appwrite.csproj +++ b/src/Appwrite/Appwrite.csproj @@ -1,8 +1,8 @@ - netcoreapp3.1;net461;netstandard2.0; + netstandard2.0;net461 Appwrite - 0.3.0 + 0.4.0 Appwrite Team Appwrite Team @@ -14,11 +14,12 @@ git https://github.com/appwrite/sdk-for-dotnet true + latest + enable - - + diff --git a/io/appwrite/src/Appwrite/Models/Exception.cs b/src/Appwrite/AppwriteException.cs similarity index 55% rename from io/appwrite/src/Appwrite/Models/Exception.cs rename to src/Appwrite/AppwriteException.cs index d8b5e4f..b2e33a1 100644 --- a/io/appwrite/src/Appwrite/Models/Exception.cs +++ b/src/Appwrite/AppwriteException.cs @@ -4,10 +4,13 @@ namespace Appwrite { public class AppwriteException : Exception { - public int? Code; - public string Response = null; - public AppwriteException(string message = null, int? code = null, string response = null) - : base(message) + public int? Code { get; set; } + public string? Response { get; set; } = null; + + public AppwriteException( + string? message = null, + int? code = null, + string? response = null) : base(message) { this.Code = code; this.Response = response; diff --git a/src/Appwrite/Client.cs b/src/Appwrite/Client.cs new file mode 100644 index 0000000..4575adf --- /dev/null +++ b/src/Appwrite/Client.cs @@ -0,0 +1,407 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Serialization; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; +using Appwrite.Extensions; +using Appwrite.Models; + +namespace Appwrite +{ + public class Client + { + public string Endpoint => _endpoint; + public Dictionary Config => _config; + + private HttpClient _http; + private readonly Dictionary _headers; + private readonly Dictionary _config; + private string _endpoint; + + private static readonly int ChunkSize = 5 * 1024 * 1024; + + public static JsonSerializerSettings DeserializerSettings { get; set; } = new JsonSerializerSettings + { + MetadataPropertyHandling = MetadataPropertyHandling.Ignore, + NullValueHandling = NullValueHandling.Ignore, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + Converters = new List + { + new StringEnumConverter() + } + }; + + public static JsonSerializerSettings SerializerSettings { get; set; } = new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + Converters = new List + { + new StringEnumConverter() + } + }; + + public Client( + string endpoint = "https://HOSTNAME/v1", + bool selfSigned = false, + HttpClient? http = null) + { + _endpoint = endpoint; + _http = http ?? new HttpClient(); + _headers = new Dictionary() + { + { "content-type", "application/json" }, + { "user-agent" , "AppwriteDotNetSDK/0.4.0 (${Environment.OSVersion.Platform}; ${Environment.OSVersion.VersionString})"}, + { "x-sdk-name", ".NET" }, + { "x-sdk-platform", "server" }, + { "x-sdk-language", "dotnet" }, + { "x-sdk-version", "0.4.0"}, { "X-Appwrite-Response-Format", "1.0.0" } + }; + + _config = new Dictionary(); + + if (selfSigned) + { + SetSelfSigned(true); + } + + JsonConvert.DefaultSettings = () => DeserializerSettings; + } + + public Client SetSelfSigned(bool selfSigned) + { + var handler = new HttpClientHandler() + { + ServerCertificateCustomValidationCallback = (request, cert, chain, errors) => true + }; + + _http = selfSigned + ? new HttpClient(handler) + : new HttpClient(); + + return this; + } + + public Client SetEndpoint(string endpoint) + { + _endpoint = endpoint; + + return this; + } + + /// Your project ID + public Client SetProject(string value) { + _config.Add("project", value); + AddHeader("X-Appwrite-Project", value); + + return this; + } + + /// Your secret API key + public Client SetKey(string value) { + _config.Add("key", value); + AddHeader("X-Appwrite-Key", value); + + return this; + } + + /// Your secret JSON Web Token + public Client SetJWT(string value) { + _config.Add("jWT", value); + AddHeader("X-Appwrite-JWT", value); + + return this; + } + + public Client SetLocale(string value) { + _config.Add("locale", value); + AddHeader("X-Appwrite-Locale", value); + + return this; + } + + public Client AddHeader(string key, string value) + { + _headers.Add(key, value); + + return this; + } + + public Task> Call( + string method, + string path, + Dictionary headers, + Dictionary parameters) + { + return Call>(method, path, headers, parameters); + } + + public async Task Call( + string method, + string path, + Dictionary headers, + Dictionary parameters, + Func, T>? convert = null) where T : class + { + var methodGet = "GET".Equals(method, StringComparison.OrdinalIgnoreCase); + + var queryString = methodGet ? + "?" + parameters.ToQueryString() : + string.Empty; + + var request = new HttpRequestMessage( + new HttpMethod(method), + _endpoint + path + queryString); + + if ("multipart/form-data".Equals( + headers["content-type"], + StringComparison.OrdinalIgnoreCase)) + { + var form = new MultipartFormDataContent(); + + foreach (var parameter in parameters) + { + if (parameter.Key == "file") + { + form.Add(((MultipartFormDataContent)parameters["file"]).First()!); + } + else if (parameter.Value is IEnumerable enumerable) + { + var list = new List(enumerable); + for (int index = 0; index < list.Count; index++) + { + form.Add(new StringContent(list[index].ToString()!), $"{parameter.Key}[{index}]"); + } + } + else + { + form.Add(new StringContent(parameter.Value.ToString()!), parameter.Key); + } + } + request.Content = form; + + } + else if (!methodGet) + { + string body = parameters.ToJson(); + + request.Content = new StringContent(body, Encoding.UTF8, "application/json"); + } + + foreach (var header in _headers) + { + if (header.Key.Equals("content-type", StringComparison.OrdinalIgnoreCase)) + { + _http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(header.Value)); + } + else + { + if (_http.DefaultRequestHeaders.Contains(header.Key)) { + _http.DefaultRequestHeaders.Remove(header.Key); + } + _http.DefaultRequestHeaders.Add(header.Key, header.Value); + } + } + + foreach (var header in headers) + { + if (header.Key.Equals("content-type", StringComparison.OrdinalIgnoreCase)) + { + request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header.Value)); + } + else if (header.Key.Equals("content-range", StringComparison.OrdinalIgnoreCase)) + { + request.Content.Headers.TryAddWithoutValidation(header.Key, header.Value); + } + else + { + if (request.Headers.Contains(header.Key)) { + request.Headers.Remove(header.Key); + } + request.Headers.Add(header.Key, header.Value); + } + } + + var response = await _http.SendAsync(request); + var code = (int)response.StatusCode; + var contentType = response.Content.Headers + .GetValues("Content-Type") + .FirstOrDefault() ?? string.Empty; + + var isJson = contentType.Contains("application/json"); + var isBytes = contentType.Contains("application/octet-stream"); + + if (code >= 400) { + var message = await response.Content.ReadAsStringAsync(); + + if (isJson) { + message = JObject.Parse(message)["message"]!.ToString(); + } + + throw new AppwriteException(message, code); + } + + if (isJson) + { + var responseString = await response.Content.ReadAsStringAsync(); + + var dict = JsonConvert.DeserializeObject>( + responseString, + DeserializerSettings); + + if (convert != null) + { + return convert(dict!); + } + + return (dict as T)!; + } + else if (isBytes) + { + return ((await response.Content.ReadAsByteArrayAsync()) as T)!; + } + else + { + return default!; + } + } + + public async Task ChunkedUpload( + string path, + Dictionary headers, + Dictionary parameters, + Func, T> converter, + string paramName, + string? idParamName = null, + Action? onProgress = null) where T : class + { + var input = parameters[paramName] as InputFile; + var size = 0L; + switch(input.SourceType) + { + case "path": + var info = new FileInfo(input.Path); + input.Data = info.OpenRead(); + size = info.Length; + break; + case "stream": + size = (input.Data as Stream).Length; + break; + case "bytes": + size = ((byte[])input.Data).Length; + break; + }; + + var offset = 0L; + var buffer = new byte[Math.Min(size, ChunkSize)]; + var result = new Dictionary(); + + if (size < ChunkSize) + { + switch(input.SourceType) + { + case "path": + case "stream": + await (input.Data as Stream).ReadAsync(buffer, 0, (int)size); + break; + case "bytes": + buffer = (byte[])input.Data; + break; + } + + var content = new MultipartFormDataContent { + { new ByteArrayContent(buffer), paramName, input.Filename } + }; + + parameters[paramName] = content; + + return await Call( + method: "POST", + path, + headers, + parameters, + converter + ); + } + + if (!string.IsNullOrEmpty(idParamName) && (string)parameters[idParamName] != "unique()") + { + // Make a request to check if a file already exists + var current = await Call>( + method: "GET", + path: "$path/${params[idParamName]}", + headers, + parameters = new Dictionary() + ); + var chunksUploaded = (long)current["chunksUploaded"]; + offset = Math.Min(chunksUploaded * ChunkSize, size); + } + + while (offset < size) + { + switch(input.SourceType) + { + case "path": + case "stream": + var stream = input.Data as Stream; + stream.Seek(offset, SeekOrigin.Begin); + await stream.ReadAsync(buffer, 0, ChunkSize); + break; + case "bytes": + buffer = ((byte[])input.Data) + .Skip((int)offset) + .Take((int)Math.Min(size - offset, ChunkSize)) + .ToArray(); + break; + } + + var content = new MultipartFormDataContent { + { new ByteArrayContent(buffer), paramName, input.Filename } + }; + + parameters[paramName] = content; + + headers["Content-Range"] = + $"bytes {offset}-{Math.Min(offset + ChunkSize - 1, size)}/{size}"; + + result = await Call>( + method: "POST", + path, + headers, + parameters + ); + + offset += ChunkSize; + + var id = result.ContainsKey("$id") + ? result["$id"]?.ToString() ?? string.Empty + : string.Empty; + var chunksTotal = result.ContainsKey("chunksTotal") + ? (long)result["chunksTotal"] + : 0; + var chunksUploaded = result.ContainsKey("chunksUploaded") + ? (long)result["chunksUploaded"] + : 0; + + headers["x-appwrite-id"] = id; + + onProgress?.Invoke( + new UploadProgress( + id: id, + progress: Math.Min(offset, size) / size * 100, + sizeUploaded: Math.Min(offset, size), + chunksTotal: chunksTotal, + chunksUploaded: chunksUploaded)); + } + + return converter(result); + } + } +} diff --git a/src/Appwrite/Extensions/Extensions.cs b/src/Appwrite/Extensions/Extensions.cs new file mode 100644 index 0000000..0c9edc2 --- /dev/null +++ b/src/Appwrite/Extensions/Extensions.cs @@ -0,0 +1,627 @@ +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Appwrite.Extensions +{ + public static class Extensions + { + public static string ToJson(this Dictionary dict) + { + return JsonConvert.SerializeObject(dict, Client.SerializerSettings); + } + + public static string ToQueryString(this Dictionary parameters) + { + var query = new List(); + + foreach (var kvp in parameters) + { + switch (kvp.Value) + { + case null: + continue; + case IList list: + foreach (var item in list) + { + query.Add($"{kvp.Key}[]={item}"); + } + break; + default: + query.Add($"{kvp.Key}={kvp.Value.ToString()}"); + break; + } + } + + return Uri.EscapeUriString(string.Join("&", query)); + } + + private static IDictionary _mappings = new Dictionary(StringComparer.InvariantCultureIgnoreCase) { + + #region Mime Types + {".323", "text/h323"}, + {".3g2", "video/3gpp2"}, + {".3gp", "video/3gpp"}, + {".3gp2", "video/3gpp2"}, + {".3gpp", "video/3gpp"}, + {".7z", "application/x-7z-compressed"}, + {".aa", "audio/audible"}, + {".AAC", "audio/aac"}, + {".aaf", "application/octet-stream"}, + {".aax", "audio/vnd.audible.aax"}, + {".ac3", "audio/ac3"}, + {".aca", "application/octet-stream"}, + {".accda", "application/msaccess.addin"}, + {".accdb", "application/msaccess"}, + {".accdc", "application/msaccess.cab"}, + {".accde", "application/msaccess"}, + {".accdr", "application/msaccess.runtime"}, + {".accdt", "application/msaccess"}, + {".accdw", "application/msaccess.webapplication"}, + {".accft", "application/msaccess.ftemplate"}, + {".acx", "application/internet-property-stream"}, + {".AddIn", "text/xml"}, + {".ade", "application/msaccess"}, + {".adobebridge", "application/x-bridge-url"}, + {".adp", "application/msaccess"}, + {".ADT", "audio/vnd.dlna.adts"}, + {".ADTS", "audio/aac"}, + {".afm", "application/octet-stream"}, + {".ai", "application/postscript"}, + {".aif", "audio/x-aiff"}, + {".aifc", "audio/aiff"}, + {".aiff", "audio/aiff"}, + {".air", "application/vnd.adobe.air-application-installer-package+zip"}, + {".amc", "application/x-mpeg"}, + {".application", "application/x-ms-application"}, + {".art", "image/x-jg"}, + {".asa", "application/xml"}, + {".asax", "application/xml"}, + {".ascx", "application/xml"}, + {".asd", "application/octet-stream"}, + {".asf", "video/x-ms-asf"}, + {".ashx", "application/xml"}, + {".asi", "application/octet-stream"}, + {".asm", "text/plain"}, + {".asmx", "application/xml"}, + {".aspx", "application/xml"}, + {".asr", "video/x-ms-asf"}, + {".asx", "video/x-ms-asf"}, + {".atom", "application/atom+xml"}, + {".au", "audio/basic"}, + {".avi", "video/x-msvideo"}, + {".axs", "application/olescript"}, + {".bas", "text/plain"}, + {".bcpio", "application/x-bcpio"}, + {".bin", "application/octet-stream"}, + {".bmp", "image/bmp"}, + {".c", "text/plain"}, + {".cab", "application/octet-stream"}, + {".caf", "audio/x-caf"}, + {".calx", "application/vnd.ms-office.calx"}, + {".cat", "application/vnd.ms-pki.seccat"}, + {".cc", "text/plain"}, + {".cd", "text/plain"}, + {".cdda", "audio/aiff"}, + {".cdf", "application/x-cdf"}, + {".cer", "application/x-x509-ca-cert"}, + {".chm", "application/octet-stream"}, + {".class", "application/x-java-applet"}, + {".clp", "application/x-msclip"}, + {".cmx", "image/x-cmx"}, + {".cnf", "text/plain"}, + {".cod", "image/cis-cod"}, + {".config", "application/xml"}, + {".contact", "text/x-ms-contact"}, + {".coverage", "application/xml"}, + {".cpio", "application/x-cpio"}, + {".cpp", "text/plain"}, + {".crd", "application/x-mscardfile"}, + {".crl", "application/pkix-crl"}, + {".crt", "application/x-x509-ca-cert"}, + {".cs", "text/plain"}, + {".csdproj", "text/plain"}, + {".csh", "application/x-csh"}, + {".csproj", "text/plain"}, + {".css", "text/css"}, + {".csv", "text/csv"}, + {".cur", "application/octet-stream"}, + {".cxx", "text/plain"}, + {".dat", "application/octet-stream"}, + {".datasource", "application/xml"}, + {".dbproj", "text/plain"}, + {".dcr", "application/x-director"}, + {".def", "text/plain"}, + {".deploy", "application/octet-stream"}, + {".der", "application/x-x509-ca-cert"}, + {".dgml", "application/xml"}, + {".dib", "image/bmp"}, + {".dif", "video/x-dv"}, + {".dir", "application/x-director"}, + {".disco", "text/xml"}, + {".dll", "application/x-msdownload"}, + {".dll.config", "text/xml"}, + {".dlm", "text/dlm"}, + {".doc", "application/msword"}, + {".docm", "application/vnd.ms-word.document.macroEnabled.12"}, + {".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"}, + {".dot", "application/msword"}, + {".dotm", "application/vnd.ms-word.template.macroEnabled.12"}, + {".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"}, + {".dsp", "application/octet-stream"}, + {".dsw", "text/plain"}, + {".dtd", "text/xml"}, + {".dtsConfig", "text/xml"}, + {".dv", "video/x-dv"}, + {".dvi", "application/x-dvi"}, + {".dwf", "drawing/x-dwf"}, + {".dwp", "application/octet-stream"}, + {".dxr", "application/x-director"}, + {".eml", "message/rfc822"}, + {".emz", "application/octet-stream"}, + {".eot", "application/octet-stream"}, + {".eps", "application/postscript"}, + {".etl", "application/etl"}, + {".etx", "text/x-setext"}, + {".evy", "application/envoy"}, + {".exe", "application/octet-stream"}, + {".exe.config", "text/xml"}, + {".fdf", "application/vnd.fdf"}, + {".fif", "application/fractals"}, + {".filters", "Application/xml"}, + {".fla", "application/octet-stream"}, + {".flr", "x-world/x-vrml"}, + {".flv", "video/x-flv"}, + {".fsscript", "application/fsharp-script"}, + {".fsx", "application/fsharp-script"}, + {".generictest", "application/xml"}, + {".gif", "image/gif"}, + {".group", "text/x-ms-group"}, + {".gsm", "audio/x-gsm"}, + {".gtar", "application/x-gtar"}, + {".gz", "application/x-gzip"}, + {".h", "text/plain"}, + {".hdf", "application/x-hdf"}, + {".hdml", "text/x-hdml"}, + {".hhc", "application/x-oleobject"}, + {".hhk", "application/octet-stream"}, + {".hhp", "application/octet-stream"}, + {".hlp", "application/winhlp"}, + {".hpp", "text/plain"}, + {".hqx", "application/mac-binhex40"}, + {".hta", "application/hta"}, + {".htc", "text/x-component"}, + {".htm", "text/html"}, + {".html", "text/html"}, + {".htt", "text/webviewhtml"}, + {".hxa", "application/xml"}, + {".hxc", "application/xml"}, + {".hxd", "application/octet-stream"}, + {".hxe", "application/xml"}, + {".hxf", "application/xml"}, + {".hxh", "application/octet-stream"}, + {".hxi", "application/octet-stream"}, + {".hxk", "application/xml"}, + {".hxq", "application/octet-stream"}, + {".hxr", "application/octet-stream"}, + {".hxs", "application/octet-stream"}, + {".hxt", "text/html"}, + {".hxv", "application/xml"}, + {".hxw", "application/octet-stream"}, + {".hxx", "text/plain"}, + {".i", "text/plain"}, + {".ico", "image/x-icon"}, + {".ics", "application/octet-stream"}, + {".idl", "text/plain"}, + {".ief", "image/ief"}, + {".iii", "application/x-iphone"}, + {".inc", "text/plain"}, + {".inf", "application/octet-stream"}, + {".inl", "text/plain"}, + {".ins", "application/x-internet-signup"}, + {".ipa", "application/x-itunes-ipa"}, + {".ipg", "application/x-itunes-ipg"}, + {".ipproj", "text/plain"}, + {".ipsw", "application/x-itunes-ipsw"}, + {".iqy", "text/x-ms-iqy"}, + {".isp", "application/x-internet-signup"}, + {".ite", "application/x-itunes-ite"}, + {".itlp", "application/x-itunes-itlp"}, + {".itms", "application/x-itunes-itms"}, + {".itpc", "application/x-itunes-itpc"}, + {".IVF", "video/x-ivf"}, + {".jar", "application/java-archive"}, + {".java", "application/octet-stream"}, + {".jck", "application/liquidmotion"}, + {".jcz", "application/liquidmotion"}, + {".jfif", "image/pjpeg"}, + {".jnlp", "application/x-java-jnlp-file"}, + {".jpb", "application/octet-stream"}, + {".jpe", "image/jpeg"}, + {".jpeg", "image/jpeg"}, + {".jpg", "image/jpeg"}, + {".js", "application/x-javascript"}, + {".json", "application/json"}, + {".jsx", "text/jscript"}, + {".jsxbin", "text/plain"}, + {".latex", "application/x-latex"}, + {".library-ms", "application/windows-library+xml"}, + {".lit", "application/x-ms-reader"}, + {".loadtest", "application/xml"}, + {".lpk", "application/octet-stream"}, + {".lsf", "video/x-la-asf"}, + {".lst", "text/plain"}, + {".lsx", "video/x-la-asf"}, + {".lzh", "application/octet-stream"}, + {".m13", "application/x-msmediaview"}, + {".m14", "application/x-msmediaview"}, + {".m1v", "video/mpeg"}, + {".m2t", "video/vnd.dlna.mpeg-tts"}, + {".m2ts", "video/vnd.dlna.mpeg-tts"}, + {".m2v", "video/mpeg"}, + {".m3u", "audio/x-mpegurl"}, + {".m3u8", "audio/x-mpegurl"}, + {".m4a", "audio/m4a"}, + {".m4b", "audio/m4b"}, + {".m4p", "audio/m4p"}, + {".m4r", "audio/x-m4r"}, + {".m4v", "video/x-m4v"}, + {".mac", "image/x-macpaint"}, + {".mak", "text/plain"}, + {".man", "application/x-troff-man"}, + {".manifest", "application/x-ms-manifest"}, + {".map", "text/plain"}, + {".master", "application/xml"}, + {".mda", "application/msaccess"}, + {".mdb", "application/x-msaccess"}, + {".mde", "application/msaccess"}, + {".mdp", "application/octet-stream"}, + {".me", "application/x-troff-me"}, + {".mfp", "application/x-shockwave-flash"}, + {".mht", "message/rfc822"}, + {".mhtml", "message/rfc822"}, + {".mid", "audio/mid"}, + {".midi", "audio/mid"}, + {".mix", "application/octet-stream"}, + {".mk", "text/plain"}, + {".mmf", "application/x-smaf"}, + {".mno", "text/xml"}, + {".mny", "application/x-msmoney"}, + {".mod", "video/mpeg"}, + {".mov", "video/quicktime"}, + {".movie", "video/x-sgi-movie"}, + {".mp2", "video/mpeg"}, + {".mp2v", "video/mpeg"}, + {".mp3", "audio/mpeg"}, + {".mp4", "video/mp4"}, + {".mp4v", "video/mp4"}, + {".mpa", "video/mpeg"}, + {".mpe", "video/mpeg"}, + {".mpeg", "video/mpeg"}, + {".mpf", "application/vnd.ms-mediapackage"}, + {".mpg", "video/mpeg"}, + {".mpp", "application/vnd.ms-project"}, + {".mpv2", "video/mpeg"}, + {".mqv", "video/quicktime"}, + {".ms", "application/x-troff-ms"}, + {".msi", "application/octet-stream"}, + {".mso", "application/octet-stream"}, + {".mts", "video/vnd.dlna.mpeg-tts"}, + {".mtx", "application/xml"}, + {".mvb", "application/x-msmediaview"}, + {".mvc", "application/x-miva-compiled"}, + {".mxp", "application/x-mmxp"}, + {".nc", "application/x-netcdf"}, + {".nsc", "video/x-ms-asf"}, + {".nws", "message/rfc822"}, + {".ocx", "application/octet-stream"}, + {".oda", "application/oda"}, + {".odc", "text/x-ms-odc"}, + {".odh", "text/plain"}, + {".odl", "text/plain"}, + {".odp", "application/vnd.oasis.opendocument.presentation"}, + {".ods", "application/oleobject"}, + {".odt", "application/vnd.oasis.opendocument.text"}, + {".one", "application/onenote"}, + {".onea", "application/onenote"}, + {".onepkg", "application/onenote"}, + {".onetmp", "application/onenote"}, + {".onetoc", "application/onenote"}, + {".onetoc2", "application/onenote"}, + {".orderedtest", "application/xml"}, + {".osdx", "application/opensearchdescription+xml"}, + {".p10", "application/pkcs10"}, + {".p12", "application/x-pkcs12"}, + {".p7b", "application/x-pkcs7-certificates"}, + {".p7c", "application/pkcs7-mime"}, + {".p7m", "application/pkcs7-mime"}, + {".p7r", "application/x-pkcs7-certreqresp"}, + {".p7s", "application/pkcs7-signature"}, + {".pbm", "image/x-portable-bitmap"}, + {".pcast", "application/x-podcast"}, + {".pct", "image/pict"}, + {".pcx", "application/octet-stream"}, + {".pcz", "application/octet-stream"}, + {".pdf", "application/pdf"}, + {".pfb", "application/octet-stream"}, + {".pfm", "application/octet-stream"}, + {".pfx", "application/x-pkcs12"}, + {".pgm", "image/x-portable-graymap"}, + {".pic", "image/pict"}, + {".pict", "image/pict"}, + {".pkgdef", "text/plain"}, + {".pkgundef", "text/plain"}, + {".pko", "application/vnd.ms-pki.pko"}, + {".pls", "audio/scpls"}, + {".pma", "application/x-perfmon"}, + {".pmc", "application/x-perfmon"}, + {".pml", "application/x-perfmon"}, + {".pmr", "application/x-perfmon"}, + {".pmw", "application/x-perfmon"}, + {".png", "image/png"}, + {".pnm", "image/x-portable-anymap"}, + {".pnt", "image/x-macpaint"}, + {".pntg", "image/x-macpaint"}, + {".pnz", "image/png"}, + {".pot", "application/vnd.ms-powerpoint"}, + {".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12"}, + {".potx", "application/vnd.openxmlformats-officedocument.presentationml.template"}, + {".ppa", "application/vnd.ms-powerpoint"}, + {".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12"}, + {".ppm", "image/x-portable-pixmap"}, + {".pps", "application/vnd.ms-powerpoint"}, + {".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12"}, + {".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"}, + {".ppt", "application/vnd.ms-powerpoint"}, + {".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12"}, + {".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"}, + {".prf", "application/pics-rules"}, + {".prm", "application/octet-stream"}, + {".prx", "application/octet-stream"}, + {".ps", "application/postscript"}, + {".psc1", "application/PowerShell"}, + {".psd", "application/octet-stream"}, + {".psess", "application/xml"}, + {".psm", "application/octet-stream"}, + {".psp", "application/octet-stream"}, + {".pub", "application/x-mspublisher"}, + {".pwz", "application/vnd.ms-powerpoint"}, + {".qht", "text/x-html-insertion"}, + {".qhtm", "text/x-html-insertion"}, + {".qt", "video/quicktime"}, + {".qti", "image/x-quicktime"}, + {".qtif", "image/x-quicktime"}, + {".qtl", "application/x-quicktimeplayer"}, + {".qxd", "application/octet-stream"}, + {".ra", "audio/x-pn-realaudio"}, + {".ram", "audio/x-pn-realaudio"}, + {".rar", "application/octet-stream"}, + {".ras", "image/x-cmu-raster"}, + {".rat", "application/rat-file"}, + {".rc", "text/plain"}, + {".rc2", "text/plain"}, + {".rct", "text/plain"}, + {".rdlc", "application/xml"}, + {".resx", "application/xml"}, + {".rf", "image/vnd.rn-realflash"}, + {".rgb", "image/x-rgb"}, + {".rgs", "text/plain"}, + {".rm", "application/vnd.rn-realmedia"}, + {".rmi", "audio/mid"}, + {".rmp", "application/vnd.rn-rn_music_package"}, + {".roff", "application/x-troff"}, + {".rpm", "audio/x-pn-realaudio-plugin"}, + {".rqy", "text/x-ms-rqy"}, + {".rtf", "application/rtf"}, + {".rtx", "text/richtext"}, + {".ruleset", "application/xml"}, + {".s", "text/plain"}, + {".safariextz", "application/x-safari-safariextz"}, + {".scd", "application/x-msschedule"}, + {".sct", "text/scriptlet"}, + {".sd2", "audio/x-sd2"}, + {".sdp", "application/sdp"}, + {".sea", "application/octet-stream"}, + {".searchConnector-ms", "application/windows-search-connector+xml"}, + {".setpay", "application/set-payment-initiation"}, + {".setreg", "application/set-registration-initiation"}, + {".settings", "application/xml"}, + {".sgimb", "application/x-sgimb"}, + {".sgml", "text/sgml"}, + {".sh", "application/x-sh"}, + {".shar", "application/x-shar"}, + {".shtml", "text/html"}, + {".sit", "application/x-stuffit"}, + {".sitemap", "application/xml"}, + {".skin", "application/xml"}, + {".sldm", "application/vnd.ms-powerpoint.slide.macroEnabled.12"}, + {".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide"}, + {".slk", "application/vnd.ms-excel"}, + {".sln", "text/plain"}, + {".slupkg-ms", "application/x-ms-license"}, + {".smd", "audio/x-smd"}, + {".smi", "application/octet-stream"}, + {".smx", "audio/x-smd"}, + {".smz", "audio/x-smd"}, + {".snd", "audio/basic"}, + {".snippet", "application/xml"}, + {".snp", "application/octet-stream"}, + {".sol", "text/plain"}, + {".sor", "text/plain"}, + {".spc", "application/x-pkcs7-certificates"}, + {".spl", "application/futuresplash"}, + {".src", "application/x-wais-source"}, + {".srf", "text/plain"}, + {".SSISDeploymentManifest", "text/xml"}, + {".ssm", "application/streamingmedia"}, + {".sst", "application/vnd.ms-pki.certstore"}, + {".stl", "application/vnd.ms-pki.stl"}, + {".sv4cpio", "application/x-sv4cpio"}, + {".sv4crc", "application/x-sv4crc"}, + {".svc", "application/xml"}, + {".swf", "application/x-shockwave-flash"}, + {".t", "application/x-troff"}, + {".tar", "application/x-tar"}, + {".tcl", "application/x-tcl"}, + {".testrunconfig", "application/xml"}, + {".testsettings", "application/xml"}, + {".tex", "application/x-tex"}, + {".texi", "application/x-texinfo"}, + {".texinfo", "application/x-texinfo"}, + {".tgz", "application/x-compressed"}, + {".thmx", "application/vnd.ms-officetheme"}, + {".thn", "application/octet-stream"}, + {".tif", "image/tiff"}, + {".tiff", "image/tiff"}, + {".tlh", "text/plain"}, + {".tli", "text/plain"}, + {".toc", "application/octet-stream"}, + {".tr", "application/x-troff"}, + {".trm", "application/x-msterminal"}, + {".trx", "application/xml"}, + {".ts", "video/vnd.dlna.mpeg-tts"}, + {".tsv", "text/tab-separated-values"}, + {".ttf", "application/octet-stream"}, + {".tts", "video/vnd.dlna.mpeg-tts"}, + {".txt", "text/plain"}, + {".u32", "application/octet-stream"}, + {".uls", "text/iuls"}, + {".user", "text/plain"}, + {".ustar", "application/x-ustar"}, + {".vb", "text/plain"}, + {".vbdproj", "text/plain"}, + {".vbk", "video/mpeg"}, + {".vbproj", "text/plain"}, + {".vbs", "text/vbscript"}, + {".vcf", "text/x-vcard"}, + {".vcproj", "Application/xml"}, + {".vcs", "text/plain"}, + {".vcxproj", "Application/xml"}, + {".vddproj", "text/plain"}, + {".vdp", "text/plain"}, + {".vdproj", "text/plain"}, + {".vdx", "application/vnd.ms-visio.viewer"}, + {".vml", "text/xml"}, + {".vscontent", "application/xml"}, + {".vsct", "text/xml"}, + {".vsd", "application/vnd.visio"}, + {".vsi", "application/ms-vsi"}, + {".vsix", "application/vsix"}, + {".vsixlangpack", "text/xml"}, + {".vsixmanifest", "text/xml"}, + {".vsmdi", "application/xml"}, + {".vspscc", "text/plain"}, + {".vss", "application/vnd.visio"}, + {".vsscc", "text/plain"}, + {".vssettings", "text/xml"}, + {".vssscc", "text/plain"}, + {".vst", "application/vnd.visio"}, + {".vstemplate", "text/xml"}, + {".vsto", "application/x-ms-vsto"}, + {".vsw", "application/vnd.visio"}, + {".vsx", "application/vnd.visio"}, + {".vtx", "application/vnd.visio"}, + {".wav", "audio/wav"}, + {".wave", "audio/wav"}, + {".wax", "audio/x-ms-wax"}, + {".wbk", "application/msword"}, + {".wbmp", "image/vnd.wap.wbmp"}, + {".wcm", "application/vnd.ms-works"}, + {".wdb", "application/vnd.ms-works"}, + {".wdp", "image/vnd.ms-photo"}, + {".webarchive", "application/x-safari-webarchive"}, + {".webtest", "application/xml"}, + {".wiq", "application/xml"}, + {".wiz", "application/msword"}, + {".wks", "application/vnd.ms-works"}, + {".WLMP", "application/wlmoviemaker"}, + {".wlpginstall", "application/x-wlpg-detect"}, + {".wlpginstall3", "application/x-wlpg3-detect"}, + {".wm", "video/x-ms-wm"}, + {".wma", "audio/x-ms-wma"}, + {".wmd", "application/x-ms-wmd"}, + {".wmf", "application/x-msmetafile"}, + {".wml", "text/vnd.wap.wml"}, + {".wmlc", "application/vnd.wap.wmlc"}, + {".wmls", "text/vnd.wap.wmlscript"}, + {".wmlsc", "application/vnd.wap.wmlscriptc"}, + {".wmp", "video/x-ms-wmp"}, + {".wmv", "video/x-ms-wmv"}, + {".wmx", "video/x-ms-wmx"}, + {".wmz", "application/x-ms-wmz"}, + {".wpl", "application/vnd.ms-wpl"}, + {".wps", "application/vnd.ms-works"}, + {".wri", "application/x-mswrite"}, + {".wrl", "x-world/x-vrml"}, + {".wrz", "x-world/x-vrml"}, + {".wsc", "text/scriptlet"}, + {".wsdl", "text/xml"}, + {".wvx", "video/x-ms-wvx"}, + {".x", "application/directx"}, + {".xaf", "x-world/x-vrml"}, + {".xaml", "application/xaml+xml"}, + {".xap", "application/x-silverlight-app"}, + {".xbap", "application/x-ms-xbap"}, + {".xbm", "image/x-xbitmap"}, + {".xdr", "text/plain"}, + {".xht", "application/xhtml+xml"}, + {".xhtml", "application/xhtml+xml"}, + {".xla", "application/vnd.ms-excel"}, + {".xlam", "application/vnd.ms-excel.addin.macroEnabled.12"}, + {".xlc", "application/vnd.ms-excel"}, + {".xld", "application/vnd.ms-excel"}, + {".xlk", "application/vnd.ms-excel"}, + {".xll", "application/vnd.ms-excel"}, + {".xlm", "application/vnd.ms-excel"}, + {".xls", "application/vnd.ms-excel"}, + {".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12"}, + {".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12"}, + {".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}, + {".xlt", "application/vnd.ms-excel"}, + {".xltm", "application/vnd.ms-excel.template.macroEnabled.12"}, + {".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"}, + {".xlw", "application/vnd.ms-excel"}, + {".xml", "text/xml"}, + {".xmta", "application/xml"}, + {".xof", "x-world/x-vrml"}, + {".XOML", "text/plain"}, + {".xpm", "image/x-xpixmap"}, + {".xps", "application/vnd.ms-xpsdocument"}, + {".xrm-ms", "text/xml"}, + {".xsc", "application/xml"}, + {".xsd", "text/xml"}, + {".xsf", "text/xml"}, + {".xsl", "text/xml"}, + {".xslt", "text/xml"}, + {".xsn", "application/octet-stream"}, + {".xss", "application/xml"}, + {".xtp", "application/octet-stream"}, + {".xwd", "image/x-xwindowdump"}, + {".z", "application/x-compress"}, + {".zip", "application/x-zip-compressed"}, + #endregion + + }; + + public static string GetMimeTypeFromExtension(string extension) + { + if (extension == null) + { + throw new ArgumentNullException("extension"); + } + + if (!extension.StartsWith(".")) + { + extension = "." + extension; + } + + return _mappings.TryGetValue(extension, out var mime) ? mime : "application/octet-stream"; + } + + public static string GetMimeType(this string path) + { + return GetMimeTypeFromExtension(System.IO.Path.GetExtension(path)); + } + } +} \ No newline at end of file diff --git a/src/Appwrite/ID.cs b/src/Appwrite/ID.cs new file mode 100644 index 0000000..9a5a27d --- /dev/null +++ b/src/Appwrite/ID.cs @@ -0,0 +1,15 @@ +namespace Appwrite +{ + public static class ID + { + public static string Unique() + { + return "unique()"; + } + + public static string Custom(string id) + { + return id; + } + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AlgoArgon2.cs b/src/Appwrite/Models/AlgoArgon2.cs new file mode 100644 index 0000000..c07c4a9 --- /dev/null +++ b/src/Appwrite/Models/AlgoArgon2.cs @@ -0,0 +1,52 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AlgoArgon2 + { + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("memoryCost")] + public long MemoryCost { get; private set; } + + [JsonProperty("timeCost")] + public long TimeCost { get; private set; } + + [JsonProperty("threads")] + public long Threads { get; private set; } + + public AlgoArgon2( + string type, + long memoryCost, + long timeCost, + long threads + ) { + Type = type; + MemoryCost = memoryCost; + TimeCost = timeCost; + Threads = threads; + } + + public static AlgoArgon2 From(Dictionary map) => new AlgoArgon2( + type: map["type"].ToString(), + memoryCost: Convert.ToInt64(map["memoryCost"]), + timeCost: Convert.ToInt64(map["timeCost"]), + threads: Convert.ToInt64(map["threads"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "type", Type }, + { "memoryCost", MemoryCost }, + { "timeCost", TimeCost }, + { "threads", Threads } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AlgoBcrypt.cs b/src/Appwrite/Models/AlgoBcrypt.cs new file mode 100644 index 0000000..e129b2f --- /dev/null +++ b/src/Appwrite/Models/AlgoBcrypt.cs @@ -0,0 +1,31 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AlgoBcrypt + { + [JsonProperty("type")] + public string Type { get; private set; } + + public AlgoBcrypt( + string type + ) { + Type = type; + } + + public static AlgoBcrypt From(Dictionary map) => new AlgoBcrypt( + type: map["type"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "type", Type } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AlgoMd5.cs b/src/Appwrite/Models/AlgoMd5.cs new file mode 100644 index 0000000..7f13739 --- /dev/null +++ b/src/Appwrite/Models/AlgoMd5.cs @@ -0,0 +1,31 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AlgoMd5 + { + [JsonProperty("type")] + public string Type { get; private set; } + + public AlgoMd5( + string type + ) { + Type = type; + } + + public static AlgoMd5 From(Dictionary map) => new AlgoMd5( + type: map["type"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "type", Type } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AlgoPhpass.cs b/src/Appwrite/Models/AlgoPhpass.cs new file mode 100644 index 0000000..bce272b --- /dev/null +++ b/src/Appwrite/Models/AlgoPhpass.cs @@ -0,0 +1,31 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AlgoPhpass + { + [JsonProperty("type")] + public string Type { get; private set; } + + public AlgoPhpass( + string type + ) { + Type = type; + } + + public static AlgoPhpass From(Dictionary map) => new AlgoPhpass( + type: map["type"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "type", Type } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AlgoScrypt.cs b/src/Appwrite/Models/AlgoScrypt.cs new file mode 100644 index 0000000..bf58c50 --- /dev/null +++ b/src/Appwrite/Models/AlgoScrypt.cs @@ -0,0 +1,59 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AlgoScrypt + { + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("costCpu")] + public long CostCpu { get; private set; } + + [JsonProperty("costMemory")] + public long CostMemory { get; private set; } + + [JsonProperty("costParallel")] + public long CostParallel { get; private set; } + + [JsonProperty("length")] + public long Length { get; private set; } + + public AlgoScrypt( + string type, + long costCpu, + long costMemory, + long costParallel, + long length + ) { + Type = type; + CostCpu = costCpu; + CostMemory = costMemory; + CostParallel = costParallel; + Length = length; + } + + public static AlgoScrypt From(Dictionary map) => new AlgoScrypt( + type: map["type"].ToString(), + costCpu: Convert.ToInt64(map["costCpu"]), + costMemory: Convert.ToInt64(map["costMemory"]), + costParallel: Convert.ToInt64(map["costParallel"]), + length: Convert.ToInt64(map["length"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "type", Type }, + { "costCpu", CostCpu }, + { "costMemory", CostMemory }, + { "costParallel", CostParallel }, + { "length", Length } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AlgoScryptModified.cs b/src/Appwrite/Models/AlgoScryptModified.cs new file mode 100644 index 0000000..6facf99 --- /dev/null +++ b/src/Appwrite/Models/AlgoScryptModified.cs @@ -0,0 +1,52 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AlgoScryptModified + { + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("salt")] + public string Salt { get; private set; } + + [JsonProperty("saltSeparator")] + public string SaltSeparator { get; private set; } + + [JsonProperty("signerKey")] + public string SignerKey { get; private set; } + + public AlgoScryptModified( + string type, + string salt, + string saltSeparator, + string signerKey + ) { + Type = type; + Salt = salt; + SaltSeparator = saltSeparator; + SignerKey = signerKey; + } + + public static AlgoScryptModified From(Dictionary map) => new AlgoScryptModified( + type: map["type"].ToString(), + salt: map["salt"].ToString(), + saltSeparator: map["saltSeparator"].ToString(), + signerKey: map["signerKey"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "type", Type }, + { "salt", Salt }, + { "saltSeparator", SaltSeparator }, + { "signerKey", SignerKey } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AlgoSha.cs b/src/Appwrite/Models/AlgoSha.cs new file mode 100644 index 0000000..9582f9f --- /dev/null +++ b/src/Appwrite/Models/AlgoSha.cs @@ -0,0 +1,31 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AlgoSha + { + [JsonProperty("type")] + public string Type { get; private set; } + + public AlgoSha( + string type + ) { + Type = type; + } + + public static AlgoSha From(Dictionary map) => new AlgoSha( + type: map["type"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "type", Type } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeBoolean.cs b/src/Appwrite/Models/AttributeBoolean.cs new file mode 100644 index 0000000..3f8b453 --- /dev/null +++ b/src/Appwrite/Models/AttributeBoolean.cs @@ -0,0 +1,66 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeBoolean + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("default")] + public bool? Default { get; private set; } + + public AttributeBoolean( + string key, + string type, + string status, + bool required, + bool? array, + bool? xdefault + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + Default = xdefault; + } + + public static AttributeBoolean From(Dictionary map) => new AttributeBoolean( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + xdefault: (bool?)map["default"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "default", Default } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeDatetime.cs b/src/Appwrite/Models/AttributeDatetime.cs new file mode 100644 index 0000000..3f35543 --- /dev/null +++ b/src/Appwrite/Models/AttributeDatetime.cs @@ -0,0 +1,73 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeDatetime + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("format")] + public string Format { get; private set; } + + [JsonProperty("default")] + public string? Default { get; private set; } + + public AttributeDatetime( + string key, + string type, + string status, + bool required, + bool? array, + string format, + string? xdefault + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + Format = format; + Default = xdefault; + } + + public static AttributeDatetime From(Dictionary map) => new AttributeDatetime( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + format: map["format"].ToString(), + xdefault: map["default"]?.ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "format", Format }, + { "default", Default } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeEmail.cs b/src/Appwrite/Models/AttributeEmail.cs new file mode 100644 index 0000000..5c90811 --- /dev/null +++ b/src/Appwrite/Models/AttributeEmail.cs @@ -0,0 +1,73 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeEmail + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("format")] + public string Format { get; private set; } + + [JsonProperty("default")] + public string? Default { get; private set; } + + public AttributeEmail( + string key, + string type, + string status, + bool required, + bool? array, + string format, + string? xdefault + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + Format = format; + Default = xdefault; + } + + public static AttributeEmail From(Dictionary map) => new AttributeEmail( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + format: map["format"].ToString(), + xdefault: map["default"]?.ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "format", Format }, + { "default", Default } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeEnum.cs b/src/Appwrite/Models/AttributeEnum.cs new file mode 100644 index 0000000..a57cd18 --- /dev/null +++ b/src/Appwrite/Models/AttributeEnum.cs @@ -0,0 +1,80 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeEnum + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("elements")] + public List Elements { get; private set; } + + [JsonProperty("format")] + public string Format { get; private set; } + + [JsonProperty("default")] + public string? Default { get; private set; } + + public AttributeEnum( + string key, + string type, + string status, + bool required, + bool? array, + List elements, + string format, + string? xdefault + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + Elements = elements; + Format = format; + Default = xdefault; + } + + public static AttributeEnum From(Dictionary map) => new AttributeEnum( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + elements: ((JArray)map["elements"]).ToObject>(), + format: map["format"].ToString(), + xdefault: map["default"]?.ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "elements", Elements }, + { "format", Format }, + { "default", Default } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeFloat.cs b/src/Appwrite/Models/AttributeFloat.cs new file mode 100644 index 0000000..90d1199 --- /dev/null +++ b/src/Appwrite/Models/AttributeFloat.cs @@ -0,0 +1,80 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeFloat + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("min")] + public double? Min { get; private set; } + + [JsonProperty("max")] + public double? Max { get; private set; } + + [JsonProperty("default")] + public double? Default { get; private set; } + + public AttributeFloat( + string key, + string type, + string status, + bool required, + bool? array, + double? min, + double? max, + double? xdefault + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + Min = min; + Max = max; + Default = xdefault; + } + + public static AttributeFloat From(Dictionary map) => new AttributeFloat( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + min: map["min"] == null ? null : Convert.ToDouble(map["min"]), + max: map["max"] == null ? null : Convert.ToDouble(map["max"]), + xdefault: map["default"] == null ? null : Convert.ToDouble(map["default"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "min", Min }, + { "max", Max }, + { "default", Default } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeInteger.cs b/src/Appwrite/Models/AttributeInteger.cs new file mode 100644 index 0000000..f0f57f8 --- /dev/null +++ b/src/Appwrite/Models/AttributeInteger.cs @@ -0,0 +1,80 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeInteger + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("min")] + public long? Min { get; private set; } + + [JsonProperty("max")] + public long? Max { get; private set; } + + [JsonProperty("default")] + public long? Default { get; private set; } + + public AttributeInteger( + string key, + string type, + string status, + bool required, + bool? array, + long? min, + long? max, + long? xdefault + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + Min = min; + Max = max; + Default = xdefault; + } + + public static AttributeInteger From(Dictionary map) => new AttributeInteger( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + min: map["min"] == null ? null : Convert.ToInt64(map["min"]), + max: map["max"] == null ? null : Convert.ToInt64(map["max"]), + xdefault: map["default"] == null ? null : Convert.ToInt64(map["default"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "min", Min }, + { "max", Max }, + { "default", Default } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeIp.cs b/src/Appwrite/Models/AttributeIp.cs new file mode 100644 index 0000000..5c97834 --- /dev/null +++ b/src/Appwrite/Models/AttributeIp.cs @@ -0,0 +1,73 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeIp + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("format")] + public string Format { get; private set; } + + [JsonProperty("default")] + public string? Default { get; private set; } + + public AttributeIp( + string key, + string type, + string status, + bool required, + bool? array, + string format, + string? xdefault + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + Format = format; + Default = xdefault; + } + + public static AttributeIp From(Dictionary map) => new AttributeIp( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + format: map["format"].ToString(), + xdefault: map["default"]?.ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "format", Format }, + { "default", Default } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeList.cs b/src/Appwrite/Models/AttributeList.cs new file mode 100644 index 0000000..81c8406 --- /dev/null +++ b/src/Appwrite/Models/AttributeList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("attributes")] + public List Attributes { get; private set; } + + public AttributeList( + long total, + List attributes + ) { + Total = total; + Attributes = attributes; + } + + public static AttributeList From(Dictionary map) => new AttributeList( + total: Convert.ToInt64(map["total"]), + attributes: ((JArray)map["attributes"]).ToObject>() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "attributes", Attributes } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeRelationship.cs b/src/Appwrite/Models/AttributeRelationship.cs new file mode 100644 index 0000000..bc34f4e --- /dev/null +++ b/src/Appwrite/Models/AttributeRelationship.cs @@ -0,0 +1,101 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeRelationship + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("relatedCollection")] + public string RelatedCollection { get; private set; } + + [JsonProperty("relationType")] + public string RelationType { get; private set; } + + [JsonProperty("twoWay")] + public bool TwoWay { get; private set; } + + [JsonProperty("twoWayKey")] + public string TwoWayKey { get; private set; } + + [JsonProperty("onDelete")] + public string OnDelete { get; private set; } + + [JsonProperty("side")] + public string Side { get; private set; } + + public AttributeRelationship( + string key, + string type, + string status, + bool required, + bool? array, + string relatedCollection, + string relationType, + bool twoWay, + string twoWayKey, + string onDelete, + string side + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + RelatedCollection = relatedCollection; + RelationType = relationType; + TwoWay = twoWay; + TwoWayKey = twoWayKey; + OnDelete = onDelete; + Side = side; + } + + public static AttributeRelationship From(Dictionary map) => new AttributeRelationship( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + relatedCollection: map["relatedCollection"].ToString(), + relationType: map["relationType"].ToString(), + twoWay: (bool)map["twoWay"], + twoWayKey: map["twoWayKey"].ToString(), + onDelete: map["onDelete"].ToString(), + side: map["side"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "relatedCollection", RelatedCollection }, + { "relationType", RelationType }, + { "twoWay", TwoWay }, + { "twoWayKey", TwoWayKey }, + { "onDelete", OnDelete }, + { "side", Side } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeString.cs b/src/Appwrite/Models/AttributeString.cs new file mode 100644 index 0000000..7aa7ea8 --- /dev/null +++ b/src/Appwrite/Models/AttributeString.cs @@ -0,0 +1,73 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeString + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("size")] + public long Size { get; private set; } + + [JsonProperty("default")] + public string? Default { get; private set; } + + public AttributeString( + string key, + string type, + string status, + bool required, + bool? array, + long size, + string? xdefault + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + Size = size; + Default = xdefault; + } + + public static AttributeString From(Dictionary map) => new AttributeString( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + size: Convert.ToInt64(map["size"]), + xdefault: map["default"]?.ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "size", Size }, + { "default", Default } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/AttributeUrl.cs b/src/Appwrite/Models/AttributeUrl.cs new file mode 100644 index 0000000..436d08e --- /dev/null +++ b/src/Appwrite/Models/AttributeUrl.cs @@ -0,0 +1,73 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class AttributeUrl + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("required")] + public bool Required { get; private set; } + + [JsonProperty("array")] + public bool? Array { get; private set; } + + [JsonProperty("format")] + public string Format { get; private set; } + + [JsonProperty("default")] + public string? Default { get; private set; } + + public AttributeUrl( + string key, + string type, + string status, + bool required, + bool? array, + string format, + string? xdefault + ) { + Key = key; + Type = type; + Status = status; + Required = required; + Array = array; + Format = format; + Default = xdefault; + } + + public static AttributeUrl From(Dictionary map) => new AttributeUrl( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + format: map["format"].ToString(), + xdefault: map["default"]?.ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "required", Required }, + { "array", Array }, + { "format", Format }, + { "default", Default } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Bucket.cs b/src/Appwrite/Models/Bucket.cs new file mode 100644 index 0000000..81fd587 --- /dev/null +++ b/src/Appwrite/Models/Bucket.cs @@ -0,0 +1,108 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Bucket + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("$permissions")] + public List Permissions { get; private set; } + + [JsonProperty("fileSecurity")] + public bool FileSecurity { get; private set; } + + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("enabled")] + public bool Enabled { get; private set; } + + [JsonProperty("maximumFileSize")] + public long MaximumFileSize { get; private set; } + + [JsonProperty("allowedFileExtensions")] + public List AllowedFileExtensions { get; private set; } + + [JsonProperty("compression")] + public string Compression { get; private set; } + + [JsonProperty("encryption")] + public bool Encryption { get; private set; } + + [JsonProperty("antivirus")] + public bool Antivirus { get; private set; } + + public Bucket( + string id, + string createdAt, + string updatedAt, + List permissions, + bool fileSecurity, + string name, + bool enabled, + long maximumFileSize, + List allowedFileExtensions, + string compression, + bool encryption, + bool antivirus + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Permissions = permissions; + FileSecurity = fileSecurity; + Name = name; + Enabled = enabled; + MaximumFileSize = maximumFileSize; + AllowedFileExtensions = allowedFileExtensions; + Compression = compression; + Encryption = encryption; + Antivirus = antivirus; + } + + public static Bucket From(Dictionary map) => new Bucket( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + permissions: ((JArray)map["$permissions"]).ToObject>(), + fileSecurity: (bool)map["fileSecurity"], + name: map["name"].ToString(), + enabled: (bool)map["enabled"], + maximumFileSize: Convert.ToInt64(map["maximumFileSize"]), + allowedFileExtensions: ((JArray)map["allowedFileExtensions"]).ToObject>(), + compression: map["compression"].ToString(), + encryption: (bool)map["encryption"], + antivirus: (bool)map["antivirus"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "$permissions", Permissions }, + { "fileSecurity", FileSecurity }, + { "name", Name }, + { "enabled", Enabled }, + { "maximumFileSize", MaximumFileSize }, + { "allowedFileExtensions", AllowedFileExtensions }, + { "compression", Compression }, + { "encryption", Encryption }, + { "antivirus", Antivirus } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/BucketList.cs b/src/Appwrite/Models/BucketList.cs new file mode 100644 index 0000000..fd4a973 --- /dev/null +++ b/src/Appwrite/Models/BucketList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class BucketList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("buckets")] + public List Buckets { get; private set; } + + public BucketList( + long total, + List buckets + ) { + Total = total; + Buckets = buckets; + } + + public static BucketList From(Dictionary map) => new BucketList( + total: Convert.ToInt64(map["total"]), + buckets: ((JArray)map["buckets"]).ToObject>>().Select(it => Bucket.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "buckets", Buckets.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Collection.cs b/src/Appwrite/Models/Collection.cs new file mode 100644 index 0000000..e7990df --- /dev/null +++ b/src/Appwrite/Models/Collection.cs @@ -0,0 +1,94 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Collection + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("$permissions")] + public List Permissions { get; private set; } + + [JsonProperty("databaseId")] + public string DatabaseId { get; private set; } + + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("enabled")] + public bool Enabled { get; private set; } + + [JsonProperty("documentSecurity")] + public bool DocumentSecurity { get; private set; } + + [JsonProperty("attributes")] + public List Attributes { get; private set; } + + [JsonProperty("indexes")] + public List Indexes { get; private set; } + + public Collection( + string id, + string createdAt, + string updatedAt, + List permissions, + string databaseId, + string name, + bool enabled, + bool documentSecurity, + List attributes, + List indexes + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Permissions = permissions; + DatabaseId = databaseId; + Name = name; + Enabled = enabled; + DocumentSecurity = documentSecurity; + Attributes = attributes; + Indexes = indexes; + } + + public static Collection From(Dictionary map) => new Collection( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + permissions: ((JArray)map["$permissions"]).ToObject>(), + databaseId: map["databaseId"].ToString(), + name: map["name"].ToString(), + enabled: (bool)map["enabled"], + documentSecurity: (bool)map["documentSecurity"], + attributes: ((JArray)map["attributes"]).ToObject>(), + indexes: ((JArray)map["indexes"]).ToObject>>().Select(it => Index.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "$permissions", Permissions }, + { "databaseId", DatabaseId }, + { "name", Name }, + { "enabled", Enabled }, + { "documentSecurity", DocumentSecurity }, + { "attributes", Attributes }, + { "indexes", Indexes.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/CollectionList.cs b/src/Appwrite/Models/CollectionList.cs new file mode 100644 index 0000000..2b8d2c7 --- /dev/null +++ b/src/Appwrite/Models/CollectionList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class CollectionList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("collections")] + public List Collections { get; private set; } + + public CollectionList( + long total, + List collections + ) { + Total = total; + Collections = collections; + } + + public static CollectionList From(Dictionary map) => new CollectionList( + total: Convert.ToInt64(map["total"]), + collections: ((JArray)map["collections"]).ToObject>>().Select(it => Collection.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "collections", Collections.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Continent.cs b/src/Appwrite/Models/Continent.cs new file mode 100644 index 0000000..595a08e --- /dev/null +++ b/src/Appwrite/Models/Continent.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Continent + { + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("code")] + public string Code { get; private set; } + + public Continent( + string name, + string code + ) { + Name = name; + Code = code; + } + + public static Continent From(Dictionary map) => new Continent( + name: map["name"].ToString(), + code: map["code"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "name", Name }, + { "code", Code } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/ContinentList.cs b/src/Appwrite/Models/ContinentList.cs new file mode 100644 index 0000000..9346fca --- /dev/null +++ b/src/Appwrite/Models/ContinentList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class ContinentList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("continents")] + public List Continents { get; private set; } + + public ContinentList( + long total, + List continents + ) { + Total = total; + Continents = continents; + } + + public static ContinentList From(Dictionary map) => new ContinentList( + total: Convert.ToInt64(map["total"]), + continents: ((JArray)map["continents"]).ToObject>>().Select(it => Continent.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "continents", Continents.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Country.cs b/src/Appwrite/Models/Country.cs new file mode 100644 index 0000000..90df96e --- /dev/null +++ b/src/Appwrite/Models/Country.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Country + { + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("code")] + public string Code { get; private set; } + + public Country( + string name, + string code + ) { + Name = name; + Code = code; + } + + public static Country From(Dictionary map) => new Country( + name: map["name"].ToString(), + code: map["code"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "name", Name }, + { "code", Code } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/CountryList.cs b/src/Appwrite/Models/CountryList.cs new file mode 100644 index 0000000..d2a019c --- /dev/null +++ b/src/Appwrite/Models/CountryList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class CountryList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("countries")] + public List Countries { get; private set; } + + public CountryList( + long total, + List countries + ) { + Total = total; + Countries = countries; + } + + public static CountryList From(Dictionary map) => new CountryList( + total: Convert.ToInt64(map["total"]), + countries: ((JArray)map["countries"]).ToObject>>().Select(it => Country.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "countries", Countries.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Currency.cs b/src/Appwrite/Models/Currency.cs new file mode 100644 index 0000000..1c1ca05 --- /dev/null +++ b/src/Appwrite/Models/Currency.cs @@ -0,0 +1,73 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Currency + { + [JsonProperty("symbol")] + public string Symbol { get; private set; } + + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("symbolNative")] + public string SymbolNative { get; private set; } + + [JsonProperty("decimalDigits")] + public long DecimalDigits { get; private set; } + + [JsonProperty("rounding")] + public double Rounding { get; private set; } + + [JsonProperty("code")] + public string Code { get; private set; } + + [JsonProperty("namePlural")] + public string NamePlural { get; private set; } + + public Currency( + string symbol, + string name, + string symbolNative, + long decimalDigits, + double rounding, + string code, + string namePlural + ) { + Symbol = symbol; + Name = name; + SymbolNative = symbolNative; + DecimalDigits = decimalDigits; + Rounding = rounding; + Code = code; + NamePlural = namePlural; + } + + public static Currency From(Dictionary map) => new Currency( + symbol: map["symbol"].ToString(), + name: map["name"].ToString(), + symbolNative: map["symbolNative"].ToString(), + decimalDigits: Convert.ToInt64(map["decimalDigits"]), + rounding: Convert.ToDouble(map["rounding"]), + code: map["code"].ToString(), + namePlural: map["namePlural"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "symbol", Symbol }, + { "name", Name }, + { "symbolNative", SymbolNative }, + { "decimalDigits", DecimalDigits }, + { "rounding", Rounding }, + { "code", Code }, + { "namePlural", NamePlural } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/CurrencyList.cs b/src/Appwrite/Models/CurrencyList.cs new file mode 100644 index 0000000..e4ab20b --- /dev/null +++ b/src/Appwrite/Models/CurrencyList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class CurrencyList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("currencies")] + public List Currencies { get; private set; } + + public CurrencyList( + long total, + List currencies + ) { + Total = total; + Currencies = currencies; + } + + public static CurrencyList From(Dictionary map) => new CurrencyList( + total: Convert.ToInt64(map["total"]), + currencies: ((JArray)map["currencies"]).ToObject>>().Select(it => Currency.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "currencies", Currencies.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Database.cs b/src/Appwrite/Models/Database.cs new file mode 100644 index 0000000..f632f4e --- /dev/null +++ b/src/Appwrite/Models/Database.cs @@ -0,0 +1,52 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Database + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + public Database( + string id, + string name, + string createdAt, + string updatedAt + ) { + Id = id; + Name = name; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + } + + public static Database From(Dictionary map) => new Database( + id: map["$id"].ToString(), + name: map["name"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "name", Name }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/DatabaseList.cs b/src/Appwrite/Models/DatabaseList.cs new file mode 100644 index 0000000..27ae468 --- /dev/null +++ b/src/Appwrite/Models/DatabaseList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class DatabaseList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("databases")] + public List Databases { get; private set; } + + public DatabaseList( + long total, + List databases + ) { + Total = total; + Databases = databases; + } + + public static DatabaseList From(Dictionary map) => new DatabaseList( + total: Convert.ToInt64(map["total"]), + databases: ((JArray)map["databases"]).ToObject>>().Select(it => Database.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "databases", Databases.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Deployment.cs b/src/Appwrite/Models/Deployment.cs new file mode 100644 index 0000000..85cc649 --- /dev/null +++ b/src/Appwrite/Models/Deployment.cs @@ -0,0 +1,115 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Deployment + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("resourceId")] + public string ResourceId { get; private set; } + + [JsonProperty("resourceType")] + public string ResourceType { get; private set; } + + [JsonProperty("entrypoint")] + public string Entrypoint { get; private set; } + + [JsonProperty("size")] + public long Size { get; private set; } + + [JsonProperty("buildId")] + public string BuildId { get; private set; } + + [JsonProperty("activate")] + public bool Activate { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("buildStdout")] + public string BuildStdout { get; private set; } + + [JsonProperty("buildStderr")] + public string BuildStderr { get; private set; } + + [JsonProperty("buildTime")] + public long BuildTime { get; private set; } + + public Deployment( + string id, + string createdAt, + string updatedAt, + string resourceId, + string resourceType, + string entrypoint, + long size, + string buildId, + bool activate, + string status, + string buildStdout, + string buildStderr, + long buildTime + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + ResourceId = resourceId; + ResourceType = resourceType; + Entrypoint = entrypoint; + Size = size; + BuildId = buildId; + Activate = activate; + Status = status; + BuildStdout = buildStdout; + BuildStderr = buildStderr; + BuildTime = buildTime; + } + + public static Deployment From(Dictionary map) => new Deployment( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + resourceId: map["resourceId"].ToString(), + resourceType: map["resourceType"].ToString(), + entrypoint: map["entrypoint"].ToString(), + size: Convert.ToInt64(map["size"]), + buildId: map["buildId"].ToString(), + activate: (bool)map["activate"], + status: map["status"].ToString(), + buildStdout: map["buildStdout"].ToString(), + buildStderr: map["buildStderr"].ToString(), + buildTime: Convert.ToInt64(map["buildTime"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "resourceId", ResourceId }, + { "resourceType", ResourceType }, + { "entrypoint", Entrypoint }, + { "size", Size }, + { "buildId", BuildId }, + { "activate", Activate }, + { "status", Status }, + { "buildStdout", BuildStdout }, + { "buildStderr", BuildStderr }, + { "buildTime", BuildTime } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/DeploymentList.cs b/src/Appwrite/Models/DeploymentList.cs new file mode 100644 index 0000000..138fa33 --- /dev/null +++ b/src/Appwrite/Models/DeploymentList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class DeploymentList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("deployments")] + public List Deployments { get; private set; } + + public DeploymentList( + long total, + List deployments + ) { + Total = total; + Deployments = deployments; + } + + public static DeploymentList From(Dictionary map) => new DeploymentList( + total: Convert.ToInt64(map["total"]), + deployments: ((JArray)map["deployments"]).ToObject>>().Select(it => Deployment.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "deployments", Deployments.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Document.cs b/src/Appwrite/Models/Document.cs new file mode 100644 index 0000000..048253b --- /dev/null +++ b/src/Appwrite/Models/Document.cs @@ -0,0 +1,75 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Document + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$collectionId")] + public string CollectionId { get; private set; } + + [JsonProperty("$databaseId")] + public string DatabaseId { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("$permissions")] + public List Permissions { get; private set; } + + public Dictionary Data { get; private set; } + + public Document( + string id, + string collectionId, + string databaseId, + string createdAt, + string updatedAt, + List permissions, + Dictionary data + ) { + Id = id; + CollectionId = collectionId; + DatabaseId = databaseId; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Permissions = permissions; + Data = data; + } + + public static Document From(Dictionary map) => new Document( + id: map["$id"].ToString(), + collectionId: map["$collectionId"].ToString(), + databaseId: map["$databaseId"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + permissions: ((JArray)map["$permissions"]).ToObject>(), + data: map + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$collectionId", CollectionId }, + { "$databaseId", DatabaseId }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "$permissions", Permissions }, + { "data", Data } + }; + + public T ConvertTo(Func, T> fromJson) => + fromJson.Invoke(Data); + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/DocumentList.cs b/src/Appwrite/Models/DocumentList.cs new file mode 100644 index 0000000..42dceed --- /dev/null +++ b/src/Appwrite/Models/DocumentList.cs @@ -0,0 +1,42 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class DocumentList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("documents")] + public List Documents { get; private set; } + + public DocumentList( + long total, + List documents + ) { + Total = total; + Documents = documents; + } + + public static DocumentList From(Dictionary map) => new DocumentList( + total: Convert.ToInt64(map["total"]), + documents: ((JArray)map["documents"]).ToObject>>().Select(it => Document.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "documents", Documents.Select(it => it.ToMap()) } + }; + + public T ConvertTo(Func, T> fromJson) => + (T)Documents.Select(it => it.ConvertTo(fromJson)); + + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Execution.cs b/src/Appwrite/Models/Execution.cs new file mode 100644 index 0000000..e04fd90 --- /dev/null +++ b/src/Appwrite/Models/Execution.cs @@ -0,0 +1,108 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Execution + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("$permissions")] + public List Permissions { get; private set; } + + [JsonProperty("functionId")] + public string FunctionId { get; private set; } + + [JsonProperty("trigger")] + public string Trigger { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("statusCode")] + public long StatusCode { get; private set; } + + [JsonProperty("response")] + public string Response { get; private set; } + + [JsonProperty("stdout")] + public string Stdout { get; private set; } + + [JsonProperty("stderr")] + public string Stderr { get; private set; } + + [JsonProperty("duration")] + public double Duration { get; private set; } + + public Execution( + string id, + string createdAt, + string updatedAt, + List permissions, + string functionId, + string trigger, + string status, + long statusCode, + string response, + string stdout, + string stderr, + double duration + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Permissions = permissions; + FunctionId = functionId; + Trigger = trigger; + Status = status; + StatusCode = statusCode; + Response = response; + Stdout = stdout; + Stderr = stderr; + Duration = duration; + } + + public static Execution From(Dictionary map) => new Execution( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + permissions: ((JArray)map["$permissions"]).ToObject>(), + functionId: map["functionId"].ToString(), + trigger: map["trigger"].ToString(), + status: map["status"].ToString(), + statusCode: Convert.ToInt64(map["statusCode"]), + response: map["response"].ToString(), + stdout: map["stdout"].ToString(), + stderr: map["stderr"].ToString(), + duration: Convert.ToDouble(map["duration"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "$permissions", Permissions }, + { "functionId", FunctionId }, + { "trigger", Trigger }, + { "status", Status }, + { "statusCode", StatusCode }, + { "response", Response }, + { "stdout", Stdout }, + { "stderr", Stderr }, + { "duration", Duration } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/ExecutionList.cs b/src/Appwrite/Models/ExecutionList.cs new file mode 100644 index 0000000..9c888af --- /dev/null +++ b/src/Appwrite/Models/ExecutionList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class ExecutionList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("executions")] + public List Executions { get; private set; } + + public ExecutionList( + long total, + List executions + ) { + Total = total; + Executions = executions; + } + + public static ExecutionList From(Dictionary map) => new ExecutionList( + total: Convert.ToInt64(map["total"]), + executions: ((JArray)map["executions"]).ToObject>>().Select(it => Execution.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "executions", Executions.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/File.cs b/src/Appwrite/Models/File.cs new file mode 100644 index 0000000..771dc68 --- /dev/null +++ b/src/Appwrite/Models/File.cs @@ -0,0 +1,101 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class File + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("bucketId")] + public string BucketId { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("$permissions")] + public List Permissions { get; private set; } + + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("signature")] + public string Signature { get; private set; } + + [JsonProperty("mimeType")] + public string MimeType { get; private set; } + + [JsonProperty("sizeOriginal")] + public long SizeOriginal { get; private set; } + + [JsonProperty("chunksTotal")] + public long ChunksTotal { get; private set; } + + [JsonProperty("chunksUploaded")] + public long ChunksUploaded { get; private set; } + + public File( + string id, + string bucketId, + string createdAt, + string updatedAt, + List permissions, + string name, + string signature, + string mimeType, + long sizeOriginal, + long chunksTotal, + long chunksUploaded + ) { + Id = id; + BucketId = bucketId; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Permissions = permissions; + Name = name; + Signature = signature; + MimeType = mimeType; + SizeOriginal = sizeOriginal; + ChunksTotal = chunksTotal; + ChunksUploaded = chunksUploaded; + } + + public static File From(Dictionary map) => new File( + id: map["$id"].ToString(), + bucketId: map["bucketId"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + permissions: ((JArray)map["$permissions"]).ToObject>(), + name: map["name"].ToString(), + signature: map["signature"].ToString(), + mimeType: map["mimeType"].ToString(), + sizeOriginal: Convert.ToInt64(map["sizeOriginal"]), + chunksTotal: Convert.ToInt64(map["chunksTotal"]), + chunksUploaded: Convert.ToInt64(map["chunksUploaded"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "bucketId", BucketId }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "$permissions", Permissions }, + { "name", Name }, + { "signature", Signature }, + { "mimeType", MimeType }, + { "sizeOriginal", SizeOriginal }, + { "chunksTotal", ChunksTotal }, + { "chunksUploaded", ChunksUploaded } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/FileList.cs b/src/Appwrite/Models/FileList.cs new file mode 100644 index 0000000..c6d60b3 --- /dev/null +++ b/src/Appwrite/Models/FileList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class FileList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("files")] + public List Files { get; private set; } + + public FileList( + long total, + List files + ) { + Total = total; + Files = files; + } + + public static FileList From(Dictionary map) => new FileList( + total: Convert.ToInt64(map["total"]), + files: ((JArray)map["files"]).ToObject>>().Select(it => File.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "files", Files.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Function.cs b/src/Appwrite/Models/Function.cs new file mode 100644 index 0000000..d5f9af2 --- /dev/null +++ b/src/Appwrite/Models/Function.cs @@ -0,0 +1,122 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Function + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("execute")] + public List Execute { get; private set; } + + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("enabled")] + public bool Enabled { get; private set; } + + [JsonProperty("runtime")] + public string Runtime { get; private set; } + + [JsonProperty("deployment")] + public string Deployment { get; private set; } + + [JsonProperty("vars")] + public List Vars { get; private set; } + + [JsonProperty("events")] + public List Events { get; private set; } + + [JsonProperty("schedule")] + public string Schedule { get; private set; } + + [JsonProperty("scheduleNext")] + public string ScheduleNext { get; private set; } + + [JsonProperty("schedulePrevious")] + public string SchedulePrevious { get; private set; } + + [JsonProperty("timeout")] + public long Timeout { get; private set; } + + public Function( + string id, + string createdAt, + string updatedAt, + List execute, + string name, + bool enabled, + string runtime, + string deployment, + List vars, + List events, + string schedule, + string scheduleNext, + string schedulePrevious, + long timeout + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Execute = execute; + Name = name; + Enabled = enabled; + Runtime = runtime; + Deployment = deployment; + Vars = vars; + Events = events; + Schedule = schedule; + ScheduleNext = scheduleNext; + SchedulePrevious = schedulePrevious; + Timeout = timeout; + } + + public static Function From(Dictionary map) => new Function( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + execute: ((JArray)map["execute"]).ToObject>(), + name: map["name"].ToString(), + enabled: (bool)map["enabled"], + runtime: map["runtime"].ToString(), + deployment: map["deployment"].ToString(), + vars: ((JArray)map["vars"]).ToObject>>().Select(it => Variable.From(map: it)).ToList(), + events: ((JArray)map["events"]).ToObject>(), + schedule: map["schedule"].ToString(), + scheduleNext: map["scheduleNext"].ToString(), + schedulePrevious: map["schedulePrevious"].ToString(), + timeout: Convert.ToInt64(map["timeout"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "execute", Execute }, + { "name", Name }, + { "enabled", Enabled }, + { "runtime", Runtime }, + { "deployment", Deployment }, + { "vars", Vars.Select(it => it.ToMap()) }, + { "events", Events }, + { "schedule", Schedule }, + { "scheduleNext", ScheduleNext }, + { "schedulePrevious", SchedulePrevious }, + { "timeout", Timeout } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/FunctionList.cs b/src/Appwrite/Models/FunctionList.cs new file mode 100644 index 0000000..9df2a0f --- /dev/null +++ b/src/Appwrite/Models/FunctionList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class FunctionList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("functions")] + public List Functions { get; private set; } + + public FunctionList( + long total, + List functions + ) { + Total = total; + Functions = functions; + } + + public static FunctionList From(Dictionary map) => new FunctionList( + total: Convert.ToInt64(map["total"]), + functions: ((JArray)map["functions"]).ToObject>>().Select(it => Function.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "functions", Functions.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/HealthAntivirus.cs b/src/Appwrite/Models/HealthAntivirus.cs new file mode 100644 index 0000000..989cbb9 --- /dev/null +++ b/src/Appwrite/Models/HealthAntivirus.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class HealthAntivirus + { + [JsonProperty("version")] + public string Version { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + public HealthAntivirus( + string version, + string status + ) { + Version = version; + Status = status; + } + + public static HealthAntivirus From(Dictionary map) => new HealthAntivirus( + version: map["version"].ToString(), + status: map["status"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "version", Version }, + { "status", Status } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/HealthQueue.cs b/src/Appwrite/Models/HealthQueue.cs new file mode 100644 index 0000000..a7f2641 --- /dev/null +++ b/src/Appwrite/Models/HealthQueue.cs @@ -0,0 +1,31 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class HealthQueue + { + [JsonProperty("size")] + public long Size { get; private set; } + + public HealthQueue( + long size + ) { + Size = size; + } + + public static HealthQueue From(Dictionary map) => new HealthQueue( + size: Convert.ToInt64(map["size"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "size", Size } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/HealthStatus.cs b/src/Appwrite/Models/HealthStatus.cs new file mode 100644 index 0000000..6923b24 --- /dev/null +++ b/src/Appwrite/Models/HealthStatus.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class HealthStatus + { + [JsonProperty("ping")] + public long Ping { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + public HealthStatus( + long ping, + string status + ) { + Ping = ping; + Status = status; + } + + public static HealthStatus From(Dictionary map) => new HealthStatus( + ping: Convert.ToInt64(map["ping"]), + status: map["status"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "ping", Ping }, + { "status", Status } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/HealthTime.cs b/src/Appwrite/Models/HealthTime.cs new file mode 100644 index 0000000..01db780 --- /dev/null +++ b/src/Appwrite/Models/HealthTime.cs @@ -0,0 +1,45 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class HealthTime + { + [JsonProperty("remoteTime")] + public long RemoteTime { get; private set; } + + [JsonProperty("localTime")] + public long LocalTime { get; private set; } + + [JsonProperty("diff")] + public long Diff { get; private set; } + + public HealthTime( + long remoteTime, + long localTime, + long diff + ) { + RemoteTime = remoteTime; + LocalTime = localTime; + Diff = diff; + } + + public static HealthTime From(Dictionary map) => new HealthTime( + remoteTime: Convert.ToInt64(map["remoteTime"]), + localTime: Convert.ToInt64(map["localTime"]), + diff: Convert.ToInt64(map["diff"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "remoteTime", RemoteTime }, + { "localTime", LocalTime }, + { "diff", Diff } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Index.cs b/src/Appwrite/Models/Index.cs new file mode 100644 index 0000000..19ce2d3 --- /dev/null +++ b/src/Appwrite/Models/Index.cs @@ -0,0 +1,59 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Index + { + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("type")] + public string Type { get; private set; } + + [JsonProperty("status")] + public string Status { get; private set; } + + [JsonProperty("attributes")] + public List Attributes { get; private set; } + + [JsonProperty("orders")] + public List? Orders { get; private set; } + + public Index( + string key, + string type, + string status, + List attributes, + List? orders + ) { + Key = key; + Type = type; + Status = status; + Attributes = attributes; + Orders = orders; + } + + public static Index From(Dictionary map) => new Index( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + attributes: ((JArray)map["attributes"]).ToObject>(), + orders: ((JArray)map["orders"]).ToObject>() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "attributes", Attributes }, + { "orders", Orders } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/IndexList.cs b/src/Appwrite/Models/IndexList.cs new file mode 100644 index 0000000..90dc4f8 --- /dev/null +++ b/src/Appwrite/Models/IndexList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class IndexList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("indexes")] + public List Indexes { get; private set; } + + public IndexList( + long total, + List indexes + ) { + Total = total; + Indexes = indexes; + } + + public static IndexList From(Dictionary map) => new IndexList( + total: Convert.ToInt64(map["total"]), + indexes: ((JArray)map["indexes"]).ToObject>>().Select(it => Index.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "indexes", Indexes.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/InputFile.cs b/src/Appwrite/Models/InputFile.cs new file mode 100644 index 0000000..bbb28cd --- /dev/null +++ b/src/Appwrite/Models/InputFile.cs @@ -0,0 +1,41 @@ +using System.IO; +using Appwrite.Extensions; + +namespace Appwrite.Models +{ + public class InputFile + { + public string Path { get; set; } + public string Filename { get; set; } + public string MimeType { get; set; } + public string SourceType { get; set; } + public object Data { get; set; } + + public static InputFile FromPath(string path) => new InputFile + { + Path = path, + Filename = System.IO.Path.GetFileName(path), + MimeType = path.GetMimeType(), + SourceType = "path" + }; + + public static InputFile FromFileInfo(FileInfo fileInfo) => + InputFile.FromPath(fileInfo.FullName); + + public static InputFile FromStream(Stream stream, string filename, string mimeType) => new InputFile + { + Data = stream, + Filename = filename, + MimeType = mimeType, + SourceType = "stream" + }; + + public static InputFile FromBytes(byte[] bytes, string filename, string mimeType) => new InputFile + { + Data = bytes, + Filename = filename, + MimeType = mimeType, + SourceType = "bytes" + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Language.cs b/src/Appwrite/Models/Language.cs new file mode 100644 index 0000000..ea567ce --- /dev/null +++ b/src/Appwrite/Models/Language.cs @@ -0,0 +1,45 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Language + { + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("code")] + public string Code { get; private set; } + + [JsonProperty("nativeName")] + public string NativeName { get; private set; } + + public Language( + string name, + string code, + string nativeName + ) { + Name = name; + Code = code; + NativeName = nativeName; + } + + public static Language From(Dictionary map) => new Language( + name: map["name"].ToString(), + code: map["code"].ToString(), + nativeName: map["nativeName"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "name", Name }, + { "code", Code }, + { "nativeName", NativeName } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/LanguageList.cs b/src/Appwrite/Models/LanguageList.cs new file mode 100644 index 0000000..2d7aa63 --- /dev/null +++ b/src/Appwrite/Models/LanguageList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class LanguageList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("languages")] + public List Languages { get; private set; } + + public LanguageList( + long total, + List languages + ) { + Total = total; + Languages = languages; + } + + public static LanguageList From(Dictionary map) => new LanguageList( + total: Convert.ToInt64(map["total"]), + languages: ((JArray)map["languages"]).ToObject>>().Select(it => Language.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "languages", Languages.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Locale.cs b/src/Appwrite/Models/Locale.cs new file mode 100644 index 0000000..e9b04e6 --- /dev/null +++ b/src/Appwrite/Models/Locale.cs @@ -0,0 +1,73 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Locale + { + [JsonProperty("ip")] + public string Ip { get; private set; } + + [JsonProperty("countryCode")] + public string CountryCode { get; private set; } + + [JsonProperty("country")] + public string Country { get; private set; } + + [JsonProperty("continentCode")] + public string ContinentCode { get; private set; } + + [JsonProperty("continent")] + public string Continent { get; private set; } + + [JsonProperty("eu")] + public bool Eu { get; private set; } + + [JsonProperty("currency")] + public string Currency { get; private set; } + + public Locale( + string ip, + string countryCode, + string country, + string continentCode, + string continent, + bool eu, + string currency + ) { + Ip = ip; + CountryCode = countryCode; + Country = country; + ContinentCode = continentCode; + Continent = continent; + Eu = eu; + Currency = currency; + } + + public static Locale From(Dictionary map) => new Locale( + ip: map["ip"].ToString(), + countryCode: map["countryCode"].ToString(), + country: map["country"].ToString(), + continentCode: map["continentCode"].ToString(), + continent: map["continent"].ToString(), + eu: (bool)map["eu"], + currency: map["currency"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "ip", Ip }, + { "countryCode", CountryCode }, + { "country", Country }, + { "continentCode", ContinentCode }, + { "continent", Continent }, + { "eu", Eu }, + { "currency", Currency } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Log.cs b/src/Appwrite/Models/Log.cs new file mode 100644 index 0000000..56e6d9e --- /dev/null +++ b/src/Appwrite/Models/Log.cs @@ -0,0 +1,171 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Log + { + [JsonProperty("event")] + public string Event { get; private set; } + + [JsonProperty("userId")] + public string UserId { get; private set; } + + [JsonProperty("userEmail")] + public string UserEmail { get; private set; } + + [JsonProperty("userName")] + public string UserName { get; private set; } + + [JsonProperty("mode")] + public string Mode { get; private set; } + + [JsonProperty("ip")] + public string Ip { get; private set; } + + [JsonProperty("time")] + public string Time { get; private set; } + + [JsonProperty("osCode")] + public string OsCode { get; private set; } + + [JsonProperty("osName")] + public string OsName { get; private set; } + + [JsonProperty("osVersion")] + public string OsVersion { get; private set; } + + [JsonProperty("clientType")] + public string ClientType { get; private set; } + + [JsonProperty("clientCode")] + public string ClientCode { get; private set; } + + [JsonProperty("clientName")] + public string ClientName { get; private set; } + + [JsonProperty("clientVersion")] + public string ClientVersion { get; private set; } + + [JsonProperty("clientEngine")] + public string ClientEngine { get; private set; } + + [JsonProperty("clientEngineVersion")] + public string ClientEngineVersion { get; private set; } + + [JsonProperty("deviceName")] + public string DeviceName { get; private set; } + + [JsonProperty("deviceBrand")] + public string DeviceBrand { get; private set; } + + [JsonProperty("deviceModel")] + public string DeviceModel { get; private set; } + + [JsonProperty("countryCode")] + public string CountryCode { get; private set; } + + [JsonProperty("countryName")] + public string CountryName { get; private set; } + + public Log( + string xevent, + string userId, + string userEmail, + string userName, + string mode, + string ip, + string time, + string osCode, + string osName, + string osVersion, + string clientType, + string clientCode, + string clientName, + string clientVersion, + string clientEngine, + string clientEngineVersion, + string deviceName, + string deviceBrand, + string deviceModel, + string countryCode, + string countryName + ) { + Event = xevent; + UserId = userId; + UserEmail = userEmail; + UserName = userName; + Mode = mode; + Ip = ip; + Time = time; + OsCode = osCode; + OsName = osName; + OsVersion = osVersion; + ClientType = clientType; + ClientCode = clientCode; + ClientName = clientName; + ClientVersion = clientVersion; + ClientEngine = clientEngine; + ClientEngineVersion = clientEngineVersion; + DeviceName = deviceName; + DeviceBrand = deviceBrand; + DeviceModel = deviceModel; + CountryCode = countryCode; + CountryName = countryName; + } + + public static Log From(Dictionary map) => new Log( + xevent: map["event"].ToString(), + userId: map["userId"].ToString(), + userEmail: map["userEmail"].ToString(), + userName: map["userName"].ToString(), + mode: map["mode"].ToString(), + ip: map["ip"].ToString(), + time: map["time"].ToString(), + osCode: map["osCode"].ToString(), + osName: map["osName"].ToString(), + osVersion: map["osVersion"].ToString(), + clientType: map["clientType"].ToString(), + clientCode: map["clientCode"].ToString(), + clientName: map["clientName"].ToString(), + clientVersion: map["clientVersion"].ToString(), + clientEngine: map["clientEngine"].ToString(), + clientEngineVersion: map["clientEngineVersion"].ToString(), + deviceName: map["deviceName"].ToString(), + deviceBrand: map["deviceBrand"].ToString(), + deviceModel: map["deviceModel"].ToString(), + countryCode: map["countryCode"].ToString(), + countryName: map["countryName"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "event", Event }, + { "userId", UserId }, + { "userEmail", UserEmail }, + { "userName", UserName }, + { "mode", Mode }, + { "ip", Ip }, + { "time", Time }, + { "osCode", OsCode }, + { "osName", OsName }, + { "osVersion", OsVersion }, + { "clientType", ClientType }, + { "clientCode", ClientCode }, + { "clientName", ClientName }, + { "clientVersion", ClientVersion }, + { "clientEngine", ClientEngine }, + { "clientEngineVersion", ClientEngineVersion }, + { "deviceName", DeviceName }, + { "deviceBrand", DeviceBrand }, + { "deviceModel", DeviceModel }, + { "countryCode", CountryCode }, + { "countryName", CountryName } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/LogList.cs b/src/Appwrite/Models/LogList.cs new file mode 100644 index 0000000..035120a --- /dev/null +++ b/src/Appwrite/Models/LogList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class LogList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("logs")] + public List Logs { get; private set; } + + public LogList( + long total, + List logs + ) { + Total = total; + Logs = logs; + } + + public static LogList From(Dictionary map) => new LogList( + total: Convert.ToInt64(map["total"]), + logs: ((JArray)map["logs"]).ToObject>>().Select(it => Log.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "logs", Logs.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Membership.cs b/src/Appwrite/Models/Membership.cs new file mode 100644 index 0000000..963ff5a --- /dev/null +++ b/src/Appwrite/Models/Membership.cs @@ -0,0 +1,108 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Membership + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("userId")] + public string UserId { get; private set; } + + [JsonProperty("userName")] + public string UserName { get; private set; } + + [JsonProperty("userEmail")] + public string UserEmail { get; private set; } + + [JsonProperty("teamId")] + public string TeamId { get; private set; } + + [JsonProperty("teamName")] + public string TeamName { get; private set; } + + [JsonProperty("invited")] + public string Invited { get; private set; } + + [JsonProperty("joined")] + public string Joined { get; private set; } + + [JsonProperty("confirm")] + public bool Confirm { get; private set; } + + [JsonProperty("roles")] + public List Roles { get; private set; } + + public Membership( + string id, + string createdAt, + string updatedAt, + string userId, + string userName, + string userEmail, + string teamId, + string teamName, + string invited, + string joined, + bool confirm, + List roles + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + UserId = userId; + UserName = userName; + UserEmail = userEmail; + TeamId = teamId; + TeamName = teamName; + Invited = invited; + Joined = joined; + Confirm = confirm; + Roles = roles; + } + + public static Membership From(Dictionary map) => new Membership( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + userId: map["userId"].ToString(), + userName: map["userName"].ToString(), + userEmail: map["userEmail"].ToString(), + teamId: map["teamId"].ToString(), + teamName: map["teamName"].ToString(), + invited: map["invited"].ToString(), + joined: map["joined"].ToString(), + confirm: (bool)map["confirm"], + roles: ((JArray)map["roles"]).ToObject>() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "userId", UserId }, + { "userName", UserName }, + { "userEmail", UserEmail }, + { "teamId", TeamId }, + { "teamName", TeamName }, + { "invited", Invited }, + { "joined", Joined }, + { "confirm", Confirm }, + { "roles", Roles } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/MembershipList.cs b/src/Appwrite/Models/MembershipList.cs new file mode 100644 index 0000000..05e47a3 --- /dev/null +++ b/src/Appwrite/Models/MembershipList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class MembershipList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("memberships")] + public List Memberships { get; private set; } + + public MembershipList( + long total, + List memberships + ) { + Total = total; + Memberships = memberships; + } + + public static MembershipList From(Dictionary map) => new MembershipList( + total: Convert.ToInt64(map["total"]), + memberships: ((JArray)map["memberships"]).ToObject>>().Select(it => Membership.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "memberships", Memberships.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/io/appwrite/src/Appwrite/Models/OrderType.cs b/src/Appwrite/Models/OrderType.cs similarity index 100% rename from io/appwrite/src/Appwrite/Models/OrderType.cs rename to src/Appwrite/Models/OrderType.cs diff --git a/src/Appwrite/Models/Phone.cs b/src/Appwrite/Models/Phone.cs new file mode 100644 index 0000000..45481bb --- /dev/null +++ b/src/Appwrite/Models/Phone.cs @@ -0,0 +1,45 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Phone + { + [JsonProperty("code")] + public string Code { get; private set; } + + [JsonProperty("countryCode")] + public string CountryCode { get; private set; } + + [JsonProperty("countryName")] + public string CountryName { get; private set; } + + public Phone( + string code, + string countryCode, + string countryName + ) { + Code = code; + CountryCode = countryCode; + CountryName = countryName; + } + + public static Phone From(Dictionary map) => new Phone( + code: map["code"].ToString(), + countryCode: map["countryCode"].ToString(), + countryName: map["countryName"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "code", Code }, + { "countryCode", CountryCode }, + { "countryName", CountryName } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/PhoneList.cs b/src/Appwrite/Models/PhoneList.cs new file mode 100644 index 0000000..56b2134 --- /dev/null +++ b/src/Appwrite/Models/PhoneList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class PhoneList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("phones")] + public List Phones { get; private set; } + + public PhoneList( + long total, + List phones + ) { + Total = total; + Phones = phones; + } + + public static PhoneList From(Dictionary map) => new PhoneList( + total: Convert.ToInt64(map["total"]), + phones: ((JArray)map["phones"]).ToObject>>().Select(it => Phone.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "phones", Phones.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Preferences.cs b/src/Appwrite/Models/Preferences.cs new file mode 100644 index 0000000..0a0e2b7 --- /dev/null +++ b/src/Appwrite/Models/Preferences.cs @@ -0,0 +1,33 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Preferences + { + public Dictionary Data { get; private set; } + + public Preferences( + Dictionary data + ) { + Data = data; + } + + public static Preferences From(Dictionary map) => new Preferences( + data: map + ); + + public Dictionary ToMap() => new Dictionary() + { + { "data", Data } + }; + + public T ConvertTo(Func, T> fromJson) => + fromJson.Invoke(Data); + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Runtime.cs b/src/Appwrite/Models/Runtime.cs new file mode 100644 index 0000000..600d71e --- /dev/null +++ b/src/Appwrite/Models/Runtime.cs @@ -0,0 +1,73 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Runtime + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("version")] + public string Version { get; private set; } + + [JsonProperty("base")] + public string Base { get; private set; } + + [JsonProperty("image")] + public string Image { get; private set; } + + [JsonProperty("logo")] + public string Logo { get; private set; } + + [JsonProperty("supports")] + public List Supports { get; private set; } + + public Runtime( + string id, + string name, + string version, + string xbase, + string image, + string logo, + List supports + ) { + Id = id; + Name = name; + Version = version; + Base = xbase; + Image = image; + Logo = logo; + Supports = supports; + } + + public static Runtime From(Dictionary map) => new Runtime( + id: map["$id"].ToString(), + name: map["name"].ToString(), + version: map["version"].ToString(), + xbase: map["base"].ToString(), + image: map["image"].ToString(), + logo: map["logo"].ToString(), + supports: ((JArray)map["supports"]).ToObject>() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "name", Name }, + { "version", Version }, + { "base", Base }, + { "image", Image }, + { "logo", Logo }, + { "supports", Supports } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/RuntimeList.cs b/src/Appwrite/Models/RuntimeList.cs new file mode 100644 index 0000000..08858f7 --- /dev/null +++ b/src/Appwrite/Models/RuntimeList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class RuntimeList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("runtimes")] + public List Runtimes { get; private set; } + + public RuntimeList( + long total, + List runtimes + ) { + Total = total; + Runtimes = runtimes; + } + + public static RuntimeList From(Dictionary map) => new RuntimeList( + total: Convert.ToInt64(map["total"]), + runtimes: ((JArray)map["runtimes"]).ToObject>>().Select(it => Runtime.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "runtimes", Runtimes.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Session.cs b/src/Appwrite/Models/Session.cs new file mode 100644 index 0000000..9702f82 --- /dev/null +++ b/src/Appwrite/Models/Session.cs @@ -0,0 +1,199 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Session + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("userId")] + public string UserId { get; private set; } + + [JsonProperty("expire")] + public string Expire { get; private set; } + + [JsonProperty("provider")] + public string Provider { get; private set; } + + [JsonProperty("providerUid")] + public string ProviderUid { get; private set; } + + [JsonProperty("providerAccessToken")] + public string ProviderAccessToken { get; private set; } + + [JsonProperty("providerAccessTokenExpiry")] + public string ProviderAccessTokenExpiry { get; private set; } + + [JsonProperty("providerRefreshToken")] + public string ProviderRefreshToken { get; private set; } + + [JsonProperty("ip")] + public string Ip { get; private set; } + + [JsonProperty("osCode")] + public string OsCode { get; private set; } + + [JsonProperty("osName")] + public string OsName { get; private set; } + + [JsonProperty("osVersion")] + public string OsVersion { get; private set; } + + [JsonProperty("clientType")] + public string ClientType { get; private set; } + + [JsonProperty("clientCode")] + public string ClientCode { get; private set; } + + [JsonProperty("clientName")] + public string ClientName { get; private set; } + + [JsonProperty("clientVersion")] + public string ClientVersion { get; private set; } + + [JsonProperty("clientEngine")] + public string ClientEngine { get; private set; } + + [JsonProperty("clientEngineVersion")] + public string ClientEngineVersion { get; private set; } + + [JsonProperty("deviceName")] + public string DeviceName { get; private set; } + + [JsonProperty("deviceBrand")] + public string DeviceBrand { get; private set; } + + [JsonProperty("deviceModel")] + public string DeviceModel { get; private set; } + + [JsonProperty("countryCode")] + public string CountryCode { get; private set; } + + [JsonProperty("countryName")] + public string CountryName { get; private set; } + + [JsonProperty("current")] + public bool Current { get; private set; } + + public Session( + string id, + string createdAt, + string userId, + string expire, + string provider, + string providerUid, + string providerAccessToken, + string providerAccessTokenExpiry, + string providerRefreshToken, + string ip, + string osCode, + string osName, + string osVersion, + string clientType, + string clientCode, + string clientName, + string clientVersion, + string clientEngine, + string clientEngineVersion, + string deviceName, + string deviceBrand, + string deviceModel, + string countryCode, + string countryName, + bool current + ) { + Id = id; + CreatedAt = createdAt; + UserId = userId; + Expire = expire; + Provider = provider; + ProviderUid = providerUid; + ProviderAccessToken = providerAccessToken; + ProviderAccessTokenExpiry = providerAccessTokenExpiry; + ProviderRefreshToken = providerRefreshToken; + Ip = ip; + OsCode = osCode; + OsName = osName; + OsVersion = osVersion; + ClientType = clientType; + ClientCode = clientCode; + ClientName = clientName; + ClientVersion = clientVersion; + ClientEngine = clientEngine; + ClientEngineVersion = clientEngineVersion; + DeviceName = deviceName; + DeviceBrand = deviceBrand; + DeviceModel = deviceModel; + CountryCode = countryCode; + CountryName = countryName; + Current = current; + } + + public static Session From(Dictionary map) => new Session( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + userId: map["userId"].ToString(), + expire: map["expire"].ToString(), + provider: map["provider"].ToString(), + providerUid: map["providerUid"].ToString(), + providerAccessToken: map["providerAccessToken"].ToString(), + providerAccessTokenExpiry: map["providerAccessTokenExpiry"].ToString(), + providerRefreshToken: map["providerRefreshToken"].ToString(), + ip: map["ip"].ToString(), + osCode: map["osCode"].ToString(), + osName: map["osName"].ToString(), + osVersion: map["osVersion"].ToString(), + clientType: map["clientType"].ToString(), + clientCode: map["clientCode"].ToString(), + clientName: map["clientName"].ToString(), + clientVersion: map["clientVersion"].ToString(), + clientEngine: map["clientEngine"].ToString(), + clientEngineVersion: map["clientEngineVersion"].ToString(), + deviceName: map["deviceName"].ToString(), + deviceBrand: map["deviceBrand"].ToString(), + deviceModel: map["deviceModel"].ToString(), + countryCode: map["countryCode"].ToString(), + countryName: map["countryName"].ToString(), + current: (bool)map["current"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "userId", UserId }, + { "expire", Expire }, + { "provider", Provider }, + { "providerUid", ProviderUid }, + { "providerAccessToken", ProviderAccessToken }, + { "providerAccessTokenExpiry", ProviderAccessTokenExpiry }, + { "providerRefreshToken", ProviderRefreshToken }, + { "ip", Ip }, + { "osCode", OsCode }, + { "osName", OsName }, + { "osVersion", OsVersion }, + { "clientType", ClientType }, + { "clientCode", ClientCode }, + { "clientName", ClientName }, + { "clientVersion", ClientVersion }, + { "clientEngine", ClientEngine }, + { "clientEngineVersion", ClientEngineVersion }, + { "deviceName", DeviceName }, + { "deviceBrand", DeviceBrand }, + { "deviceModel", DeviceModel }, + { "countryCode", CountryCode }, + { "countryName", CountryName }, + { "current", Current } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/SessionList.cs b/src/Appwrite/Models/SessionList.cs new file mode 100644 index 0000000..919e382 --- /dev/null +++ b/src/Appwrite/Models/SessionList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class SessionList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("sessions")] + public List Sessions { get; private set; } + + public SessionList( + long total, + List sessions + ) { + Total = total; + Sessions = sessions; + } + + public static SessionList From(Dictionary map) => new SessionList( + total: Convert.ToInt64(map["total"]), + sessions: ((JArray)map["sessions"]).ToObject>>().Select(it => Session.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "sessions", Sessions.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Team.cs b/src/Appwrite/Models/Team.cs new file mode 100644 index 0000000..7fc180c --- /dev/null +++ b/src/Appwrite/Models/Team.cs @@ -0,0 +1,66 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Team + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("prefs")] + public Preferences Prefs { get; private set; } + + public Team( + string id, + string createdAt, + string updatedAt, + string name, + long total, + Preferences prefs + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Name = name; + Total = total; + Prefs = prefs; + } + + public static Team From(Dictionary map) => new Team( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + name: map["name"].ToString(), + total: Convert.ToInt64(map["total"]), + prefs: Preferences.From(map: ((JObject)map["prefs"]).ToObject>()!) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "name", Name }, + { "total", Total }, + { "prefs", Prefs.ToMap() } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/TeamList.cs b/src/Appwrite/Models/TeamList.cs new file mode 100644 index 0000000..0bca6f2 --- /dev/null +++ b/src/Appwrite/Models/TeamList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class TeamList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("teams")] + public List Teams { get; private set; } + + public TeamList( + long total, + List teams + ) { + Total = total; + Teams = teams; + } + + public static TeamList From(Dictionary map) => new TeamList( + total: Convert.ToInt64(map["total"]), + teams: ((JArray)map["teams"]).ToObject>>().Select(it => Team.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "teams", Teams.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Token.cs b/src/Appwrite/Models/Token.cs new file mode 100644 index 0000000..ebbebea --- /dev/null +++ b/src/Appwrite/Models/Token.cs @@ -0,0 +1,59 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Token + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("userId")] + public string UserId { get; private set; } + + [JsonProperty("secret")] + public string Secret { get; private set; } + + [JsonProperty("expire")] + public string Expire { get; private set; } + + public Token( + string id, + string createdAt, + string userId, + string secret, + string expire + ) { + Id = id; + CreatedAt = createdAt; + UserId = userId; + Secret = secret; + Expire = expire; + } + + public static Token From(Dictionary map) => new Token( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + userId: map["userId"].ToString(), + secret: map["secret"].ToString(), + expire: map["expire"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "userId", UserId }, + { "secret", Secret }, + { "expire", Expire } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/UploadProgress.cs b/src/Appwrite/Models/UploadProgress.cs new file mode 100644 index 0000000..12ef7eb --- /dev/null +++ b/src/Appwrite/Models/UploadProgress.cs @@ -0,0 +1,26 @@ +namespace Appwrite +{ + public class UploadProgress + { + public string Id { get; private set; } + public double Progress { get; private set; } + public long SizeUploaded { get; private set; } + public long ChunksTotal { get; private set; } + public long ChunksUploaded { get; private set; } + + public UploadProgress( + string id, + double progress, + long sizeUploaded, + long chunksTotal, + long chunksUploaded + ) + { + Id = id; + Progress = progress; + SizeUploaded = sizeUploaded; + ChunksTotal = chunksTotal; + ChunksUploaded = chunksUploaded; + } + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/User.cs b/src/Appwrite/Models/User.cs new file mode 100644 index 0000000..3e9dc39 --- /dev/null +++ b/src/Appwrite/Models/User.cs @@ -0,0 +1,129 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class User + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("name")] + public string Name { get; private set; } + + [JsonProperty("password")] + public string? Password { get; private set; } + + [JsonProperty("hash")] + public string? Hash { get; private set; } + + [JsonProperty("hashOptions")] + public object? HashOptions { get; private set; } + + [JsonProperty("registration")] + public string Registration { get; private set; } + + [JsonProperty("status")] + public bool Status { get; private set; } + + [JsonProperty("passwordUpdate")] + public string PasswordUpdate { get; private set; } + + [JsonProperty("email")] + public string Email { get; private set; } + + [JsonProperty("phone")] + public string Phone { get; private set; } + + [JsonProperty("emailVerification")] + public bool EmailVerification { get; private set; } + + [JsonProperty("phoneVerification")] + public bool PhoneVerification { get; private set; } + + [JsonProperty("prefs")] + public Preferences Prefs { get; private set; } + + public User( + string id, + string createdAt, + string updatedAt, + string name, + string? password, + string? hash, + object? hashOptions, + string registration, + bool status, + string passwordUpdate, + string email, + string phone, + bool emailVerification, + bool phoneVerification, + Preferences prefs + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Name = name; + Password = password; + Hash = hash; + HashOptions = hashOptions; + Registration = registration; + Status = status; + PasswordUpdate = passwordUpdate; + Email = email; + Phone = phone; + EmailVerification = emailVerification; + PhoneVerification = phoneVerification; + Prefs = prefs; + } + + public static User From(Dictionary map) => new User( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + name: map["name"].ToString(), + password: map["password"]?.ToString(), + hash: map["hash"]?.ToString(), + hashOptions: map["hashOptions"]?.ToString(), + registration: map["registration"].ToString(), + status: (bool)map["status"], + passwordUpdate: map["passwordUpdate"].ToString(), + email: map["email"].ToString(), + phone: map["phone"].ToString(), + emailVerification: (bool)map["emailVerification"], + phoneVerification: (bool)map["phoneVerification"], + prefs: Preferences.From(map: ((JObject)map["prefs"]).ToObject>()!) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "name", Name }, + { "password", Password }, + { "hash", Hash }, + { "hashOptions", HashOptions }, + { "registration", Registration }, + { "status", Status }, + { "passwordUpdate", PasswordUpdate }, + { "email", Email }, + { "phone", Phone }, + { "emailVerification", EmailVerification }, + { "phoneVerification", PhoneVerification }, + { "prefs", Prefs.ToMap() } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/UserList.cs b/src/Appwrite/Models/UserList.cs new file mode 100644 index 0000000..5e88573 --- /dev/null +++ b/src/Appwrite/Models/UserList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class UserList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("users")] + public List Users { get; private set; } + + public UserList( + long total, + List users + ) { + Total = total; + Users = users; + } + + public static UserList From(Dictionary map) => new UserList( + total: Convert.ToInt64(map["total"]), + users: ((JArray)map["users"]).ToObject>>().Select(it => User.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "users", Users.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/Variable.cs b/src/Appwrite/Models/Variable.cs new file mode 100644 index 0000000..2697167 --- /dev/null +++ b/src/Appwrite/Models/Variable.cs @@ -0,0 +1,66 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class Variable + { + [JsonProperty("$id")] + public string Id { get; private set; } + + [JsonProperty("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonProperty("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonProperty("key")] + public string Key { get; private set; } + + [JsonProperty("value")] + public string Value { get; private set; } + + [JsonProperty("functionId")] + public string FunctionId { get; private set; } + + public Variable( + string id, + string createdAt, + string updatedAt, + string key, + string xvalue, + string functionId + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Key = key; + Value = xvalue; + FunctionId = functionId; + } + + public static Variable From(Dictionary map) => new Variable( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + key: map["key"].ToString(), + xvalue: map["value"].ToString(), + functionId: map["functionId"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "key", Key }, + { "value", Value }, + { "functionId", FunctionId } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Models/VariableList.cs b/src/Appwrite/Models/VariableList.cs new file mode 100644 index 0000000..1402159 --- /dev/null +++ b/src/Appwrite/Models/VariableList.cs @@ -0,0 +1,38 @@ + +using System; +using System.Linq; +using System.Collections.Generic; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Appwrite.Models +{ + public class VariableList + { + [JsonProperty("total")] + public long Total { get; private set; } + + [JsonProperty("variables")] + public List Variables { get; private set; } + + public VariableList( + long total, + List variables + ) { + Total = total; + Variables = variables; + } + + public static VariableList From(Dictionary map) => new VariableList( + total: Convert.ToInt64(map["total"]), + variables: ((JArray)map["variables"]).ToObject>>().Select(it => Variable.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "variables", Variables.Select(it => it.ToMap()) } + }; + } +} \ No newline at end of file diff --git a/src/Appwrite/Permission.cs b/src/Appwrite/Permission.cs new file mode 100644 index 0000000..ecfcda7 --- /dev/null +++ b/src/Appwrite/Permission.cs @@ -0,0 +1,30 @@ +namespace Appwrite +{ + public static class Permission + { + public static string Read(string role) + { + return $"read(\"{role}\")"; + } + + public static string Write(string role) + { + return $"write(\"{role}\")"; + } + + public static string Create(string role) + { + return $"create(\"{role}\")"; + } + + public static string Update(string role) + { + return $"update(\"{role}\")"; + } + + public static string Delete(string role) + { + return $"delete(\"{role}\")"; + } + } +} diff --git a/src/Appwrite/Query.cs b/src/Appwrite/Query.cs new file mode 100644 index 0000000..c940f4d --- /dev/null +++ b/src/Appwrite/Query.cs @@ -0,0 +1,139 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Appwrite +{ + public static class Query + { + public static string Equal(string attribute, object value) + { + return AddQuery(attribute, "equal", value); + } + + public static string NotEqual(string attribute, object value) + { + return AddQuery(attribute, "notEqual", value); + } + + public static string LessThan(string attribute, object value) + { + return AddQuery(attribute, "lessThan", value); + } + + public static string LessThanEqual(string attribute, object value) + { + return AddQuery(attribute, "lessThanEqual", value); + } + + public static string GreaterThan(string attribute, object value) + { + return AddQuery(attribute, "greaterThan", value); + } + + public static string GreaterThanEqual(string attribute, object value) + { + return AddQuery(attribute, "greaterThanEqual", value); + } + + public static string Search(string attribute, string value) + { + return AddQuery(attribute, "search", value); + } + + public static string IsNull(string attribute) + { + return $"isNull(\"{attribute}\")"; + } + + public static string IsNotNull(string attribute) + { + return $"isNotNull(\"{attribute}\")"; + } + + public static string StartsWith(string attribute, string value) + { + return AddQuery(attribute, "startsWith", value); + } + + public static string EndsWith(string attribute, string value) + { + return AddQuery(attribute, "endsWith", value); + } + + public static string Between(string attribute, string start, string end) + { + return AddQuery(attribute, "between", new List { start, end }); + } + + public static string Between(string attribute, int start, int end) + { + return AddQuery(attribute, "between", new List { start, end }); + } + + public static string Between(string attribute, double start, double end) + { + return AddQuery(attribute, "between", new List { start, end }); + } + + public static string Select(List attributes) + { + return $"select([{string.Join(",", attributes.Select(attribute => $"\"{attribute}\""))}])"; + } + + public static string CursorAfter(string documentId) + { + return $"cursorAfter(\"{documentId}\")"; + } + + public static string CursorBefore(string documentId) { + return $"cursorBefore(\"{documentId}\")"; + } + + public static string OrderAsc(string attribute) { + return $"orderAsc(\"{attribute}\")"; + } + + public static string OrderDesc(string attribute) { + return $"orderDesc(\"{attribute}\")"; + } + + public static string Limit(int limit) { + return $"limit({limit})"; + } + + public static string Offset(int offset) { + return $"offset({offset})"; + } + + private static string AddQuery(string attribute, string method, object value) + { + if (value is IList list) + { + var parsed = new List(); + foreach (var item in list) + { + parsed.Add(ParseValues(item)); + } + return $"{method}(\"{attribute}\", [{string.Join(",", parsed)}])"; + } + else + { + return $"{method}(\"{attribute}\", [{ParseValues(value)}])"; + } + } + + private static string ParseValues(object value) + { + switch (value) + { + case string str: + return $"\"{str}\""; + case bool boolean: + return boolean.ToString().ToLower(); + default: + return value.ToString(); + } + } + } +} \ No newline at end of file diff --git a/src/Appwrite/Role.cs b/src/Appwrite/Role.cs new file mode 100644 index 0000000..7fc1fdb --- /dev/null +++ b/src/Appwrite/Role.cs @@ -0,0 +1,41 @@ +namespace Appwrite +{ + public static class Role + { + public static string Any() + { + return "any"; + } + + public static string User(string id, string status = "") + { + return status == string.Empty + ? $"user:{id}" + : $"user:{id}/{status}"; + } + + public static string Users(string status = "") + { + return status == string.Empty + ? "users" : + $"users/{status}"; + } + + public static string Guests() + { + return "guests"; + } + + public static string Team(string id, string role = "") + { + return role == string.Empty + ? $"team:{id}" + : $"team:{id}/{role}"; + } + + public static string Member(string id) + { + return $"member:{id}"; + } + } +} \ No newline at end of file diff --git a/src/Appwrite/Services/Account.cs b/src/Appwrite/Services/Account.cs new file mode 100644 index 0000000..c918102 --- /dev/null +++ b/src/Appwrite/Services/Account.cs @@ -0,0 +1,780 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Account : Service + { + public Account(Client client) : base(client) + { + } + + /// + /// Get Account + /// + /// Get currently logged in user data as JSON object. + /// + /// + public Task Get() + { + var path = "/account"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Email + /// + /// Update currently logged in user account email address. After changing user + /// address, the user confirmation status will get reset. A new confirmation + /// email is not sent automatically however you can use the send confirmation + /// email endpoint again to send the confirmation email. For security measures, + /// user password is required to complete this request. + /// This endpoint can also be used to convert an anonymous account to a normal + /// one, by passing an email address and a new password. + /// + /// + /// + public Task UpdateEmail(string email, string password) + { + var path = "/account/email"; + + var parameters = new Dictionary() + { + { "email", email }, + { "password", password } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List Logs + /// + /// Get currently logged in user list of latest security activity logs. Each + /// log returns user IP address, location and date and time of log. + /// + /// + public Task ListLogs(List? queries = null) + { + var path = "/account/logs"; + + var parameters = new Dictionary() + { + { "queries", queries } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.LogList Convert(Dictionary it) => + Models.LogList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Name + /// + /// Update currently logged in user account name. + /// + /// + public Task UpdateName(string name) + { + var path = "/account/name"; + + var parameters = new Dictionary() + { + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Password + /// + /// Update currently logged in user password. For validation, user is required + /// to pass in the new password, and the old password. For users created with + /// OAuth, Team Invites and Magic URL, oldPassword is optional. + /// + /// + public Task UpdatePassword(string password, string? oldPassword = null) + { + var path = "/account/password"; + + var parameters = new Dictionary() + { + { "password", password }, + { "oldPassword", oldPassword } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Phone + /// + /// Update the currently logged in user's phone number. After updating the + /// phone number, the phone verification status will be reset. A confirmation + /// SMS is not sent automatically, however you can use the [POST + /// /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) + /// endpoint to send a confirmation SMS. + /// + /// + public Task UpdatePhone(string phone, string password) + { + var path = "/account/phone"; + + var parameters = new Dictionary() + { + { "phone", phone }, + { "password", password } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Account Preferences + /// + /// Get currently logged in user preferences as a key-value object. + /// + /// + public Task GetPrefs() + { + var path = "/account/prefs"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Preferences Convert(Dictionary it) => + Models.Preferences.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Preferences + /// + /// Update currently logged in user account preferences. The object you pass is + /// stored as is, and replaces any previous value. The maximum allowed prefs + /// size is 64kB and throws error if exceeded. + /// + /// + public Task UpdatePrefs(object prefs) + { + var path = "/account/prefs"; + + var parameters = new Dictionary() + { + { "prefs", prefs } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Password Recovery + /// + /// Sends the user an email with a temporary secret key for password reset. + /// When the user clicks the confirmation link he is redirected back to your + /// app password reset URL with the secret key and email address values + /// attached to the URL query string. Use the query string params to submit a + /// request to the [PUT + /// /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to + /// complete the process. The verification link sent to the user's email + /// address is valid for 1 hour. + /// + /// + public Task CreateRecovery(string email, string url) + { + var path = "/account/recovery"; + + var parameters = new Dictionary() + { + { "email", email }, + { "url", url } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Token Convert(Dictionary it) => + Models.Token.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Password Recovery (confirmation) + /// + /// Use this endpoint to complete the user account password reset. Both the + /// **userId** and **secret** arguments will be passed as query parameters to + /// the redirect URL you have provided when sending your request to the [POST + /// /account/recovery](/docs/client/account#accountCreateRecovery) endpoint. + /// + /// Please note that in order to avoid a [Redirect + /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + /// the only valid redirect URLs are the ones from domains you have set when + /// adding your platforms in the console interface. + /// + /// + public Task UpdateRecovery(string userId, string secret, string password, string passwordAgain) + { + var path = "/account/recovery"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "secret", secret }, + { "password", password }, + { "passwordAgain", passwordAgain } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Token Convert(Dictionary it) => + Models.Token.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List Sessions + /// + /// Get currently logged in user list of active sessions across different + /// devices. + /// + /// + public Task ListSessions() + { + var path = "/account/sessions"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.SessionList Convert(Dictionary it) => + Models.SessionList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Sessions + /// + /// Delete all sessions from the user account and remove any sessions cookies + /// from the end client. + /// + /// + public Task DeleteSessions() + { + var path = "/account/sessions"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Get Session + /// + /// Use this endpoint to get a logged in user's session using a Session ID. + /// Inputting 'current' will return the current session being used. + /// + /// + public Task GetSession(string sessionId) + { + var path = "/account/sessions/{sessionId}" + .Replace("{sessionId}", sessionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Session Convert(Dictionary it) => + Models.Session.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update OAuth Session (Refresh Tokens) + /// + /// Access tokens have limited lifespan and expire to mitigate security risks. + /// If session was created using an OAuth provider, this route can be used to + /// "refresh" the access token. + /// + /// + public Task UpdateSession(string sessionId) + { + var path = "/account/sessions/{sessionId}" + .Replace("{sessionId}", sessionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Session Convert(Dictionary it) => + Models.Session.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Session + /// + /// Use this endpoint to log out the currently logged in user from all their + /// account sessions across all of their different devices. When using the + /// Session ID argument, only the unique session ID provided is deleted. + /// + /// + /// + public Task DeleteSession(string sessionId) + { + var path = "/account/sessions/{sessionId}" + .Replace("{sessionId}", sessionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Update Status + /// + /// Block the currently logged in user account. Behind the scene, the user + /// record is not deleted but permanently blocked from any access. To + /// completely delete a user, use the Users API instead. + /// + /// + public Task UpdateStatus() + { + var path = "/account/status"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Email Verification + /// + /// Use this endpoint to send a verification message to your user email address + /// to confirm they are the valid owners of that address. Both the **userId** + /// and **secret** arguments will be passed as query parameters to the URL you + /// have provided to be attached to the verification email. The provided URL + /// should redirect the user back to your app and allow you to complete the + /// verification process by verifying both the **userId** and **secret** + /// parameters. Learn more about how to [complete the verification + /// process](/docs/client/account#accountUpdateEmailVerification). The + /// verification link sent to the user's email address is valid for 7 days. + /// + /// Please note that in order to avoid a [Redirect + /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), + /// the only valid redirect URLs are the ones from domains you have set when + /// adding your platforms in the console interface. + /// + /// + /// + public Task CreateVerification(string url) + { + var path = "/account/verification"; + + var parameters = new Dictionary() + { + { "url", url } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Token Convert(Dictionary it) => + Models.Token.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Email Verification (confirmation) + /// + /// Use this endpoint to complete the user email verification process. Use both + /// the **userId** and **secret** parameters that were attached to your app URL + /// to verify the user email ownership. If confirmed this route will return a + /// 200 status code. + /// + /// + public Task UpdateVerification(string userId, string secret) + { + var path = "/account/verification"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "secret", secret } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Token Convert(Dictionary it) => + Models.Token.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Phone Verification + /// + /// Use this endpoint to send a verification SMS to the currently logged in + /// user. This endpoint is meant for use after updating a user's phone number + /// using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone) + /// endpoint. Learn more about how to [complete the verification + /// process](/docs/client/account#accountUpdatePhoneVerification). The + /// verification code sent to the user's phone number is valid for 15 minutes. + /// + /// + public Task CreatePhoneVerification() + { + var path = "/account/verification/phone"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Token Convert(Dictionary it) => + Models.Token.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Phone Verification (confirmation) + /// + /// Use this endpoint to complete the user phone verification process. Use the + /// **userId** and **secret** that were sent to your user's phone number to + /// verify the user email ownership. If confirmed this route will return a 200 + /// status code. + /// + /// + public Task UpdatePhoneVerification(string userId, string secret) + { + var path = "/account/verification/phone"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "secret", secret } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Token Convert(Dictionary it) => + Models.Token.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + } +} diff --git a/src/Appwrite/Services/Avatars.cs b/src/Appwrite/Services/Avatars.cs new file mode 100644 index 0000000..d08528f --- /dev/null +++ b/src/Appwrite/Services/Avatars.cs @@ -0,0 +1,283 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Avatars : Service + { + public Avatars(Client client) : base(client) + { + } + + /// + /// Get Browser Icon + /// + /// You can use this endpoint to show different browser icons to your users. + /// The code argument receives the browser code as it appears in your user [GET + /// /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use + /// width, height and quality arguments to change the output settings. + /// + /// When one dimension is specified and the other is 0, the image is scaled + /// with preserved aspect ratio. If both dimensions are 0, the API provides an + /// image at source quality. If dimensions are not specified, the default size + /// of image returned is 100x100px. + /// + /// + public Task GetBrowser(string code, long? width = null, long? height = null, long? quality = null) + { + var path = "/avatars/browsers/{code}" + .Replace("{code}", code); + + var parameters = new Dictionary() + { + { "width", width }, + { "height", height }, + { "quality", quality } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + /// + /// Get Credit Card Icon + /// + /// The credit card endpoint will return you the icon of the credit card + /// provider you need. Use width, height and quality arguments to change the + /// output settings. + /// + /// When one dimension is specified and the other is 0, the image is scaled + /// with preserved aspect ratio. If both dimensions are 0, the API provides an + /// image at source quality. If dimensions are not specified, the default size + /// of image returned is 100x100px. + /// + /// + /// + public Task GetCreditCard(string code, long? width = null, long? height = null, long? quality = null) + { + var path = "/avatars/credit-cards/{code}" + .Replace("{code}", code); + + var parameters = new Dictionary() + { + { "width", width }, + { "height", height }, + { "quality", quality } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + /// + /// Get Favicon + /// + /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote + /// website URL. + /// + /// + /// + public Task GetFavicon(string url) + { + var path = "/avatars/favicon"; + + var parameters = new Dictionary() + { + { "url", url } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + /// + /// Get Country Flag + /// + /// You can use this endpoint to show different country flags icons to your + /// users. The code argument receives the 2 letter country code. Use width, + /// height and quality arguments to change the output settings. Country codes + /// follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard. + /// + /// When one dimension is specified and the other is 0, the image is scaled + /// with preserved aspect ratio. If both dimensions are 0, the API provides an + /// image at source quality. If dimensions are not specified, the default size + /// of image returned is 100x100px. + /// + /// + /// + public Task GetFlag(string code, long? width = null, long? height = null, long? quality = null) + { + var path = "/avatars/flags/{code}" + .Replace("{code}", code); + + var parameters = new Dictionary() + { + { "width", width }, + { "height", height }, + { "quality", quality } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + /// + /// Get Image from URL + /// + /// Use this endpoint to fetch a remote image URL and crop it to any image size + /// you want. This endpoint is very useful if you need to crop and display + /// remote images in your app or in case you want to make sure a 3rd party + /// image is properly served using a TLS protocol. + /// + /// When one dimension is specified and the other is 0, the image is scaled + /// with preserved aspect ratio. If both dimensions are 0, the API provides an + /// image at source quality. If dimensions are not specified, the default size + /// of image returned is 400x400px. + /// + /// + /// + public Task GetImage(string url, long? width = null, long? height = null) + { + var path = "/avatars/image"; + + var parameters = new Dictionary() + { + { "url", url }, + { "width", width }, + { "height", height } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + /// + /// Get User Initials + /// + /// Use this endpoint to show your user initials avatar icon on your website or + /// app. By default, this route will try to print your logged-in user name or + /// email initials. You can also overwrite the user name if you pass the 'name' + /// parameter. If no name is given and no user is logged, an empty avatar will + /// be returned. + /// + /// You can use the color and background params to change the avatar colors. By + /// default, a random theme will be selected. The random theme will persist for + /// the user's initials when reloading the same theme will always return for + /// the same initials. + /// + /// When one dimension is specified and the other is 0, the image is scaled + /// with preserved aspect ratio. If both dimensions are 0, the API provides an + /// image at source quality. If dimensions are not specified, the default size + /// of image returned is 100x100px. + /// + /// + /// + public Task GetInitials(string? name = null, long? width = null, long? height = null, string? background = null) + { + var path = "/avatars/initials"; + + var parameters = new Dictionary() + { + { "name", name }, + { "width", width }, + { "height", height }, + { "background", background } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + /// + /// Get QR Code + /// + /// Converts a given plain text to a QR code image. You can use the query + /// parameters to change the size and style of the resulting image. + /// + /// + /// + public Task GetQR(string text, long? size = null, long? margin = null, bool? download = null) + { + var path = "/avatars/qr"; + + var parameters = new Dictionary() + { + { "text", text }, + { "size", size }, + { "margin", margin }, + { "download", download } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + } +} diff --git a/src/Appwrite/Services/Databases.cs b/src/Appwrite/Services/Databases.cs new file mode 100644 index 0000000..f036c71 --- /dev/null +++ b/src/Appwrite/Services/Databases.cs @@ -0,0 +1,1627 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Databases : Service + { + public Databases(Client client) : base(client) + { + } + + /// + /// List Databases + /// + /// Get a list of all databases from the current Appwrite project. You can use + /// the search parameter to filter your results. + /// + /// + public Task List(List? queries = null, string? search = null) + { + var path = "/databases"; + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.DatabaseList Convert(Dictionary it) => + Models.DatabaseList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Database + /// + /// Create a new Database. + /// + /// + /// + public Task Create(string databaseId, string name) + { + var path = "/databases"; + + var parameters = new Dictionary() + { + { "databaseId", databaseId }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Database Convert(Dictionary it) => + Models.Database.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Database + /// + /// Get a database by its unique ID. This endpoint response returns a JSON + /// object with the database metadata. + /// + /// + public Task Get(string databaseId) + { + var path = "/databases/{databaseId}" + .Replace("{databaseId}", databaseId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Database Convert(Dictionary it) => + Models.Database.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Database + /// + /// Update a database by its unique ID. + /// + /// + public Task Update(string databaseId, string name) + { + var path = "/databases/{databaseId}" + .Replace("{databaseId}", databaseId); + + var parameters = new Dictionary() + { + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Database Convert(Dictionary it) => + Models.Database.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Database + /// + /// Delete a database by its unique ID. Only API keys with with databases.write + /// scope can delete a database. + /// + /// + public Task Delete(string databaseId) + { + var path = "/databases/{databaseId}" + .Replace("{databaseId}", databaseId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// List Collections + /// + /// Get a list of all collections that belong to the provided databaseId. You + /// can use the search parameter to filter your results. + /// + /// + public Task ListCollections(string databaseId, List? queries = null, string? search = null) + { + var path = "/databases/{databaseId}/collections" + .Replace("{databaseId}", databaseId); + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.CollectionList Convert(Dictionary it) => + Models.CollectionList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Collection + /// + /// Create a new Collection. Before using this route, you should create a new + /// database resource using either a [server + /// integration](/docs/server/databases#databasesCreateCollection) API or + /// directly from your database console. + /// + /// + public Task CreateCollection(string databaseId, string collectionId, string name, List? permissions = null, bool? documentSecurity = null) + { + var path = "/databases/{databaseId}/collections" + .Replace("{databaseId}", databaseId); + + var parameters = new Dictionary() + { + { "collectionId", collectionId }, + { "name", name }, + { "permissions", permissions }, + { "documentSecurity", documentSecurity } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Collection Convert(Dictionary it) => + Models.Collection.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Collection + /// + /// Get a collection by its unique ID. This endpoint response returns a JSON + /// object with the collection metadata. + /// + /// + public Task GetCollection(string databaseId, string collectionId) + { + var path = "/databases/{databaseId}/collections/{collectionId}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Collection Convert(Dictionary it) => + Models.Collection.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Collection + /// + /// Update a collection by its unique ID. + /// + /// + public Task UpdateCollection(string databaseId, string collectionId, string name, List? permissions = null, bool? documentSecurity = null, bool? enabled = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "name", name }, + { "permissions", permissions }, + { "documentSecurity", documentSecurity }, + { "enabled", enabled } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Collection Convert(Dictionary it) => + Models.Collection.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Collection + /// + /// Delete a collection by its unique ID. Only users with write permissions + /// have access to delete this resource. + /// + /// + public Task DeleteCollection(string databaseId, string collectionId) + { + var path = "/databases/{databaseId}/collections/{collectionId}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// List Attributes + /// + public Task ListAttributes(string databaseId, string collectionId) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeList Convert(Dictionary it) => + Models.AttributeList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Boolean Attribute + /// + /// Create a boolean attribute. + /// + /// + /// + public Task CreateBooleanAttribute(string databaseId, string collectionId, string key, bool required, bool? xdefault = null, bool? array = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault }, + { "array", array } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeBoolean Convert(Dictionary it) => + Models.AttributeBoolean.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Boolean Attribute + /// + public Task UpdateBooleanAttribute(string databaseId, string collectionId, string key, bool required, bool xdefault) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "required", required }, + { "default", xdefault } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeBoolean Convert(Dictionary it) => + Models.AttributeBoolean.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create DateTime Attribute + /// + public Task CreateDatetimeAttribute(string databaseId, string collectionId, string key, bool required, string? xdefault = null, bool? array = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault }, + { "array", array } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeDatetime Convert(Dictionary it) => + Models.AttributeDatetime.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update DateTime Attribute + /// + public Task UpdateDatetimeAttribute(string databaseId, string collectionId, string key, bool required, string xdefault) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "required", required }, + { "default", xdefault } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeDatetime Convert(Dictionary it) => + Models.AttributeDatetime.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Email Attribute + /// + /// Create an email attribute. + /// + /// + /// + public Task CreateEmailAttribute(string databaseId, string collectionId, string key, bool required, string? xdefault = null, bool? array = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/email" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault }, + { "array", array } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeEmail Convert(Dictionary it) => + Models.AttributeEmail.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Email Attribute + /// + /// Update an email attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + /// + public Task UpdateEmailAttribute(string databaseId, string collectionId, string key, bool required, string xdefault) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "required", required }, + { "default", xdefault } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeEmail Convert(Dictionary it) => + Models.AttributeEmail.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Enum Attribute + /// + public Task CreateEnumAttribute(string databaseId, string collectionId, string key, List elements, bool required, string? xdefault = null, bool? array = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "elements", elements }, + { "required", required }, + { "default", xdefault }, + { "array", array } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeEnum Convert(Dictionary it) => + Models.AttributeEnum.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Enum Attribute + /// + /// Update an enum attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + /// + public Task UpdateEnumAttribute(string databaseId, string collectionId, string key, List elements, bool required, string xdefault) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "elements", elements }, + { "required", required }, + { "default", xdefault } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeEnum Convert(Dictionary it) => + Models.AttributeEnum.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Float Attribute + /// + /// Create a float attribute. Optionally, minimum and maximum values can be + /// provided. + /// + /// + /// + public Task CreateFloatAttribute(string databaseId, string collectionId, string key, bool required, double? min = null, double? max = null, double? xdefault = null, bool? array = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/float" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "min", min }, + { "max", max }, + { "default", xdefault }, + { "array", array } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeFloat Convert(Dictionary it) => + Models.AttributeFloat.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Float Attribute + /// + /// Update a float attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + /// + public Task UpdateFloatAttribute(string databaseId, string collectionId, string key, bool required, double min, double max, double xdefault) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "required", required }, + { "min", min }, + { "max", max }, + { "default", xdefault } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeFloat Convert(Dictionary it) => + Models.AttributeFloat.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Integer Attribute + /// + /// Create an integer attribute. Optionally, minimum and maximum values can be + /// provided. + /// + /// + /// + public Task CreateIntegerAttribute(string databaseId, string collectionId, string key, bool required, long? min = null, long? max = null, long? xdefault = null, bool? array = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "min", min }, + { "max", max }, + { "default", xdefault }, + { "array", array } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeInteger Convert(Dictionary it) => + Models.AttributeInteger.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Integer Attribute + /// + /// Update an integer attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + /// + public Task UpdateIntegerAttribute(string databaseId, string collectionId, string key, bool required, long min, long max, long xdefault) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "required", required }, + { "min", min }, + { "max", max }, + { "default", xdefault } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeInteger Convert(Dictionary it) => + Models.AttributeInteger.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create IP Address Attribute + /// + /// Create IP address attribute. + /// + /// + /// + public Task CreateIpAttribute(string databaseId, string collectionId, string key, bool required, string? xdefault = null, bool? array = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault }, + { "array", array } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeIp Convert(Dictionary it) => + Models.AttributeIp.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update IP Address Attribute + /// + /// Update an ip attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + /// + public Task UpdateIpAttribute(string databaseId, string collectionId, string key, bool required, string xdefault) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "required", required }, + { "default", xdefault } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeIp Convert(Dictionary it) => + Models.AttributeIp.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Relationship Attribute + /// + /// Create relationship attribute. [Learn more about relationship + /// attributes](/docs/databases-relationships#relationship-attributes). + /// + /// + /// + public Task CreateRelationshipAttribute(string databaseId, string collectionId, string relatedCollectionId, string type, bool? twoWay = null, string? key = null, string? twoWayKey = null, string? onDelete = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "relatedCollectionId", relatedCollectionId }, + { "type", type }, + { "twoWay", twoWay }, + { "key", key }, + { "twoWayKey", twoWayKey }, + { "onDelete", onDelete } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeRelationship Convert(Dictionary it) => + Models.AttributeRelationship.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create String Attribute + /// + /// Create a string attribute. + /// + /// + /// + public Task CreateStringAttribute(string databaseId, string collectionId, string key, long size, bool required, string? xdefault = null, bool? array = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/string" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "size", size }, + { "required", required }, + { "default", xdefault }, + { "array", array } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeString Convert(Dictionary it) => + Models.AttributeString.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update String Attribute + /// + /// Update a string attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + /// + public Task UpdateStringAttribute(string databaseId, string collectionId, string key, bool required, string xdefault) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "required", required }, + { "default", xdefault } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeString Convert(Dictionary it) => + Models.AttributeString.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create URL Attribute + /// + /// Create a URL attribute. + /// + /// + /// + public Task CreateUrlAttribute(string databaseId, string collectionId, string key, bool required, string? xdefault = null, bool? array = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/url" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault }, + { "array", array } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeUrl Convert(Dictionary it) => + Models.AttributeUrl.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update URL Attribute + /// + /// Update an url attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + /// + public Task UpdateUrlAttribute(string databaseId, string collectionId, string key, bool required, string xdefault) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "required", required }, + { "default", xdefault } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeUrl Convert(Dictionary it) => + Models.AttributeUrl.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Attribute + /// + public Task GetAttribute(string databaseId, string collectionId, string key) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Delete Attribute + /// + public Task DeleteAttribute(string databaseId, string collectionId, string key) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Update Relationship Attribute + /// + /// Update relationship attribute. [Learn more about relationship + /// attributes](/docs/databases-relationships#relationship-attributes). + /// + /// + /// + public Task UpdateRelationshipAttribute(string databaseId, string collectionId, string key, string? onDelete = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + { "onDelete", onDelete } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.AttributeRelationship Convert(Dictionary it) => + Models.AttributeRelationship.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List Documents + /// + /// Get a list of all the user's documents in a given collection. You can use + /// the query params to filter your results. + /// + /// + public Task ListDocuments(string databaseId, string collectionId, List? queries = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/documents" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "queries", queries } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.DocumentList Convert(Dictionary it) => + Models.DocumentList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Document + /// + /// Create a new Document. Before using this route, you should create a new + /// collection resource using either a [server + /// integration](/docs/server/databases#databasesCreateCollection) API or + /// directly from your database console. + /// + /// + public Task CreateDocument(string databaseId, string collectionId, string documentId, object data, List? permissions = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/documents" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "documentId", documentId }, + { "data", data }, + { "permissions", permissions } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Document Convert(Dictionary it) => + Models.Document.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Document + /// + /// Get a document by its unique ID. This endpoint response returns a JSON + /// object with the document data. + /// + /// + public Task GetDocument(string databaseId, string collectionId, string documentId, List? queries = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{documentId}", documentId); + + var parameters = new Dictionary() + { + { "queries", queries } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Document Convert(Dictionary it) => + Models.Document.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Document + /// + /// Update a document by its unique ID. Using the patch method you can pass + /// only specific fields that will get updated. + /// + /// + public Task UpdateDocument(string databaseId, string collectionId, string documentId, object? data = null, List? permissions = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{documentId}", documentId); + + var parameters = new Dictionary() + { + { "data", data }, + { "permissions", permissions } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Document Convert(Dictionary it) => + Models.Document.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Document + /// + /// Delete a document by its unique ID. + /// + /// + public Task DeleteDocument(string databaseId, string collectionId, string documentId) + { + var path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{documentId}", documentId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// List Indexes + /// + public Task ListIndexes(string databaseId, string collectionId) + { + var path = "/databases/{databaseId}/collections/{collectionId}/indexes" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.IndexList Convert(Dictionary it) => + Models.IndexList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Index + /// + public Task CreateIndex(string databaseId, string collectionId, string key, string type, List attributes, List? orders = null) + { + var path = "/databases/{databaseId}/collections/{collectionId}/indexes" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "type", type }, + { "attributes", attributes }, + { "orders", orders } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Index Convert(Dictionary it) => + Models.Index.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Index + /// + public Task GetIndex(string databaseId, string collectionId, string key) + { + var path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Index Convert(Dictionary it) => + Models.Index.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Index + /// + public Task DeleteIndex(string databaseId, string collectionId, string key) + { + var path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + } +} diff --git a/src/Appwrite/Services/Functions.cs b/src/Appwrite/Services/Functions.cs new file mode 100644 index 0000000..e2f48b0 --- /dev/null +++ b/src/Appwrite/Services/Functions.cs @@ -0,0 +1,761 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Functions : Service + { + public Functions(Client client) : base(client) + { + } + + /// + /// List Functions + /// + /// Get a list of all the project's functions. You can use the query params to + /// filter your results. + /// + /// + public Task List(List? queries = null, string? search = null) + { + var path = "/functions"; + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.FunctionList Convert(Dictionary it) => + Models.FunctionList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Function + /// + /// Create a new function. You can pass a list of + /// [permissions](/docs/permissions) to allow different project users or team + /// with access to execute the function using the client API. + /// + /// + public Task Create(string functionId, string name, string runtime, List? execute = null, List? events = null, string? schedule = null, long? timeout = null, bool? enabled = null) + { + var path = "/functions"; + + var parameters = new Dictionary() + { + { "functionId", functionId }, + { "name", name }, + { "execute", execute }, + { "runtime", runtime }, + { "events", events }, + { "schedule", schedule }, + { "timeout", timeout }, + { "enabled", enabled } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Function Convert(Dictionary it) => + Models.Function.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List runtimes + /// + /// Get a list of all runtimes that are currently active on your instance. + /// + /// + public Task ListRuntimes() + { + var path = "/functions/runtimes"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.RuntimeList Convert(Dictionary it) => + Models.RuntimeList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Function + /// + /// Get a function by its unique ID. + /// + /// + public Task Get(string functionId) + { + var path = "/functions/{functionId}" + .Replace("{functionId}", functionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Function Convert(Dictionary it) => + Models.Function.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Function + /// + /// Update function by its unique ID. + /// + /// + public Task Update(string functionId, string name, List? execute = null, List? events = null, string? schedule = null, long? timeout = null, bool? enabled = null) + { + var path = "/functions/{functionId}" + .Replace("{functionId}", functionId); + + var parameters = new Dictionary() + { + { "name", name }, + { "execute", execute }, + { "events", events }, + { "schedule", schedule }, + { "timeout", timeout }, + { "enabled", enabled } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Function Convert(Dictionary it) => + Models.Function.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Function + /// + /// Delete a function by its unique ID. + /// + /// + public Task Delete(string functionId) + { + var path = "/functions/{functionId}" + .Replace("{functionId}", functionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// List Deployments + /// + /// Get a list of all the project's code deployments. You can use the query + /// params to filter your results. + /// + /// + public Task ListDeployments(string functionId, List? queries = null, string? search = null) + { + var path = "/functions/{functionId}/deployments" + .Replace("{functionId}", functionId); + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.DeploymentList Convert(Dictionary it) => + Models.DeploymentList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Deployment + /// + /// Create a new function code deployment. Use this endpoint to upload a new + /// version of your code function. To execute your newly uploaded code, you'll + /// need to update the function's deployment to use your new deployment UID. + /// + /// This endpoint accepts a tar.gz file compressed with your code. Make sure to + /// include any dependencies your code has within the compressed file. You can + /// learn more about code packaging in the [Appwrite Cloud Functions + /// tutorial](/docs/functions). + /// + /// Use the "command" param to set the entry point used to execute your code. + /// + /// + public Task CreateDeployment(string functionId, string entrypoint, InputFile code, bool activate, Action? onProgress = null) + { + var path = "/functions/{functionId}/deployments" + .Replace("{functionId}", functionId); + + var parameters = new Dictionary() + { + { "entrypoint", entrypoint }, + { "code", code }, + { "activate", activate } + }; + + var headers = new Dictionary() + { + { "content-type", "multipart/form-data" } + }; + + + + static Models.Deployment Convert(Dictionary it) => + Models.Deployment.From(map: it); + + string? idParamName = null; + + var paramName = "code"; + + return _client.ChunkedUpload( + path, + headers, + parameters, + Convert, + paramName, + idParamName, + onProgress); + } + + /// + /// Get Deployment + /// + /// Get a code deployment by its unique ID. + /// + /// + public Task GetDeployment(string functionId, string deploymentId) + { + var path = "/functions/{functionId}/deployments/{deploymentId}" + .Replace("{functionId}", functionId) + .Replace("{deploymentId}", deploymentId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Deployment Convert(Dictionary it) => + Models.Deployment.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Function Deployment + /// + /// 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. + /// + /// + public Task UpdateDeployment(string functionId, string deploymentId) + { + var path = "/functions/{functionId}/deployments/{deploymentId}" + .Replace("{functionId}", functionId) + .Replace("{deploymentId}", deploymentId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Function Convert(Dictionary it) => + Models.Function.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Deployment + /// + /// Delete a code deployment by its unique ID. + /// + /// + public Task DeleteDeployment(string functionId, string deploymentId) + { + var path = "/functions/{functionId}/deployments/{deploymentId}" + .Replace("{functionId}", functionId) + .Replace("{deploymentId}", deploymentId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Create Build + /// + public Task CreateBuild(string functionId, string deploymentId, string buildId) + { + var path = "/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}" + .Replace("{functionId}", functionId) + .Replace("{deploymentId}", deploymentId) + .Replace("{buildId}", buildId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// List Executions + /// + /// Get a list of all the current user function execution logs. You can use the + /// query params to filter your results. + /// + /// + public Task ListExecutions(string functionId, List? queries = null, string? search = null) + { + var path = "/functions/{functionId}/executions" + .Replace("{functionId}", functionId); + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.ExecutionList Convert(Dictionary it) => + Models.ExecutionList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Execution + /// + /// Trigger a function execution. The returned object will return you the + /// current execution status. You can ping the `Get Execution` endpoint to get + /// updates on the current execution status. Once this endpoint is called, your + /// function execution process will start asynchronously. + /// + /// + public Task CreateExecution(string functionId, string? data = null, bool? xasync = null) + { + var path = "/functions/{functionId}/executions" + .Replace("{functionId}", functionId); + + var parameters = new Dictionary() + { + { "data", data }, + { "async", xasync } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Execution Convert(Dictionary it) => + Models.Execution.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Execution + /// + /// Get a function execution log by its unique ID. + /// + /// + public Task GetExecution(string functionId, string executionId) + { + var path = "/functions/{functionId}/executions/{executionId}" + .Replace("{functionId}", functionId) + .Replace("{executionId}", executionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Execution Convert(Dictionary it) => + Models.Execution.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List Variables + /// + /// Get a list of all variables of a specific function. + /// + /// + public Task ListVariables(string functionId) + { + var path = "/functions/{functionId}/variables" + .Replace("{functionId}", functionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.VariableList Convert(Dictionary it) => + Models.VariableList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Variable + /// + /// Create a new function variable. These variables can be accessed within + /// function in the `env` object under the request variable. + /// + /// + public Task CreateVariable(string functionId, string key, string xvalue) + { + var path = "/functions/{functionId}/variables" + .Replace("{functionId}", functionId); + + var parameters = new Dictionary() + { + { "key", key }, + { "value", xvalue } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Variable Convert(Dictionary it) => + Models.Variable.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Variable + /// + /// Get a variable by its unique ID. + /// + /// + public Task GetVariable(string functionId, string variableId) + { + var path = "/functions/{functionId}/variables/{variableId}" + .Replace("{functionId}", functionId) + .Replace("{variableId}", variableId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Variable Convert(Dictionary it) => + Models.Variable.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Variable + /// + /// Update variable by its unique ID. + /// + /// + public Task UpdateVariable(string functionId, string variableId, string key, string? xvalue = null) + { + var path = "/functions/{functionId}/variables/{variableId}" + .Replace("{functionId}", functionId) + .Replace("{variableId}", variableId); + + var parameters = new Dictionary() + { + { "key", key }, + { "value", xvalue } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Variable Convert(Dictionary it) => + Models.Variable.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Variable + /// + /// Delete a variable by its unique ID. + /// + /// + public Task DeleteVariable(string functionId, string variableId) + { + var path = "/functions/{functionId}/variables/{variableId}" + .Replace("{functionId}", functionId) + .Replace("{variableId}", variableId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + } +} diff --git a/src/Appwrite/Services/Graphql.cs b/src/Appwrite/Services/Graphql.cs new file mode 100644 index 0000000..7d1cc7e --- /dev/null +++ b/src/Appwrite/Services/Graphql.cs @@ -0,0 +1,89 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Graphql : Service + { + public Graphql(Client client) : base(client) + { + } + + /// + /// GraphQL Endpoint + /// + /// Execute a GraphQL mutation. + /// + /// + public Task Query(object query) + { + var path = "/graphql"; + + var parameters = new Dictionary() + { + { "query", query } + }; + + var headers = new Dictionary() + { + { "x-sdk-graphql", "true" }, + { "content-type", "application/json" } + }; + + + + static object Convert(Dictionary it) => + it; + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// GraphQL Endpoint + /// + /// Execute a GraphQL mutation. + /// + /// + public Task Mutation(object query) + { + var path = "/graphql/mutation"; + + var parameters = new Dictionary() + { + { "query", query } + }; + + var headers = new Dictionary() + { + { "x-sdk-graphql", "true" }, + { "content-type", "application/json" } + }; + + + + static object Convert(Dictionary it) => + it; + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + } +} diff --git a/src/Appwrite/Services/Health.cs b/src/Appwrite/Services/Health.cs new file mode 100644 index 0000000..ec0e0e1 --- /dev/null +++ b/src/Appwrite/Services/Health.cs @@ -0,0 +1,365 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Health : Service + { + public Health(Client client) : base(client) + { + } + + /// + /// Get HTTP + /// + /// Check the Appwrite HTTP server is up and responsive. + /// + /// + public Task Get() + { + var path = "/health"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthStatus Convert(Dictionary it) => + Models.HealthStatus.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Antivirus + /// + /// Check the Appwrite Antivirus server is up and connection is successful. + /// + /// + public Task GetAntivirus() + { + var path = "/health/anti-virus"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthAntivirus Convert(Dictionary it) => + Models.HealthAntivirus.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Cache + /// + /// Check the Appwrite in-memory cache server is up and connection is + /// successful. + /// + /// + public Task GetCache() + { + var path = "/health/cache"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthStatus Convert(Dictionary it) => + Models.HealthStatus.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get DB + /// + /// Check the Appwrite database server is up and connection is successful. + /// + /// + public Task GetDB() + { + var path = "/health/db"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthStatus Convert(Dictionary it) => + Models.HealthStatus.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Certificates Queue + /// + /// Get the number of certificates that are waiting to be issued against + /// [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue + /// server. + /// + /// + public Task GetQueueCertificates() + { + var path = "/health/queue/certificates"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthQueue Convert(Dictionary it) => + Models.HealthQueue.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Functions Queue + /// + public Task GetQueueFunctions() + { + var path = "/health/queue/functions"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthQueue Convert(Dictionary it) => + Models.HealthQueue.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Logs Queue + /// + /// Get the number of logs that are waiting to be processed in the Appwrite + /// internal queue server. + /// + /// + public Task GetQueueLogs() + { + var path = "/health/queue/logs"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthQueue Convert(Dictionary it) => + Models.HealthQueue.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Webhooks Queue + /// + /// Get the number of webhooks that are waiting to be processed in the Appwrite + /// internal queue server. + /// + /// + public Task GetQueueWebhooks() + { + var path = "/health/queue/webhooks"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthQueue Convert(Dictionary it) => + Models.HealthQueue.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Local Storage + /// + /// Check the Appwrite local storage device is up and connection is successful. + /// + /// + public Task GetStorageLocal() + { + var path = "/health/storage/local"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthStatus Convert(Dictionary it) => + Models.HealthStatus.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Time + /// + /// Check the Appwrite server time is synced with Google remote NTP server. We + /// use this technology to smoothly handle leap seconds with no disruptive + /// events. The [Network Time + /// Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is + /// used by hundreds of millions of computers and devices to synchronize their + /// clocks over the Internet. If your computer sets its own clock, it likely + /// uses NTP. + /// + /// + public Task GetTime() + { + var path = "/health/time"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.HealthTime Convert(Dictionary it) => + Models.HealthTime.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + } +} diff --git a/src/Appwrite/Services/Locale.cs b/src/Appwrite/Services/Locale.cs new file mode 100644 index 0000000..73f91ae --- /dev/null +++ b/src/Appwrite/Services/Locale.cs @@ -0,0 +1,267 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Locale : Service + { + public Locale(Client client) : base(client) + { + } + + /// + /// Get User Locale + /// + /// Get the current user location based on IP. Returns an object with user + /// country code, country name, continent name, continent code, ip address and + /// suggested currency. You can use the locale header to get the data in a + /// supported language. + /// + /// ([IP Geolocation by DB-IP](https://db-ip.com)) + /// + /// + public Task Get() + { + var path = "/locale"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Locale Convert(Dictionary it) => + Models.Locale.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List Continents + /// + /// List of all continents. You can use the locale header to get the data in a + /// supported language. + /// + /// + public Task ListContinents() + { + var path = "/locale/continents"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.ContinentList Convert(Dictionary it) => + Models.ContinentList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List Countries + /// + /// List of all countries. You can use the locale header to get the data in a + /// supported language. + /// + /// + public Task ListCountries() + { + var path = "/locale/countries"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.CountryList Convert(Dictionary it) => + Models.CountryList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List EU Countries + /// + /// List of all countries that are currently members of the EU. You can use the + /// locale header to get the data in a supported language. + /// + /// + public Task ListCountriesEU() + { + var path = "/locale/countries/eu"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.CountryList Convert(Dictionary it) => + Models.CountryList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List Countries Phone Codes + /// + /// List of all countries phone codes. You can use the locale header to get the + /// data in a supported language. + /// + /// + public Task ListCountriesPhones() + { + var path = "/locale/countries/phones"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.PhoneList Convert(Dictionary it) => + Models.PhoneList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List Currencies + /// + /// List of all currencies, including currency symbol, name, plural, and + /// decimal digits for all major and minor currencies. You can use the locale + /// header to get the data in a supported language. + /// + /// + public Task ListCurrencies() + { + var path = "/locale/currencies"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.CurrencyList Convert(Dictionary it) => + Models.CurrencyList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List Languages + /// + /// List of all languages classified by ISO 639-1 including 2-letter code, name + /// in English, and name in the respective language. + /// + /// + public Task ListLanguages() + { + var path = "/locale/languages"; + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.LanguageList Convert(Dictionary it) => + Models.LanguageList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + } +} diff --git a/io/appwrite/src/Appwrite/Services/Service.cs b/src/Appwrite/Services/Service.cs similarity index 100% rename from io/appwrite/src/Appwrite/Services/Service.cs rename to src/Appwrite/Services/Service.cs diff --git a/src/Appwrite/Services/Storage.cs b/src/Appwrite/Services/Storage.cs new file mode 100644 index 0000000..605476e --- /dev/null +++ b/src/Appwrite/Services/Storage.cs @@ -0,0 +1,522 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Storage : Service + { + public Storage(Client client) : base(client) + { + } + + /// + /// List buckets + /// + /// Get a list of all the storage buckets. You can use the query params to + /// filter your results. + /// + /// + public Task ListBuckets(List? queries = null, string? search = null) + { + var path = "/storage/buckets"; + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.BucketList Convert(Dictionary it) => + Models.BucketList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create bucket + /// + /// Create a new storage bucket. + /// + /// + public Task CreateBucket(string bucketId, string name, List? permissions = null, bool? fileSecurity = null, bool? enabled = null, long? maximumFileSize = null, List? allowedFileExtensions = null, string? compression = null, bool? encryption = null, bool? antivirus = null) + { + var path = "/storage/buckets"; + + var parameters = new Dictionary() + { + { "bucketId", bucketId }, + { "name", name }, + { "permissions", permissions }, + { "fileSecurity", fileSecurity }, + { "enabled", enabled }, + { "maximumFileSize", maximumFileSize }, + { "allowedFileExtensions", allowedFileExtensions }, + { "compression", compression }, + { "encryption", encryption }, + { "antivirus", antivirus } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Bucket Convert(Dictionary it) => + Models.Bucket.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Bucket + /// + /// Get a storage bucket by its unique ID. This endpoint response returns a + /// JSON object with the storage bucket metadata. + /// + /// + public Task GetBucket(string bucketId) + { + var path = "/storage/buckets/{bucketId}" + .Replace("{bucketId}", bucketId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Bucket Convert(Dictionary it) => + Models.Bucket.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Bucket + /// + /// Update a storage bucket by its unique ID. + /// + /// + public Task UpdateBucket(string bucketId, string name, List? permissions = null, bool? fileSecurity = null, bool? enabled = null, long? maximumFileSize = null, List? allowedFileExtensions = null, string? compression = null, bool? encryption = null, bool? antivirus = null) + { + var path = "/storage/buckets/{bucketId}" + .Replace("{bucketId}", bucketId); + + var parameters = new Dictionary() + { + { "name", name }, + { "permissions", permissions }, + { "fileSecurity", fileSecurity }, + { "enabled", enabled }, + { "maximumFileSize", maximumFileSize }, + { "allowedFileExtensions", allowedFileExtensions }, + { "compression", compression }, + { "encryption", encryption }, + { "antivirus", antivirus } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Bucket Convert(Dictionary it) => + Models.Bucket.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Bucket + /// + /// Delete a storage bucket by its unique ID. + /// + /// + public Task DeleteBucket(string bucketId) + { + var path = "/storage/buckets/{bucketId}" + .Replace("{bucketId}", bucketId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// List Files + /// + /// Get a list of all the user files. You can use the query params to filter + /// your results. + /// + /// + public Task ListFiles(string bucketId, List? queries = null, string? search = null) + { + var path = "/storage/buckets/{bucketId}/files" + .Replace("{bucketId}", bucketId); + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.FileList Convert(Dictionary it) => + Models.FileList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create File + /// + /// Create a new file. Before using this route, you should create a new bucket + /// resource using either a [server + /// integration](/docs/server/storage#storageCreateBucket) API or directly from + /// your Appwrite console. + /// + /// Larger files should be uploaded using multiple requests with the + /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) + /// header to send a partial request with a maximum supported chunk of `5MB`. + /// The `content-range` header values should always be in bytes. + /// + /// When the first request is sent, the server will return the **File** object, + /// and the subsequent part request must include the file's **id** in + /// `x-appwrite-id` header to allow the server to know that the partial upload + /// is for the existing file and not for a new one. + /// + /// If you're creating a new file using one of the Appwrite SDKs, all the + /// chunking logic will be managed by the SDK internally. + /// + /// + /// + public Task CreateFile(string bucketId, string fileId, InputFile file, List? permissions = null, Action? onProgress = null) + { + var path = "/storage/buckets/{bucketId}/files" + .Replace("{bucketId}", bucketId); + + var parameters = new Dictionary() + { + { "fileId", fileId }, + { "file", file }, + { "permissions", permissions } + }; + + var headers = new Dictionary() + { + { "content-type", "multipart/form-data" } + }; + + + + static Models.File Convert(Dictionary it) => + Models.File.From(map: it); + + string? idParamName = "fileId"; + + var paramName = "file"; + + return _client.ChunkedUpload( + path, + headers, + parameters, + Convert, + paramName, + idParamName, + onProgress); + } + + /// + /// Get File + /// + /// Get a file by its unique ID. This endpoint response returns a JSON object + /// with the file metadata. + /// + /// + public Task GetFile(string bucketId, string fileId) + { + var path = "/storage/buckets/{bucketId}/files/{fileId}" + .Replace("{bucketId}", bucketId) + .Replace("{fileId}", fileId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.File Convert(Dictionary it) => + Models.File.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update File + /// + /// Update a file by its unique ID. Only users with write permissions have + /// access to update this resource. + /// + /// + public Task UpdateFile(string bucketId, string fileId, List? permissions = null) + { + var path = "/storage/buckets/{bucketId}/files/{fileId}" + .Replace("{bucketId}", bucketId) + .Replace("{fileId}", fileId); + + var parameters = new Dictionary() + { + { "permissions", permissions } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.File Convert(Dictionary it) => + Models.File.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete File + /// + /// Delete a file by its unique ID. Only users with write permissions have + /// access to delete this resource. + /// + /// + public Task DeleteFile(string bucketId, string fileId) + { + var path = "/storage/buckets/{bucketId}/files/{fileId}" + .Replace("{bucketId}", bucketId) + .Replace("{fileId}", fileId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Get File for Download + /// + /// Get a file 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. + /// + /// + public Task GetFileDownload(string bucketId, string fileId) + { + var path = "/storage/buckets/{bucketId}/files/{fileId}/download" + .Replace("{bucketId}", bucketId) + .Replace("{fileId}", fileId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + /// + /// Get File Preview + /// + /// Get a file preview image. Currently, this method supports preview for image + /// files (jpg, png, and gif), other supported formats, like pdf, docs, slides, + /// and spreadsheets, will return the file icon image. You can also pass query + /// string arguments for cutting and resizing your preview image. Preview is + /// supported only for image files smaller than 10MB. + /// + /// + public Task GetFilePreview(string bucketId, string fileId, long? width = null, long? height = null, string? gravity = null, long? quality = null, long? borderWidth = null, string? borderColor = null, long? borderRadius = null, double? opacity = null, long? rotation = null, string? background = null, string? output = null) + { + var path = "/storage/buckets/{bucketId}/files/{fileId}/preview" + .Replace("{bucketId}", bucketId) + .Replace("{fileId}", fileId); + + var parameters = new Dictionary() + { + { "width", width }, + { "height", height }, + { "gravity", gravity }, + { "quality", quality }, + { "borderWidth", borderWidth }, + { "borderColor", borderColor }, + { "borderRadius", borderRadius }, + { "opacity", opacity }, + { "rotation", rotation }, + { "background", background }, + { "output", output } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + /// + /// Get File for View + /// + /// Get a file content by its unique ID. This endpoint is similar to the + /// download method but returns with no 'Content-Disposition: attachment' + /// header. + /// + /// + public Task GetFileView(string bucketId, string fileId) + { + var path = "/storage/buckets/{bucketId}/files/{fileId}/view" + .Replace("{bucketId}", bucketId) + .Replace("{fileId}", fileId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + } + + } +} diff --git a/src/Appwrite/Services/Teams.cs b/src/Appwrite/Services/Teams.cs new file mode 100644 index 0000000..06d7dda --- /dev/null +++ b/src/Appwrite/Services/Teams.cs @@ -0,0 +1,526 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Teams : Service + { + public Teams(Client client) : base(client) + { + } + + /// + /// List Teams + /// + /// Get a list of all the teams in which the current user is a member. You can + /// use the parameters to filter your results. + /// + /// + public Task List(List? queries = null, string? search = null) + { + var path = "/teams"; + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.TeamList Convert(Dictionary it) => + Models.TeamList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Team + /// + /// Create a new team. The user who creates the team will automatically be + /// assigned as the owner of the team. Only the users with the owner role can + /// invite new members, add new owners and delete or update the team. + /// + /// + public Task Create(string teamId, string name, List? roles = null) + { + var path = "/teams"; + + var parameters = new Dictionary() + { + { "teamId", teamId }, + { "name", name }, + { "roles", roles } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Team Convert(Dictionary it) => + Models.Team.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Team + /// + /// Get a team by its ID. All team members have read access for this resource. + /// + /// + public Task Get(string teamId) + { + var path = "/teams/{teamId}" + .Replace("{teamId}", teamId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Team Convert(Dictionary it) => + Models.Team.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Name + /// + /// Update the team's name by its unique ID. + /// + /// + public Task UpdateName(string teamId, string name) + { + var path = "/teams/{teamId}" + .Replace("{teamId}", teamId); + + var parameters = new Dictionary() + { + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Team Convert(Dictionary it) => + Models.Team.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Team + /// + /// Delete a team using its ID. Only team members with the owner role can + /// delete the team. + /// + /// + public Task Delete(string teamId) + { + var path = "/teams/{teamId}" + .Replace("{teamId}", teamId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// List Team Memberships + /// + /// Use this endpoint to list a team's members using the team's ID. All team + /// members have read access to this endpoint. + /// + /// + public Task ListMemberships(string teamId, List? queries = null, string? search = null) + { + var path = "/teams/{teamId}/memberships" + .Replace("{teamId}", teamId); + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.MembershipList Convert(Dictionary it) => + Models.MembershipList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create Team Membership + /// + /// Invite a new member to join your team. Provide an ID for existing users, or + /// invite unregistered users using an email or phone number. If initiated from + /// a Client SDK, Appwrite will send an email or sms with a link to join the + /// team to the invited user, and an account will be created for them if one + /// doesn't exist. If initiated from a Server SDK, the new member will be added + /// automatically to the team. + /// + /// You only need to provide one of a user ID, email, or phone number. Appwrite + /// will prioritize accepting the user ID > email > phone number if you provide + /// more than one of these parameters. + /// + /// Use the `url` parameter to redirect the user from the invitation email to + /// your app. After the user is redirected, use the [Update Team Membership + /// Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow + /// the user to accept the invitation to the team. + /// + /// Please note that to avoid a [Redirect + /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + /// Appwrite will accept the only redirect URLs under the domains you have + /// added as a platform on the Appwrite Console. + /// + /// + /// + public Task CreateMembership(string teamId, List roles, string url, string? email = null, string? userId = null, string? phone = null, string? name = null) + { + var path = "/teams/{teamId}/memberships" + .Replace("{teamId}", teamId); + + var parameters = new Dictionary() + { + { "email", email }, + { "userId", userId }, + { "phone", phone }, + { "roles", roles }, + { "url", url }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Membership Convert(Dictionary it) => + Models.Membership.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Team Membership + /// + /// Get a team member by the membership unique id. All team members have read + /// access for this resource. + /// + /// + public Task GetMembership(string teamId, string membershipId) + { + var path = "/teams/{teamId}/memberships/{membershipId}" + .Replace("{teamId}", teamId) + .Replace("{membershipId}", membershipId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Membership Convert(Dictionary it) => + Models.Membership.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Membership Roles + /// + /// Modify the roles of a team member. Only team members with the owner role + /// have access to this endpoint. Learn more about [roles and + /// permissions](/docs/permissions). + /// + /// + public Task UpdateMembershipRoles(string teamId, string membershipId, List roles) + { + var path = "/teams/{teamId}/memberships/{membershipId}" + .Replace("{teamId}", teamId) + .Replace("{membershipId}", membershipId); + + var parameters = new Dictionary() + { + { "roles", roles } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Membership Convert(Dictionary it) => + Models.Membership.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete Team Membership + /// + /// This endpoint allows a user to leave a team or for a team owner to delete + /// the membership of any other team member. You can also use this endpoint to + /// delete a user membership even if it is not accepted. + /// + /// + public Task DeleteMembership(string teamId, string membershipId) + { + var path = "/teams/{teamId}/memberships/{membershipId}" + .Replace("{teamId}", teamId) + .Replace("{membershipId}", membershipId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Update Team Membership Status + /// + /// Use this endpoint to allow a user to accept an invitation to join a team + /// after being redirected back to your app from the invitation email received + /// by the user. + /// + /// If the request is successful, a session for the user is automatically + /// created. + /// + /// + /// + public Task UpdateMembershipStatus(string teamId, string membershipId, string userId, string secret) + { + var path = "/teams/{teamId}/memberships/{membershipId}/status" + .Replace("{teamId}", teamId) + .Replace("{membershipId}", membershipId); + + var parameters = new Dictionary() + { + { "userId", userId }, + { "secret", secret } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Membership Convert(Dictionary it) => + Models.Membership.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get Team Preferences + /// + /// Get the team's shared preferences by its unique ID. If a preference doesn't + /// need to be shared by all team members, prefer storing them in [user + /// preferences](/docs/client/account#accountGetPrefs). + /// + /// + public Task GetPrefs(string teamId) + { + var path = "/teams/{teamId}/prefs" + .Replace("{teamId}", teamId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Preferences Convert(Dictionary it) => + Models.Preferences.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Preferences + /// + /// Update the team's preferences by its unique ID. The object you pass is + /// stored as is and replaces any previous value. The maximum allowed prefs + /// size is 64kB and throws an error if exceeded. + /// + /// + public Task UpdatePrefs(string teamId, object prefs) + { + var path = "/teams/{teamId}/prefs" + .Replace("{teamId}", teamId); + + var parameters = new Dictionary() + { + { "prefs", prefs } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Preferences Convert(Dictionary it) => + Models.Preferences.From(map: it); + + + return _client.Call( + method: "PUT", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + } +} diff --git a/src/Appwrite/Services/Users.cs b/src/Appwrite/Services/Users.cs new file mode 100644 index 0000000..1b1f057 --- /dev/null +++ b/src/Appwrite/Services/Users.cs @@ -0,0 +1,957 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; + +namespace Appwrite.Services +{ + public class Users : Service + { + public Users(Client client) : base(client) + { + } + + /// + /// List Users + /// + /// Get a list of all the project's users. You can use the query params to + /// filter your results. + /// + /// + public Task List(List? queries = null, string? search = null) + { + var path = "/users"; + + var parameters = new Dictionary() + { + { "queries", queries }, + { "search", search } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.UserList Convert(Dictionary it) => + Models.UserList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create User + /// + /// Create a new user. + /// + /// + public Task Create(string userId, string? email = null, string? phone = null, string? password = null, string? name = null) + { + var path = "/users"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "email", email }, + { "phone", phone }, + { "password", password }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create User with Argon2 Password + /// + /// Create a new user. Password provided must be hashed with the + /// [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST + /// /users](/docs/server/users#usersCreate) endpoint to create users with a + /// plain text password. + /// + /// + public Task CreateArgon2User(string userId, string email, string password, string? name = null) + { + var path = "/users/argon2"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "email", email }, + { "password", password }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create User with Bcrypt Password + /// + /// Create a new user. Password provided must be hashed with the + /// [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST + /// /users](/docs/server/users#usersCreate) endpoint to create users with a + /// plain text password. + /// + /// + public Task CreateBcryptUser(string userId, string email, string password, string? name = null) + { + var path = "/users/bcrypt"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "email", email }, + { "password", password }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create User with MD5 Password + /// + /// Create a new user. Password provided must be hashed with the + /// [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST + /// /users](/docs/server/users#usersCreate) endpoint to create users with a + /// plain text password. + /// + /// + public Task CreateMD5User(string userId, string email, string password, string? name = null) + { + var path = "/users/md5"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "email", email }, + { "password", password }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create User with PHPass Password + /// + /// Create a new user. Password provided must be hashed with the + /// [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST + /// /users](/docs/server/users#usersCreate) endpoint to create users with a + /// plain text password. + /// + /// + public Task CreatePHPassUser(string userId, string email, string password, string? name = null) + { + var path = "/users/phpass"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "email", email }, + { "password", password }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create User with Scrypt Password + /// + /// Create a new user. Password provided must be hashed with the + /// [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST + /// /users](/docs/server/users#usersCreate) endpoint to create users with a + /// plain text password. + /// + /// + public Task CreateScryptUser(string userId, string email, string password, string passwordSalt, long passwordCpu, long passwordMemory, long passwordParallel, long passwordLength, string? name = null) + { + var path = "/users/scrypt"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "email", email }, + { "password", password }, + { "passwordSalt", passwordSalt }, + { "passwordCpu", passwordCpu }, + { "passwordMemory", passwordMemory }, + { "passwordParallel", passwordParallel }, + { "passwordLength", passwordLength }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create User with Scrypt Modified Password + /// + /// Create a new user. Password provided must be hashed with the [Scrypt + /// Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) + /// algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint + /// to create users with a plain text password. + /// + /// + public Task CreateScryptModifiedUser(string userId, string email, string password, string passwordSalt, string passwordSaltSeparator, string passwordSignerKey, string? name = null) + { + var path = "/users/scrypt-modified"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "email", email }, + { "password", password }, + { "passwordSalt", passwordSalt }, + { "passwordSaltSeparator", passwordSaltSeparator }, + { "passwordSignerKey", passwordSignerKey }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create User with SHA Password + /// + /// Create a new user. Password provided must be hashed with the + /// [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use + /// the [POST /users](/docs/server/users#usersCreate) endpoint to create users + /// with a plain text password. + /// + /// + public Task CreateSHAUser(string userId, string email, string password, string? passwordVersion = null, string? name = null) + { + var path = "/users/sha"; + + var parameters = new Dictionary() + { + { "userId", userId }, + { "email", email }, + { "password", password }, + { "passwordVersion", passwordVersion }, + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "POST", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get User + /// + /// Get a user by its unique ID. + /// + /// + public Task Get(string userId) + { + var path = "/users/{userId}" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete User + /// + /// Delete a user by its unique ID, thereby releasing it's ID. Since ID is + /// released and can be reused, all user-related resources like documents or + /// storage files should be deleted before user deletion. If you want to keep + /// ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) + /// endpoint instead. + /// + /// + public Task Delete(string userId) + { + var path = "/users/{userId}" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Update Email + /// + /// Update the user email by its unique ID. + /// + /// + public Task UpdateEmail(string userId, string email) + { + var path = "/users/{userId}/email" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + { "email", email } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List User Logs + /// + /// Get the user activity logs list by its unique ID. + /// + /// + public Task ListLogs(string userId, List? queries = null) + { + var path = "/users/{userId}/logs" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + { "queries", queries } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.LogList Convert(Dictionary it) => + Models.LogList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List User Memberships + /// + /// Get the user membership list by its unique ID. + /// + /// + public Task ListMemberships(string userId) + { + var path = "/users/{userId}/memberships" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.MembershipList Convert(Dictionary it) => + Models.MembershipList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Name + /// + /// Update the user name by its unique ID. + /// + /// + public Task UpdateName(string userId, string name) + { + var path = "/users/{userId}/name" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + { "name", name } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Password + /// + /// Update the user password by its unique ID. + /// + /// + public Task UpdatePassword(string userId, string password) + { + var path = "/users/{userId}/password" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + { "password", password } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Phone + /// + /// Update the user phone by its unique ID. + /// + /// + public Task UpdatePhone(string userId, string number) + { + var path = "/users/{userId}/phone" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + { "number", number } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get User Preferences + /// + /// Get the user preferences by its unique ID. + /// + /// + public Task GetPrefs(string userId) + { + var path = "/users/{userId}/prefs" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Preferences Convert(Dictionary it) => + Models.Preferences.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update User Preferences + /// + /// Update the user preferences by its unique ID. The object you pass is stored + /// as is, and replaces any previous value. The maximum allowed prefs size is + /// 64kB and throws error if exceeded. + /// + /// + public Task UpdatePrefs(string userId, object prefs) + { + var path = "/users/{userId}/prefs" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + { "prefs", prefs } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.Preferences Convert(Dictionary it) => + Models.Preferences.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List User Sessions + /// + /// Get the user sessions list by its unique ID. + /// + /// + public Task ListSessions(string userId) + { + var path = "/users/{userId}/sessions" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.SessionList Convert(Dictionary it) => + Models.SessionList.From(map: it); + + + return _client.Call( + method: "GET", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete User Sessions + /// + /// Delete all user's sessions by using the user's unique ID. + /// + /// + public Task DeleteSessions(string userId) + { + var path = "/users/{userId}/sessions" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Delete User Session + /// + /// Delete a user sessions by its unique ID. + /// + /// + public Task DeleteSession(string userId, string sessionId) + { + var path = "/users/{userId}/sessions/{sessionId}" + .Replace("{userId}", userId) + .Replace("{sessionId}", sessionId); + + var parameters = new Dictionary() + { + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + + + return _client.Call( + method: "DELETE", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Update User Status + /// + /// Update the user status by its unique ID. Use this endpoint as an + /// alternative to deleting a user if you want to keep user's ID reserved. + /// + /// + public Task UpdateStatus(string userId, bool status) + { + var path = "/users/{userId}/status" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + { "status", status } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Email Verification + /// + /// Update the user email verification status by its unique ID. + /// + /// + public Task UpdateEmailVerification(string userId, bool emailVerification) + { + var path = "/users/{userId}/verification" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + { "emailVerification", emailVerification } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update Phone Verification + /// + /// Update the user phone verification status by its unique ID. + /// + /// + public Task UpdatePhoneVerification(string userId, bool phoneVerification) + { + var path = "/users/{userId}/verification/phone" + .Replace("{userId}", userId); + + var parameters = new Dictionary() + { + { "phoneVerification", phoneVerification } + }; + + var headers = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + static Models.User Convert(Dictionary it) => + Models.User.From(map: it); + + + return _client.Call( + method: "PATCH", + path: path, + headers: headers, + parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + } +}