appwrite 2.4.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +134 -57
  3. data/lib/appwrite/exception.rb +5 -7
  4. data/lib/appwrite/file.rb +5 -13
  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/collection.rb +62 -0
  15. data/lib/appwrite/models/collection_list.rb +32 -0
  16. data/lib/appwrite/models/continent.rb +32 -0
  17. data/lib/appwrite/models/continent_list.rb +32 -0
  18. data/lib/appwrite/models/country.rb +32 -0
  19. data/lib/appwrite/models/country_list.rb +32 -0
  20. data/lib/appwrite/models/currency.rb +57 -0
  21. data/lib/appwrite/models/currency_list.rb +32 -0
  22. data/lib/appwrite/models/document.rb +50 -0
  23. data/lib/appwrite/models/document_list.rb +36 -0
  24. data/lib/appwrite/models/execution.rb +72 -0
  25. data/lib/appwrite/models/execution_list.rb +32 -0
  26. data/lib/appwrite/models/file.rb +62 -0
  27. data/lib/appwrite/models/file_list.rb +32 -0
  28. data/lib/appwrite/models/function.rb +92 -0
  29. data/lib/appwrite/models/function_list.rb +32 -0
  30. data/lib/appwrite/models/health_antivirus.rb +32 -0
  31. data/lib/appwrite/models/health_queue.rb +27 -0
  32. data/lib/appwrite/models/health_status.rb +32 -0
  33. data/lib/appwrite/models/health_time.rb +37 -0
  34. data/lib/appwrite/models/index.rb +47 -0
  35. data/lib/appwrite/models/index_list.rb +32 -0
  36. data/lib/appwrite/models/language.rb +37 -0
  37. data/lib/appwrite/models/language_list.rb +32 -0
  38. data/lib/appwrite/models/locale.rb +57 -0
  39. data/lib/appwrite/models/log.rb +127 -0
  40. data/lib/appwrite/models/log_list.rb +32 -0
  41. data/lib/appwrite/models/membership.rb +67 -0
  42. data/lib/appwrite/models/membership_list.rb +32 -0
  43. data/lib/appwrite/models/phone.rb +37 -0
  44. data/lib/appwrite/models/phone_list.rb +32 -0
  45. data/lib/appwrite/models/preferences.rb +30 -0
  46. data/lib/appwrite/models/runtime.rb +57 -0
  47. data/lib/appwrite/models/runtime_list.rb +32 -0
  48. data/lib/appwrite/models/session.rb +132 -0
  49. data/lib/appwrite/models/session_list.rb +32 -0
  50. data/lib/appwrite/models/tag.rb +47 -0
  51. data/lib/appwrite/models/tag_list.rb +32 -0
  52. data/lib/appwrite/models/team.rb +42 -0
  53. data/lib/appwrite/models/team_list.rb +32 -0
  54. data/lib/appwrite/models/token.rb +42 -0
  55. data/lib/appwrite/models/user.rb +62 -0
  56. data/lib/appwrite/models/user_list.rb +32 -0
  57. data/lib/appwrite/query.rb +42 -0
  58. data/lib/appwrite/service.rb +0 -5
  59. data/lib/appwrite/services/account.rb +370 -138
  60. data/lib/appwrite/services/avatars.rb +189 -125
  61. data/lib/appwrite/services/database.rb +876 -130
  62. data/lib/appwrite/services/functions.rb +364 -182
  63. data/lib/appwrite/services/health.rb +202 -58
  64. data/lib/appwrite/services/locale.rb +134 -32
  65. data/lib/appwrite/services/storage.rb +210 -121
  66. data/lib/appwrite/services/teams.rb +299 -118
  67. data/lib/appwrite/services/users.rb +322 -127
  68. data/lib/appwrite.rb +55 -0
  69. metadata +72 -111
  70. data/.github/ISSUE_TEMPLATE/bug.yaml +0 -82
  71. data/.github/ISSUE_TEMPLATE/documentation.yaml +0 -32
  72. data/.github/ISSUE_TEMPLATE/feature.yaml +0 -40
  73. data/.travis.yml +0 -16
  74. data/CHANGELOG.md +0 -1
  75. data/Gemfile +0 -4
  76. data/LICENSE +0 -12
  77. data/README.md +0 -96
  78. data/appwrite.gemspec +0 -11
  79. data/docs/examples/account/create-recovery.md +0 -15
  80. data/docs/examples/account/create-verification.md +0 -15
  81. data/docs/examples/account/delete-session.md +0 -15
  82. data/docs/examples/account/delete-sessions.md +0 -15
  83. data/docs/examples/account/delete.md +0 -15
  84. data/docs/examples/account/get-logs.md +0 -15
  85. data/docs/examples/account/get-prefs.md +0 -15
  86. data/docs/examples/account/get-session.md +0 -15
  87. data/docs/examples/account/get-sessions.md +0 -15
  88. data/docs/examples/account/get.md +0 -15
  89. data/docs/examples/account/update-email.md +0 -15
  90. data/docs/examples/account/update-name.md +0 -15
  91. data/docs/examples/account/update-password.md +0 -15
  92. data/docs/examples/account/update-prefs.md +0 -15
  93. data/docs/examples/account/update-recovery.md +0 -15
  94. data/docs/examples/account/update-verification.md +0 -15
  95. data/docs/examples/avatars/get-browser.md +0 -15
  96. data/docs/examples/avatars/get-credit-card.md +0 -15
  97. data/docs/examples/avatars/get-favicon.md +0 -15
  98. data/docs/examples/avatars/get-flag.md +0 -15
  99. data/docs/examples/avatars/get-image.md +0 -15
  100. data/docs/examples/avatars/get-initials.md +0 -15
  101. data/docs/examples/avatars/get-q-r.md +0 -15
  102. data/docs/examples/database/create-collection.md +0 -15
  103. data/docs/examples/database/create-document.md +0 -15
  104. data/docs/examples/database/delete-collection.md +0 -15
  105. data/docs/examples/database/delete-document.md +0 -15
  106. data/docs/examples/database/get-collection.md +0 -15
  107. data/docs/examples/database/get-document.md +0 -15
  108. data/docs/examples/database/list-collections.md +0 -15
  109. data/docs/examples/database/list-documents.md +0 -15
  110. data/docs/examples/database/update-collection.md +0 -15
  111. data/docs/examples/database/update-document.md +0 -15
  112. data/docs/examples/functions/create-execution.md +0 -15
  113. data/docs/examples/functions/create-tag.md +0 -15
  114. data/docs/examples/functions/create.md +0 -15
  115. data/docs/examples/functions/delete-tag.md +0 -15
  116. data/docs/examples/functions/delete.md +0 -15
  117. data/docs/examples/functions/get-execution.md +0 -15
  118. data/docs/examples/functions/get-tag.md +0 -15
  119. data/docs/examples/functions/get.md +0 -15
  120. data/docs/examples/functions/list-executions.md +0 -15
  121. data/docs/examples/functions/list-tags.md +0 -15
  122. data/docs/examples/functions/list.md +0 -15
  123. data/docs/examples/functions/update-tag.md +0 -15
  124. data/docs/examples/functions/update.md +0 -15
  125. data/docs/examples/health/get-anti-virus.md +0 -15
  126. data/docs/examples/health/get-cache.md +0 -15
  127. data/docs/examples/health/get-d-b.md +0 -15
  128. data/docs/examples/health/get-queue-certificates.md +0 -15
  129. data/docs/examples/health/get-queue-functions.md +0 -15
  130. data/docs/examples/health/get-queue-logs.md +0 -15
  131. data/docs/examples/health/get-queue-tasks.md +0 -15
  132. data/docs/examples/health/get-queue-usage.md +0 -15
  133. data/docs/examples/health/get-queue-webhooks.md +0 -15
  134. data/docs/examples/health/get-storage-local.md +0 -15
  135. data/docs/examples/health/get-time.md +0 -15
  136. data/docs/examples/health/get.md +0 -15
  137. data/docs/examples/locale/get-continents.md +0 -15
  138. data/docs/examples/locale/get-countries-e-u.md +0 -15
  139. data/docs/examples/locale/get-countries-phones.md +0 -15
  140. data/docs/examples/locale/get-countries.md +0 -15
  141. data/docs/examples/locale/get-currencies.md +0 -15
  142. data/docs/examples/locale/get-languages.md +0 -15
  143. data/docs/examples/locale/get.md +0 -15
  144. data/docs/examples/storage/create-file.md +0 -15
  145. data/docs/examples/storage/delete-file.md +0 -15
  146. data/docs/examples/storage/get-file-download.md +0 -15
  147. data/docs/examples/storage/get-file-preview.md +0 -15
  148. data/docs/examples/storage/get-file-view.md +0 -15
  149. data/docs/examples/storage/get-file.md +0 -15
  150. data/docs/examples/storage/list-files.md +0 -15
  151. data/docs/examples/storage/update-file.md +0 -15
  152. data/docs/examples/teams/create-membership.md +0 -15
  153. data/docs/examples/teams/create.md +0 -15
  154. data/docs/examples/teams/delete-membership.md +0 -15
  155. data/docs/examples/teams/delete.md +0 -15
  156. data/docs/examples/teams/get-memberships.md +0 -15
  157. data/docs/examples/teams/get.md +0 -15
  158. data/docs/examples/teams/list.md +0 -15
  159. data/docs/examples/teams/update-membership-roles.md +0 -15
  160. data/docs/examples/teams/update-membership-status.md +0 -15
  161. data/docs/examples/teams/update.md +0 -15
  162. data/docs/examples/users/create.md +0 -15
  163. data/docs/examples/users/delete-session.md +0 -15
  164. data/docs/examples/users/delete-sessions.md +0 -15
  165. data/docs/examples/users/delete.md +0 -15
  166. data/docs/examples/users/get-logs.md +0 -15
  167. data/docs/examples/users/get-prefs.md +0 -15
  168. data/docs/examples/users/get-sessions.md +0 -15
  169. data/docs/examples/users/get.md +0 -15
  170. data/docs/examples/users/list.md +0 -15
  171. data/docs/examples/users/update-email.md +0 -15
  172. data/docs/examples/users/update-name.md +0 -15
  173. data/docs/examples/users/update-password.md +0 -15
  174. data/docs/examples/users/update-prefs.md +0 -15
  175. data/docs/examples/users/update-status.md +0 -15
  176. data/docs/examples/users/update-verification.md +0 -15
@@ -1,33 +1,64 @@
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
+ include Models
7
+ # Get a list of all the project's functions. You can use the query params to
8
+ # filter your results.
9
+ #
10
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
11
+ # @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.
12
+ # @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)
13
+ # @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)
14
+ # @param [string] cursor_direction Direction of the cursor.
15
+ # @param [string] order_type Order result by ASC or DESC order.
16
+ #
17
+ # @return [FunctionList]
18
+ def list(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
5
19
  path = '/functions'
6
20
 
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
21
+ params = {
22
+ search: search,
23
+ limit: limit,
24
+ offset: offset,
25
+ cursor: cursor,
26
+ cursorDirection: cursor_direction,
27
+ orderType: order_type,
28
+ }
29
+
30
+ headers = {
31
+ "content-type": 'application/json',
32
+ }
33
+
34
+ @client.call(
35
+ method: 'GET',
36
+ path: path,
37
+ params: params,
38
+ headers: headers,
39
+ response_type: FunctionList
40
+ )
41
+ end
20
42
 
21
- if !order_type.nil?
22
- params[:orderType] = order_type
43
+ # Create a new function. You can pass a list of
44
+ # [permissions](/docs/permissions) to allow different project users or team
45
+ # with access to execute the function using the client API.
46
+ #
47
+ # @param [string] function_id Function ID. Choose your own unique ID or pass the string `unique()` 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.
48
+ # @param [string] name Function name. Max length: 128 chars.
49
+ # @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.
50
+ # @param [string] runtime Execution runtime.
51
+ # @param [object] vars Key-value JSON object that will be passed to the function as environment variables.
52
+ # @param [array] events Events list.
53
+ # @param [string] schedule Schedule CRON syntax.
54
+ # @param [number] timeout Function maximum execution time in seconds.
55
+ #
56
+ # @return [Function]
57
+ def create(function_id:, name:, execute:, runtime:, vars: nil, events: nil, schedule: nil, timeout: nil)
58
+ if function_id.nil?
59
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
23
60
  end
24
61
 
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
62
  if name.nil?
32
63
  raise Appwrite::Exception.new('Missing required parameter: "name"')
33
64
  end
@@ -42,41 +73,58 @@ module Appwrite
42
73
 
43
74
  path = '/functions'
44
75
 
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
76
+ params = {
77
+ functionId: function_id,
78
+ name: name,
79
+ execute: execute,
80
+ runtime: runtime,
81
+ vars: vars,
82
+ events: events,
83
+ schedule: schedule,
84
+ timeout: timeout,
85
+ }
86
+
87
+ headers = {
88
+ "content-type": 'application/json',
89
+ }
90
+
91
+ @client.call(
92
+ method: 'POST',
93
+ path: path,
94
+ params: params,
95
+ headers: headers,
96
+ response_type: Function
97
+ )
98
+ end
74
99
 
75
- return @client.call('post', path, {
76
- 'content-type' => 'application/json',
77
- }, params);
100
+ # Get a list of all runtimes that are currently active in your project.
101
+ #
102
+ #
103
+ # @return [RuntimeList]
104
+ def list_runtimes()
105
+ path = '/functions/runtimes'
106
+
107
+ params = {
108
+ }
109
+
110
+ headers = {
111
+ "content-type": 'application/json',
112
+ }
113
+
114
+ @client.call(
115
+ method: 'GET',
116
+ path: path,
117
+ params: params,
118
+ headers: headers,
119
+ response_type: RuntimeList
120
+ )
78
121
  end
79
122
 
123
+ # Get a function by its unique ID.
124
+ #
125
+ # @param [string] function_id Function ID.
126
+ #
127
+ # @return [Function]
80
128
  def get(function_id:)
81
129
  if function_id.nil?
82
130
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -85,13 +133,33 @@ module Appwrite
85
133
  path = '/functions/{functionId}'
86
134
  .gsub('{functionId}', function_id)
87
135
 
88
- params = {}
136
+ params = {
137
+ }
89
138
 
90
- return @client.call('get', path, {
91
- 'content-type' => 'application/json',
92
- }, params);
139
+ headers = {
140
+ "content-type": 'application/json',
141
+ }
142
+
143
+ @client.call(
144
+ method: 'GET',
145
+ path: path,
146
+ params: params,
147
+ headers: headers,
148
+ response_type: Function
149
+ )
93
150
  end
94
151
 
152
+ # Update function by its unique ID.
153
+ #
154
+ # @param [string] function_id Function ID.
155
+ # @param [string] name Function name. Max length: 128 chars.
156
+ # @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.
157
+ # @param [object] vars Key-value JSON object that will be passed to the function as environment variables.
158
+ # @param [array] events Events list.
159
+ # @param [string] schedule Schedule CRON syntax.
160
+ # @param [number] timeout Maximum execution time in seconds.
161
+ #
162
+ # @return [Function]
95
163
  def update(function_id:, name:, execute:, vars: nil, events: nil, schedule: nil, timeout: nil)
96
164
  if function_id.nil?
97
165
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -108,37 +176,33 @@ module Appwrite
108
176
  path = '/functions/{functionId}'
109
177
  .gsub('{functionId}', function_id)
110
178
 
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);
179
+ params = {
180
+ name: name,
181
+ execute: execute,
182
+ vars: vars,
183
+ events: events,
184
+ schedule: schedule,
185
+ timeout: timeout,
186
+ }
187
+
188
+ headers = {
189
+ "content-type": 'application/json',
190
+ }
191
+
192
+ @client.call(
193
+ method: 'PUT',
194
+ path: path,
195
+ params: params,
196
+ headers: headers,
197
+ response_type: Function
198
+ )
140
199
  end
141
200
 
201
+ # Delete a function by its unique ID.
202
+ #
203
+ # @param [string] function_id Function ID.
204
+ #
205
+ # @return []
142
206
  def delete(function_id:)
143
207
  if function_id.nil?
144
208
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -147,14 +211,35 @@ module Appwrite
147
211
  path = '/functions/{functionId}'
148
212
  .gsub('{functionId}', function_id)
149
213
 
150
- params = {}
214
+ params = {
215
+ }
151
216
 
152
- return @client.call('delete', path, {
153
- 'content-type' => 'application/json',
154
- }, params);
217
+ headers = {
218
+ "content-type": 'application/json',
219
+ }
220
+
221
+ @client.call(
222
+ method: 'DELETE',
223
+ path: path,
224
+ params: params,
225
+ headers: headers,
226
+ )
155
227
  end
156
228
 
157
- def list_executions(function_id:, search: nil, limit: nil, offset: nil, order_type: nil)
229
+ # Get a list of all the current user function execution logs. You can use the
230
+ # query params to filter your results. On admin mode, this endpoint will
231
+ # return a list of all of the project's executions. [Learn more about
232
+ # different API modes](/docs/admin).
233
+ #
234
+ # @param [string] function_id Function ID.
235
+ # @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.
236
+ # @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)
237
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
238
+ # @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)
239
+ # @param [string] cursor_direction Direction of the cursor.
240
+ #
241
+ # @return [ExecutionList]
242
+ def list_executions(function_id:, limit: nil, offset: nil, search: nil, cursor: nil, cursor_direction: nil)
158
243
  if function_id.nil?
159
244
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
160
245
  end
@@ -162,29 +247,36 @@ module Appwrite
162
247
  path = '/functions/{functionId}/executions'
163
248
  .gsub('{functionId}', function_id)
164
249
 
165
- params = {}
166
-
167
- if !search.nil?
168
- params[:search] = search
169
- end
170
-
171
- if !limit.nil?
172
- params[:limit] = limit
173
- end
174
-
175
- if !offset.nil?
176
- params[:offset] = offset
177
- end
178
-
179
- if !order_type.nil?
180
- params[:orderType] = order_type
181
- end
182
-
183
- return @client.call('get', path, {
184
- 'content-type' => 'application/json',
185
- }, params);
250
+ params = {
251
+ limit: limit,
252
+ offset: offset,
253
+ search: search,
254
+ cursor: cursor,
255
+ cursorDirection: cursor_direction,
256
+ }
257
+
258
+ headers = {
259
+ "content-type": 'application/json',
260
+ }
261
+
262
+ @client.call(
263
+ method: 'GET',
264
+ path: path,
265
+ params: params,
266
+ headers: headers,
267
+ response_type: ExecutionList
268
+ )
186
269
  end
187
270
 
271
+ # Trigger a function execution. The returned object will return you the
272
+ # current execution status. You can ping the `Get Execution` endpoint to get
273
+ # updates on the current execution status. Once this endpoint is called, your
274
+ # function execution process will start asynchronously.
275
+ #
276
+ # @param [string] function_id Function ID.
277
+ # @param [string] data String of custom data to send to function.
278
+ #
279
+ # @return [Execution]
188
280
  def create_execution(function_id:, data: nil)
189
281
  if function_id.nil?
190
282
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -193,17 +285,29 @@ module Appwrite
193
285
  path = '/functions/{functionId}/executions'
194
286
  .gsub('{functionId}', function_id)
195
287
 
196
- params = {}
197
-
198
- if !data.nil?
199
- params[:data] = data
200
- end
201
-
202
- return @client.call('post', path, {
203
- 'content-type' => 'application/json',
204
- }, params);
288
+ params = {
289
+ data: data,
290
+ }
291
+
292
+ headers = {
293
+ "content-type": 'application/json',
294
+ }
295
+
296
+ @client.call(
297
+ method: 'POST',
298
+ path: path,
299
+ params: params,
300
+ headers: headers,
301
+ response_type: Execution
302
+ )
205
303
  end
206
304
 
305
+ # Get a function execution log by its unique ID.
306
+ #
307
+ # @param [string] function_id Function ID.
308
+ # @param [string] execution_id Execution ID.
309
+ #
310
+ # @return [Execution]
207
311
  def get_execution(function_id:, execution_id:)
208
312
  if function_id.nil?
209
313
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -217,13 +321,30 @@ module Appwrite
217
321
  .gsub('{functionId}', function_id)
218
322
  .gsub('{executionId}', execution_id)
219
323
 
220
- params = {}
324
+ params = {
325
+ }
326
+
327
+ headers = {
328
+ "content-type": 'application/json',
329
+ }
221
330
 
222
- return @client.call('get', path, {
223
- 'content-type' => 'application/json',
224
- }, params);
331
+ @client.call(
332
+ method: 'GET',
333
+ path: path,
334
+ params: params,
335
+ headers: headers,
336
+ response_type: Execution
337
+ )
225
338
  end
226
339
 
340
+ # Update the function code tag ID using the unique function ID. Use this
341
+ # endpoint to switch the code tag that should be executed by the execution
342
+ # endpoint.
343
+ #
344
+ # @param [string] function_id Function ID.
345
+ # @param [string] tag Tag ID.
346
+ #
347
+ # @return [Function]
227
348
  def update_tag(function_id:, tag:)
228
349
  if function_id.nil?
229
350
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -236,18 +357,36 @@ module Appwrite
236
357
  path = '/functions/{functionId}/tag'
237
358
  .gsub('{functionId}', function_id)
238
359
 
239
- params = {}
240
-
241
- if !tag.nil?
242
- params[:tag] = tag
243
- end
244
-
245
- return @client.call('patch', path, {
246
- 'content-type' => 'application/json',
247
- }, params);
360
+ params = {
361
+ tag: tag,
362
+ }
363
+
364
+ headers = {
365
+ "content-type": 'application/json',
366
+ }
367
+
368
+ @client.call(
369
+ method: 'PATCH',
370
+ path: path,
371
+ params: params,
372
+ headers: headers,
373
+ response_type: Function
374
+ )
248
375
  end
249
376
 
250
- def list_tags(function_id:, search: nil, limit: nil, offset: nil, order_type: nil)
377
+ # Get a list of all the project's code tags. You can use the query params to
378
+ # filter your results.
379
+ #
380
+ # @param [string] function_id Function ID.
381
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
382
+ # @param [number] limit Maximum number of tags to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
383
+ # @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)
384
+ # @param [string] cursor ID of the tag used as the starting point for the query, excluding the tag itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
385
+ # @param [string] cursor_direction Direction of the cursor.
386
+ # @param [string] order_type Order result by ASC or DESC order.
387
+ #
388
+ # @return [TagList]
389
+ def list_tags(function_id:, search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
251
390
  if function_id.nil?
252
391
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
253
392
  end
@@ -255,29 +394,44 @@ module Appwrite
255
394
  path = '/functions/{functionId}/tags'
256
395
  .gsub('{functionId}', function_id)
257
396
 
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
270
- end
271
-
272
- if !order_type.nil?
273
- params[:orderType] = order_type
274
- end
275
-
276
- return @client.call('get', path, {
277
- 'content-type' => 'application/json',
278
- }, params);
397
+ params = {
398
+ search: search,
399
+ limit: limit,
400
+ offset: offset,
401
+ cursor: cursor,
402
+ cursorDirection: cursor_direction,
403
+ orderType: order_type,
404
+ }
405
+
406
+ headers = {
407
+ "content-type": 'application/json',
408
+ }
409
+
410
+ @client.call(
411
+ method: 'GET',
412
+ path: path,
413
+ params: params,
414
+ headers: headers,
415
+ response_type: TagList
416
+ )
279
417
  end
280
418
 
419
+ # Create a new function code tag. Use this endpoint to upload a new version
420
+ # of your code function. To execute your newly uploaded code, you'll need to
421
+ # update the function's tag to use your new tag UID.
422
+ #
423
+ # This endpoint accepts a tar.gz file compressed with your code. Make sure to
424
+ # include any dependencies your code has within the compressed file. You can
425
+ # learn more about code packaging in the [Appwrite Cloud Functions
426
+ # tutorial](/docs/functions).
427
+ #
428
+ # Use the "command" param to set the entry point used to execute your code.
429
+ #
430
+ # @param [string] function_id Function ID.
431
+ # @param [string] command Code execution command.
432
+ # @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.
433
+ #
434
+ # @return [Tag]
281
435
  def create_tag(function_id:, command:, code:)
282
436
  if function_id.nil?
283
437
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -294,21 +448,30 @@ module Appwrite
294
448
  path = '/functions/{functionId}/tags'
295
449
  .gsub('{functionId}', function_id)
296
450
 
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);
451
+ params = {
452
+ command: command,
453
+ code: code,
454
+ }
455
+
456
+ headers = {
457
+ "content-type": 'multipart/form-data',
458
+ }
459
+
460
+ @client.call(
461
+ method: 'POST',
462
+ path: path,
463
+ params: params,
464
+ headers: headers,
465
+ response_type: Tag
466
+ )
310
467
  end
311
468
 
469
+ # Get a code tag by its unique ID.
470
+ #
471
+ # @param [string] function_id Function ID.
472
+ # @param [string] tag_id Tag ID.
473
+ #
474
+ # @return [Tag]
312
475
  def get_tag(function_id:, tag_id:)
313
476
  if function_id.nil?
314
477
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -322,13 +485,28 @@ module Appwrite
322
485
  .gsub('{functionId}', function_id)
323
486
  .gsub('{tagId}', tag_id)
324
487
 
325
- params = {}
488
+ params = {
489
+ }
326
490
 
327
- return @client.call('get', path, {
328
- 'content-type' => 'application/json',
329
- }, params);
491
+ headers = {
492
+ "content-type": 'application/json',
493
+ }
494
+
495
+ @client.call(
496
+ method: 'GET',
497
+ path: path,
498
+ params: params,
499
+ headers: headers,
500
+ response_type: Tag
501
+ )
330
502
  end
331
503
 
504
+ # Delete a code tag by its unique ID.
505
+ #
506
+ # @param [string] function_id Function ID.
507
+ # @param [string] tag_id Tag ID.
508
+ #
509
+ # @return []
332
510
  def delete_tag(function_id:, tag_id:)
333
511
  if function_id.nil?
334
512
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
@@ -342,16 +520,20 @@ module Appwrite
342
520
  .gsub('{functionId}', function_id)
343
521
  .gsub('{tagId}', tag_id)
344
522
 
345
- params = {}
346
-
347
- return @client.call('delete', path, {
348
- 'content-type' => 'application/json',
349
- }, params);
350
- end
523
+ params = {
524
+ }
351
525
 
526
+ headers = {
527
+ "content-type": 'application/json',
528
+ }
352
529
 
353
- protected
530
+ @client.call(
531
+ method: 'DELETE',
532
+ path: path,
533
+ params: params,
534
+ headers: headers,
535
+ )
536
+ end
354
537
 
355
- private
356
538
  end
357
539
  end