appwrite 2.4.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +197 -56
  3. data/lib/appwrite/exception.rb +7 -7
  4. data/lib/appwrite/file.rb +9 -15
  5. data/lib/appwrite/models/attribute_boolean.rb +52 -0
  6. data/lib/appwrite/models/attribute_email.rb +57 -0
  7. data/lib/appwrite/models/attribute_enum.rb +62 -0
  8. data/lib/appwrite/models/attribute_float.rb +62 -0
  9. data/lib/appwrite/models/attribute_integer.rb +62 -0
  10. data/lib/appwrite/models/attribute_ip.rb +57 -0
  11. data/lib/appwrite/models/attribute_list.rb +32 -0
  12. data/lib/appwrite/models/attribute_string.rb +57 -0
  13. data/lib/appwrite/models/attribute_url.rb +57 -0
  14. data/lib/appwrite/models/bucket.rb +82 -0
  15. data/lib/appwrite/models/bucket_list.rb +32 -0
  16. data/lib/appwrite/models/collection.rb +62 -0
  17. data/lib/appwrite/models/collection_list.rb +32 -0
  18. data/lib/appwrite/models/continent.rb +32 -0
  19. data/lib/appwrite/models/continent_list.rb +32 -0
  20. data/lib/appwrite/models/country.rb +32 -0
  21. data/lib/appwrite/models/country_list.rb +32 -0
  22. data/lib/appwrite/models/currency.rb +57 -0
  23. data/lib/appwrite/models/currency_list.rb +32 -0
  24. data/lib/appwrite/models/deployment.rb +77 -0
  25. data/lib/appwrite/models/deployment_list.rb +32 -0
  26. data/lib/appwrite/models/document.rb +50 -0
  27. data/lib/appwrite/models/document_list.rb +36 -0
  28. data/lib/appwrite/models/execution.rb +72 -0
  29. data/lib/appwrite/models/execution_list.rb +32 -0
  30. data/lib/appwrite/models/file.rb +77 -0
  31. data/lib/appwrite/models/file_list.rb +32 -0
  32. data/lib/appwrite/models/function.rb +92 -0
  33. data/lib/appwrite/models/function_list.rb +32 -0
  34. data/lib/appwrite/models/health_antivirus.rb +32 -0
  35. data/lib/appwrite/models/health_queue.rb +27 -0
  36. data/lib/appwrite/models/health_status.rb +32 -0
  37. data/lib/appwrite/models/health_time.rb +37 -0
  38. data/lib/appwrite/models/index.rb +47 -0
  39. data/lib/appwrite/models/index_list.rb +32 -0
  40. data/lib/appwrite/models/language.rb +37 -0
  41. data/lib/appwrite/models/language_list.rb +32 -0
  42. data/lib/appwrite/models/locale.rb +57 -0
  43. data/lib/appwrite/models/log.rb +127 -0
  44. data/lib/appwrite/models/log_list.rb +32 -0
  45. data/lib/appwrite/models/membership.rb +67 -0
  46. data/lib/appwrite/models/membership_list.rb +32 -0
  47. data/lib/appwrite/models/phone.rb +37 -0
  48. data/lib/appwrite/models/phone_list.rb +32 -0
  49. data/lib/appwrite/models/preferences.rb +30 -0
  50. data/lib/appwrite/models/runtime.rb +57 -0
  51. data/lib/appwrite/models/runtime_list.rb +32 -0
  52. data/lib/appwrite/models/session.rb +142 -0
  53. data/lib/appwrite/models/session_list.rb +32 -0
  54. data/lib/appwrite/models/team.rb +42 -0
  55. data/lib/appwrite/models/team_list.rb +32 -0
  56. data/lib/appwrite/models/token.rb +42 -0
  57. data/lib/appwrite/models/user.rb +62 -0
  58. data/lib/appwrite/models/user_list.rb +32 -0
  59. data/lib/appwrite/query.rb +42 -0
  60. data/lib/appwrite/service.rb +0 -5
  61. data/lib/appwrite/services/account.rb +400 -138
  62. data/lib/appwrite/services/avatars.rb +188 -125
  63. data/lib/appwrite/services/database.rb +875 -130
  64. data/lib/appwrite/services/functions.rb +439 -207
  65. data/lib/appwrite/services/health.rb +201 -58
  66. data/lib/appwrite/services/locale.rb +133 -32
  67. data/lib/appwrite/services/storage.rb +469 -118
  68. data/lib/appwrite/services/teams.rb +302 -118
  69. data/lib/appwrite/services/users.rb +322 -127
  70. data/lib/appwrite.rb +57 -0
  71. metadata +74 -108
  72. data/.travis.yml +0 -16
  73. data/CHANGELOG.md +0 -1
  74. data/Gemfile +0 -4
  75. data/LICENSE +0 -12
  76. data/README.md +0 -96
  77. data/appwrite.gemspec +0 -11
  78. data/docs/examples/account/create-recovery.md +0 -15
  79. data/docs/examples/account/create-verification.md +0 -15
  80. data/docs/examples/account/delete-session.md +0 -15
  81. data/docs/examples/account/delete-sessions.md +0 -15
  82. data/docs/examples/account/delete.md +0 -15
  83. data/docs/examples/account/get-logs.md +0 -15
  84. data/docs/examples/account/get-prefs.md +0 -15
  85. data/docs/examples/account/get-session.md +0 -15
  86. data/docs/examples/account/get-sessions.md +0 -15
  87. data/docs/examples/account/get.md +0 -15
  88. data/docs/examples/account/update-email.md +0 -15
  89. data/docs/examples/account/update-name.md +0 -15
  90. data/docs/examples/account/update-password.md +0 -15
  91. data/docs/examples/account/update-prefs.md +0 -15
  92. data/docs/examples/account/update-recovery.md +0 -15
  93. data/docs/examples/account/update-verification.md +0 -15
  94. data/docs/examples/avatars/get-browser.md +0 -15
  95. data/docs/examples/avatars/get-credit-card.md +0 -15
  96. data/docs/examples/avatars/get-favicon.md +0 -15
  97. data/docs/examples/avatars/get-flag.md +0 -15
  98. data/docs/examples/avatars/get-image.md +0 -15
  99. data/docs/examples/avatars/get-initials.md +0 -15
  100. data/docs/examples/avatars/get-q-r.md +0 -15
  101. data/docs/examples/database/create-collection.md +0 -15
  102. data/docs/examples/database/create-document.md +0 -15
  103. data/docs/examples/database/delete-collection.md +0 -15
  104. data/docs/examples/database/delete-document.md +0 -15
  105. data/docs/examples/database/get-collection.md +0 -15
  106. data/docs/examples/database/get-document.md +0 -15
  107. data/docs/examples/database/list-collections.md +0 -15
  108. data/docs/examples/database/list-documents.md +0 -15
  109. data/docs/examples/database/update-collection.md +0 -15
  110. data/docs/examples/database/update-document.md +0 -15
  111. data/docs/examples/functions/create-execution.md +0 -15
  112. data/docs/examples/functions/create-tag.md +0 -15
  113. data/docs/examples/functions/create.md +0 -15
  114. data/docs/examples/functions/delete-tag.md +0 -15
  115. data/docs/examples/functions/delete.md +0 -15
  116. data/docs/examples/functions/get-execution.md +0 -15
  117. data/docs/examples/functions/get-tag.md +0 -15
  118. data/docs/examples/functions/get.md +0 -15
  119. data/docs/examples/functions/list-executions.md +0 -15
  120. data/docs/examples/functions/list-tags.md +0 -15
  121. data/docs/examples/functions/list.md +0 -15
  122. data/docs/examples/functions/update-tag.md +0 -15
  123. data/docs/examples/functions/update.md +0 -15
  124. data/docs/examples/health/get-anti-virus.md +0 -15
  125. data/docs/examples/health/get-cache.md +0 -15
  126. data/docs/examples/health/get-d-b.md +0 -15
  127. data/docs/examples/health/get-queue-certificates.md +0 -15
  128. data/docs/examples/health/get-queue-functions.md +0 -15
  129. data/docs/examples/health/get-queue-logs.md +0 -15
  130. data/docs/examples/health/get-queue-tasks.md +0 -15
  131. data/docs/examples/health/get-queue-usage.md +0 -15
  132. data/docs/examples/health/get-queue-webhooks.md +0 -15
  133. data/docs/examples/health/get-storage-local.md +0 -15
  134. data/docs/examples/health/get-time.md +0 -15
  135. data/docs/examples/health/get.md +0 -15
  136. data/docs/examples/locale/get-continents.md +0 -15
  137. data/docs/examples/locale/get-countries-e-u.md +0 -15
  138. data/docs/examples/locale/get-countries-phones.md +0 -15
  139. data/docs/examples/locale/get-countries.md +0 -15
  140. data/docs/examples/locale/get-currencies.md +0 -15
  141. data/docs/examples/locale/get-languages.md +0 -15
  142. data/docs/examples/locale/get.md +0 -15
  143. data/docs/examples/storage/create-file.md +0 -15
  144. data/docs/examples/storage/delete-file.md +0 -15
  145. data/docs/examples/storage/get-file-download.md +0 -15
  146. data/docs/examples/storage/get-file-preview.md +0 -15
  147. data/docs/examples/storage/get-file-view.md +0 -15
  148. data/docs/examples/storage/get-file.md +0 -15
  149. data/docs/examples/storage/list-files.md +0 -15
  150. data/docs/examples/storage/update-file.md +0 -15
  151. data/docs/examples/teams/create-membership.md +0 -15
  152. data/docs/examples/teams/create.md +0 -15
  153. data/docs/examples/teams/delete-membership.md +0 -15
  154. data/docs/examples/teams/delete.md +0 -15
  155. data/docs/examples/teams/get-memberships.md +0 -15
  156. data/docs/examples/teams/get.md +0 -15
  157. data/docs/examples/teams/list.md +0 -15
  158. data/docs/examples/teams/update-membership-roles.md +0 -15
  159. data/docs/examples/teams/update-membership-status.md +0 -15
  160. data/docs/examples/teams/update.md +0 -15
  161. data/docs/examples/users/create.md +0 -15
  162. data/docs/examples/users/delete-session.md +0 -15
  163. data/docs/examples/users/delete-sessions.md +0 -15
  164. data/docs/examples/users/delete.md +0 -15
  165. data/docs/examples/users/get-logs.md +0 -15
  166. data/docs/examples/users/get-prefs.md +0 -15
  167. data/docs/examples/users/get-sessions.md +0 -15
  168. data/docs/examples/users/get.md +0 -15
  169. data/docs/examples/users/list.md +0 -15
  170. data/docs/examples/users/update-email.md +0 -15
  171. data/docs/examples/users/update-name.md +0 -15
  172. data/docs/examples/users/update-password.md +0 -15
  173. data/docs/examples/users/update-prefs.md +0 -15
  174. data/docs/examples/users/update-status.md +0 -15
  175. data/docs/examples/users/update-verification.md +0 -15
@@ -1,37 +1,68 @@
1
+ #frozen_string_literal: true
2
+
1
3
  module Appwrite
2
4
  class Database < Service
3
5
 
4
- def list_collections(search: nil, limit: nil, offset: nil, order_type: nil)
6
+ # Get a list of all the user collections. You can use the query params to
7
+ # filter your results. On admin mode, this endpoint will return a list of all
8
+ # of the project's collections. [Learn more about different API
9
+ # modes](/docs/admin).
10
+ #
11
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
12
+ # @param [number] limit Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
13
+ # @param [number] offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
14
+ # @param [string] cursor ID of the collection used as the starting point for the query, excluding the collection itself. Should be used for efficient pagination when working with large sets of data.
15
+ # @param [string] cursor_direction Direction of the cursor.
16
+ # @param [string] order_type Order result by ASC or DESC order.
17
+ #
18
+ # @return [CollectionList]
19
+ def list_collections(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
5
20
  path = '/database/collections'
6
21
 
7
- params = {}
8
-
9
- if !search.nil?
10
- params[:search] = search
11
- end
12
-
13
- if !limit.nil?
14
- params[:limit] = limit
15
- end
16
-
17
- if !offset.nil?
18
- params[:offset] = offset
19
- end
22
+ params = {
23
+ search: search,
24
+ limit: limit,
25
+ offset: offset,
26
+ cursor: cursor,
27
+ cursorDirection: cursor_direction,
28
+ orderType: order_type,
29
+ }
30
+
31
+ headers = {
32
+ "content-type": 'application/json',
33
+ }
34
+
35
+ @client.call(
36
+ method: 'GET',
37
+ path: path,
38
+ headers: headers,
39
+ params: params,
40
+ response_type: Models::CollectionList
41
+ )
42
+ end
20
43
 
21
- if !order_type.nil?
22
- params[:orderType] = order_type
44
+ # Create a new Collection.
45
+ #
46
+ # @param [string] collection_id Unique Id. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
47
+ # @param [string] name Collection name. Max length: 128 chars.
48
+ # @param [string] permission Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the `read` and `write` params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
49
+ # @param [array] read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
50
+ # @param [array] write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
51
+ #
52
+ # @return [Collection]
53
+ def create_collection(collection_id:, name:, permission:, read:, write:)
54
+ if collection_id.nil?
55
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
23
56
  end
24
57
 
25
- return @client.call('get', path, {
26
- 'content-type' => 'application/json',
27
- }, params);
28
- end
29
-
30
- def create_collection(name:, read:, write:, rules:)
31
58
  if name.nil?
32
59
  raise Appwrite::Exception.new('Missing required parameter: "name"')
33
60
  end
34
61
 
62
+ if permission.nil?
63
+ raise Appwrite::Exception.new('Missing required parameter: "permission"')
64
+ end
65
+
35
66
  if read.nil?
36
67
  raise Appwrite::Exception.new('Missing required parameter: "read"')
37
68
  end
@@ -40,36 +71,113 @@ module Appwrite
40
71
  raise Appwrite::Exception.new('Missing required parameter: "write"')
41
72
  end
42
73
 
43
- if rules.nil?
44
- raise Appwrite::Exception.new('Missing required parameter: "rules"')
45
- end
46
-
47
74
  path = '/database/collections'
48
75
 
49
- params = {}
76
+ params = {
77
+ collectionId: collection_id,
78
+ name: name,
79
+ permission: permission,
80
+ read: read,
81
+ write: write,
82
+ }
83
+
84
+ headers = {
85
+ "content-type": 'application/json',
86
+ }
87
+
88
+ @client.call(
89
+ method: 'POST',
90
+ path: path,
91
+ headers: headers,
92
+ params: params,
93
+ response_type: Models::Collection
94
+ )
95
+ end
50
96
 
51
- if !name.nil?
52
- params[:name] = name
97
+ # Get a collection by its unique ID. This endpoint response returns a JSON
98
+ # object with the collection metadata.
99
+ #
100
+ # @param [string] collection_id Collection ID.
101
+ #
102
+ # @return [Collection]
103
+ def get_collection(collection_id:)
104
+ if collection_id.nil?
105
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
53
106
  end
54
107
 
55
- if !read.nil?
56
- params[:read] = read
108
+ path = '/database/collections/{collectionId}'
109
+ .gsub('{collectionId}', collection_id)
110
+
111
+ params = {
112
+ }
113
+
114
+ headers = {
115
+ "content-type": 'application/json',
116
+ }
117
+
118
+ @client.call(
119
+ method: 'GET',
120
+ path: path,
121
+ headers: headers,
122
+ params: params,
123
+ response_type: Models::Collection
124
+ )
125
+ end
126
+
127
+ # Update a collection by its unique ID.
128
+ #
129
+ # @param [string] collection_id Collection ID.
130
+ # @param [string] name Collection name. Max length: 128 chars.
131
+ # @param [string] permission Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the `read` and `write` params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
132
+ # @param [array] read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
133
+ # @param [array] write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
134
+ # @param [boolean] enabled Is collection enabled?
135
+ #
136
+ # @return [Collection]
137
+ def update_collection(collection_id:, name:, permission:, read: nil, write: nil, enabled: nil)
138
+ if collection_id.nil?
139
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
57
140
  end
58
141
 
59
- if !write.nil?
60
- params[:write] = write
142
+ if name.nil?
143
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
61
144
  end
62
145
 
63
- if !rules.nil?
64
- params[:rules] = rules
146
+ if permission.nil?
147
+ raise Appwrite::Exception.new('Missing required parameter: "permission"')
65
148
  end
66
149
 
67
- return @client.call('post', path, {
68
- 'content-type' => 'application/json',
69
- }, params);
150
+ path = '/database/collections/{collectionId}'
151
+ .gsub('{collectionId}', collection_id)
152
+
153
+ params = {
154
+ name: name,
155
+ permission: permission,
156
+ read: read,
157
+ write: write,
158
+ enabled: enabled,
159
+ }
160
+
161
+ headers = {
162
+ "content-type": 'application/json',
163
+ }
164
+
165
+ @client.call(
166
+ method: 'PUT',
167
+ path: path,
168
+ headers: headers,
169
+ params: params,
170
+ response_type: Models::Collection
171
+ )
70
172
  end
71
173
 
72
- def get_collection(collection_id:)
174
+ # Delete a collection by its unique ID. Only users with write permissions
175
+ # have access to delete this resource.
176
+ #
177
+ # @param [string] collection_id Collection ID.
178
+ #
179
+ # @return []
180
+ def delete_collection(collection_id:)
73
181
  if collection_id.nil?
74
182
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
75
183
  end
@@ -77,149 +185,608 @@ module Appwrite
77
185
  path = '/database/collections/{collectionId}'
78
186
  .gsub('{collectionId}', collection_id)
79
187
 
80
- params = {}
188
+ params = {
189
+ }
190
+
191
+ headers = {
192
+ "content-type": 'application/json',
193
+ }
81
194
 
82
- return @client.call('get', path, {
83
- 'content-type' => 'application/json',
84
- }, params);
195
+ @client.call(
196
+ method: 'DELETE',
197
+ path: path,
198
+ headers: headers,
199
+ params: params,
200
+ )
85
201
  end
86
202
 
87
- def update_collection(collection_id:, name:, read: nil, write: nil, rules: nil)
203
+ #
204
+ #
205
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
206
+ #
207
+ # @return [AttributeList]
208
+ def list_attributes(collection_id:)
88
209
  if collection_id.nil?
89
210
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
90
211
  end
91
212
 
92
- if name.nil?
93
- raise Appwrite::Exception.new('Missing required parameter: "name"')
213
+ path = '/database/collections/{collectionId}/attributes'
214
+ .gsub('{collectionId}', collection_id)
215
+
216
+ params = {
217
+ }
218
+
219
+ headers = {
220
+ "content-type": 'application/json',
221
+ }
222
+
223
+ @client.call(
224
+ method: 'GET',
225
+ path: path,
226
+ headers: headers,
227
+ params: params,
228
+ response_type: Models::AttributeList
229
+ )
230
+ end
231
+
232
+ # Create a boolean attribute.
233
+ #
234
+ #
235
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
236
+ # @param [string] key Attribute Key.
237
+ # @param [boolean] required Is attribute required?
238
+ # @param [boolean] default Default value for attribute when not provided. Cannot be set when attribute is required.
239
+ # @param [boolean] array Is attribute an array?
240
+ #
241
+ # @return [AttributeBoolean]
242
+ def create_boolean_attribute(collection_id:, key:, required:, default: nil, array: nil)
243
+ if collection_id.nil?
244
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
94
245
  end
95
246
 
96
- path = '/database/collections/{collectionId}'
247
+ if key.nil?
248
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
249
+ end
250
+
251
+ if required.nil?
252
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
253
+ end
254
+
255
+ path = '/database/collections/{collectionId}/attributes/boolean'
97
256
  .gsub('{collectionId}', collection_id)
98
257
 
99
- params = {}
258
+ params = {
259
+ key: key,
260
+ required: required,
261
+ default: default,
262
+ array: array,
263
+ }
264
+
265
+ headers = {
266
+ "content-type": 'application/json',
267
+ }
268
+
269
+ @client.call(
270
+ method: 'POST',
271
+ path: path,
272
+ headers: headers,
273
+ params: params,
274
+ response_type: Models::AttributeBoolean
275
+ )
276
+ end
100
277
 
101
- if !name.nil?
102
- params[:name] = name
278
+ # Create an email attribute.
279
+ #
280
+ #
281
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
282
+ # @param [string] key Attribute Key.
283
+ # @param [boolean] required Is attribute required?
284
+ # @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
285
+ # @param [boolean] array Is attribute an array?
286
+ #
287
+ # @return [AttributeEmail]
288
+ def create_email_attribute(collection_id:, key:, required:, default: nil, array: nil)
289
+ if collection_id.nil?
290
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
103
291
  end
104
292
 
105
- if !read.nil?
106
- params[:read] = read
293
+ if key.nil?
294
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
107
295
  end
108
296
 
109
- if !write.nil?
110
- params[:write] = write
297
+ if required.nil?
298
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
111
299
  end
112
300
 
113
- if !rules.nil?
114
- params[:rules] = rules
301
+ path = '/database/collections/{collectionId}/attributes/email'
302
+ .gsub('{collectionId}', collection_id)
303
+
304
+ params = {
305
+ key: key,
306
+ required: required,
307
+ default: default,
308
+ array: array,
309
+ }
310
+
311
+ headers = {
312
+ "content-type": 'application/json',
313
+ }
314
+
315
+ @client.call(
316
+ method: 'POST',
317
+ path: path,
318
+ headers: headers,
319
+ params: params,
320
+ response_type: Models::AttributeEmail
321
+ )
322
+ end
323
+
324
+ #
325
+ #
326
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
327
+ # @param [string] key Attribute Key.
328
+ # @param [array] elements Array of elements in enumerated type. Uses length of longest element to determine size.
329
+ # @param [boolean] required Is attribute required?
330
+ # @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
331
+ # @param [boolean] array Is attribute an array?
332
+ #
333
+ # @return [AttributeEnum]
334
+ def create_enum_attribute(collection_id:, key:, elements:, required:, default: nil, array: nil)
335
+ if collection_id.nil?
336
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
337
+ end
338
+
339
+ if key.nil?
340
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
115
341
  end
116
342
 
117
- return @client.call('put', path, {
118
- 'content-type' => 'application/json',
119
- }, params);
343
+ if elements.nil?
344
+ raise Appwrite::Exception.new('Missing required parameter: "elements"')
345
+ end
346
+
347
+ if required.nil?
348
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
349
+ end
350
+
351
+ path = '/database/collections/{collectionId}/attributes/enum'
352
+ .gsub('{collectionId}', collection_id)
353
+
354
+ params = {
355
+ key: key,
356
+ elements: elements,
357
+ required: required,
358
+ default: default,
359
+ array: array,
360
+ }
361
+
362
+ headers = {
363
+ "content-type": 'application/json',
364
+ }
365
+
366
+ @client.call(
367
+ method: 'POST',
368
+ path: path,
369
+ headers: headers,
370
+ params: params,
371
+ response_type: Models::AttributeEnum
372
+ )
120
373
  end
121
374
 
122
- def delete_collection(collection_id:)
375
+ # Create a float attribute. Optionally, minimum and maximum values can be
376
+ # provided.
377
+ #
378
+ #
379
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
380
+ # @param [string] key Attribute Key.
381
+ # @param [boolean] required Is attribute required?
382
+ # @param [number] min Minimum value to enforce on new documents
383
+ # @param [number] max Maximum value to enforce on new documents
384
+ # @param [number] default Default value for attribute when not provided. Cannot be set when attribute is required.
385
+ # @param [boolean] array Is attribute an array?
386
+ #
387
+ # @return [AttributeFloat]
388
+ def create_float_attribute(collection_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
123
389
  if collection_id.nil?
124
390
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
125
391
  end
126
392
 
127
- path = '/database/collections/{collectionId}'
393
+ if key.nil?
394
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
395
+ end
396
+
397
+ if required.nil?
398
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
399
+ end
400
+
401
+ path = '/database/collections/{collectionId}/attributes/float'
128
402
  .gsub('{collectionId}', collection_id)
129
403
 
130
- params = {}
404
+ params = {
405
+ key: key,
406
+ required: required,
407
+ min: min,
408
+ max: max,
409
+ default: default,
410
+ array: array,
411
+ }
412
+
413
+ headers = {
414
+ "content-type": 'application/json',
415
+ }
416
+
417
+ @client.call(
418
+ method: 'POST',
419
+ path: path,
420
+ headers: headers,
421
+ params: params,
422
+ response_type: Models::AttributeFloat
423
+ )
424
+ end
425
+
426
+ # Create an integer attribute. Optionally, minimum and maximum values can be
427
+ # provided.
428
+ #
429
+ #
430
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
431
+ # @param [string] key Attribute Key.
432
+ # @param [boolean] required Is attribute required?
433
+ # @param [number] min Minimum value to enforce on new documents
434
+ # @param [number] max Maximum value to enforce on new documents
435
+ # @param [number] default Default value for attribute when not provided. Cannot be set when attribute is required.
436
+ # @param [boolean] array Is attribute an array?
437
+ #
438
+ # @return [AttributeInteger]
439
+ def create_integer_attribute(collection_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
440
+ if collection_id.nil?
441
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
442
+ end
443
+
444
+ if key.nil?
445
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
446
+ end
447
+
448
+ if required.nil?
449
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
450
+ end
131
451
 
132
- return @client.call('delete', path, {
133
- 'content-type' => 'application/json',
134
- }, params);
452
+ path = '/database/collections/{collectionId}/attributes/integer'
453
+ .gsub('{collectionId}', collection_id)
454
+
455
+ params = {
456
+ key: key,
457
+ required: required,
458
+ min: min,
459
+ max: max,
460
+ default: default,
461
+ array: array,
462
+ }
463
+
464
+ headers = {
465
+ "content-type": 'application/json',
466
+ }
467
+
468
+ @client.call(
469
+ method: 'POST',
470
+ path: path,
471
+ headers: headers,
472
+ params: params,
473
+ response_type: Models::AttributeInteger
474
+ )
135
475
  end
136
476
 
137
- def list_documents(collection_id:, filters: nil, limit: nil, offset: nil, order_field: nil, order_type: nil, order_cast: nil, search: nil)
477
+ # Create IP address attribute.
478
+ #
479
+ #
480
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
481
+ # @param [string] key Attribute Key.
482
+ # @param [boolean] required Is attribute required?
483
+ # @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
484
+ # @param [boolean] array Is attribute an array?
485
+ #
486
+ # @return [AttributeIp]
487
+ def create_ip_attribute(collection_id:, key:, required:, default: nil, array: nil)
138
488
  if collection_id.nil?
139
489
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
140
490
  end
141
491
 
142
- path = '/database/collections/{collectionId}/documents'
492
+ if key.nil?
493
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
494
+ end
495
+
496
+ if required.nil?
497
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
498
+ end
499
+
500
+ path = '/database/collections/{collectionId}/attributes/ip'
143
501
  .gsub('{collectionId}', collection_id)
144
502
 
145
- params = {}
503
+ params = {
504
+ key: key,
505
+ required: required,
506
+ default: default,
507
+ array: array,
508
+ }
509
+
510
+ headers = {
511
+ "content-type": 'application/json',
512
+ }
513
+
514
+ @client.call(
515
+ method: 'POST',
516
+ path: path,
517
+ headers: headers,
518
+ params: params,
519
+ response_type: Models::AttributeIp
520
+ )
521
+ end
146
522
 
147
- if !filters.nil?
148
- params[:filters] = filters
523
+ # Create a string attribute.
524
+ #
525
+ #
526
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
527
+ # @param [string] key Attribute Key.
528
+ # @param [number] size Attribute size for text attributes, in number of characters.
529
+ # @param [boolean] required Is attribute required?
530
+ # @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
531
+ # @param [boolean] array Is attribute an array?
532
+ #
533
+ # @return [AttributeString]
534
+ def create_string_attribute(collection_id:, key:, size:, required:, default: nil, array: nil)
535
+ if collection_id.nil?
536
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
149
537
  end
150
538
 
151
- if !limit.nil?
152
- params[:limit] = limit
539
+ if key.nil?
540
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
153
541
  end
154
542
 
155
- if !offset.nil?
156
- params[:offset] = offset
543
+ if size.nil?
544
+ raise Appwrite::Exception.new('Missing required parameter: "size"')
157
545
  end
158
546
 
159
- if !order_field.nil?
160
- params[:orderField] = order_field
547
+ if required.nil?
548
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
161
549
  end
162
550
 
163
- if !order_type.nil?
164
- params[:orderType] = order_type
551
+ path = '/database/collections/{collectionId}/attributes/string'
552
+ .gsub('{collectionId}', collection_id)
553
+
554
+ params = {
555
+ key: key,
556
+ size: size,
557
+ required: required,
558
+ default: default,
559
+ array: array,
560
+ }
561
+
562
+ headers = {
563
+ "content-type": 'application/json',
564
+ }
565
+
566
+ @client.call(
567
+ method: 'POST',
568
+ path: path,
569
+ headers: headers,
570
+ params: params,
571
+ response_type: Models::AttributeString
572
+ )
573
+ end
574
+
575
+ # Create a URL attribute.
576
+ #
577
+ #
578
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
579
+ # @param [string] key Attribute Key.
580
+ # @param [boolean] required Is attribute required?
581
+ # @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
582
+ # @param [boolean] array Is attribute an array?
583
+ #
584
+ # @return [AttributeUrl]
585
+ def create_url_attribute(collection_id:, key:, required:, default: nil, array: nil)
586
+ if collection_id.nil?
587
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
165
588
  end
166
589
 
167
- if !order_cast.nil?
168
- params[:orderCast] = order_cast
590
+ if key.nil?
591
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
169
592
  end
170
593
 
171
- if !search.nil?
172
- params[:search] = search
594
+ if required.nil?
595
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
173
596
  end
174
597
 
175
- return @client.call('get', path, {
176
- 'content-type' => 'application/json',
177
- }, params);
598
+ path = '/database/collections/{collectionId}/attributes/url'
599
+ .gsub('{collectionId}', collection_id)
600
+
601
+ params = {
602
+ key: key,
603
+ required: required,
604
+ default: default,
605
+ array: array,
606
+ }
607
+
608
+ headers = {
609
+ "content-type": 'application/json',
610
+ }
611
+
612
+ @client.call(
613
+ method: 'POST',
614
+ path: path,
615
+ headers: headers,
616
+ params: params,
617
+ response_type: Models::AttributeUrl
618
+ )
178
619
  end
179
620
 
180
- def create_document(collection_id:, data:, read: nil, write: nil, parent_document: nil, parent_property: nil, parent_property_type: nil)
621
+ #
622
+ #
623
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
624
+ # @param [string] key Attribute Key.
625
+ #
626
+ # @return []
627
+ def get_attribute(collection_id:, key:)
181
628
  if collection_id.nil?
182
629
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
183
630
  end
184
631
 
185
- if data.nil?
186
- raise Appwrite::Exception.new('Missing required parameter: "data"')
632
+ if key.nil?
633
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
187
634
  end
188
635
 
189
- path = '/database/collections/{collectionId}/documents'
636
+ path = '/database/collections/{collectionId}/attributes/{key}'
190
637
  .gsub('{collectionId}', collection_id)
638
+ .gsub('{key}', key)
191
639
 
192
- params = {}
640
+ params = {
641
+ }
642
+
643
+ headers = {
644
+ "content-type": 'application/json',
645
+ }
646
+
647
+ @client.call(
648
+ method: 'GET',
649
+ path: path,
650
+ headers: headers,
651
+ params: params,
652
+ )
653
+ end
193
654
 
194
- if !data.nil?
195
- params[:data] = data
655
+ #
656
+ #
657
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
658
+ # @param [string] key Attribute Key.
659
+ #
660
+ # @return []
661
+ def delete_attribute(collection_id:, key:)
662
+ if collection_id.nil?
663
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
196
664
  end
197
665
 
198
- if !read.nil?
199
- params[:read] = read
666
+ if key.nil?
667
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
200
668
  end
201
669
 
202
- if !write.nil?
203
- params[:write] = write
670
+ path = '/database/collections/{collectionId}/attributes/{key}'
671
+ .gsub('{collectionId}', collection_id)
672
+ .gsub('{key}', key)
673
+
674
+ params = {
675
+ }
676
+
677
+ headers = {
678
+ "content-type": 'application/json',
679
+ }
680
+
681
+ @client.call(
682
+ method: 'DELETE',
683
+ path: path,
684
+ headers: headers,
685
+ params: params,
686
+ )
687
+ end
688
+
689
+ # Get a list of all the user documents. You can use the query params to
690
+ # filter your results. On admin mode, this endpoint will return a list of all
691
+ # of the project's documents. [Learn more about different API
692
+ # modes](/docs/admin).
693
+ #
694
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
695
+ # @param [array] queries Array of query strings.
696
+ # @param [number] limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
697
+ # @param [number] offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
698
+ # @param [string] cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
699
+ # @param [string] cursor_direction Direction of the cursor.
700
+ # @param [array] order_attributes Array of attributes used to sort results.
701
+ # @param [array] order_types Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order.
702
+ #
703
+ # @return [DocumentList]
704
+ def list_documents(collection_id:, queries: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_attributes: nil, order_types: nil)
705
+ if collection_id.nil?
706
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
204
707
  end
205
708
 
206
- if !parent_document.nil?
207
- params[:parentDocument] = parent_document
709
+ path = '/database/collections/{collectionId}/documents'
710
+ .gsub('{collectionId}', collection_id)
711
+
712
+ params = {
713
+ queries: queries,
714
+ limit: limit,
715
+ offset: offset,
716
+ cursor: cursor,
717
+ cursorDirection: cursor_direction,
718
+ orderAttributes: order_attributes,
719
+ orderTypes: order_types,
720
+ }
721
+
722
+ headers = {
723
+ "content-type": 'application/json',
724
+ }
725
+
726
+ @client.call(
727
+ method: 'GET',
728
+ path: path,
729
+ headers: headers,
730
+ params: params,
731
+ response_type: Models::DocumentList
732
+ )
733
+ end
734
+
735
+ # Create a new Document. Before using this route, you should create a new
736
+ # collection resource using either a [server
737
+ # integration](/docs/server/database#databaseCreateCollection) API or
738
+ # directly from your database console.
739
+ #
740
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). Make sure to define attributes before creating documents.
741
+ # @param [string] document_id Document ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
742
+ # @param [object] data Document data as JSON object.
743
+ # @param [array] read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
744
+ # @param [array] write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
745
+ #
746
+ # @return [Document]
747
+ def create_document(collection_id:, document_id:, data:, read: nil, write: nil)
748
+ if collection_id.nil?
749
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
208
750
  end
209
751
 
210
- if !parent_property.nil?
211
- params[:parentProperty] = parent_property
752
+ if document_id.nil?
753
+ raise Appwrite::Exception.new('Missing required parameter: "documentId"')
212
754
  end
213
755
 
214
- if !parent_property_type.nil?
215
- params[:parentPropertyType] = parent_property_type
756
+ if data.nil?
757
+ raise Appwrite::Exception.new('Missing required parameter: "data"')
216
758
  end
217
759
 
218
- return @client.call('post', path, {
219
- 'content-type' => 'application/json',
220
- }, params);
760
+ path = '/database/collections/{collectionId}/documents'
761
+ .gsub('{collectionId}', collection_id)
762
+
763
+ params = {
764
+ documentId: document_id,
765
+ data: data,
766
+ read: read,
767
+ write: write,
768
+ }
769
+
770
+ headers = {
771
+ "content-type": 'application/json',
772
+ }
773
+
774
+ @client.call(
775
+ method: 'POST',
776
+ path: path,
777
+ headers: headers,
778
+ params: params,
779
+ response_type: Models::Document
780
+ )
221
781
  end
222
782
 
783
+ # Get a document by its unique ID. This endpoint response returns a JSON
784
+ # object with the document data.
785
+ #
786
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
787
+ # @param [string] document_id Document ID.
788
+ #
789
+ # @return [Document]
223
790
  def get_document(collection_id:, document_id:)
224
791
  if collection_id.nil?
225
792
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
@@ -233,13 +800,32 @@ module Appwrite
233
800
  .gsub('{collectionId}', collection_id)
234
801
  .gsub('{documentId}', document_id)
235
802
 
236
- params = {}
803
+ params = {
804
+ }
805
+
806
+ headers = {
807
+ "content-type": 'application/json',
808
+ }
237
809
 
238
- return @client.call('get', path, {
239
- 'content-type' => 'application/json',
240
- }, params);
810
+ @client.call(
811
+ method: 'GET',
812
+ path: path,
813
+ headers: headers,
814
+ params: params,
815
+ response_type: Models::Document
816
+ )
241
817
  end
242
818
 
819
+ # Update a document by its unique ID. Using the patch method you can pass
820
+ # only specific fields that will get updated.
821
+ #
822
+ # @param [string] collection_id Collection ID.
823
+ # @param [string] document_id Document ID.
824
+ # @param [object] data Document data as JSON object.
825
+ # @param [array] read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
826
+ # @param [array] write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
827
+ #
828
+ # @return [Document]
243
829
  def update_document(collection_id:, document_id:, data:, read: nil, write: nil)
244
830
  if collection_id.nil?
245
831
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
@@ -257,48 +843,207 @@ module Appwrite
257
843
  .gsub('{collectionId}', collection_id)
258
844
  .gsub('{documentId}', document_id)
259
845
 
260
- params = {}
846
+ params = {
847
+ data: data,
848
+ read: read,
849
+ write: write,
850
+ }
851
+
852
+ headers = {
853
+ "content-type": 'application/json',
854
+ }
855
+
856
+ @client.call(
857
+ method: 'PATCH',
858
+ path: path,
859
+ headers: headers,
860
+ params: params,
861
+ response_type: Models::Document
862
+ )
863
+ end
261
864
 
262
- if !data.nil?
263
- params[:data] = data
865
+ # Delete a document by its unique ID. This endpoint deletes only the parent
866
+ # documents, its attributes and relations to other documents. Child documents
867
+ # **will not** be deleted.
868
+ #
869
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
870
+ # @param [string] document_id Document ID.
871
+ #
872
+ # @return []
873
+ def delete_document(collection_id:, document_id:)
874
+ if collection_id.nil?
875
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
264
876
  end
265
877
 
266
- if !read.nil?
267
- params[:read] = read
878
+ if document_id.nil?
879
+ raise Appwrite::Exception.new('Missing required parameter: "documentId"')
268
880
  end
269
881
 
270
- if !write.nil?
271
- params[:write] = write
882
+ path = '/database/collections/{collectionId}/documents/{documentId}'
883
+ .gsub('{collectionId}', collection_id)
884
+ .gsub('{documentId}', document_id)
885
+
886
+ params = {
887
+ }
888
+
889
+ headers = {
890
+ "content-type": 'application/json',
891
+ }
892
+
893
+ @client.call(
894
+ method: 'DELETE',
895
+ path: path,
896
+ headers: headers,
897
+ params: params,
898
+ )
899
+ end
900
+
901
+ #
902
+ #
903
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
904
+ #
905
+ # @return [IndexList]
906
+ def list_indexes(collection_id:)
907
+ if collection_id.nil?
908
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
272
909
  end
273
910
 
274
- return @client.call('patch', path, {
275
- 'content-type' => 'application/json',
276
- }, params);
911
+ path = '/database/collections/{collectionId}/indexes'
912
+ .gsub('{collectionId}', collection_id)
913
+
914
+ params = {
915
+ }
916
+
917
+ headers = {
918
+ "content-type": 'application/json',
919
+ }
920
+
921
+ @client.call(
922
+ method: 'GET',
923
+ path: path,
924
+ headers: headers,
925
+ params: params,
926
+ response_type: Models::IndexList
927
+ )
277
928
  end
278
929
 
279
- def delete_document(collection_id:, document_id:)
930
+ #
931
+ #
932
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
933
+ # @param [string] key Index Key.
934
+ # @param [string] type Index type.
935
+ # @param [array] attributes Array of attributes to index.
936
+ # @param [array] orders Array of index orders.
937
+ #
938
+ # @return [Index]
939
+ def create_index(collection_id:, key:, type:, attributes:, orders: nil)
280
940
  if collection_id.nil?
281
941
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
282
942
  end
283
943
 
284
- if document_id.nil?
285
- raise Appwrite::Exception.new('Missing required parameter: "documentId"')
944
+ if key.nil?
945
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
286
946
  end
287
947
 
288
- path = '/database/collections/{collectionId}/documents/{documentId}'
948
+ if type.nil?
949
+ raise Appwrite::Exception.new('Missing required parameter: "type"')
950
+ end
951
+
952
+ if attributes.nil?
953
+ raise Appwrite::Exception.new('Missing required parameter: "attributes"')
954
+ end
955
+
956
+ path = '/database/collections/{collectionId}/indexes'
289
957
  .gsub('{collectionId}', collection_id)
290
- .gsub('{documentId}', document_id)
291
958
 
292
- params = {}
959
+ params = {
960
+ key: key,
961
+ type: type,
962
+ attributes: attributes,
963
+ orders: orders,
964
+ }
965
+
966
+ headers = {
967
+ "content-type": 'application/json',
968
+ }
969
+
970
+ @client.call(
971
+ method: 'POST',
972
+ path: path,
973
+ headers: headers,
974
+ params: params,
975
+ response_type: Models::Index
976
+ )
977
+ end
978
+
979
+ #
980
+ #
981
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
982
+ # @param [string] key Index Key.
983
+ #
984
+ # @return [Index]
985
+ def get_index(collection_id:, key:)
986
+ if collection_id.nil?
987
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
988
+ end
989
+
990
+ if key.nil?
991
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
992
+ end
293
993
 
294
- return @client.call('delete', path, {
295
- 'content-type' => 'application/json',
296
- }, params);
994
+ path = '/database/collections/{collectionId}/indexes/{key}'
995
+ .gsub('{collectionId}', collection_id)
996
+ .gsub('{key}', key)
997
+
998
+ params = {
999
+ }
1000
+
1001
+ headers = {
1002
+ "content-type": 'application/json',
1003
+ }
1004
+
1005
+ @client.call(
1006
+ method: 'GET',
1007
+ path: path,
1008
+ headers: headers,
1009
+ params: params,
1010
+ response_type: Models::Index
1011
+ )
297
1012
  end
298
1013
 
1014
+ #
1015
+ #
1016
+ # @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
1017
+ # @param [string] key Index Key.
1018
+ #
1019
+ # @return []
1020
+ def delete_index(collection_id:, key:)
1021
+ if collection_id.nil?
1022
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
1023
+ end
1024
+
1025
+ if key.nil?
1026
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1027
+ end
299
1028
 
300
- protected
1029
+ path = '/database/collections/{collectionId}/indexes/{key}'
1030
+ .gsub('{collectionId}', collection_id)
1031
+ .gsub('{key}', key)
1032
+
1033
+ params = {
1034
+ }
1035
+
1036
+ headers = {
1037
+ "content-type": 'application/json',
1038
+ }
1039
+
1040
+ @client.call(
1041
+ method: 'DELETE',
1042
+ path: path,
1043
+ headers: headers,
1044
+ params: params,
1045
+ )
1046
+ end
301
1047
 
302
- private
303
1048
  end
304
1049
  end