appwrite 2.4.0 → 4.0.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.
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,33 +1,63 @@
1
+ #frozen_string_literal: true
2
+
1
3
  module Appwrite
2
4
  class Functions < Service
3
5
 
4
- def list(search: nil, limit: nil, offset: nil, order_type: nil)
6
+ # Get a list of all the project's functions. You can use the query params to
7
+ # filter your results.
8
+ #
9
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
10
+ # @param [number] limit Maximum number of functions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
11
+ # @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)
12
+ # @param [string] cursor ID of the function used as the starting point for the query, excluding the function itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
13
+ # @param [string] cursor_direction Direction of the cursor.
14
+ # @param [string] order_type Order result by ASC or DESC order.
15
+ #
16
+ # @return [FunctionList]
17
+ def list(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
5
18
  path = '/functions'
6
19
 
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
20
+ params = {
21
+ search: search,
22
+ limit: limit,
23
+ offset: offset,
24
+ cursor: cursor,
25
+ cursorDirection: cursor_direction,
26
+ orderType: order_type,
27
+ }
28
+
29
+ headers = {
30
+ "content-type": 'application/json',
31
+ }
32
+
33
+ @client.call(
34
+ method: 'GET',
35
+ path: path,
36
+ headers: headers,
37
+ params: params,
38
+ response_type: Models::FunctionList
39
+ )
40
+ end
20
41
 
21
- if !order_type.nil?
22
- params[:orderType] = order_type
42
+ # Create a new function. You can pass a list of
43
+ # [permissions](/docs/permissions) to allow different project users or team
44
+ # with access to execute the function using the client API.
45
+ #
46
+ # @param [string] function_id Function 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 Function name. Max length: 128 chars.
48
+ # @param [array] execute An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
49
+ # @param [string] runtime Execution runtime.
50
+ # @param [object] vars Key-value JSON object that will be passed to the function as environment variables.
51
+ # @param [array] events Events list.
52
+ # @param [string] schedule Schedule CRON syntax.
53
+ # @param [number] timeout Function maximum execution time in seconds.
54
+ #
55
+ # @return [Function]
56
+ def create(function_id:, name:, execute:, runtime:, vars: nil, events: nil, schedule: nil, timeout: nil)
57
+ if function_id.nil?
58
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
23
59
  end
24
60
 
25
- return @client.call('get', path, {
26
- 'content-type' => 'application/json',
27
- }, params);
28
- end
29
-
30
- def create(name:, execute:, runtime:, vars: nil, events: nil, schedule: nil, timeout: nil)
31
61
  if name.nil?
32
62
  raise Appwrite::Exception.new('Missing required parameter: "name"')
33
63
  end
@@ -42,41 +72,58 @@ module Appwrite
42
72
 
43
73
  path = '/functions'
44
74
 
45
- params = {}
46
-
47
- if !name.nil?
48
- params[:name] = name
49
- end
50
-
51
- if !execute.nil?
52
- params[:execute] = execute
53
- end
54
-
55
- if !runtime.nil?
56
- params[:runtime] = runtime
57
- end
58
-
59
- if !vars.nil?
60
- params[:vars] = vars
61
- end
62
-
63
- if !events.nil?
64
- params[:events] = events
65
- end
66
-
67
- if !schedule.nil?
68
- params[:schedule] = schedule
69
- end
70
-
71
- if !timeout.nil?
72
- params[:timeout] = timeout
73
- end
75
+ params = {
76
+ functionId: function_id,
77
+ name: name,
78
+ execute: execute,
79
+ runtime: runtime,
80
+ vars: vars,
81
+ events: events,
82
+ schedule: schedule,
83
+ timeout: timeout,
84
+ }
85
+
86
+ headers = {
87
+ "content-type": 'application/json',
88
+ }
89
+
90
+ @client.call(
91
+ method: 'POST',
92
+ path: path,
93
+ headers: headers,
94
+ params: params,
95
+ response_type: Models::Function
96
+ )
97
+ end
74
98
 
75
- return @client.call('post', path, {
76
- 'content-type' => 'application/json',
77
- }, params);
99
+ # Get a list of all runtimes that are currently active in your project.
100
+ #
101
+ #
102
+ # @return [RuntimeList]
103
+ def list_runtimes()
104
+ path = '/functions/runtimes'
105
+
106
+ params = {
107
+ }
108
+
109
+ headers = {
110
+ "content-type": 'application/json',
111
+ }
112
+
113
+ @client.call(
114
+ method: 'GET',
115
+ path: path,
116
+ headers: headers,
117
+ params: params,
118
+ response_type: Models::RuntimeList
119
+ )
78
120
  end
79
121
 
122
+ # Get a function by its unique ID.
123
+ #
124
+ # @param [string] function_id Function ID.
125
+ #
126
+ # @return [Function]
80
127
  def get(function_id:)
81
128
  if function_id.nil?
82
129
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -85,13 +132,33 @@ module Appwrite
85
132
  path = '/functions/{functionId}'
86
133
  .gsub('{functionId}', function_id)
87
134
 
88
- params = {}
135
+ params = {
136
+ }
89
137
 
90
- return @client.call('get', path, {
91
- 'content-type' => 'application/json',
92
- }, params);
138
+ headers = {
139
+ "content-type": 'application/json',
140
+ }
141
+
142
+ @client.call(
143
+ method: 'GET',
144
+ path: path,
145
+ headers: headers,
146
+ params: params,
147
+ response_type: Models::Function
148
+ )
93
149
  end
94
150
 
151
+ # Update function by its unique ID.
152
+ #
153
+ # @param [string] function_id Function ID.
154
+ # @param [string] name Function name. Max length: 128 chars.
155
+ # @param [array] execute An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
156
+ # @param [object] vars Key-value JSON object that will be passed to the function as environment variables.
157
+ # @param [array] events Events list.
158
+ # @param [string] schedule Schedule CRON syntax.
159
+ # @param [number] timeout Maximum execution time in seconds.
160
+ #
161
+ # @return [Function]
95
162
  def update(function_id:, name:, execute:, vars: nil, events: nil, schedule: nil, timeout: nil)
96
163
  if function_id.nil?
97
164
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -108,37 +175,33 @@ module Appwrite
108
175
  path = '/functions/{functionId}'
109
176
  .gsub('{functionId}', function_id)
110
177
 
111
- params = {}
112
-
113
- if !name.nil?
114
- params[:name] = name
115
- end
116
-
117
- if !execute.nil?
118
- params[:execute] = execute
119
- end
120
-
121
- if !vars.nil?
122
- params[:vars] = vars
123
- end
124
-
125
- if !events.nil?
126
- params[:events] = events
127
- end
128
-
129
- if !schedule.nil?
130
- params[:schedule] = schedule
131
- end
132
-
133
- if !timeout.nil?
134
- params[:timeout] = timeout
135
- end
136
-
137
- return @client.call('put', path, {
138
- 'content-type' => 'application/json',
139
- }, params);
178
+ params = {
179
+ name: name,
180
+ execute: execute,
181
+ vars: vars,
182
+ events: events,
183
+ schedule: schedule,
184
+ timeout: timeout,
185
+ }
186
+
187
+ headers = {
188
+ "content-type": 'application/json',
189
+ }
190
+
191
+ @client.call(
192
+ method: 'PUT',
193
+ path: path,
194
+ headers: headers,
195
+ params: params,
196
+ response_type: Models::Function
197
+ )
140
198
  end
141
199
 
200
+ # Delete a function by its unique ID.
201
+ #
202
+ # @param [string] function_id Function ID.
203
+ #
204
+ # @return []
142
205
  def delete(function_id:)
143
206
  if function_id.nil?
144
207
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -147,211 +210,380 @@ module Appwrite
147
210
  path = '/functions/{functionId}'
148
211
  .gsub('{functionId}', function_id)
149
212
 
150
- params = {}
213
+ params = {
214
+ }
215
+
216
+ headers = {
217
+ "content-type": 'application/json',
218
+ }
151
219
 
152
- return @client.call('delete', path, {
153
- 'content-type' => 'application/json',
154
- }, params);
220
+ @client.call(
221
+ method: 'DELETE',
222
+ path: path,
223
+ headers: headers,
224
+ params: params,
225
+ )
155
226
  end
156
227
 
157
- def list_executions(function_id:, search: nil, limit: nil, offset: nil, order_type: nil)
228
+ # Get a list of all the project's code deployments. You can use the query
229
+ # params to filter your results.
230
+ #
231
+ # @param [string] function_id Function ID.
232
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
233
+ # @param [number] limit Maximum number of deployments to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
234
+ # @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)
235
+ # @param [string] cursor ID of the deployment used as the starting point for the query, excluding the deployment itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
236
+ # @param [string] cursor_direction Direction of the cursor.
237
+ # @param [string] order_type Order result by ASC or DESC order.
238
+ #
239
+ # @return [DeploymentList]
240
+ def list_deployments(function_id:, search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
158
241
  if function_id.nil?
159
242
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
160
243
  end
161
244
 
162
- path = '/functions/{functionId}/executions'
245
+ path = '/functions/{functionId}/deployments'
163
246
  .gsub('{functionId}', function_id)
164
247
 
165
- params = {}
248
+ params = {
249
+ search: search,
250
+ limit: limit,
251
+ offset: offset,
252
+ cursor: cursor,
253
+ cursorDirection: cursor_direction,
254
+ orderType: order_type,
255
+ }
256
+
257
+ headers = {
258
+ "content-type": 'application/json',
259
+ }
260
+
261
+ @client.call(
262
+ method: 'GET',
263
+ path: path,
264
+ headers: headers,
265
+ params: params,
266
+ response_type: Models::DeploymentList
267
+ )
268
+ end
166
269
 
167
- if !search.nil?
168
- params[:search] = search
270
+ # Create a new function code deployment. Use this endpoint to upload a new
271
+ # version of your code function. To execute your newly uploaded code, you'll
272
+ # need to update the function's deployment to use your new deployment UID.
273
+ #
274
+ # This endpoint accepts a tar.gz file compressed with your code. Make sure to
275
+ # include any dependencies your code has within the compressed file. You can
276
+ # learn more about code packaging in the [Appwrite Cloud Functions
277
+ # tutorial](/docs/functions).
278
+ #
279
+ # Use the "command" param to set the entry point used to execute your code.
280
+ #
281
+ # @param [string] function_id Function ID.
282
+ # @param [string] entrypoint Entrypoint File.
283
+ # @param [file] code Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.
284
+ # @param [boolean] activate Automatically activate the deployment when it is finished building.
285
+ #
286
+ # @return [Deployment]
287
+ def create_deployment(function_id:, entrypoint:, code:, activate:, on_progress: nil)
288
+ if function_id.nil?
289
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
169
290
  end
170
291
 
171
- if !limit.nil?
172
- params[:limit] = limit
292
+ if entrypoint.nil?
293
+ raise Appwrite::Exception.new('Missing required parameter: "entrypoint"')
173
294
  end
174
295
 
175
- if !offset.nil?
176
- params[:offset] = offset
296
+ if code.nil?
297
+ raise Appwrite::Exception.new('Missing required parameter: "code"')
177
298
  end
178
299
 
179
- if !order_type.nil?
180
- params[:orderType] = order_type
300
+ if activate.nil?
301
+ raise Appwrite::Exception.new('Missing required parameter: "activate"')
181
302
  end
182
303
 
183
- return @client.call('get', path, {
184
- 'content-type' => 'application/json',
185
- }, params);
304
+ path = '/functions/{functionId}/deployments'
305
+ .gsub('{functionId}', function_id)
306
+
307
+ params = {
308
+ entrypoint: entrypoint,
309
+ code: code,
310
+ activate: activate,
311
+ }
312
+
313
+ headers = {
314
+ "content-type": 'multipart/form-data',
315
+ }
316
+
317
+ param_name = 'code'
318
+
319
+ @client.chunked_upload(
320
+ path: path,
321
+ headers: headers,
322
+ params: params,
323
+ param_name: param_name,
324
+ on_progress: on_progress,
325
+ response_type: Models::Deployment
326
+ )
186
327
  end
187
328
 
188
- def create_execution(function_id:, data: nil)
329
+ # Get a code deployment by its unique ID.
330
+ #
331
+ # @param [string] function_id Function ID.
332
+ # @param [string] deployment_id Deployment ID.
333
+ #
334
+ # @return [DeploymentList]
335
+ def get_deployment(function_id:, deployment_id:)
189
336
  if function_id.nil?
190
337
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
191
338
  end
192
339
 
193
- path = '/functions/{functionId}/executions'
194
- .gsub('{functionId}', function_id)
195
-
196
- params = {}
197
-
198
- if !data.nil?
199
- params[:data] = data
340
+ if deployment_id.nil?
341
+ raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
200
342
  end
201
343
 
202
- return @client.call('post', path, {
203
- 'content-type' => 'application/json',
204
- }, params);
344
+ path = '/functions/{functionId}/deployments/{deploymentId}'
345
+ .gsub('{functionId}', function_id)
346
+ .gsub('{deploymentId}', deployment_id)
347
+
348
+ params = {
349
+ }
350
+
351
+ headers = {
352
+ "content-type": 'application/json',
353
+ }
354
+
355
+ @client.call(
356
+ method: 'GET',
357
+ path: path,
358
+ headers: headers,
359
+ params: params,
360
+ response_type: Models::DeploymentList
361
+ )
205
362
  end
206
363
 
207
- def get_execution(function_id:, execution_id:)
364
+ # Update the function code deployment ID using the unique function ID. Use
365
+ # this endpoint to switch the code deployment that should be executed by the
366
+ # execution endpoint.
367
+ #
368
+ # @param [string] function_id Function ID.
369
+ # @param [string] deployment_id Deployment ID.
370
+ #
371
+ # @return [Function]
372
+ def update_deployment(function_id:, deployment_id:)
208
373
  if function_id.nil?
209
374
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
210
375
  end
211
376
 
212
- if execution_id.nil?
213
- raise Appwrite::Exception.new('Missing required parameter: "executionId"')
377
+ if deployment_id.nil?
378
+ raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
214
379
  end
215
380
 
216
- path = '/functions/{functionId}/executions/{executionId}'
381
+ path = '/functions/{functionId}/deployments/{deploymentId}'
217
382
  .gsub('{functionId}', function_id)
218
- .gsub('{executionId}', execution_id)
219
-
220
- params = {}
221
-
222
- return @client.call('get', path, {
223
- 'content-type' => 'application/json',
224
- }, params);
383
+ .gsub('{deploymentId}', deployment_id)
384
+
385
+ params = {
386
+ }
387
+
388
+ headers = {
389
+ "content-type": 'application/json',
390
+ }
391
+
392
+ @client.call(
393
+ method: 'PATCH',
394
+ path: path,
395
+ headers: headers,
396
+ params: params,
397
+ response_type: Models::Function
398
+ )
225
399
  end
226
400
 
227
- def update_tag(function_id:, tag:)
401
+ # Delete a code deployment by its unique ID.
402
+ #
403
+ # @param [string] function_id Function ID.
404
+ # @param [string] deployment_id Deployment ID.
405
+ #
406
+ # @return []
407
+ def delete_deployment(function_id:, deployment_id:)
228
408
  if function_id.nil?
229
409
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
230
410
  end
231
411
 
232
- if tag.nil?
233
- raise Appwrite::Exception.new('Missing required parameter: "tag"')
412
+ if deployment_id.nil?
413
+ raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
234
414
  end
235
415
 
236
- path = '/functions/{functionId}/tag'
416
+ path = '/functions/{functionId}/deployments/{deploymentId}'
237
417
  .gsub('{functionId}', function_id)
418
+ .gsub('{deploymentId}', deployment_id)
238
419
 
239
- params = {}
420
+ params = {
421
+ }
240
422
 
241
- if !tag.nil?
242
- params[:tag] = tag
243
- end
423
+ headers = {
424
+ "content-type": 'application/json',
425
+ }
244
426
 
245
- return @client.call('patch', path, {
246
- 'content-type' => 'application/json',
247
- }, params);
427
+ @client.call(
428
+ method: 'DELETE',
429
+ path: path,
430
+ headers: headers,
431
+ params: params,
432
+ )
248
433
  end
249
434
 
250
- def list_tags(function_id:, search: nil, limit: nil, offset: nil, order_type: nil)
435
+ #
436
+ #
437
+ # @param [string] function_id Function ID.
438
+ # @param [string] deployment_id Deployment ID.
439
+ # @param [string] build_id Build unique ID.
440
+ #
441
+ # @return []
442
+ def retry_build(function_id:, deployment_id:, build_id:)
251
443
  if function_id.nil?
252
444
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
253
445
  end
254
446
 
255
- path = '/functions/{functionId}/tags'
256
- .gsub('{functionId}', function_id)
257
-
258
- params = {}
259
-
260
- if !search.nil?
261
- params[:search] = search
262
- end
263
-
264
- if !limit.nil?
265
- params[:limit] = limit
266
- end
267
-
268
- if !offset.nil?
269
- params[:offset] = offset
447
+ if deployment_id.nil?
448
+ raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
270
449
  end
271
450
 
272
- if !order_type.nil?
273
- params[:orderType] = order_type
451
+ if build_id.nil?
452
+ raise Appwrite::Exception.new('Missing required parameter: "buildId"')
274
453
  end
275
454
 
276
- return @client.call('get', path, {
277
- 'content-type' => 'application/json',
278
- }, params);
455
+ path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'
456
+ .gsub('{functionId}', function_id)
457
+ .gsub('{deploymentId}', deployment_id)
458
+ .gsub('{buildId}', build_id)
459
+
460
+ params = {
461
+ }
462
+
463
+ headers = {
464
+ "content-type": 'application/json',
465
+ }
466
+
467
+ @client.call(
468
+ method: 'POST',
469
+ path: path,
470
+ headers: headers,
471
+ params: params,
472
+ )
279
473
  end
280
474
 
281
- def create_tag(function_id:, command:, code:)
475
+ # Get a list of all the current user function execution logs. You can use the
476
+ # query params to filter your results. On admin mode, this endpoint will
477
+ # return a list of all of the project's executions. [Learn more about
478
+ # different API modes](/docs/admin).
479
+ #
480
+ # @param [string] function_id Function ID.
481
+ # @param [number] limit Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
482
+ # @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)
483
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
484
+ # @param [string] cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
485
+ # @param [string] cursor_direction Direction of the cursor.
486
+ #
487
+ # @return [ExecutionList]
488
+ def list_executions(function_id:, limit: nil, offset: nil, search: nil, cursor: nil, cursor_direction: nil)
282
489
  if function_id.nil?
283
490
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
284
491
  end
285
492
 
286
- if command.nil?
287
- raise Appwrite::Exception.new('Missing required parameter: "command"')
288
- end
289
-
290
- if code.nil?
291
- raise Appwrite::Exception.new('Missing required parameter: "code"')
292
- end
293
-
294
- path = '/functions/{functionId}/tags'
493
+ path = '/functions/{functionId}/executions'
295
494
  .gsub('{functionId}', function_id)
296
495
 
297
- params = {}
298
-
299
- if !command.nil?
300
- params[:command] = command
301
- end
302
-
303
- if !code.nil?
304
- params[:code] = code
305
- end
306
-
307
- return @client.call('post', path, {
308
- 'content-type' => 'multipart/form-data',
309
- }, params);
496
+ params = {
497
+ limit: limit,
498
+ offset: offset,
499
+ search: search,
500
+ cursor: cursor,
501
+ cursorDirection: cursor_direction,
502
+ }
503
+
504
+ headers = {
505
+ "content-type": 'application/json',
506
+ }
507
+
508
+ @client.call(
509
+ method: 'GET',
510
+ path: path,
511
+ headers: headers,
512
+ params: params,
513
+ response_type: Models::ExecutionList
514
+ )
310
515
  end
311
516
 
312
- def get_tag(function_id:, tag_id:)
517
+ # Trigger a function execution. The returned object will return you the
518
+ # current execution status. You can ping the `Get Execution` endpoint to get
519
+ # updates on the current execution status. Once this endpoint is called, your
520
+ # function execution process will start asynchronously.
521
+ #
522
+ # @param [string] function_id Function ID.
523
+ # @param [string] data String of custom data to send to function.
524
+ # @param [boolean] async Execute code asynchronously. Default value is true.
525
+ #
526
+ # @return [Execution]
527
+ def create_execution(function_id:, data: nil, async: nil)
313
528
  if function_id.nil?
314
529
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
315
530
  end
316
531
 
317
- if tag_id.nil?
318
- raise Appwrite::Exception.new('Missing required parameter: "tagId"')
319
- end
320
-
321
- path = '/functions/{functionId}/tags/{tagId}'
532
+ path = '/functions/{functionId}/executions'
322
533
  .gsub('{functionId}', function_id)
323
- .gsub('{tagId}', tag_id)
324
-
325
- params = {}
326
534
 
327
- return @client.call('get', path, {
328
- 'content-type' => 'application/json',
329
- }, params);
535
+ params = {
536
+ data: data,
537
+ async: async,
538
+ }
539
+
540
+ headers = {
541
+ "content-type": 'application/json',
542
+ }
543
+
544
+ @client.call(
545
+ method: 'POST',
546
+ path: path,
547
+ headers: headers,
548
+ params: params,
549
+ response_type: Models::Execution
550
+ )
330
551
  end
331
552
 
332
- def delete_tag(function_id:, tag_id:)
553
+ # Get a function execution log by its unique ID.
554
+ #
555
+ # @param [string] function_id Function ID.
556
+ # @param [string] execution_id Execution ID.
557
+ #
558
+ # @return [Execution]
559
+ def get_execution(function_id:, execution_id:)
333
560
  if function_id.nil?
334
561
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
335
562
  end
336
563
 
337
- if tag_id.nil?
338
- raise Appwrite::Exception.new('Missing required parameter: "tagId"')
564
+ if execution_id.nil?
565
+ raise Appwrite::Exception.new('Missing required parameter: "executionId"')
339
566
  end
340
567
 
341
- path = '/functions/{functionId}/tags/{tagId}'
568
+ path = '/functions/{functionId}/executions/{executionId}'
342
569
  .gsub('{functionId}', function_id)
343
- .gsub('{tagId}', tag_id)
570
+ .gsub('{executionId}', execution_id)
344
571
 
345
- params = {}
572
+ params = {
573
+ }
346
574
 
347
- return @client.call('delete', path, {
348
- 'content-type' => 'application/json',
349
- }, params);
350
- end
575
+ headers = {
576
+ "content-type": 'application/json',
577
+ }
351
578
 
579
+ @client.call(
580
+ method: 'GET',
581
+ path: path,
582
+ headers: headers,
583
+ params: params,
584
+ response_type: Models::Execution
585
+ )
586
+ end
352
587
 
353
- protected
354
-
355
- private
356
588
  end
357
589
  end