diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4d35e..1f2e10b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,30 @@ -# Change Log \ No newline at end of file +# Change Log + +## 16.1.0 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `dart38` and `flutter332` support to runtime models +* Add `gif` support to `ImageFormat` enum +* Add `encrypt` support to `StringAttribute` model +* Add `sequence` support to `Document` model +* Add `upsertDocument` support to `Databases` service + +## 16.0.0 + +* Add `` to doc examples due to the new multi region endpoints +* Add doc examples and methods for bulk api transactions: `createDocuments`, `deleteDocuments` etc. +* Add doc examples, class and methods for new `Sites` service +* Add doc examples, class and methods for new `Tokens` service +* Add enums for `BuildRuntime `, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType` +* Update enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329 +* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage +* Add `queries` and `search` params to `listMemberships` method +* Remove `search` param from `listExecutions` method + +## 15.0.0 + +* Fix requests failing by removing `Content-Type` header from `GET` and `HEAD` requests + +## 14.0.0 + +* Fix pong response & chunked upload diff --git a/README.md b/README.md index 4d908bc..74b56ca 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 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.7.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-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) diff --git a/appwrite.gemspec b/appwrite.gemspec index 3c76b6b..99c8f2d 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '16.0.0' + spec.version = '16.1.0' 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.author = 'Appwrite Team' diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index ce8dea7..e683108 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -4,9 +4,8 @@ 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 - .set_key('') # Your secret API key - .set_jwt('') # Your secret JSON Web Token databases = Databases.new(client) diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 469234c..16abc5e 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -4,6 +4,7 @@ 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 databases = Databases.new(client) diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..9b5a5f4 --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,19 @@ +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 + +databases = Databases.new(client) + +result = databases.decrement_document_attribute( + database_id: '', + collection_id: '', + document_id: '', + attribute: '', + value: null, # optional + min: null # optional +) diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..40d8ba2 --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,19 @@ +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 + +databases = Databases.new(client) + +result = databases.increment_document_attribute( + database_id: '', + collection_id: '', + document_id: '', + attribute: '', + value: null, # optional + max: null # optional +) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md new file mode 100644 index 0000000..2380818 --- /dev/null +++ b/docs/examples/databases/upsert-document.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_session('') # The user session to authenticate with + +databases = Databases.new(client) + +result = databases.upsert_document( + database_id: '', + collection_id: '', + document_id: '', + data: {}, + permissions: ["read("any")"] # optional +) diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 353e38f..30c42aa 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -12,5 +12,5 @@ databases = Databases.new(client) result = databases.upsert_documents( database_id: '', collection_id: '', - documents: [] # optional + documents: [] ) diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 2158e4c..6a8c307 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'=> '16.0.0', + 'x-sdk-version'=> '16.1.0', 'X-Appwrite-Response-Format' => '1.7.0' } @endpoint = 'https://cloud.appwrite.io/v1' diff --git a/lib/appwrite/enums/build_runtime.rb b/lib/appwrite/enums/build_runtime.rb index e113a77..1101024 100644 --- a/lib/appwrite/enums/build_runtime.rb +++ b/lib/appwrite/enums/build_runtime.rb @@ -38,6 +38,7 @@ module BuildRuntime DART_3_1 = 'dart-3.1' DART_3_3 = 'dart-3.3' DART_3_5 = 'dart-3.5' + DART_3_8 = 'dart-3.8' DOTNET_6_0 = 'dotnet-6.0' DOTNET_7_0 = 'dotnet-7.0' DOTNET_8_0 = 'dotnet-8.0' @@ -64,6 +65,7 @@ module BuildRuntime FLUTTER_3_24 = 'flutter-3.24' FLUTTER_3_27 = 'flutter-3.27' FLUTTER_3_29 = 'flutter-3.29' + FLUTTER_3_32 = 'flutter-3.32' end end end \ No newline at end of file diff --git a/lib/appwrite/enums/image_format.rb b/lib/appwrite/enums/image_format.rb index f1e0ea2..3cd22ed 100644 --- a/lib/appwrite/enums/image_format.rb +++ b/lib/appwrite/enums/image_format.rb @@ -7,6 +7,7 @@ module ImageFormat 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 726c326..96d3b45 100644 --- a/lib/appwrite/enums/runtime.rb +++ b/lib/appwrite/enums/runtime.rb @@ -38,6 +38,7 @@ module Runtime DART_3_1 = 'dart-3.1' DART_3_3 = 'dart-3.3' DART_3_5 = 'dart-3.5' + DART_3_8 = 'dart-3.8' DOTNET_6_0 = 'dotnet-6.0' DOTNET_7_0 = 'dotnet-7.0' DOTNET_8_0 = 'dotnet-8.0' @@ -64,6 +65,7 @@ module Runtime FLUTTER_3_24 = 'flutter-3.24' FLUTTER_3_27 = 'flutter-3.27' FLUTTER_3_29 = 'flutter-3.29' + FLUTTER_3_32 = 'flutter-3.32' end end end \ No newline at end of file diff --git a/lib/appwrite/models/attribute_string.rb b/lib/appwrite/models/attribute_string.rb index 85037d5..79416f4 100644 --- a/lib/appwrite/models/attribute_string.rb +++ b/lib/appwrite/models/attribute_string.rb @@ -13,6 +13,7 @@ class AttributeString attr_reader :updated_at attr_reader :size attr_reader :default + attr_reader :encrypt def initialize( key:, @@ -24,7 +25,8 @@ def initialize( created_at:, updated_at:, size:, - default: + default: , + encrypt: ) @key = key @type = type @@ -36,6 +38,7 @@ def initialize( @updated_at = updated_at @size = size @default = default + @encrypt = encrypt end def self.from(map:) @@ -49,7 +52,8 @@ def self.from(map:) created_at: map["$createdAt"], updated_at: map["$updatedAt"], size: map["size"], - default: map["default"] + default: map["default"], + encrypt: map["encrypt"] ) end @@ -64,7 +68,8 @@ def to_map "$createdAt": @created_at, "$updatedAt": @updated_at, "size": @size, - "default": @default + "default": @default, + "encrypt": @encrypt } end end diff --git a/lib/appwrite/models/document.rb b/lib/appwrite/models/document.rb index 59d200e..0bab705 100644 --- a/lib/appwrite/models/document.rb +++ b/lib/appwrite/models/document.rb @@ -4,6 +4,7 @@ module Appwrite module Models class Document attr_reader :id + attr_reader :sequence attr_reader :collection_id attr_reader :database_id attr_reader :created_at @@ -13,6 +14,7 @@ class Document def initialize( id:, + sequence:, collection_id:, database_id:, created_at:, @@ -21,6 +23,7 @@ def initialize( data: ) @id = id + @sequence = sequence @collection_id = collection_id @database_id = database_id @created_at = created_at @@ -32,6 +35,7 @@ def initialize( def self.from(map:) Document.new( id: map["$id"], + sequence: map["$sequence"], collection_id: map["$collectionId"], database_id: map["$databaseId"], created_at: map["$createdAt"], @@ -44,6 +48,7 @@ def self.from(map:) def to_map { "$id": @id, + "$sequence": @sequence, "$collectionId": @collection_id, "$databaseId": @database_id, "$createdAt": @created_at, diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index 7f3fec2..9e78f69 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -1729,6 +1729,10 @@ def create_document(database_id:, collection_id:, document_id:, data:, permissio end + # **WARNING: Experimental Feature** - This endpoint is experimental and not + # yet officially supported. It may be subject to breaking changes or removal + # in future versions. + # # Create new Documents. Before using this route, you should create a new # collection resource using either a [server # integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1774,6 +1778,10 @@ def create_documents(database_id:, collection_id:, documents:) end + # **WARNING: Experimental Feature** - This endpoint is experimental and not + # yet officially supported. It may be subject to breaking changes or removal + # in future versions. + # # Create or update Documents. Before using this route, you should create a # new collection resource using either a [server # integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1785,7 +1793,7 @@ def create_documents(database_id:, collection_id:, documents:) # @param [Array] documents Array of document data as JSON objects. May contain partial documents. # # @return [DocumentList] - def upsert_documents(database_id:, collection_id:, documents: nil) + def upsert_documents(database_id:, collection_id:, documents:) api_path = '/databases/{databaseId}/collections/{collectionId}/documents' .gsub('{databaseId}', database_id) .gsub('{collectionId}', collection_id) @@ -1798,6 +1806,10 @@ def upsert_documents(database_id:, collection_id:, documents: nil) raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + if documents.nil? + raise Appwrite::Exception.new('Missing required parameter: "documents"') + end + api_params = { documents: documents, } @@ -1816,6 +1828,10 @@ def upsert_documents(database_id:, collection_id:, documents: nil) end + # **WARNING: Experimental Feature** - This endpoint is experimental and not + # yet officially supported. It may be subject to breaking changes or removal + # in future versions. + # # Update all documents that match your queries, if no queries are submitted # then all documents are updated. You can pass only specific fields to be # updated. @@ -1858,6 +1874,10 @@ def update_documents(database_id:, collection_id:, data: nil, queries: nil) end + # **WARNING: Experimental Feature** - This endpoint is experimental and not + # yet officially supported. It may be subject to breaking changes or removal + # in future versions. + # # Bulk delete documents using queries, if no queries are passed then all # documents are deleted. # @@ -1941,6 +1961,63 @@ def get_document(database_id:, collection_id:, document_id:, queries: nil) end + # **WARNING: Experimental Feature** - This endpoint is experimental and not + # yet officially supported. It may be subject to breaking changes or removal + # in future versions. + # + # Create or update a Document. Before using this route, you should create a + # new collection resource using either a [server + # integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + # API or directly from your database console. + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. + # @param [String] document_id Document ID. + # @param [Hash] data Document data as JSON object. Include all required attributes of the document to be created or updated. + # @param [Array] permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + # + # @return [Document] + def upsert_document(database_id:, collection_id:, document_id:, data:, permissions: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if document_id.nil? + 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, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Document + ) + end + + # Update a document by its unique ID. Using the patch method you can pass # only specific fields that will get updated. # @@ -2029,6 +2106,110 @@ def delete_document(database_id:, collection_id:, document_id:) end + # Decrement a specific attribute of a document by a given value. + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. + # @param [String] document_id Document ID. + # @param [String] attribute Attribute key. + # @param [Float] value Value to decrement the attribute by. The value must be a number. + # @param [Float] min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + # + # @return [Document] + def decrement_document_attribute(database_id:, collection_id:, document_id:, attribute:, value: nil, min: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if document_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "documentId"') + end + + if attribute.nil? + raise Appwrite::Exception.new('Missing required parameter: "attribute"') + end + + api_params = { + value: value, + min: min, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Document + ) + end + + + # Increment a specific attribute of a document by a given value. + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. + # @param [String] document_id Document ID. + # @param [String] attribute Attribute key. + # @param [Float] value Value to increment the attribute by. The value must be a number. + # @param [Float] max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + # + # @return [Document] + def increment_document_attribute(database_id:, collection_id:, document_id:, attribute:, value: nil, max: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if document_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "documentId"') + end + + if attribute.nil? + raise Appwrite::Exception.new('Missing required parameter: "attribute"') + end + + api_params = { + value: value, + max: max, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Document + ) + end + + # List indexes in the collection. # # @param [String] database_id Database ID. diff --git a/lib/appwrite/services/tokens.rb b/lib/appwrite/services/tokens.rb index acc1739..6d3bd6d 100644 --- a/lib/appwrite/services/tokens.rb +++ b/lib/appwrite/services/tokens.rb @@ -46,7 +46,7 @@ def list(bucket_id:, file_id:, queries: nil) # Create a new token. A token is linked to a file. Token can be passed as a - # header or request get parameter. + # request URL search parameter. # # @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. diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index 6bb2063..0f44a9b 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -1290,7 +1290,7 @@ def update_status(user_id:, status:) # List the messaging targets that are associated with a user. # # @param [String] user_id User ID. - # @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. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels + # @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. You may filter on the following attributes: userId, providerId, identifier, providerType # # @return [TargetList] def list_targets(user_id:, queries: nil)