appwrite 15.1.0.pre.rc.1 → 16.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class ResourceTokenList
6
+ attr_reader :total
7
+ attr_reader :tokens
8
+
9
+ def initialize(
10
+ total:,
11
+ tokens:
12
+ )
13
+ @total = total
14
+ @tokens = tokens
15
+ end
16
+
17
+ def self.from(map:)
18
+ ResourceTokenList.new(
19
+ total: map["total"],
20
+ tokens: map["tokens"].map { |it| ResourceToken.from(map: it) }
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "total": @total,
27
+ "tokens": @tokens.map { |it| it.to_map }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,167 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class Site
6
+ attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
9
+ attr_reader :name
10
+ attr_reader :enabled
11
+ attr_reader :live
12
+ attr_reader :logging
13
+ attr_reader :framework
14
+ attr_reader :deployment_id
15
+ attr_reader :deployment_created_at
16
+ attr_reader :deployment_screenshot_light
17
+ attr_reader :deployment_screenshot_dark
18
+ attr_reader :latest_deployment_id
19
+ attr_reader :latest_deployment_created_at
20
+ attr_reader :latest_deployment_status
21
+ attr_reader :vars
22
+ attr_reader :timeout
23
+ attr_reader :install_command
24
+ attr_reader :build_command
25
+ attr_reader :output_directory
26
+ attr_reader :installation_id
27
+ attr_reader :provider_repository_id
28
+ attr_reader :provider_branch
29
+ attr_reader :provider_root_directory
30
+ attr_reader :provider_silent_mode
31
+ attr_reader :specification
32
+ attr_reader :build_runtime
33
+ attr_reader :adapter
34
+ attr_reader :fallback_file
35
+
36
+ def initialize(
37
+ id:,
38
+ created_at:,
39
+ updated_at:,
40
+ name:,
41
+ enabled:,
42
+ live:,
43
+ logging:,
44
+ framework:,
45
+ deployment_id:,
46
+ deployment_created_at:,
47
+ deployment_screenshot_light:,
48
+ deployment_screenshot_dark:,
49
+ latest_deployment_id:,
50
+ latest_deployment_created_at:,
51
+ latest_deployment_status:,
52
+ vars:,
53
+ timeout:,
54
+ install_command:,
55
+ build_command:,
56
+ output_directory:,
57
+ installation_id:,
58
+ provider_repository_id:,
59
+ provider_branch:,
60
+ provider_root_directory:,
61
+ provider_silent_mode:,
62
+ specification:,
63
+ build_runtime:,
64
+ adapter:,
65
+ fallback_file:
66
+ )
67
+ @id = id
68
+ @created_at = created_at
69
+ @updated_at = updated_at
70
+ @name = name
71
+ @enabled = enabled
72
+ @live = live
73
+ @logging = logging
74
+ @framework = framework
75
+ @deployment_id = deployment_id
76
+ @deployment_created_at = deployment_created_at
77
+ @deployment_screenshot_light = deployment_screenshot_light
78
+ @deployment_screenshot_dark = deployment_screenshot_dark
79
+ @latest_deployment_id = latest_deployment_id
80
+ @latest_deployment_created_at = latest_deployment_created_at
81
+ @latest_deployment_status = latest_deployment_status
82
+ @vars = vars
83
+ @timeout = timeout
84
+ @install_command = install_command
85
+ @build_command = build_command
86
+ @output_directory = output_directory
87
+ @installation_id = installation_id
88
+ @provider_repository_id = provider_repository_id
89
+ @provider_branch = provider_branch
90
+ @provider_root_directory = provider_root_directory
91
+ @provider_silent_mode = provider_silent_mode
92
+ @specification = specification
93
+ @build_runtime = build_runtime
94
+ @adapter = adapter
95
+ @fallback_file = fallback_file
96
+ end
97
+
98
+ def self.from(map:)
99
+ Site.new(
100
+ id: map["$id"],
101
+ created_at: map["$createdAt"],
102
+ updated_at: map["$updatedAt"],
103
+ name: map["name"],
104
+ enabled: map["enabled"],
105
+ live: map["live"],
106
+ logging: map["logging"],
107
+ framework: map["framework"],
108
+ deployment_id: map["deploymentId"],
109
+ deployment_created_at: map["deploymentCreatedAt"],
110
+ deployment_screenshot_light: map["deploymentScreenshotLight"],
111
+ deployment_screenshot_dark: map["deploymentScreenshotDark"],
112
+ latest_deployment_id: map["latestDeploymentId"],
113
+ latest_deployment_created_at: map["latestDeploymentCreatedAt"],
114
+ latest_deployment_status: map["latestDeploymentStatus"],
115
+ vars: map["vars"].map { |it| Variable.from(map: it) },
116
+ timeout: map["timeout"],
117
+ install_command: map["installCommand"],
118
+ build_command: map["buildCommand"],
119
+ output_directory: map["outputDirectory"],
120
+ installation_id: map["installationId"],
121
+ provider_repository_id: map["providerRepositoryId"],
122
+ provider_branch: map["providerBranch"],
123
+ provider_root_directory: map["providerRootDirectory"],
124
+ provider_silent_mode: map["providerSilentMode"],
125
+ specification: map["specification"],
126
+ build_runtime: map["buildRuntime"],
127
+ adapter: map["adapter"],
128
+ fallback_file: map["fallbackFile"]
129
+ )
130
+ end
131
+
132
+ def to_map
133
+ {
134
+ "$id": @id,
135
+ "$createdAt": @created_at,
136
+ "$updatedAt": @updated_at,
137
+ "name": @name,
138
+ "enabled": @enabled,
139
+ "live": @live,
140
+ "logging": @logging,
141
+ "framework": @framework,
142
+ "deploymentId": @deployment_id,
143
+ "deploymentCreatedAt": @deployment_created_at,
144
+ "deploymentScreenshotLight": @deployment_screenshot_light,
145
+ "deploymentScreenshotDark": @deployment_screenshot_dark,
146
+ "latestDeploymentId": @latest_deployment_id,
147
+ "latestDeploymentCreatedAt": @latest_deployment_created_at,
148
+ "latestDeploymentStatus": @latest_deployment_status,
149
+ "vars": @vars.map { |it| it.to_map },
150
+ "timeout": @timeout,
151
+ "installCommand": @install_command,
152
+ "buildCommand": @build_command,
153
+ "outputDirectory": @output_directory,
154
+ "installationId": @installation_id,
155
+ "providerRepositoryId": @provider_repository_id,
156
+ "providerBranch": @provider_branch,
157
+ "providerRootDirectory": @provider_root_directory,
158
+ "providerSilentMode": @provider_silent_mode,
159
+ "specification": @specification,
160
+ "buildRuntime": @build_runtime,
161
+ "adapter": @adapter,
162
+ "fallbackFile": @fallback_file
163
+ }
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class SiteList
6
+ attr_reader :total
7
+ attr_reader :sites
8
+
9
+ def initialize(
10
+ total:,
11
+ sites:
12
+ )
13
+ @total = total
14
+ @sites = sites
15
+ end
16
+
17
+ def self.from(map:)
18
+ SiteList.new(
19
+ total: map["total"],
20
+ sites: map["sites"].map { |it| Site.from(map: it) }
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "total": @total,
27
+ "sites": @sites.map { |it| it.to_map }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -8,6 +8,7 @@ module Appwrite
8
8
  attr_reader :updated_at
9
9
  attr_reader :key
10
10
  attr_reader :value
11
+ attr_reader :secret
11
12
  attr_reader :resource_type
12
13
  attr_reader :resource_id
13
14
 
@@ -17,6 +18,7 @@ module Appwrite
17
18
  updated_at:,
18
19
  key:,
19
20
  value:,
21
+ secret:,
20
22
  resource_type:,
21
23
  resource_id:
22
24
  )
@@ -25,6 +27,7 @@ module Appwrite
25
27
  @updated_at = updated_at
26
28
  @key = key
27
29
  @value = value
30
+ @secret = secret
28
31
  @resource_type = resource_type
29
32
  @resource_id = resource_id
30
33
  end
@@ -36,6 +39,7 @@ module Appwrite
36
39
  updated_at: map["$updatedAt"],
37
40
  key: map["key"],
38
41
  value: map["value"],
42
+ secret: map["secret"],
39
43
  resource_type: map["resourceType"],
40
44
  resource_id: map["resourceId"]
41
45
  )
@@ -48,6 +52,7 @@ module Appwrite
48
52
  "$updatedAt": @updated_at,
49
53
  "key": @key,
50
54
  "value": @value,
55
+ "secret": @secret,
51
56
  "resourceType": @resource_type,
52
57
  "resourceId": @resource_id
53
58
  }
@@ -21,7 +21,7 @@ module Appwrite
21
21
  # @param [Browser] code Browser Code.
22
22
  # @param [Integer] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
23
23
  # @param [Integer] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
24
- # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
24
+ # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
25
25
  #
26
26
  # @return []
27
27
  def get_browser(code:, width: nil, height: nil, quality: nil)
@@ -63,7 +63,7 @@ module Appwrite
63
63
  # @param [CreditCard] code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay.
64
64
  # @param [Integer] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
65
65
  # @param [Integer] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
66
- # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
66
+ # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
67
67
  #
68
68
  # @return []
69
69
  def get_credit_card(code:, width: nil, height: nil, quality: nil)
@@ -137,7 +137,7 @@ module Appwrite
137
137
  # @param [Flag] code Country Code. ISO Alpha-2 country code format.
138
138
  # @param [Integer] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
139
139
  # @param [Integer] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
140
- # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
140
+ # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
141
141
  #
142
142
  # @return []
143
143
  def get_flag(code:, width: nil, height: nil, quality: nil)
@@ -1729,11 +1729,14 @@ module Appwrite
1729
1729
  end
1730
1730
 
1731
1731
 
1732
+ # **WARNING: Experimental Feature** - This endpoint is experimental and not
1733
+ # yet officially supported. It may be subject to breaking changes or removal
1734
+ # in future versions.
1735
+ #
1732
1736
  # Create new Documents. Before using this route, you should create a new
1733
1737
  # collection resource using either a [server
1734
1738
  # integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1735
1739
  # API or directly from your database console.
1736
- #
1737
1740
  #
1738
1741
  # @param [String] database_id Database ID.
1739
1742
  # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.
@@ -1775,6 +1778,10 @@ module Appwrite
1775
1778
  end
1776
1779
 
1777
1780
 
1781
+ # **WARNING: Experimental Feature** - This endpoint is experimental and not
1782
+ # yet officially supported. It may be subject to breaking changes or removal
1783
+ # in future versions.
1784
+ #
1778
1785
  # Create or update Documents. Before using this route, you should create a
1779
1786
  # new collection resource using either a [server
1780
1787
  # integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
@@ -1786,7 +1793,7 @@ module Appwrite
1786
1793
  # @param [Array] documents Array of document data as JSON objects. May contain partial documents.
1787
1794
  #
1788
1795
  # @return [DocumentList]
1789
- def upsert_documents(database_id:, collection_id:, documents: nil)
1796
+ def upsert_documents(database_id:, collection_id:, documents:)
1790
1797
  api_path = '/databases/{databaseId}/collections/{collectionId}/documents'
1791
1798
  .gsub('{databaseId}', database_id)
1792
1799
  .gsub('{collectionId}', collection_id)
@@ -1799,6 +1806,10 @@ module Appwrite
1799
1806
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
1800
1807
  end
1801
1808
 
1809
+ if documents.nil?
1810
+ raise Appwrite::Exception.new('Missing required parameter: "documents"')
1811
+ end
1812
+
1802
1813
  api_params = {
1803
1814
  documents: documents,
1804
1815
  }
@@ -1817,6 +1828,10 @@ module Appwrite
1817
1828
  end
1818
1829
 
1819
1830
 
1831
+ # **WARNING: Experimental Feature** - This endpoint is experimental and not
1832
+ # yet officially supported. It may be subject to breaking changes or removal
1833
+ # in future versions.
1834
+ #
1820
1835
  # Update all documents that match your queries, if no queries are submitted
1821
1836
  # then all documents are updated. You can pass only specific fields to be
1822
1837
  # updated.
@@ -1859,6 +1874,10 @@ module Appwrite
1859
1874
  end
1860
1875
 
1861
1876
 
1877
+ # **WARNING: Experimental Feature** - This endpoint is experimental and not
1878
+ # yet officially supported. It may be subject to breaking changes or removal
1879
+ # in future versions.
1880
+ #
1862
1881
  # Bulk delete documents using queries, if no queries are passed then all
1863
1882
  # documents are deleted.
1864
1883
  #
@@ -1942,6 +1961,63 @@ module Appwrite
1942
1961
  end
1943
1962
 
1944
1963
 
1964
+ # **WARNING: Experimental Feature** - This endpoint is experimental and not
1965
+ # yet officially supported. It may be subject to breaking changes or removal
1966
+ # in future versions.
1967
+ #
1968
+ # Create or update a Document. Before using this route, you should create a
1969
+ # new collection resource using either a [server
1970
+ # integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1971
+ # API or directly from your database console.
1972
+ #
1973
+ # @param [String] database_id Database ID.
1974
+ # @param [String] collection_id Collection ID.
1975
+ # @param [String] document_id Document ID.
1976
+ # @param [Hash] data Document data as JSON object. Include all required attributes of the document to be created or updated.
1977
+ # @param [Array] permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
1978
+ #
1979
+ # @return [Document]
1980
+ def upsert_document(database_id:, collection_id:, document_id:, data:, permissions: nil)
1981
+ api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
1982
+ .gsub('{databaseId}', database_id)
1983
+ .gsub('{collectionId}', collection_id)
1984
+ .gsub('{documentId}', document_id)
1985
+
1986
+ if database_id.nil?
1987
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1988
+ end
1989
+
1990
+ if collection_id.nil?
1991
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
1992
+ end
1993
+
1994
+ if document_id.nil?
1995
+ raise Appwrite::Exception.new('Missing required parameter: "documentId"')
1996
+ end
1997
+
1998
+ if data.nil?
1999
+ raise Appwrite::Exception.new('Missing required parameter: "data"')
2000
+ end
2001
+
2002
+ api_params = {
2003
+ data: data,
2004
+ permissions: permissions,
2005
+ }
2006
+
2007
+ api_headers = {
2008
+ "content-type": 'application/json',
2009
+ }
2010
+
2011
+ @client.call(
2012
+ method: 'PUT',
2013
+ path: api_path,
2014
+ headers: api_headers,
2015
+ params: api_params,
2016
+ response_type: Models::Document
2017
+ )
2018
+ end
2019
+
2020
+
1945
2021
  # Update a document by its unique ID. Using the patch method you can pass
1946
2022
  # only specific fields that will get updated.
1947
2023
  #
@@ -2030,6 +2106,110 @@ module Appwrite
2030
2106
  end
2031
2107
 
2032
2108
 
2109
+ # Decrement a specific attribute of a document by a given value.
2110
+ #
2111
+ # @param [String] database_id Database ID.
2112
+ # @param [String] collection_id Collection ID.
2113
+ # @param [String] document_id Document ID.
2114
+ # @param [String] attribute Attribute key.
2115
+ # @param [Float] value Value to decrement the attribute by. The value must be a number.
2116
+ # @param [Float] min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.
2117
+ #
2118
+ # @return [Document]
2119
+ def decrement_document_attribute(database_id:, collection_id:, document_id:, attribute:, value: nil, min: nil)
2120
+ api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'
2121
+ .gsub('{databaseId}', database_id)
2122
+ .gsub('{collectionId}', collection_id)
2123
+ .gsub('{documentId}', document_id)
2124
+ .gsub('{attribute}', attribute)
2125
+
2126
+ if database_id.nil?
2127
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
2128
+ end
2129
+
2130
+ if collection_id.nil?
2131
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
2132
+ end
2133
+
2134
+ if document_id.nil?
2135
+ raise Appwrite::Exception.new('Missing required parameter: "documentId"')
2136
+ end
2137
+
2138
+ if attribute.nil?
2139
+ raise Appwrite::Exception.new('Missing required parameter: "attribute"')
2140
+ end
2141
+
2142
+ api_params = {
2143
+ value: value,
2144
+ min: min,
2145
+ }
2146
+
2147
+ api_headers = {
2148
+ "content-type": 'application/json',
2149
+ }
2150
+
2151
+ @client.call(
2152
+ method: 'PATCH',
2153
+ path: api_path,
2154
+ headers: api_headers,
2155
+ params: api_params,
2156
+ response_type: Models::Document
2157
+ )
2158
+ end
2159
+
2160
+
2161
+ # Increment a specific attribute of a document by a given value.
2162
+ #
2163
+ # @param [String] database_id Database ID.
2164
+ # @param [String] collection_id Collection ID.
2165
+ # @param [String] document_id Document ID.
2166
+ # @param [String] attribute Attribute key.
2167
+ # @param [Float] value Value to increment the attribute by. The value must be a number.
2168
+ # @param [Float] max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.
2169
+ #
2170
+ # @return [Document]
2171
+ def increment_document_attribute(database_id:, collection_id:, document_id:, attribute:, value: nil, max: nil)
2172
+ api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'
2173
+ .gsub('{databaseId}', database_id)
2174
+ .gsub('{collectionId}', collection_id)
2175
+ .gsub('{documentId}', document_id)
2176
+ .gsub('{attribute}', attribute)
2177
+
2178
+ if database_id.nil?
2179
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
2180
+ end
2181
+
2182
+ if collection_id.nil?
2183
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
2184
+ end
2185
+
2186
+ if document_id.nil?
2187
+ raise Appwrite::Exception.new('Missing required parameter: "documentId"')
2188
+ end
2189
+
2190
+ if attribute.nil?
2191
+ raise Appwrite::Exception.new('Missing required parameter: "attribute"')
2192
+ end
2193
+
2194
+ api_params = {
2195
+ value: value,
2196
+ max: max,
2197
+ }
2198
+
2199
+ api_headers = {
2200
+ "content-type": 'application/json',
2201
+ }
2202
+
2203
+ @client.call(
2204
+ method: 'PATCH',
2205
+ path: api_path,
2206
+ headers: api_headers,
2207
+ params: api_params,
2208
+ response_type: Models::Document
2209
+ )
2210
+ end
2211
+
2212
+
2033
2213
  # List indexes in the collection.
2034
2214
  #
2035
2215
  # @param [String] database_id Database ID.
@@ -2077,9 +2257,10 @@ module Appwrite
2077
2257
  # @param [IndexType] type Index type.
2078
2258
  # @param [Array] attributes Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.
2079
2259
  # @param [Array] orders Array of index orders. Maximum of 100 orders are allowed.
2260
+ # @param [Array] lengths Length of index. Maximum of 100
2080
2261
  #
2081
2262
  # @return [Index]
2082
- def create_index(database_id:, collection_id:, key:, type:, attributes:, orders: nil)
2263
+ def create_index(database_id:, collection_id:, key:, type:, attributes:, orders: nil, lengths: nil)
2083
2264
  api_path = '/databases/{databaseId}/collections/{collectionId}/indexes'
2084
2265
  .gsub('{databaseId}', database_id)
2085
2266
  .gsub('{collectionId}', collection_id)
@@ -2109,6 +2290,7 @@ module Appwrite
2109
2290
  type: type,
2110
2291
  attributes: attributes,
2111
2292
  orders: orders,
2293
+ lengths: lengths,
2112
2294
  }
2113
2295
 
2114
2296
  api_headers = {