diff --git a/CHANGELOG.md b/CHANGELOG.md index 61856a1..f8be27f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 20.1.1 + +* Update SDK as per latest server specs, these include - + * Updates to Runtime enums + * `Output` is now renamed to `ImageFormat` - Note that this is a breaking change + * Introduces Backups module for managing Database backups + * Introduces Organization module + ## 20.1.0 * Added ability to create columns and indexes synchronously while creating a table @@ -7,7 +15,8 @@ ## 20.0.0 * Rename `VCSDeploymentType` enum to `VCSReferenceType` -* Change `create_template_deployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) and `reference` parameters +* Change `create_template_deployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) + and `reference` parameters * Add `get_screenshot` method to `Avatars` service * Add `Theme`, `Timezone` and `Output` enums diff --git a/LICENSE b/LICENSE index c1602fc..6f8702b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2026 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: diff --git a/README.md b/README.md index 10803b5..18ece0d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-ruby/releases).** +**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-ruby/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 Ruby 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) +Appwrite is an open-source backend as a service server that abstracts and simplifies 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 Ruby 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) ![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) diff --git a/appwrite.gemspec b/appwrite.gemspec index 9b7c7d8..823ce74 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,9 +1,9 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '20.1.0' + spec.version = '20.1.1' spec.license = 'BSD-3-Clause' - spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API' + spec.summary = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API' spec.author = 'Appwrite Team' spec.homepage = 'https://appwrite.io/support' spec.email = 'team@appwrite.io' diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index 682c247..481add5 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -9,4 +9,6 @@ client = Client.new account = Account.new(client) -result = account.create_jwt() +result = account.create_jwt( + duration: 0 # optional +) diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 0271404..3abbfda 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -33,5 +33,5 @@ result = avatars.get_screenshot( width: 800, # optional height: 600, # optional quality: 85, # optional - output: Output::JPG # optional + output: ImageFormat::JPG # optional ) diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md new file mode 100644 index 0000000..0cca8d1 --- /dev/null +++ b/docs/examples/backups/create-archive.md @@ -0,0 +1,15 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.create_archive( + services: [], + resource_id: '' # optional +) diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md new file mode 100644 index 0000000..99fa26a --- /dev/null +++ b/docs/examples/backups/create-policy.md @@ -0,0 +1,20 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.create_policy( + policy_id: '', + services: [], + retention: 1, + schedule: '', + name: '', # optional + resource_id: '', # optional + enabled: false # optional +) diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md new file mode 100644 index 0000000..9c5e7e6 --- /dev/null +++ b/docs/examples/backups/create-restoration.md @@ -0,0 +1,17 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.create_restoration( + archive_id: '', + services: [], + new_resource_id: '', # optional + new_resource_name: '' # optional +) diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md new file mode 100644 index 0000000..c1ebd6a --- /dev/null +++ b/docs/examples/backups/delete-archive.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.delete_archive( + archive_id: '' +) diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md new file mode 100644 index 0000000..19fe061 --- /dev/null +++ b/docs/examples/backups/delete-policy.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.delete_policy( + policy_id: '' +) diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md new file mode 100644 index 0000000..f6c4953 --- /dev/null +++ b/docs/examples/backups/get-archive.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.get_archive( + archive_id: '' +) diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md new file mode 100644 index 0000000..2e686bc --- /dev/null +++ b/docs/examples/backups/get-policy.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.get_policy( + policy_id: '' +) diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md new file mode 100644 index 0000000..b0055ca --- /dev/null +++ b/docs/examples/backups/get-restoration.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.get_restoration( + restoration_id: '' +) diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md new file mode 100644 index 0000000..5bf1900 --- /dev/null +++ b/docs/examples/backups/list-archives.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.list_archives( + queries: [] # optional +) diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md new file mode 100644 index 0000000..8cda1de --- /dev/null +++ b/docs/examples/backups/list-policies.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.list_policies( + queries: [] # optional +) diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md new file mode 100644 index 0000000..3a874e5 --- /dev/null +++ b/docs/examples/backups/list-restorations.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.list_restorations( + queries: [] # optional +) diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md new file mode 100644 index 0000000..acade15 --- /dev/null +++ b/docs/examples/backups/update-policy.md @@ -0,0 +1,18 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +backups = Backups.new(client) + +result = backups.update_policy( + policy_id: '', + name: '', # optional + retention: 1, # optional + schedule: '', # optional + enabled: false # optional +) diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 5a1eb56..0f736a1 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -15,7 +15,13 @@ result = databases.update_document( database_id: '', collection_id: '', document_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional permissions: [Permission.read(Role.any())], # optional transaction_id: '' # optional ) diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index c85f594..00bdc9a 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -12,7 +12,13 @@ databases = Databases.new(client) result = databases.update_documents( database_id: '', collection_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional queries: [], # optional transaction_id: '' # optional ) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index fa2f1cd..07c7b7e 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -15,7 +15,13 @@ result = databases.upsert_document( database_id: '', collection_id: '', document_id: '', - data: {}, + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 30, + "isAdmin" => false + }, # optional permissions: [Permission.read(Role.any())], # optional transaction_id: '' # optional ) diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md new file mode 100644 index 0000000..f9d2a85 --- /dev/null +++ b/docs/examples/organizations/delete.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +organizations = Organizations.new(client) + +result = organizations.delete( + organization_id: '' +) diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md new file mode 100644 index 0000000..991f6e5 --- /dev/null +++ b/docs/examples/organizations/estimation-delete-organization.md @@ -0,0 +1,14 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +organizations = Organizations.new(client) + +result = organizations.estimation_delete_organization( + organization_id: '' +) diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index fc6fca6..16e8acc 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -15,7 +15,13 @@ result = tables_db.update_row( database_id: '', table_id: '', row_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional permissions: [Permission.read(Role.any())], # optional transaction_id: '' # optional ) diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 7c538a1..c82754d 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -12,7 +12,13 @@ tables_db = TablesDB.new(client) result = tables_db.update_rows( database_id: '', table_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional queries: [], # optional transaction_id: '' # optional ) diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 6201834..11210f3 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -15,7 +15,13 @@ result = tables_db.upsert_row( database_id: '', table_id: '', row_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional permissions: [Permission.read(Role.any())], # optional transaction_id: '' # optional ) diff --git a/lib/appwrite.rb b/lib/appwrite.rb index e3243c4..be8ade8 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -135,6 +135,15 @@ require_relative 'appwrite/models/transaction' require_relative 'appwrite/models/subscriber' require_relative 'appwrite/models/target' +require_relative 'appwrite/models/backup_archive' +require_relative 'appwrite/models/invoice' +require_relative 'appwrite/models/backup_policy' +require_relative 'appwrite/models/backup_restoration' +require_relative 'appwrite/models/usage_resources' +require_relative 'appwrite/models/estimation_delete_organization' +require_relative 'appwrite/models/backup_archive_list' +require_relative 'appwrite/models/backup_policy_list' +require_relative 'appwrite/models/backup_restoration_list' require_relative 'appwrite/enums/authenticator_type' require_relative 'appwrite/enums/authentication_factor' @@ -144,7 +153,7 @@ require_relative 'appwrite/enums/flag' require_relative 'appwrite/enums/theme' require_relative 'appwrite/enums/timezone' -require_relative 'appwrite/enums/output' +require_relative 'appwrite/enums/image_format' require_relative 'appwrite/enums/relationship_type' require_relative 'appwrite/enums/relation_mutate' require_relative 'appwrite/enums/index_type' @@ -161,7 +170,6 @@ require_relative 'appwrite/enums/adapter' require_relative 'appwrite/enums/compression' require_relative 'appwrite/enums/image_gravity' -require_relative 'appwrite/enums/image_format' require_relative 'appwrite/enums/password_hash' require_relative 'appwrite/enums/messaging_provider_type' require_relative 'appwrite/enums/database_type' @@ -177,12 +185,14 @@ require_relative 'appwrite/services/account' require_relative 'appwrite/services/avatars' +require_relative 'appwrite/services/backups' require_relative 'appwrite/services/databases' require_relative 'appwrite/services/functions' require_relative 'appwrite/services/graphql' require_relative 'appwrite/services/health' require_relative 'appwrite/services/locale' require_relative 'appwrite/services/messaging' +require_relative 'appwrite/services/organizations' require_relative 'appwrite/services/sites' require_relative 'appwrite/services/storage' require_relative 'appwrite/services/tables_db' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index bc09ceb..80999aa 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -15,7 +15,7 @@ def initialize 'x-sdk-name'=> 'Ruby', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'ruby', - 'x-sdk-version'=> '20.1.0', + 'x-sdk-version'=> '20.1.1', 'X-Appwrite-Response-Format' => '1.8.0' } @endpoint = 'https://cloud.appwrite.io/v1' @@ -123,7 +123,6 @@ def set_self_signed(self_signed = true) self end - # Add Header # # @param [String] key The key for the header to add diff --git a/lib/appwrite/enums/build_runtime.rb b/lib/appwrite/enums/build_runtime.rb index a9a862d..1dd730d 100644 --- a/lib/appwrite/enums/build_runtime.rb +++ b/lib/appwrite/enums/build_runtime.rb @@ -23,9 +23,6 @@ module BuildRuntime PYTHON_3_12 = 'python-3.12' PYTHON_ML_3_11 = 'python-ml-3.11' PYTHON_ML_3_12 = 'python-ml-3.12' - DENO_1_21 = 'deno-1.21' - DENO_1_24 = 'deno-1.24' - DENO_1_35 = 'deno-1.35' DENO_1_40 = 'deno-1.40' DENO_1_46 = 'deno-1.46' DENO_2_0 = 'deno-2.0' diff --git a/lib/appwrite/enums/name.rb b/lib/appwrite/enums/name.rb index 0e18cbb..21c2b72 100644 --- a/lib/appwrite/enums/name.rb +++ b/lib/appwrite/enums/name.rb @@ -11,6 +11,7 @@ module Name V1_WEBHOOKS = 'v1-webhooks' V1_CERTIFICATES = 'v1-certificates' V1_BUILDS = 'v1-builds' + V1_SCREENSHOTS = 'v1-screenshots' V1_MESSAGING = 'v1-messaging' V1_MIGRATIONS = 'v1-migrations' end diff --git a/lib/appwrite/enums/o_auth_provider.rb b/lib/appwrite/enums/o_auth_provider.rb index 8621b65..9a75276 100644 --- a/lib/appwrite/enums/o_auth_provider.rb +++ b/lib/appwrite/enums/o_auth_provider.rb @@ -40,7 +40,6 @@ module OAuthProvider YANDEX = 'yandex' ZOHO = 'zoho' ZOOM = 'zoom' - MOCK = 'mock' end end end \ No newline at end of file diff --git a/lib/appwrite/enums/output.rb b/lib/appwrite/enums/output.rb deleted file mode 100644 index fa255a8..0000000 --- a/lib/appwrite/enums/output.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Appwrite - module Enums - module Output - JPG = 'jpg' - JPEG = 'jpeg' - PNG = 'png' - WEBP = 'webp' - HEIC = 'heic' - AVIF = 'avif' - GIF = 'gif' - end - end -end \ No newline at end of file diff --git a/lib/appwrite/enums/runtime.rb b/lib/appwrite/enums/runtime.rb index 7bfa368..25f0877 100644 --- a/lib/appwrite/enums/runtime.rb +++ b/lib/appwrite/enums/runtime.rb @@ -23,9 +23,6 @@ module Runtime PYTHON_3_12 = 'python-3.12' PYTHON_ML_3_11 = 'python-ml-3.11' PYTHON_ML_3_12 = 'python-ml-3.12' - DENO_1_21 = 'deno-1.21' - DENO_1_24 = 'deno-1.24' - DENO_1_35 = 'deno-1.35' DENO_1_40 = 'deno-1.40' DENO_1_46 = 'deno-1.46' DENO_2_0 = 'deno-2.0' diff --git a/lib/appwrite/models/backup_archive.rb b/lib/appwrite/models/backup_archive.rb new file mode 100644 index 0000000..f8cb598 --- /dev/null +++ b/lib/appwrite/models/backup_archive.rb @@ -0,0 +1,82 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class BackupArchive + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :policy_id + attr_reader :size + attr_reader :status + attr_reader :started_at + attr_reader :migration_id + attr_reader :services + attr_reader :resources + attr_reader :resource_id + attr_reader :resource_type + + def initialize( + id:, + created_at:, + updated_at:, + policy_id:, + size:, + status:, + started_at:, + migration_id:, + services:, + resources:, + resource_id: , + resource_type: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @policy_id = policy_id + @size = size + @status = status + @started_at = started_at + @migration_id = migration_id + @services = services + @resources = resources + @resource_id = resource_id + @resource_type = resource_type + end + + def self.from(map:) + BackupArchive.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + policy_id: map["policyId"], + size: map["size"], + status: map["status"], + started_at: map["startedAt"], + migration_id: map["migrationId"], + services: map["services"], + resources: map["resources"], + resource_id: map["resourceId"], + resource_type: map["resourceType"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "policyId": @policy_id, + "size": @size, + "status": @status, + "startedAt": @started_at, + "migrationId": @migration_id, + "services": @services, + "resources": @resources, + "resourceId": @resource_id, + "resourceType": @resource_type + } + end + end + end +end diff --git a/lib/appwrite/models/backup_archive_list.rb b/lib/appwrite/models/backup_archive_list.rb new file mode 100644 index 0000000..40d4a3c --- /dev/null +++ b/lib/appwrite/models/backup_archive_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class BackupArchiveList + attr_reader :total + attr_reader :archives + + def initialize( + total:, + archives: + ) + @total = total + @archives = archives + end + + def self.from(map:) + BackupArchiveList.new( + total: map["total"], + archives: map["archives"].map { |it| BackupArchive.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "archives": @archives.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/backup_policy.rb b/lib/appwrite/models/backup_policy.rb new file mode 100644 index 0000000..9a2146e --- /dev/null +++ b/lib/appwrite/models/backup_policy.rb @@ -0,0 +1,77 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class BackupPolicy + attr_reader :id + attr_reader :name + attr_reader :created_at + attr_reader :updated_at + attr_reader :services + attr_reader :resources + attr_reader :resource_id + attr_reader :resource_type + attr_reader :retention + attr_reader :schedule + attr_reader :enabled + + def initialize( + id:, + name:, + created_at:, + updated_at:, + services:, + resources:, + resource_id: , + resource_type: , + retention:, + schedule:, + enabled: + ) + @id = id + @name = name + @created_at = created_at + @updated_at = updated_at + @services = services + @resources = resources + @resource_id = resource_id + @resource_type = resource_type + @retention = retention + @schedule = schedule + @enabled = enabled + end + + def self.from(map:) + BackupPolicy.new( + id: map["$id"], + name: map["name"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + services: map["services"], + resources: map["resources"], + resource_id: map["resourceId"], + resource_type: map["resourceType"], + retention: map["retention"], + schedule: map["schedule"], + enabled: map["enabled"] + ) + end + + def to_map + { + "$id": @id, + "name": @name, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "services": @services, + "resources": @resources, + "resourceId": @resource_id, + "resourceType": @resource_type, + "retention": @retention, + "schedule": @schedule, + "enabled": @enabled + } + end + end + end +end diff --git a/lib/appwrite/models/backup_policy_list.rb b/lib/appwrite/models/backup_policy_list.rb new file mode 100644 index 0000000..b7790d2 --- /dev/null +++ b/lib/appwrite/models/backup_policy_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class BackupPolicyList + attr_reader :total + attr_reader :policies + + def initialize( + total:, + policies: + ) + @total = total + @policies = policies + end + + def self.from(map:) + BackupPolicyList.new( + total: map["total"], + policies: map["policies"].map { |it| BackupPolicy.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "policies": @policies.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/backup_restoration.rb b/lib/appwrite/models/backup_restoration.rb new file mode 100644 index 0000000..669e6cb --- /dev/null +++ b/lib/appwrite/models/backup_restoration.rb @@ -0,0 +1,77 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class BackupRestoration + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :archive_id + attr_reader :policy_id + attr_reader :status + attr_reader :started_at + attr_reader :migration_id + attr_reader :services + attr_reader :resources + attr_reader :options + + def initialize( + id:, + created_at:, + updated_at:, + archive_id:, + policy_id:, + status:, + started_at:, + migration_id:, + services:, + resources:, + options: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @archive_id = archive_id + @policy_id = policy_id + @status = status + @started_at = started_at + @migration_id = migration_id + @services = services + @resources = resources + @options = options + end + + def self.from(map:) + BackupRestoration.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + archive_id: map["archiveId"], + policy_id: map["policyId"], + status: map["status"], + started_at: map["startedAt"], + migration_id: map["migrationId"], + services: map["services"], + resources: map["resources"], + options: map["options"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "archiveId": @archive_id, + "policyId": @policy_id, + "status": @status, + "startedAt": @started_at, + "migrationId": @migration_id, + "services": @services, + "resources": @resources, + "options": @options + } + end + end + end +end diff --git a/lib/appwrite/models/backup_restoration_list.rb b/lib/appwrite/models/backup_restoration_list.rb new file mode 100644 index 0000000..102e840 --- /dev/null +++ b/lib/appwrite/models/backup_restoration_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class BackupRestorationList + attr_reader :total + attr_reader :restorations + + def initialize( + total:, + restorations: + ) + @total = total + @restorations = restorations + end + + def self.from(map:) + BackupRestorationList.new( + total: map["total"], + restorations: map["restorations"].map { |it| BackupRestoration.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "restorations": @restorations.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/bucket.rb b/lib/appwrite/models/bucket.rb index 42f3df2..ab45b57 100644 --- a/lib/appwrite/models/bucket.rb +++ b/lib/appwrite/models/bucket.rb @@ -16,6 +16,7 @@ class Bucket attr_reader :encryption attr_reader :antivirus attr_reader :transformations + attr_reader :total_size def initialize( id:, @@ -30,7 +31,8 @@ def initialize( compression:, encryption:, antivirus:, - transformations: + transformations:, + total_size: ) @id = id @created_at = created_at @@ -45,6 +47,7 @@ def initialize( @encryption = encryption @antivirus = antivirus @transformations = transformations + @total_size = total_size end def self.from(map:) @@ -61,7 +64,8 @@ def self.from(map:) compression: map["compression"], encryption: map["encryption"], antivirus: map["antivirus"], - transformations: map["transformations"] + transformations: map["transformations"], + total_size: map["totalSize"] ) end @@ -79,7 +83,8 @@ def to_map "compression": @compression, "encryption": @encryption, "antivirus": @antivirus, - "transformations": @transformations + "transformations": @transformations, + "totalSize": @total_size } end end diff --git a/lib/appwrite/models/database.rb b/lib/appwrite/models/database.rb index 47cca3c..6ee3169 100644 --- a/lib/appwrite/models/database.rb +++ b/lib/appwrite/models/database.rb @@ -9,6 +9,8 @@ class Database attr_reader :updated_at attr_reader :enabled attr_reader :type + attr_reader :policies + attr_reader :archives def initialize( id:, @@ -16,7 +18,9 @@ def initialize( created_at:, updated_at:, enabled:, - type: + type:, + policies:, + archives: ) @id = id @name = name @@ -24,6 +28,8 @@ def initialize( @updated_at = updated_at @enabled = enabled @type = validate_type(type) + @policies = policies + @archives = archives end def self.from(map:) @@ -33,7 +39,9 @@ def self.from(map:) created_at: map["$createdAt"], updated_at: map["$updatedAt"], enabled: map["enabled"], - type: map["type"] + type: map["type"], + policies: map["policies"].map { |it| Index.from(map: it) }, + archives: map["archives"].map { |it| Collection.from(map: it) } ) end @@ -44,7 +52,9 @@ def to_map "$createdAt": @created_at, "$updatedAt": @updated_at, "enabled": @enabled, - "type": @type + "type": @type, + "policies": @policies.map { |it| it.to_map }, + "archives": @archives.map { |it| it.to_map } } end diff --git a/lib/appwrite/models/estimation_delete_organization.rb b/lib/appwrite/models/estimation_delete_organization.rb new file mode 100644 index 0000000..c29c05f --- /dev/null +++ b/lib/appwrite/models/estimation_delete_organization.rb @@ -0,0 +1,27 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class EstimationDeleteOrganization + attr_reader :unpaid_invoices + + def initialize( + unpaid_invoices: + ) + @unpaid_invoices = unpaid_invoices + end + + def self.from(map:) + EstimationDeleteOrganization.new( + unpaid_invoices: map["unpaidInvoices"].map { |it| Invoice.from(map: it) } + ) + end + + def to_map + { + "unpaidInvoices": @unpaid_invoices.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/file.rb b/lib/appwrite/models/file.rb index fa58884..53a964e 100644 --- a/lib/appwrite/models/file.rb +++ b/lib/appwrite/models/file.rb @@ -14,6 +14,8 @@ class File attr_reader :size_original attr_reader :chunks_total attr_reader :chunks_uploaded + attr_reader :encryption + attr_reader :compression def initialize( id:, @@ -26,7 +28,9 @@ def initialize( mime_type:, size_original:, chunks_total:, - chunks_uploaded: + chunks_uploaded:, + encryption:, + compression: ) @id = id @bucket_id = bucket_id @@ -39,6 +43,8 @@ def initialize( @size_original = size_original @chunks_total = chunks_total @chunks_uploaded = chunks_uploaded + @encryption = encryption + @compression = compression end def self.from(map:) @@ -53,7 +59,9 @@ def self.from(map:) mime_type: map["mimeType"], size_original: map["sizeOriginal"], chunks_total: map["chunksTotal"], - chunks_uploaded: map["chunksUploaded"] + chunks_uploaded: map["chunksUploaded"], + encryption: map["encryption"], + compression: map["compression"] ) end @@ -69,7 +77,9 @@ def to_map "mimeType": @mime_type, "sizeOriginal": @size_original, "chunksTotal": @chunks_total, - "chunksUploaded": @chunks_uploaded + "chunksUploaded": @chunks_uploaded, + "encryption": @encryption, + "compression": @compression } end end diff --git a/lib/appwrite/models/invoice.rb b/lib/appwrite/models/invoice.rb new file mode 100644 index 0000000..d8abb37 --- /dev/null +++ b/lib/appwrite/models/invoice.rb @@ -0,0 +1,132 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Invoice + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :permissions + attr_reader :team_id + attr_reader :aggregation_id + attr_reader :plan + attr_reader :usage + attr_reader :amount + attr_reader :tax + attr_reader :tax_amount + attr_reader :vat + attr_reader :vat_amount + attr_reader :gross_amount + attr_reader :credits_used + attr_reader :currency + attr_reader :client_secret + attr_reader :status + attr_reader :last_error + attr_reader :due_at + attr_reader :from + attr_reader :to + + def initialize( + id:, + created_at:, + updated_at:, + permissions:, + team_id:, + aggregation_id:, + plan:, + usage:, + amount:, + tax:, + tax_amount:, + vat:, + vat_amount:, + gross_amount:, + credits_used:, + currency:, + client_secret:, + status:, + last_error:, + due_at:, + from:, + to: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @permissions = permissions + @team_id = team_id + @aggregation_id = aggregation_id + @plan = plan + @usage = usage + @amount = amount + @tax = tax + @tax_amount = tax_amount + @vat = vat + @vat_amount = vat_amount + @gross_amount = gross_amount + @credits_used = credits_used + @currency = currency + @client_secret = client_secret + @status = status + @last_error = last_error + @due_at = due_at + @from = from + @to = to + end + + def self.from(map:) + Invoice.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + permissions: map["$permissions"], + team_id: map["teamId"], + aggregation_id: map["aggregationId"], + plan: map["plan"], + usage: map["usage"].map { |it| UsageResources.from(map: it) }, + amount: map["amount"], + tax: map["tax"], + tax_amount: map["taxAmount"], + vat: map["vat"], + vat_amount: map["vatAmount"], + gross_amount: map["grossAmount"], + credits_used: map["creditsUsed"], + currency: map["currency"], + client_secret: map["clientSecret"], + status: map["status"], + last_error: map["lastError"], + due_at: map["dueAt"], + from: map["from"], + to: map["to"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "$permissions": @permissions, + "teamId": @team_id, + "aggregationId": @aggregation_id, + "plan": @plan, + "usage": @usage.map { |it| it.to_map }, + "amount": @amount, + "tax": @tax, + "taxAmount": @tax_amount, + "vat": @vat, + "vatAmount": @vat_amount, + "grossAmount": @gross_amount, + "creditsUsed": @credits_used, + "currency": @currency, + "clientSecret": @client_secret, + "status": @status, + "lastError": @last_error, + "dueAt": @due_at, + "from": @from, + "to": @to + } + end + end + end +end diff --git a/lib/appwrite/models/usage_resources.rb b/lib/appwrite/models/usage_resources.rb new file mode 100644 index 0000000..e99af07 --- /dev/null +++ b/lib/appwrite/models/usage_resources.rb @@ -0,0 +1,52 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class UsageResources + attr_reader :name + attr_reader :value + attr_reader :amount + attr_reader :rate + attr_reader :desc + attr_reader :resource_id + + def initialize( + name:, + value:, + amount:, + rate:, + desc:, + resource_id: + ) + @name = name + @value = value + @amount = amount + @rate = rate + @desc = desc + @resource_id = resource_id + end + + def self.from(map:) + UsageResources.new( + name: map["name"], + value: map["value"], + amount: map["amount"], + rate: map["rate"], + desc: map["desc"], + resource_id: map["resourceId"] + ) + end + + def to_map + { + "name": @name, + "value": @value, + "amount": @amount, + "rate": @rate, + "desc": @desc, + "resourceId": @resource_id + } + end + end + end +end diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index f291d9c..fd0c6c3 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -180,12 +180,14 @@ def delete_identity(identity_id:) # from its creation and will be invalid if the user will logout in that time # frame. # + # @param [Integer] duration Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. # # @return [Jwt] - def create_jwt() + def create_jwt(duration: nil) api_path = '/account/jwts' api_params = { + duration: duration, } api_headers = { diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index fba6855..e100c0c 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -312,7 +312,7 @@ def get_qr(text:, size: nil, margin: nil, download: nil) # @param [Integer] width Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width). # @param [Integer] height Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height). # @param [Integer] quality Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. - # @param [Output] output Output format type (jpeg, jpg, png, gif and webp). + # @param [ImageFormat] output Output format type (jpeg, jpg, png, gif and webp). # # @return [] def get_screenshot(url:, headers: nil, viewport_width: nil, viewport_height: nil, scale: nil, theme: nil, user_agent: nil, fullpage: nil, locale: nil, timezone: nil, latitude: nil, longitude: nil, accuracy: nil, touch: nil, permissions: nil, sleep: nil, width: nil, height: nil, quality: nil, output: nil) diff --git a/lib/appwrite/services/backups.rb b/lib/appwrite/services/backups.rb new file mode 100644 index 0000000..1247e28 --- /dev/null +++ b/lib/appwrite/services/backups.rb @@ -0,0 +1,383 @@ +#frozen_string_literal: true + +module Appwrite + class Backups < Service + + def initialize(client) + @client = client + end + + # List all archives for a project. + # + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + # + # @return [BackupArchiveList] + def list_archives(queries: nil) + api_path = '/backups/archives' + + api_params = { + queries: queries, + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupArchiveList + ) + end + + # Create a new archive asynchronously for a project. + # + # @param [Array] services Array of services to backup + # @param [String] resource_id Resource ID. When set, only this single resource will be backed up. + # + # @return [BackupArchive] + def create_archive(services:, resource_id: nil) + api_path = '/backups/archives' + + if services.nil? + raise Appwrite::Exception.new('Missing required parameter: "services"') + end + + api_params = { + services: services, + resourceId: resource_id, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupArchive + ) + end + + # Get a backup archive using it's ID. + # + # @param [String] archive_id Archive ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # + # @return [BackupArchive] + def get_archive(archive_id:) + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + + if archive_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "archiveId"') + end + + api_params = { + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupArchive + ) + end + + # Delete an existing archive for a project. + # + # @param [String] archive_id Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # + # @return [] + def delete_archive(archive_id:) + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + + if archive_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "archiveId"') + end + + api_params = { + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + + # List all policies for a project. + # + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + # + # @return [BackupPolicyList] + def list_policies(queries: nil) + api_path = '/backups/policies' + + api_params = { + queries: queries, + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupPolicyList + ) + end + + # Create a new backup policy. + # + # @param [String] policy_id Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [Array] services Array of services to backup + # @param [Integer] retention Days to keep backups before deletion + # @param [String] schedule Schedule CRON syntax. + # @param [String] name Policy name. Max length: 128 chars. + # @param [String] resource_id Resource ID. When set, only this single resource will be backed up. + # @param [] enabled Is policy enabled? When set to 'disabled', no backups will be taken + # + # @return [BackupPolicy] + def create_policy(policy_id:, services:, retention:, schedule:, name: nil, resource_id: nil, enabled: nil) + api_path = '/backups/policies' + + if policy_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "policyId"') + end + + if services.nil? + raise Appwrite::Exception.new('Missing required parameter: "services"') + end + + if retention.nil? + raise Appwrite::Exception.new('Missing required parameter: "retention"') + end + + if schedule.nil? + raise Appwrite::Exception.new('Missing required parameter: "schedule"') + end + + api_params = { + policyId: policy_id, + name: name, + services: services, + resourceId: resource_id, + enabled: enabled, + retention: retention, + schedule: schedule, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupPolicy + ) + end + + # Get a backup policy using it's ID. + # + # @param [String] policy_id Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # + # @return [BackupPolicy] + def get_policy(policy_id:) + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + + if policy_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "policyId"') + end + + api_params = { + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupPolicy + ) + end + + # Update an existing policy using it's ID. + # + # @param [String] policy_id Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] name Policy name. Max length: 128 chars. + # @param [Integer] retention Days to keep backups before deletion + # @param [String] schedule Cron expression + # @param [] enabled Is Backup enabled? When set to 'disabled', No backup will be taken + # + # @return [BackupPolicy] + def update_policy(policy_id:, name: nil, retention: nil, schedule: nil, enabled: nil) + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + + if policy_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "policyId"') + end + + api_params = { + name: name, + retention: retention, + schedule: schedule, + enabled: enabled, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupPolicy + ) + end + + # Delete a policy using it's ID. + # + # @param [String] policy_id Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # + # @return [] + def delete_policy(policy_id:) + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + + if policy_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "policyId"') + end + + api_params = { + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + + # Create and trigger a new restoration for a backup on a project. + # + # @param [String] archive_id Backup archive ID to restore + # @param [Array] services Array of services to restore + # @param [String] new_resource_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] new_resource_name Database name. Max length: 128 chars. + # + # @return [BackupRestoration] + def create_restoration(archive_id:, services:, new_resource_id: nil, new_resource_name: nil) + api_path = '/backups/restoration' + + if archive_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "archiveId"') + end + + if services.nil? + raise Appwrite::Exception.new('Missing required parameter: "services"') + end + + api_params = { + archiveId: archive_id, + services: services, + newResourceId: new_resource_id, + newResourceName: new_resource_name, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupRestoration + ) + end + + # List all backup restorations for a project. + # + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + # + # @return [BackupRestorationList] + def list_restorations(queries: nil) + api_path = '/backups/restorations' + + api_params = { + queries: queries, + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupRestorationList + ) + end + + # Get the current status of a backup restoration. + # + # @param [String] restoration_id Restoration ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # + # @return [BackupRestoration] + def get_restoration(restoration_id:) + api_path = '/backups/restorations/{restorationId}' + .gsub('{restorationId}', restoration_id) + + if restoration_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "restorationId"') + end + + api_params = { + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::BackupRestoration + ) + end + + end +end \ No newline at end of file diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index 0c01f9a..471ad4a 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -2108,6 +2108,7 @@ def get_attribute(database_id:, collection_id:, key:) path: api_path, headers: api_headers, params: api_params, + response_type: Models::AttributeBoolean ) end @@ -2557,7 +2558,7 @@ def get_document(database_id:, collection_id:, document_id:, queries: nil, trans # @param [String] transaction_id Transaction ID for staging the operation. # # @return [Document] - def upsert_document(database_id:, collection_id:, document_id:, data:, permissions: nil, transaction_id: nil) + def upsert_document(database_id:, collection_id:, document_id:, data: nil, permissions: nil, transaction_id: nil) api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' .gsub('{databaseId}', database_id) .gsub('{collectionId}', collection_id) @@ -2575,10 +2576,6 @@ def upsert_document(database_id:, collection_id:, document_id:, data:, permissio raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if data.nil? - raise Appwrite::Exception.new('Missing required parameter: "data"') - end - api_params = { data: data, permissions: permissions, diff --git a/lib/appwrite/services/organizations.rb b/lib/appwrite/services/organizations.rb new file mode 100644 index 0000000..de54f42 --- /dev/null +++ b/lib/appwrite/services/organizations.rb @@ -0,0 +1,68 @@ +#frozen_string_literal: true + +module Appwrite + class Organizations < Service + + def initialize(client) + @client = client + end + + # Delete an organization. + # + # @param [String] organization_id Team ID. + # + # @return [] + def delete(organization_id:) + api_path = '/organizations/{organizationId}' + .gsub('{organizationId}', organization_id) + + if organization_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "organizationId"') + end + + api_params = { + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + + # Get estimation for deleting an organization. + # + # @param [String] organization_id Team ID. + # + # @return [EstimationDeleteOrganization] + def estimation_delete_organization(organization_id:) + api_path = '/organizations/{organizationId}/estimations/delete-organization' + .gsub('{organizationId}', organization_id) + + if organization_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "organizationId"') + end + + api_params = { + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::EstimationDeleteOrganization + ) + end + + end +end \ No newline at end of file diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index a5323d1..68ed8f5 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -43,9 +43,9 @@ def list_buckets(queries: nil, search: nil, total: nil) # @param [Array] permissions An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] file_security Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - # @param [Integer] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. + # @param [Integer] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 5GB. # @param [Array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - # @param [Compression] compression Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + # @param [Compression] compression Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled # @param [] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled # @param [] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled # @param [] transformations Are image transformations enabled? @@ -125,9 +125,9 @@ def get_bucket(bucket_id:) # @param [Array] permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] file_security Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - # @param [Integer] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. + # @param [Integer] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 5GB. # @param [Array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - # @param [Compression] compression Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + # @param [Compression] compression Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled # @param [] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled # @param [] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled # @param [] transformations Are image transformations enabled? @@ -337,10 +337,10 @@ def get_file(bucket_id:, file_id:) # Update a file by its unique ID. Only users with write permissions have # access to update this resource. # - # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). - # @param [String] file_id File unique ID. - # @param [String] name Name of the file - # @param [Array] permissions An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + # @param [String] bucket_id Bucket unique ID. + # @param [String] file_id File ID. + # @param [String] name File name. + # @param [Array] permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). # # @return [File] def update_file(bucket_id:, file_id:, name: nil, permissions: nil) diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index 4c657ab..2bb6e02 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -1996,6 +1996,7 @@ def get_column(database_id:, table_id:, key:) path: api_path, headers: api_headers, params: api_params, + response_type: Models::ColumnBoolean ) end