@appwrite.io/console 0.2.0 → 0.4.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 (322) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/sdk.js +3353 -1497
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +3350 -1498
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +3353 -1497
  7. package/docs/examples/account/create-anonymous-session.md +1 -1
  8. package/docs/examples/account/create-email-session.md +1 -1
  9. package/docs/examples/account/create-j-w-t.md +1 -1
  10. package/docs/examples/account/create-magic-u-r-l-session.md +1 -1
  11. package/docs/examples/account/create-o-auth2session.md +1 -1
  12. package/docs/examples/account/create-phone-session.md +1 -1
  13. package/docs/examples/account/create-phone-verification.md +1 -1
  14. package/docs/examples/account/create-recovery.md +1 -1
  15. package/docs/examples/account/create-verification.md +1 -1
  16. package/docs/examples/account/create.md +1 -1
  17. package/docs/examples/account/{create-with-invite-code.md → delete-identity.md} +2 -2
  18. package/docs/examples/account/delete-session.md +1 -1
  19. package/docs/examples/account/delete-sessions.md +1 -1
  20. package/docs/examples/account/get-prefs.md +1 -1
  21. package/docs/examples/account/get-session.md +1 -1
  22. package/docs/examples/account/get.md +1 -1
  23. package/docs/examples/account/list-identities.md +18 -0
  24. package/docs/examples/account/list-logs.md +1 -1
  25. package/docs/examples/account/list-sessions.md +1 -1
  26. package/docs/examples/account/update-email.md +1 -1
  27. package/docs/examples/account/update-magic-u-r-l-session.md +1 -1
  28. package/docs/examples/account/update-name.md +1 -1
  29. package/docs/examples/account/update-password.md +1 -1
  30. package/docs/examples/account/update-phone-session.md +1 -1
  31. package/docs/examples/account/update-phone-verification.md +1 -1
  32. package/docs/examples/account/update-phone.md +1 -1
  33. package/docs/examples/account/update-prefs.md +1 -1
  34. package/docs/examples/account/update-recovery.md +1 -1
  35. package/docs/examples/account/update-session.md +1 -1
  36. package/docs/examples/account/update-status.md +1 -1
  37. package/docs/examples/account/update-verification.md +1 -1
  38. package/docs/examples/assistant/chat.md +18 -0
  39. package/docs/examples/avatars/get-browser.md +1 -1
  40. package/docs/examples/avatars/get-credit-card.md +1 -1
  41. package/docs/examples/avatars/get-favicon.md +1 -1
  42. package/docs/examples/avatars/get-flag.md +1 -1
  43. package/docs/examples/avatars/get-image.md +1 -1
  44. package/docs/examples/avatars/get-initials.md +1 -1
  45. package/docs/examples/avatars/get-q-r.md +1 -1
  46. package/docs/examples/console/variables.md +1 -1
  47. package/docs/examples/databases/create-boolean-attribute.md +1 -1
  48. package/docs/examples/databases/create-collection.md +1 -1
  49. package/docs/examples/databases/create-datetime-attribute.md +1 -1
  50. package/docs/examples/databases/create-document.md +1 -1
  51. package/docs/examples/databases/create-email-attribute.md +1 -1
  52. package/docs/examples/databases/create-enum-attribute.md +1 -1
  53. package/docs/examples/databases/create-float-attribute.md +1 -1
  54. package/docs/examples/databases/create-index.md +1 -1
  55. package/docs/examples/databases/create-integer-attribute.md +1 -1
  56. package/docs/examples/databases/create-ip-attribute.md +1 -1
  57. package/docs/examples/databases/create-relationship-attribute.md +1 -1
  58. package/docs/examples/databases/create-string-attribute.md +1 -1
  59. package/docs/examples/databases/create-url-attribute.md +1 -1
  60. package/docs/examples/databases/create.md +1 -1
  61. package/docs/examples/databases/delete-attribute.md +1 -1
  62. package/docs/examples/databases/delete-collection.md +1 -1
  63. package/docs/examples/databases/delete-document.md +1 -1
  64. package/docs/examples/databases/delete-index.md +1 -1
  65. package/docs/examples/databases/delete.md +1 -1
  66. package/docs/examples/databases/get-attribute.md +1 -1
  67. package/docs/examples/databases/get-collection-usage.md +1 -1
  68. package/docs/examples/databases/get-collection.md +1 -1
  69. package/docs/examples/databases/get-database-usage.md +1 -1
  70. package/docs/examples/databases/get-document.md +1 -1
  71. package/docs/examples/databases/get-index.md +1 -1
  72. package/docs/examples/databases/get-usage.md +1 -1
  73. package/docs/examples/databases/get.md +1 -1
  74. package/docs/examples/databases/list-attributes.md +1 -1
  75. package/docs/examples/databases/list-collection-logs.md +1 -1
  76. package/docs/examples/databases/list-collections.md +1 -1
  77. package/docs/examples/databases/list-document-logs.md +1 -1
  78. package/docs/examples/databases/list-documents.md +1 -1
  79. package/docs/examples/databases/list-indexes.md +1 -1
  80. package/docs/examples/databases/list-logs.md +1 -1
  81. package/docs/examples/databases/list.md +1 -1
  82. package/docs/examples/databases/update-boolean-attribute.md +1 -1
  83. package/docs/examples/databases/update-collection.md +1 -1
  84. package/docs/examples/databases/update-datetime-attribute.md +1 -1
  85. package/docs/examples/databases/update-document.md +1 -1
  86. package/docs/examples/databases/update-email-attribute.md +1 -1
  87. package/docs/examples/databases/update-enum-attribute.md +1 -1
  88. package/docs/examples/databases/update-float-attribute.md +1 -1
  89. package/docs/examples/databases/update-integer-attribute.md +1 -1
  90. package/docs/examples/databases/update-ip-attribute.md +1 -1
  91. package/docs/examples/databases/update-relationship-attribute.md +1 -1
  92. package/docs/examples/databases/update-string-attribute.md +1 -1
  93. package/docs/examples/databases/update-url-attribute.md +1 -1
  94. package/docs/examples/databases/update.md +1 -1
  95. package/docs/examples/functions/create-build.md +1 -1
  96. package/docs/examples/functions/create-deployment.md +2 -2
  97. package/docs/examples/functions/create-execution.md +1 -1
  98. package/docs/examples/functions/create-variable.md +1 -1
  99. package/docs/examples/functions/create.md +2 -2
  100. package/docs/examples/functions/delete-deployment.md +1 -1
  101. package/docs/examples/functions/delete-variable.md +1 -1
  102. package/docs/examples/functions/delete.md +1 -1
  103. package/docs/examples/functions/download-deployment.md +14 -0
  104. package/docs/examples/functions/get-deployment.md +1 -1
  105. package/docs/examples/functions/get-execution.md +1 -1
  106. package/docs/examples/functions/get-function-usage.md +1 -1
  107. package/docs/examples/functions/get-usage.md +1 -1
  108. package/docs/examples/functions/get-variable.md +1 -1
  109. package/docs/examples/functions/get.md +1 -1
  110. package/docs/examples/functions/list-deployments.md +1 -1
  111. package/docs/examples/functions/list-executions.md +1 -1
  112. package/docs/examples/functions/list-runtimes.md +1 -1
  113. package/docs/examples/functions/list-variables.md +1 -1
  114. package/docs/examples/functions/list.md +1 -1
  115. package/docs/examples/functions/update-deployment.md +1 -1
  116. package/docs/examples/functions/update-variable.md +1 -1
  117. package/docs/examples/functions/update.md +1 -1
  118. package/docs/examples/graphql/mutation.md +1 -1
  119. package/docs/examples/graphql/query.md +1 -1
  120. package/docs/examples/health/get-antivirus.md +1 -1
  121. package/docs/examples/health/get-cache.md +1 -1
  122. package/docs/examples/health/get-d-b.md +1 -1
  123. package/docs/examples/health/get-pub-sub.md +1 -1
  124. package/docs/examples/health/get-queue-builds.md +18 -0
  125. package/docs/examples/health/get-queue-certificates.md +1 -1
  126. package/docs/examples/health/get-queue-databases.md +18 -0
  127. package/docs/examples/health/get-queue-deletes.md +18 -0
  128. package/docs/examples/health/get-queue-functions.md +1 -1
  129. package/docs/examples/health/get-queue-logs.md +1 -1
  130. package/docs/examples/health/get-queue-mails.md +18 -0
  131. package/docs/examples/health/get-queue-messaging.md +18 -0
  132. package/docs/examples/health/get-queue-migrations.md +18 -0
  133. package/docs/examples/health/get-queue-webhooks.md +1 -1
  134. package/docs/examples/health/get-queue.md +1 -1
  135. package/docs/examples/health/get-storage-local.md +1 -1
  136. package/docs/examples/health/get-time.md +1 -1
  137. package/docs/examples/health/get.md +1 -1
  138. package/docs/examples/locale/get.md +1 -1
  139. package/docs/examples/locale/list-codes.md +18 -0
  140. package/docs/examples/locale/list-continents.md +1 -1
  141. package/docs/examples/locale/list-countries-e-u.md +1 -1
  142. package/docs/examples/locale/list-countries-phones.md +1 -1
  143. package/docs/examples/locale/list-countries.md +1 -1
  144. package/docs/examples/locale/list-currencies.md +1 -1
  145. package/docs/examples/locale/list-languages.md +1 -1
  146. package/docs/examples/migrations/create-appwrite-migration.md +18 -0
  147. package/docs/examples/migrations/create-firebase-migration.md +18 -0
  148. package/docs/examples/migrations/create-firebase-o-auth-migration.md +18 -0
  149. package/docs/examples/migrations/create-n-host-migration.md +18 -0
  150. package/docs/examples/migrations/create-supabase-migration.md +18 -0
  151. package/docs/examples/migrations/delete-firebase-auth.md +18 -0
  152. package/docs/examples/migrations/delete.md +18 -0
  153. package/docs/examples/migrations/get-appwrite-report.md +18 -0
  154. package/docs/examples/migrations/get-firebase-report-o-auth.md +18 -0
  155. package/docs/examples/migrations/get-firebase-report.md +18 -0
  156. package/docs/examples/migrations/get-n-host-report.md +18 -0
  157. package/docs/examples/migrations/get-supabase-report.md +18 -0
  158. package/docs/examples/migrations/get.md +18 -0
  159. package/docs/examples/migrations/list-firebase-projects.md +18 -0
  160. package/docs/examples/migrations/list.md +18 -0
  161. package/docs/examples/migrations/retry.md +18 -0
  162. package/docs/examples/project/create-variable.md +18 -0
  163. package/docs/examples/project/delete-variable.md +18 -0
  164. package/docs/examples/project/get-usage.md +2 -2
  165. package/docs/examples/project/get-variable.md +18 -0
  166. package/docs/examples/project/list-variables.md +18 -0
  167. package/docs/examples/project/update-variable.md +18 -0
  168. package/docs/examples/projects/create-key.md +1 -1
  169. package/docs/examples/projects/create-platform.md +1 -1
  170. package/docs/examples/projects/create-webhook.md +1 -1
  171. package/docs/examples/projects/create.md +2 -2
  172. package/docs/examples/projects/delete-email-template.md +18 -0
  173. package/docs/examples/projects/delete-key.md +1 -1
  174. package/docs/examples/projects/delete-platform.md +1 -1
  175. package/docs/examples/projects/delete-sms-template.md +18 -0
  176. package/docs/examples/projects/delete-webhook.md +1 -1
  177. package/docs/examples/projects/delete.md +2 -2
  178. package/docs/examples/projects/get-email-template.md +18 -0
  179. package/docs/examples/projects/get-key.md +1 -1
  180. package/docs/examples/projects/get-platform.md +1 -1
  181. package/docs/examples/projects/get-sms-template.md +18 -0
  182. package/docs/examples/projects/get-webhook.md +1 -1
  183. package/docs/examples/projects/get.md +1 -1
  184. package/docs/examples/projects/list-keys.md +1 -1
  185. package/docs/examples/projects/list-platforms.md +1 -1
  186. package/docs/examples/projects/list-webhooks.md +1 -1
  187. package/docs/examples/projects/list.md +1 -1
  188. package/docs/examples/projects/update-auth-duration.md +1 -1
  189. package/docs/examples/projects/update-auth-limit.md +1 -1
  190. package/docs/examples/projects/update-auth-password-dictionary.md +1 -1
  191. package/docs/examples/projects/update-auth-password-history.md +1 -1
  192. package/docs/examples/projects/update-auth-sessions-limit.md +1 -1
  193. package/docs/examples/projects/update-auth-status.md +1 -1
  194. package/docs/examples/projects/update-email-template.md +18 -0
  195. package/docs/examples/projects/update-key.md +1 -1
  196. package/docs/examples/projects/update-o-auth2.md +1 -1
  197. package/docs/examples/projects/{delete-domain.md → update-personal-data-check.md} +2 -2
  198. package/docs/examples/projects/update-platform.md +1 -1
  199. package/docs/examples/projects/{create-domain.md → update-service-status-all.md} +2 -2
  200. package/docs/examples/projects/update-service-status.md +1 -1
  201. package/docs/examples/projects/update-sms-template.md +18 -0
  202. package/docs/examples/projects/{get-domain.md → update-smtp-configuration.md} +2 -2
  203. package/docs/examples/projects/{list-domains.md → update-team.md} +2 -2
  204. package/docs/examples/projects/update-webhook-signature.md +1 -1
  205. package/docs/examples/projects/update-webhook.md +1 -1
  206. package/docs/examples/projects/update.md +1 -1
  207. package/docs/examples/proxy/create-rule.md +18 -0
  208. package/docs/examples/proxy/delete-rule.md +18 -0
  209. package/docs/examples/proxy/get-rule.md +18 -0
  210. package/docs/examples/proxy/list-rules.md +18 -0
  211. package/docs/examples/proxy/update-rule-verification.md +18 -0
  212. package/docs/examples/storage/create-bucket.md +1 -1
  213. package/docs/examples/storage/create-file.md +1 -1
  214. package/docs/examples/storage/delete-bucket.md +1 -1
  215. package/docs/examples/storage/delete-file.md +1 -1
  216. package/docs/examples/storage/get-bucket-usage.md +1 -1
  217. package/docs/examples/storage/get-bucket.md +1 -1
  218. package/docs/examples/storage/get-file-download.md +1 -1
  219. package/docs/examples/storage/get-file-preview.md +1 -1
  220. package/docs/examples/storage/get-file-view.md +1 -1
  221. package/docs/examples/storage/get-file.md +1 -1
  222. package/docs/examples/storage/get-usage.md +1 -1
  223. package/docs/examples/storage/list-buckets.md +1 -1
  224. package/docs/examples/storage/list-files.md +1 -1
  225. package/docs/examples/storage/update-bucket.md +1 -1
  226. package/docs/examples/storage/update-file.md +1 -1
  227. package/docs/examples/teams/create-membership.md +2 -2
  228. package/docs/examples/teams/create.md +1 -1
  229. package/docs/examples/teams/delete-membership.md +1 -1
  230. package/docs/examples/teams/delete.md +1 -1
  231. package/docs/examples/teams/get-membership.md +1 -1
  232. package/docs/examples/teams/get-prefs.md +1 -1
  233. package/docs/examples/teams/get.md +1 -1
  234. package/docs/examples/teams/list-logs.md +1 -1
  235. package/docs/examples/teams/list-memberships.md +1 -1
  236. package/docs/examples/teams/list.md +1 -1
  237. package/docs/examples/teams/update-membership-status.md +1 -1
  238. package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
  239. package/docs/examples/teams/update-name.md +1 -1
  240. package/docs/examples/teams/update-prefs.md +1 -1
  241. package/docs/examples/users/create-argon2user.md +1 -1
  242. package/docs/examples/users/create-bcrypt-user.md +1 -1
  243. package/docs/examples/users/create-m-d5user.md +1 -1
  244. package/docs/examples/users/create-p-h-pass-user.md +1 -1
  245. package/docs/examples/users/create-s-h-a-user.md +1 -1
  246. package/docs/examples/users/create-scrypt-modified-user.md +1 -1
  247. package/docs/examples/users/create-scrypt-user.md +1 -1
  248. package/docs/examples/users/create.md +1 -1
  249. package/docs/examples/users/delete-identity.md +18 -0
  250. package/docs/examples/users/delete-session.md +1 -1
  251. package/docs/examples/users/delete-sessions.md +1 -1
  252. package/docs/examples/users/delete.md +1 -1
  253. package/docs/examples/users/get-prefs.md +1 -1
  254. package/docs/examples/users/get-usage.md +1 -1
  255. package/docs/examples/users/get.md +1 -1
  256. package/docs/examples/users/list-identities.md +18 -0
  257. package/docs/examples/users/list-logs.md +1 -1
  258. package/docs/examples/users/list-memberships.md +1 -1
  259. package/docs/examples/users/list-sessions.md +1 -1
  260. package/docs/examples/users/list.md +1 -1
  261. package/docs/examples/users/update-email-verification.md +1 -1
  262. package/docs/examples/users/update-email.md +1 -1
  263. package/docs/examples/users/update-labels.md +18 -0
  264. package/docs/examples/users/update-name.md +1 -1
  265. package/docs/examples/users/update-password.md +1 -1
  266. package/docs/examples/users/update-phone-verification.md +1 -1
  267. package/docs/examples/users/update-phone.md +1 -1
  268. package/docs/examples/users/update-prefs.md +1 -1
  269. package/docs/examples/users/update-status.md +1 -1
  270. package/docs/examples/vcs/create-repository-detection.md +18 -0
  271. package/docs/examples/vcs/create-repository.md +18 -0
  272. package/docs/examples/vcs/delete-installation.md +18 -0
  273. package/docs/examples/vcs/get-installation.md +18 -0
  274. package/docs/examples/vcs/get-repository.md +18 -0
  275. package/docs/examples/vcs/list-installations.md +18 -0
  276. package/docs/examples/vcs/list-repositories.md +18 -0
  277. package/docs/examples/vcs/list-repository-branches.md +18 -0
  278. package/docs/examples/vcs/update-external-deployments.md +18 -0
  279. package/package.json +3 -2
  280. package/src/client.ts +2 -2
  281. package/src/index.ts +4 -0
  282. package/src/models.ts +863 -233
  283. package/src/query.ts +1 -1
  284. package/src/role.ts +72 -6
  285. package/src/services/account.ts +1052 -1055
  286. package/src/services/assistant.ts +38 -0
  287. package/src/services/avatars.ts +338 -337
  288. package/src/services/console.ts +16 -16
  289. package/src/services/databases.ts +2170 -2140
  290. package/src/services/functions.ts +804 -657
  291. package/src/services/graphql.ts +47 -47
  292. package/src/services/health.ts +373 -204
  293. package/src/services/locale.ts +156 -137
  294. package/src/services/migrations.ts +707 -0
  295. package/src/services/project.ts +178 -20
  296. package/src/services/projects.ts +1511 -1256
  297. package/src/services/proxy.ts +150 -0
  298. package/src/services/storage.ts +572 -577
  299. package/src/services/teams.ts +498 -501
  300. package/src/services/users.ts +1091 -1001
  301. package/src/services/vcs.ts +272 -0
  302. package/types/index.d.ts +4 -0
  303. package/types/models.d.ts +863 -233
  304. package/types/role.d.ts +62 -0
  305. package/types/services/account.d.ts +116 -104
  306. package/types/services/assistant.d.ts +14 -0
  307. package/types/services/avatars.d.ts +18 -17
  308. package/types/services/console.d.ts +2 -2
  309. package/types/services/databases.d.ts +111 -105
  310. package/types/services/functions.d.ts +95 -55
  311. package/types/services/graphql.d.ts +4 -4
  312. package/types/services/health.d.ts +97 -26
  313. package/types/services/locale.d.ts +24 -14
  314. package/types/services/migrations.d.ts +185 -0
  315. package/types/services/project.d.ts +60 -3
  316. package/types/services/projects.d.ts +174 -104
  317. package/types/services/proxy.d.ts +59 -0
  318. package/types/services/storage.d.ts +29 -28
  319. package/types/services/teams.d.ts +36 -35
  320. package/types/services/users.d.ts +105 -66
  321. package/types/services/vcs.d.ts +97 -0
  322. package/docs/examples/projects/update-domain-verification.md +0 -18
@@ -10,797 +10,944 @@ export class Functions extends Service {
10
10
  super(client);
11
11
  }
12
12
 
13
- /**
14
- * List Functions
15
- *
16
- * Get a list of all the project's functions. You can use the query params to
17
- * filter your results.
18
- *
19
- * @param {string[]} queries
20
- * @param {string} search
21
- * @throws {AppwriteException}
22
- * @returns {Promise}
23
- */
24
- async list(queries?: string[], search?: string): Promise<Models.FunctionList> {
25
- let path = '/functions';
26
- let payload: Payload = {};
27
-
28
- if (typeof queries !== 'undefined') {
29
- payload['queries'] = queries;
30
- }
31
-
32
- if (typeof search !== 'undefined') {
33
- payload['search'] = search;
34
- }
35
-
36
- const uri = new URL(this.client.config.endpoint + path);
37
- return await this.client.call('get', uri, {
38
- 'content-type': 'application/json',
39
- }, payload);
13
+ /**
14
+ * List functions
15
+ *
16
+ * Get a list of all the project's functions. You can use the query params to
17
+ * filter your results.
18
+ *
19
+ * @param {string[]} queries
20
+ * @param {string} search
21
+ * @throws {AppwriteException}
22
+ * @returns {Promise}
23
+ */
24
+ async list(queries?: string[], search?: string): Promise<Models.FunctionList> {
25
+ const apiPath = '/functions';
26
+ const payload: Payload = {};
27
+
28
+ if (typeof queries !== 'undefined') {
29
+ payload['queries'] = queries;
40
30
  }
41
31
 
42
- /**
43
- * Create Function
44
- *
45
- * Create a new function. You can pass a list of
46
- * [permissions](/docs/permissions) to allow different project users or team
47
- * with access to execute the function using the client API.
48
- *
49
- * @param {string} functionId
50
- * @param {string} name
51
- * @param {string} runtime
52
- * @param {string[]} execute
53
- * @param {string[]} events
54
- * @param {string} schedule
55
- * @param {number} timeout
56
- * @param {boolean} enabled
57
- * @throws {AppwriteException}
58
- * @returns {Promise}
59
- */
60
- async create(functionId: string, name: string, runtime: string, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean): Promise<Models.Function> {
61
- if (typeof functionId === 'undefined') {
62
- throw new AppwriteException('Missing required parameter: "functionId"');
63
- }
64
-
65
- if (typeof name === 'undefined') {
66
- throw new AppwriteException('Missing required parameter: "name"');
67
- }
32
+ if (typeof search !== 'undefined') {
33
+ payload['search'] = search;
34
+ }
68
35
 
69
- if (typeof runtime === 'undefined') {
70
- throw new AppwriteException('Missing required parameter: "runtime"');
71
- }
36
+ const uri = new URL(this.client.config.endpoint + apiPath);
37
+ return await this.client.call('get', uri, {
38
+ 'content-type': 'application/json',
39
+ }, payload);
40
+ }
41
+
42
+ /**
43
+ * Create function
44
+ *
45
+ * Create a new function. You can pass a list of
46
+ * [permissions](https://appwrite.io/docs/permissions) to allow different
47
+ * project users or team with access to execute the function using the client
48
+ * API.
49
+ *
50
+ * @param {string} functionId
51
+ * @param {string} name
52
+ * @param {string} runtime
53
+ * @param {string[]} execute
54
+ * @param {string[]} events
55
+ * @param {string} schedule
56
+ * @param {number} timeout
57
+ * @param {boolean} enabled
58
+ * @param {boolean} logging
59
+ * @param {string} entrypoint
60
+ * @param {string} commands
61
+ * @param {string} installationId
62
+ * @param {string} providerRepositoryId
63
+ * @param {string} providerBranch
64
+ * @param {boolean} providerSilentMode
65
+ * @param {string} providerRootDirectory
66
+ * @param {string} templateRepository
67
+ * @param {string} templateOwner
68
+ * @param {string} templateRootDirectory
69
+ * @param {string} templateBranch
70
+ * @throws {AppwriteException}
71
+ * @returns {Promise}
72
+ */
73
+ async create(functionId: string, name: string, runtime: string, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, templateRepository?: string, templateOwner?: string, templateRootDirectory?: string, templateBranch?: string): Promise<Models.Function> {
74
+ if (typeof functionId === 'undefined') {
75
+ throw new AppwriteException('Missing required parameter: "functionId"');
76
+ }
72
77
 
73
- let path = '/functions';
74
- let payload: Payload = {};
78
+ if (typeof name === 'undefined') {
79
+ throw new AppwriteException('Missing required parameter: "name"');
80
+ }
75
81
 
76
- if (typeof functionId !== 'undefined') {
77
- payload['functionId'] = functionId;
78
- }
82
+ if (typeof runtime === 'undefined') {
83
+ throw new AppwriteException('Missing required parameter: "runtime"');
84
+ }
79
85
 
80
- if (typeof name !== 'undefined') {
81
- payload['name'] = name;
82
- }
86
+ const apiPath = '/functions';
87
+ const payload: Payload = {};
83
88
 
84
- if (typeof execute !== 'undefined') {
85
- payload['execute'] = execute;
86
- }
89
+ if (typeof functionId !== 'undefined') {
90
+ payload['functionId'] = functionId;
91
+ }
87
92
 
88
- if (typeof runtime !== 'undefined') {
89
- payload['runtime'] = runtime;
90
- }
93
+ if (typeof name !== 'undefined') {
94
+ payload['name'] = name;
95
+ }
91
96
 
92
- if (typeof events !== 'undefined') {
93
- payload['events'] = events;
94
- }
97
+ if (typeof runtime !== 'undefined') {
98
+ payload['runtime'] = runtime;
99
+ }
95
100
 
96
- if (typeof schedule !== 'undefined') {
97
- payload['schedule'] = schedule;
98
- }
101
+ if (typeof execute !== 'undefined') {
102
+ payload['execute'] = execute;
103
+ }
99
104
 
100
- if (typeof timeout !== 'undefined') {
101
- payload['timeout'] = timeout;
102
- }
105
+ if (typeof events !== 'undefined') {
106
+ payload['events'] = events;
107
+ }
103
108
 
104
- if (typeof enabled !== 'undefined') {
105
- payload['enabled'] = enabled;
106
- }
109
+ if (typeof schedule !== 'undefined') {
110
+ payload['schedule'] = schedule;
111
+ }
107
112
 
108
- const uri = new URL(this.client.config.endpoint + path);
109
- return await this.client.call('post', uri, {
110
- 'content-type': 'application/json',
111
- }, payload);
113
+ if (typeof timeout !== 'undefined') {
114
+ payload['timeout'] = timeout;
112
115
  }
113
116
 
114
- /**
115
- * List runtimes
116
- *
117
- * Get a list of all runtimes that are currently active on your instance.
118
- *
119
- * @throws {AppwriteException}
120
- * @returns {Promise}
121
- */
122
- async listRuntimes(): Promise<Models.RuntimeList> {
123
- let path = '/functions/runtimes';
124
- let payload: Payload = {};
125
-
126
- const uri = new URL(this.client.config.endpoint + path);
127
- return await this.client.call('get', uri, {
128
- 'content-type': 'application/json',
129
- }, payload);
117
+ if (typeof enabled !== 'undefined') {
118
+ payload['enabled'] = enabled;
130
119
  }
131
120
 
132
- /**
133
- * Get Functions Usage
134
- *
135
- *
136
- * @param {string} range
137
- * @throws {AppwriteException}
138
- * @returns {Promise}
139
- */
140
- async getUsage(range?: string): Promise<Models.UsageFunctions> {
141
- let path = '/functions/usage';
142
- let payload: Payload = {};
143
-
144
- if (typeof range !== 'undefined') {
145
- payload['range'] = range;
146
- }
121
+ if (typeof logging !== 'undefined') {
122
+ payload['logging'] = logging;
123
+ }
147
124
 
148
- const uri = new URL(this.client.config.endpoint + path);
149
- return await this.client.call('get', uri, {
150
- 'content-type': 'application/json',
151
- }, payload);
125
+ if (typeof entrypoint !== 'undefined') {
126
+ payload['entrypoint'] = entrypoint;
152
127
  }
153
128
 
154
- /**
155
- * Get Function
156
- *
157
- * Get a function by its unique ID.
158
- *
159
- * @param {string} functionId
160
- * @throws {AppwriteException}
161
- * @returns {Promise}
162
- */
163
- async get(functionId: string): Promise<Models.Function> {
164
- if (typeof functionId === 'undefined') {
165
- throw new AppwriteException('Missing required parameter: "functionId"');
166
- }
129
+ if (typeof commands !== 'undefined') {
130
+ payload['commands'] = commands;
131
+ }
167
132
 
168
- let path = '/functions/{functionId}'.replace('{functionId}', functionId);
169
- let payload: Payload = {};
133
+ if (typeof installationId !== 'undefined') {
134
+ payload['installationId'] = installationId;
135
+ }
170
136
 
171
- const uri = new URL(this.client.config.endpoint + path);
172
- return await this.client.call('get', uri, {
173
- 'content-type': 'application/json',
174
- }, payload);
137
+ if (typeof providerRepositoryId !== 'undefined') {
138
+ payload['providerRepositoryId'] = providerRepositoryId;
175
139
  }
176
140
 
177
- /**
178
- * Update Function
179
- *
180
- * Update function by its unique ID.
181
- *
182
- * @param {string} functionId
183
- * @param {string} name
184
- * @param {string[]} execute
185
- * @param {string[]} events
186
- * @param {string} schedule
187
- * @param {number} timeout
188
- * @param {boolean} enabled
189
- * @throws {AppwriteException}
190
- * @returns {Promise}
191
- */
192
- async update(functionId: string, name: string, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean): Promise<Models.Function> {
193
- if (typeof functionId === 'undefined') {
194
- throw new AppwriteException('Missing required parameter: "functionId"');
195
- }
141
+ if (typeof providerBranch !== 'undefined') {
142
+ payload['providerBranch'] = providerBranch;
143
+ }
196
144
 
197
- if (typeof name === 'undefined') {
198
- throw new AppwriteException('Missing required parameter: "name"');
199
- }
145
+ if (typeof providerSilentMode !== 'undefined') {
146
+ payload['providerSilentMode'] = providerSilentMode;
147
+ }
200
148
 
201
- let path = '/functions/{functionId}'.replace('{functionId}', functionId);
202
- let payload: Payload = {};
149
+ if (typeof providerRootDirectory !== 'undefined') {
150
+ payload['providerRootDirectory'] = providerRootDirectory;
151
+ }
203
152
 
204
- if (typeof name !== 'undefined') {
205
- payload['name'] = name;
206
- }
153
+ if (typeof templateRepository !== 'undefined') {
154
+ payload['templateRepository'] = templateRepository;
155
+ }
207
156
 
208
- if (typeof execute !== 'undefined') {
209
- payload['execute'] = execute;
210
- }
157
+ if (typeof templateOwner !== 'undefined') {
158
+ payload['templateOwner'] = templateOwner;
159
+ }
211
160
 
212
- if (typeof events !== 'undefined') {
213
- payload['events'] = events;
214
- }
161
+ if (typeof templateRootDirectory !== 'undefined') {
162
+ payload['templateRootDirectory'] = templateRootDirectory;
163
+ }
215
164
 
216
- if (typeof schedule !== 'undefined') {
217
- payload['schedule'] = schedule;
218
- }
165
+ if (typeof templateBranch !== 'undefined') {
166
+ payload['templateBranch'] = templateBranch;
167
+ }
219
168
 
220
- if (typeof timeout !== 'undefined') {
221
- payload['timeout'] = timeout;
222
- }
169
+ const uri = new URL(this.client.config.endpoint + apiPath);
170
+ return await this.client.call('post', uri, {
171
+ 'content-type': 'application/json',
172
+ }, payload);
173
+ }
174
+
175
+ /**
176
+ * List runtimes
177
+ *
178
+ * Get a list of all runtimes that are currently active on your instance.
179
+ *
180
+ * @throws {AppwriteException}
181
+ * @returns {Promise}
182
+ */
183
+ async listRuntimes(): Promise<Models.RuntimeList> {
184
+ const apiPath = '/functions/runtimes';
185
+ const payload: Payload = {};
186
+
187
+ const uri = new URL(this.client.config.endpoint + apiPath);
188
+ return await this.client.call('get', uri, {
189
+ 'content-type': 'application/json',
190
+ }, payload);
191
+ }
192
+
193
+ /**
194
+ * Get functions usage
195
+ *
196
+ *
197
+ * @param {string} range
198
+ * @throws {AppwriteException}
199
+ * @returns {Promise}
200
+ */
201
+ async getUsage(range?: string): Promise<Models.UsageFunctions> {
202
+ const apiPath = '/functions/usage';
203
+ const payload: Payload = {};
204
+
205
+ if (typeof range !== 'undefined') {
206
+ payload['range'] = range;
207
+ }
223
208
 
224
- if (typeof enabled !== 'undefined') {
225
- payload['enabled'] = enabled;
226
- }
209
+ const uri = new URL(this.client.config.endpoint + apiPath);
210
+ return await this.client.call('get', uri, {
211
+ 'content-type': 'application/json',
212
+ }, payload);
213
+ }
214
+
215
+ /**
216
+ * Get function
217
+ *
218
+ * Get a function by its unique ID.
219
+ *
220
+ * @param {string} functionId
221
+ * @throws {AppwriteException}
222
+ * @returns {Promise}
223
+ */
224
+ async get(functionId: string): Promise<Models.Function> {
225
+ if (typeof functionId === 'undefined') {
226
+ throw new AppwriteException('Missing required parameter: "functionId"');
227
+ }
227
228
 
228
- const uri = new URL(this.client.config.endpoint + path);
229
- return await this.client.call('put', uri, {
230
- 'content-type': 'application/json',
231
- }, payload);
229
+ const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
230
+ const payload: Payload = {};
231
+
232
+ const uri = new URL(this.client.config.endpoint + apiPath);
233
+ return await this.client.call('get', uri, {
234
+ 'content-type': 'application/json',
235
+ }, payload);
236
+ }
237
+
238
+ /**
239
+ * Update function
240
+ *
241
+ * Update function by its unique ID.
242
+ *
243
+ * @param {string} functionId
244
+ * @param {string} name
245
+ * @param {string} runtime
246
+ * @param {string[]} execute
247
+ * @param {string[]} events
248
+ * @param {string} schedule
249
+ * @param {number} timeout
250
+ * @param {boolean} enabled
251
+ * @param {boolean} logging
252
+ * @param {string} entrypoint
253
+ * @param {string} commands
254
+ * @param {string} installationId
255
+ * @param {string} providerRepositoryId
256
+ * @param {string} providerBranch
257
+ * @param {boolean} providerSilentMode
258
+ * @param {string} providerRootDirectory
259
+ * @throws {AppwriteException}
260
+ * @returns {Promise}
261
+ */
262
+ async update(functionId: string, name: string, runtime?: string, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string): Promise<Models.Function> {
263
+ if (typeof functionId === 'undefined') {
264
+ throw new AppwriteException('Missing required parameter: "functionId"');
232
265
  }
233
266
 
234
- /**
235
- * Delete Function
236
- *
237
- * Delete a function by its unique ID.
238
- *
239
- * @param {string} functionId
240
- * @throws {AppwriteException}
241
- * @returns {Promise}
242
- */
243
- async delete(functionId: string): Promise<{}> {
244
- if (typeof functionId === 'undefined') {
245
- throw new AppwriteException('Missing required parameter: "functionId"');
246
- }
267
+ if (typeof name === 'undefined') {
268
+ throw new AppwriteException('Missing required parameter: "name"');
269
+ }
247
270
 
248
- let path = '/functions/{functionId}'.replace('{functionId}', functionId);
249
- let payload: Payload = {};
271
+ const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
272
+ const payload: Payload = {};
250
273
 
251
- const uri = new URL(this.client.config.endpoint + path);
252
- return await this.client.call('delete', uri, {
253
- 'content-type': 'application/json',
254
- }, payload);
274
+ if (typeof name !== 'undefined') {
275
+ payload['name'] = name;
255
276
  }
256
277
 
257
- /**
258
- * List Deployments
259
- *
260
- * Get a list of all the project's code deployments. You can use the query
261
- * params to filter your results.
262
- *
263
- * @param {string} functionId
264
- * @param {string[]} queries
265
- * @param {string} search
266
- * @throws {AppwriteException}
267
- * @returns {Promise}
268
- */
269
- async listDeployments(functionId: string, queries?: string[], search?: string): Promise<Models.DeploymentList> {
270
- if (typeof functionId === 'undefined') {
271
- throw new AppwriteException('Missing required parameter: "functionId"');
272
- }
278
+ if (typeof runtime !== 'undefined') {
279
+ payload['runtime'] = runtime;
280
+ }
273
281
 
274
- let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
275
- let payload: Payload = {};
282
+ if (typeof execute !== 'undefined') {
283
+ payload['execute'] = execute;
284
+ }
276
285
 
277
- if (typeof queries !== 'undefined') {
278
- payload['queries'] = queries;
279
- }
286
+ if (typeof events !== 'undefined') {
287
+ payload['events'] = events;
288
+ }
280
289
 
281
- if (typeof search !== 'undefined') {
282
- payload['search'] = search;
283
- }
290
+ if (typeof schedule !== 'undefined') {
291
+ payload['schedule'] = schedule;
292
+ }
284
293
 
285
- const uri = new URL(this.client.config.endpoint + path);
286
- return await this.client.call('get', uri, {
287
- 'content-type': 'application/json',
288
- }, payload);
294
+ if (typeof timeout !== 'undefined') {
295
+ payload['timeout'] = timeout;
289
296
  }
290
297
 
291
- /**
292
- * Create Deployment
293
- *
294
- * Create a new function code deployment. Use this endpoint to upload a new
295
- * version of your code function. To execute your newly uploaded code, you'll
296
- * need to update the function's deployment to use your new deployment UID.
297
- *
298
- * This endpoint accepts a tar.gz file compressed with your code. Make sure to
299
- * include any dependencies your code has within the compressed file. You can
300
- * learn more about code packaging in the [Appwrite Cloud Functions
301
- * tutorial](/docs/functions).
302
- *
303
- * Use the "command" param to set the entry point used to execute your code.
304
- *
305
- * @param {string} functionId
306
- * @param {string} entrypoint
307
- * @param {File} code
308
- * @param {boolean} activate
309
- * @throws {AppwriteException}
310
- * @returns {Promise}
311
- */
312
- async createDeployment(functionId: string, entrypoint: string, code: File, activate: boolean, onProgress = (progress: UploadProgress) => {}): Promise<Models.Deployment> {
313
- if (typeof functionId === 'undefined') {
314
- throw new AppwriteException('Missing required parameter: "functionId"');
315
- }
298
+ if (typeof enabled !== 'undefined') {
299
+ payload['enabled'] = enabled;
300
+ }
316
301
 
317
- if (typeof entrypoint === 'undefined') {
318
- throw new AppwriteException('Missing required parameter: "entrypoint"');
319
- }
302
+ if (typeof logging !== 'undefined') {
303
+ payload['logging'] = logging;
304
+ }
320
305
 
321
- if (typeof code === 'undefined') {
322
- throw new AppwriteException('Missing required parameter: "code"');
323
- }
306
+ if (typeof entrypoint !== 'undefined') {
307
+ payload['entrypoint'] = entrypoint;
308
+ }
324
309
 
325
- if (typeof activate === 'undefined') {
326
- throw new AppwriteException('Missing required parameter: "activate"');
327
- }
310
+ if (typeof commands !== 'undefined') {
311
+ payload['commands'] = commands;
312
+ }
328
313
 
329
- let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
330
- let payload: Payload = {};
314
+ if (typeof installationId !== 'undefined') {
315
+ payload['installationId'] = installationId;
316
+ }
331
317
 
332
- if (typeof entrypoint !== 'undefined') {
333
- payload['entrypoint'] = entrypoint;
334
- }
318
+ if (typeof providerRepositoryId !== 'undefined') {
319
+ payload['providerRepositoryId'] = providerRepositoryId;
320
+ }
335
321
 
336
- if (typeof code !== 'undefined') {
337
- payload['code'] = code;
338
- }
322
+ if (typeof providerBranch !== 'undefined') {
323
+ payload['providerBranch'] = providerBranch;
324
+ }
339
325
 
340
- if (typeof activate !== 'undefined') {
341
- payload['activate'] = activate;
342
- }
326
+ if (typeof providerSilentMode !== 'undefined') {
327
+ payload['providerSilentMode'] = providerSilentMode;
328
+ }
343
329
 
344
- const uri = new URL(this.client.config.endpoint + path);
330
+ if (typeof providerRootDirectory !== 'undefined') {
331
+ payload['providerRootDirectory'] = providerRootDirectory;
332
+ }
345
333
 
346
- if(!(code instanceof File)) {
347
- throw new AppwriteException('Parameter "code" has to be a File.');
348
- }
334
+ const uri = new URL(this.client.config.endpoint + apiPath);
335
+ return await this.client.call('put', uri, {
336
+ 'content-type': 'application/json',
337
+ }, payload);
338
+ }
339
+
340
+ /**
341
+ * Delete function
342
+ *
343
+ * Delete a function by its unique ID.
344
+ *
345
+ * @param {string} functionId
346
+ * @throws {AppwriteException}
347
+ * @returns {Promise}
348
+ */
349
+ async delete(functionId: string): Promise<{}> {
350
+ if (typeof functionId === 'undefined') {
351
+ throw new AppwriteException('Missing required parameter: "functionId"');
352
+ }
349
353
 
350
- const size = code.size;
354
+ const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
355
+ const payload: Payload = {};
356
+
357
+ const uri = new URL(this.client.config.endpoint + apiPath);
358
+ return await this.client.call('delete', uri, {
359
+ 'content-type': 'application/json',
360
+ }, payload);
361
+ }
362
+
363
+ /**
364
+ * List deployments
365
+ *
366
+ * Get a list of all the project's code deployments. You can use the query
367
+ * params to filter your results.
368
+ *
369
+ * @param {string} functionId
370
+ * @param {string[]} queries
371
+ * @param {string} search
372
+ * @throws {AppwriteException}
373
+ * @returns {Promise}
374
+ */
375
+ async listDeployments(functionId: string, queries?: string[], search?: string): Promise<Models.DeploymentList> {
376
+ if (typeof functionId === 'undefined') {
377
+ throw new AppwriteException('Missing required parameter: "functionId"');
378
+ }
351
379
 
352
- if (size <= Service.CHUNK_SIZE) {
353
- return await this.client.call('post', uri, {
380
+ const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
381
+ const payload: Payload = {};
354
382
 
355
- 'content-type': 'multipart/form-data',
356
- }, payload);
357
- }
358
- let id = undefined;
359
- let response = undefined;
383
+ if (typeof queries !== 'undefined') {
384
+ payload['queries'] = queries;
385
+ }
360
386
 
361
- const headers: { [header: string]: string } = {
362
- 'content-type': 'multipart/form-data',
363
- }
387
+ if (typeof search !== 'undefined') {
388
+ payload['search'] = search;
389
+ }
364
390
 
365
- let counter = 0;
366
- const totalCounters = Math.ceil(size / Service.CHUNK_SIZE);
391
+ const uri = new URL(this.client.config.endpoint + apiPath);
392
+ return await this.client.call('get', uri, {
393
+ 'content-type': 'application/json',
394
+ }, payload);
395
+ }
396
+
397
+ /**
398
+ * Create deployment
399
+ *
400
+ * Create a new function code deployment. Use this endpoint to upload a new
401
+ * version of your code function. To execute your newly uploaded code, you'll
402
+ * need to update the function's deployment to use your new deployment UID.
403
+ *
404
+ * This endpoint accepts a tar.gz file compressed with your code. Make sure to
405
+ * include any dependencies your code has within the compressed file. You can
406
+ * learn more about code packaging in the [Appwrite Cloud Functions
407
+ * tutorial](https://appwrite.io/docs/functions).
408
+ *
409
+ * Use the "command" param to set the entrypoint used to execute your code.
410
+ *
411
+ * @param {string} functionId
412
+ * @param {File} code
413
+ * @param {boolean} activate
414
+ * @param {string} entrypoint
415
+ * @param {string} commands
416
+ * @throws {AppwriteException}
417
+ * @returns {Promise}
418
+ */
419
+ async createDeployment(functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress = (progress: UploadProgress) => {}): Promise<Models.Deployment> {
420
+ if (typeof functionId === 'undefined') {
421
+ throw new AppwriteException('Missing required parameter: "functionId"');
422
+ }
367
423
 
368
- for (counter; counter < totalCounters; counter++) {
369
- const start = (counter * Service.CHUNK_SIZE);
370
- const end = Math.min((((counter * Service.CHUNK_SIZE) + Service.CHUNK_SIZE) - 1), size);
424
+ if (typeof code === 'undefined') {
425
+ throw new AppwriteException('Missing required parameter: "code"');
426
+ }
371
427
 
372
- headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
428
+ if (typeof activate === 'undefined') {
429
+ throw new AppwriteException('Missing required parameter: "activate"');
430
+ }
373
431
 
374
- if (id) {
375
- headers['x-appwrite-id'] = id;
376
- }
432
+ const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
433
+ const payload: Payload = {};
377
434
 
378
- const stream = code.slice(start, end + 1);
379
- payload['code'] = new File([stream], code.name);
435
+ if (typeof entrypoint !== 'undefined') {
436
+ payload['entrypoint'] = entrypoint;
437
+ }
380
438
 
381
- response = await this.client.call('post', uri, headers, payload);
439
+ if (typeof commands !== 'undefined') {
440
+ payload['commands'] = commands;
441
+ }
382
442
 
383
- if (!id) {
384
- id = response['$id'];
385
- }
443
+ if (typeof code !== 'undefined') {
444
+ payload['code'] = code;
445
+ }
386
446
 
387
- if (onProgress) {
388
- onProgress({
389
- $id: response.$id,
390
- progress: Math.min((counter + 1) * Service.CHUNK_SIZE - 1, size) / size * 100,
391
- sizeUploaded: end,
392
- chunksTotal: response.chunksTotal,
393
- chunksUploaded: response.chunksUploaded
394
- });
395
- }
396
- }
447
+ if (typeof activate !== 'undefined') {
448
+ payload['activate'] = activate;
449
+ }
397
450
 
398
- return response;
399
- }
400
-
401
- /**
402
- * Get Deployment
403
- *
404
- * Get a code deployment by its unique ID.
405
- *
406
- * @param {string} functionId
407
- * @param {string} deploymentId
408
- * @throws {AppwriteException}
409
- * @returns {Promise}
410
- */
411
- async getDeployment(functionId: string, deploymentId: string): Promise<Models.Deployment> {
412
- if (typeof functionId === 'undefined') {
413
- throw new AppwriteException('Missing required parameter: "functionId"');
414
- }
451
+ const uri = new URL(this.client.config.endpoint + apiPath);
415
452
 
416
- if (typeof deploymentId === 'undefined') {
417
- throw new AppwriteException('Missing required parameter: "deploymentId"');
418
- }
453
+ if(!(code instanceof File)) {
454
+ throw new AppwriteException('Parameter "code" has to be a File.');
455
+ }
419
456
 
420
- let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
421
- let payload: Payload = {};
457
+ const size = code.size;
422
458
 
423
- const uri = new URL(this.client.config.endpoint + path);
424
- return await this.client.call('get', uri, {
425
- 'content-type': 'application/json',
459
+ if (size <= Service.CHUNK_SIZE) {
460
+ return await this.client.call('post', uri, {
461
+ 'content-type': 'multipart/form-data',
426
462
  }, payload);
427
463
  }
428
464
 
429
- /**
430
- * Update Function Deployment
431
- *
432
- * Update the function code deployment ID using the unique function ID. Use
433
- * this endpoint to switch the code deployment that should be executed by the
434
- * execution endpoint.
435
- *
436
- * @param {string} functionId
437
- * @param {string} deploymentId
438
- * @throws {AppwriteException}
439
- * @returns {Promise}
440
- */
441
- async updateDeployment(functionId: string, deploymentId: string): Promise<Models.Function> {
442
- if (typeof functionId === 'undefined') {
443
- throw new AppwriteException('Missing required parameter: "functionId"');
444
- }
445
-
446
- if (typeof deploymentId === 'undefined') {
447
- throw new AppwriteException('Missing required parameter: "deploymentId"');
448
- }
449
-
450
- let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
451
- let payload: Payload = {};
452
-
453
- const uri = new URL(this.client.config.endpoint + path);
454
- return await this.client.call('patch', uri, {
455
- 'content-type': 'application/json',
456
- }, payload);
465
+ const apiHeaders: { [header: string]: string } = {
466
+ 'content-type': 'multipart/form-data',
457
467
  }
458
468
 
459
- /**
460
- * Delete Deployment
461
- *
462
- * Delete a code deployment by its unique ID.
463
- *
464
- * @param {string} functionId
465
- * @param {string} deploymentId
466
- * @throws {AppwriteException}
467
- * @returns {Promise}
468
- */
469
- async deleteDeployment(functionId: string, deploymentId: string): Promise<{}> {
470
- if (typeof functionId === 'undefined') {
471
- throw new AppwriteException('Missing required parameter: "functionId"');
472
- }
469
+ let offset = 0;
470
+ let response = undefined;
473
471
 
474
- if (typeof deploymentId === 'undefined') {
475
- throw new AppwriteException('Missing required parameter: "deploymentId"');
476
- }
472
+ while (offset < size) {
473
+ let end = Math.min(offset + Service.CHUNK_SIZE - 1, size - 1);
477
474
 
478
- let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
479
- let payload: Payload = {};
475
+ apiHeaders['content-range'] = 'bytes ' + offset + '-' + end + '/' + size;
476
+ if (response && response.$id) {
477
+ apiHeaders['x-appwrite-id'] = response.$id;
478
+ }
480
479
 
481
- const uri = new URL(this.client.config.endpoint + path);
482
- return await this.client.call('delete', uri, {
483
- 'content-type': 'application/json',
484
- }, payload);
485
- }
480
+ const chunk = code.slice(offset, end + 1);
481
+ payload['code'] = new File([chunk], code.name);
482
+ response = await this.client.call('post', uri, apiHeaders, payload);
486
483
 
487
- /**
488
- * Create Build
489
- *
490
- *
491
- * @param {string} functionId
492
- * @param {string} deploymentId
493
- * @param {string} buildId
494
- * @throws {AppwriteException}
495
- * @returns {Promise}
496
- */
497
- async createBuild(functionId: string, deploymentId: string, buildId: string): Promise<{}> {
498
- if (typeof functionId === 'undefined') {
499
- throw new AppwriteException('Missing required parameter: "functionId"');
484
+ if (onProgress) {
485
+ onProgress({
486
+ $id: response.$id,
487
+ progress: (offset / size) * 100,
488
+ sizeUploaded: offset,
489
+ chunksTotal: response.chunksTotal,
490
+ chunksUploaded: response.chunksUploaded
491
+ });
500
492
  }
493
+ offset += Service.CHUNK_SIZE;
494
+ }
495
+ return response;
496
+ }
497
+
498
+ /**
499
+ * Get deployment
500
+ *
501
+ * Get a code deployment by its unique ID.
502
+ *
503
+ * @param {string} functionId
504
+ * @param {string} deploymentId
505
+ * @throws {AppwriteException}
506
+ * @returns {Promise}
507
+ */
508
+ async getDeployment(functionId: string, deploymentId: string): Promise<Models.Deployment> {
509
+ if (typeof functionId === 'undefined') {
510
+ throw new AppwriteException('Missing required parameter: "functionId"');
511
+ }
501
512
 
502
- if (typeof deploymentId === 'undefined') {
503
- throw new AppwriteException('Missing required parameter: "deploymentId"');
504
- }
513
+ if (typeof deploymentId === 'undefined') {
514
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
515
+ }
505
516
 
506
- if (typeof buildId === 'undefined') {
507
- throw new AppwriteException('Missing required parameter: "buildId"');
508
- }
517
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
518
+ const payload: Payload = {};
519
+
520
+ const uri = new URL(this.client.config.endpoint + apiPath);
521
+ return await this.client.call('get', uri, {
522
+ 'content-type': 'application/json',
523
+ }, payload);
524
+ }
525
+
526
+ /**
527
+ * Update function deployment
528
+ *
529
+ * Update the function code deployment ID using the unique function ID. Use
530
+ * this endpoint to switch the code deployment that should be executed by the
531
+ * execution endpoint.
532
+ *
533
+ * @param {string} functionId
534
+ * @param {string} deploymentId
535
+ * @throws {AppwriteException}
536
+ * @returns {Promise}
537
+ */
538
+ async updateDeployment(functionId: string, deploymentId: string): Promise<Models.Function> {
539
+ if (typeof functionId === 'undefined') {
540
+ throw new AppwriteException('Missing required parameter: "functionId"');
541
+ }
509
542
 
510
- let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
511
- let payload: Payload = {};
543
+ if (typeof deploymentId === 'undefined') {
544
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
545
+ }
512
546
 
513
- const uri = new URL(this.client.config.endpoint + path);
514
- return await this.client.call('post', uri, {
515
- 'content-type': 'application/json',
516
- }, payload);
547
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
548
+ const payload: Payload = {};
549
+
550
+ const uri = new URL(this.client.config.endpoint + apiPath);
551
+ return await this.client.call('patch', uri, {
552
+ 'content-type': 'application/json',
553
+ }, payload);
554
+ }
555
+
556
+ /**
557
+ * Delete deployment
558
+ *
559
+ * Delete a code deployment by its unique ID.
560
+ *
561
+ * @param {string} functionId
562
+ * @param {string} deploymentId
563
+ * @throws {AppwriteException}
564
+ * @returns {Promise}
565
+ */
566
+ async deleteDeployment(functionId: string, deploymentId: string): Promise<{}> {
567
+ if (typeof functionId === 'undefined') {
568
+ throw new AppwriteException('Missing required parameter: "functionId"');
517
569
  }
518
570
 
519
- /**
520
- * List Executions
521
- *
522
- * Get a list of all the current user function execution logs. You can use the
523
- * query params to filter your results.
524
- *
525
- * @param {string} functionId
526
- * @param {string[]} queries
527
- * @param {string} search
528
- * @throws {AppwriteException}
529
- * @returns {Promise}
530
- */
531
- async listExecutions(functionId: string, queries?: string[], search?: string): Promise<Models.ExecutionList> {
532
- if (typeof functionId === 'undefined') {
533
- throw new AppwriteException('Missing required parameter: "functionId"');
534
- }
571
+ if (typeof deploymentId === 'undefined') {
572
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
573
+ }
535
574
 
536
- let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
537
- let payload: Payload = {};
575
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
576
+ const payload: Payload = {};
577
+
578
+ const uri = new URL(this.client.config.endpoint + apiPath);
579
+ return await this.client.call('delete', uri, {
580
+ 'content-type': 'application/json',
581
+ }, payload);
582
+ }
583
+
584
+ /**
585
+ * Create build
586
+ *
587
+ * Create a new build for an Appwrite Function deployment. This endpoint can
588
+ * be used to retry a failed build.
589
+ *
590
+ * @param {string} functionId
591
+ * @param {string} deploymentId
592
+ * @param {string} buildId
593
+ * @throws {AppwriteException}
594
+ * @returns {Promise}
595
+ */
596
+ async createBuild(functionId: string, deploymentId: string, buildId: string): Promise<{}> {
597
+ if (typeof functionId === 'undefined') {
598
+ throw new AppwriteException('Missing required parameter: "functionId"');
599
+ }
538
600
 
539
- if (typeof queries !== 'undefined') {
540
- payload['queries'] = queries;
541
- }
601
+ if (typeof deploymentId === 'undefined') {
602
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
603
+ }
542
604
 
543
- if (typeof search !== 'undefined') {
544
- payload['search'] = search;
545
- }
605
+ if (typeof buildId === 'undefined') {
606
+ throw new AppwriteException('Missing required parameter: "buildId"');
607
+ }
546
608
 
547
- const uri = new URL(this.client.config.endpoint + path);
548
- return await this.client.call('get', uri, {
549
- 'content-type': 'application/json',
550
- }, payload);
609
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
610
+ const payload: Payload = {};
611
+
612
+ const uri = new URL(this.client.config.endpoint + apiPath);
613
+ return await this.client.call('post', uri, {
614
+ 'content-type': 'application/json',
615
+ }, payload);
616
+ }
617
+
618
+ /**
619
+ * Download Deployment
620
+ *
621
+ * Get a Deployment's contents by its unique ID. This endpoint supports range
622
+ * requests for partial or streaming file download.
623
+ *
624
+ * @param {string} functionId
625
+ * @param {string} deploymentId
626
+ * @throws {AppwriteException}
627
+ * @returns {URL}
628
+ */
629
+ downloadDeployment(functionId: string, deploymentId: string): URL {
630
+ if (typeof functionId === 'undefined') {
631
+ throw new AppwriteException('Missing required parameter: "functionId"');
551
632
  }
552
633
 
553
- /**
554
- * Create Execution
555
- *
556
- * Trigger a function execution. The returned object will return you the
557
- * current execution status. You can ping the `Get Execution` endpoint to get
558
- * updates on the current execution status. Once this endpoint is called, your
559
- * function execution process will start asynchronously.
560
- *
561
- * @param {string} functionId
562
- * @param {string} data
563
- * @param {boolean} async
564
- * @throws {AppwriteException}
565
- * @returns {Promise}
566
- */
567
- async createExecution(functionId: string, data?: string, async?: boolean): Promise<Models.Execution> {
568
- if (typeof functionId === 'undefined') {
569
- throw new AppwriteException('Missing required parameter: "functionId"');
570
- }
634
+ if (typeof deploymentId === 'undefined') {
635
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
636
+ }
571
637
 
572
- let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
573
- let payload: Payload = {};
638
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
639
+ const payload: Payload = {};
574
640
 
575
- if (typeof data !== 'undefined') {
576
- payload['data'] = data;
577
- }
641
+ const uri = new URL(this.client.config.endpoint + apiPath);
642
+ payload['project'] = this.client.config.project;
578
643
 
579
- if (typeof async !== 'undefined') {
580
- payload['async'] = async;
581
- }
582
644
 
583
- const uri = new URL(this.client.config.endpoint + path);
584
- return await this.client.call('post', uri, {
585
- 'content-type': 'application/json',
586
- }, payload);
645
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
646
+ uri.searchParams.append(key, value);
647
+ }
648
+ return uri;
649
+ }
650
+
651
+ /**
652
+ * List executions
653
+ *
654
+ * Get a list of all the current user function execution logs. You can use the
655
+ * query params to filter your results.
656
+ *
657
+ * @param {string} functionId
658
+ * @param {string[]} queries
659
+ * @param {string} search
660
+ * @throws {AppwriteException}
661
+ * @returns {Promise}
662
+ */
663
+ async listExecutions(functionId: string, queries?: string[], search?: string): Promise<Models.ExecutionList> {
664
+ if (typeof functionId === 'undefined') {
665
+ throw new AppwriteException('Missing required parameter: "functionId"');
587
666
  }
588
667
 
589
- /**
590
- * Get Execution
591
- *
592
- * Get a function execution log by its unique ID.
593
- *
594
- * @param {string} functionId
595
- * @param {string} executionId
596
- * @throws {AppwriteException}
597
- * @returns {Promise}
598
- */
599
- async getExecution(functionId: string, executionId: string): Promise<Models.Execution> {
600
- if (typeof functionId === 'undefined') {
601
- throw new AppwriteException('Missing required parameter: "functionId"');
602
- }
668
+ const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
669
+ const payload: Payload = {};
603
670
 
604
- if (typeof executionId === 'undefined') {
605
- throw new AppwriteException('Missing required parameter: "executionId"');
606
- }
671
+ if (typeof queries !== 'undefined') {
672
+ payload['queries'] = queries;
673
+ }
607
674
 
608
- let path = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
609
- let payload: Payload = {};
675
+ if (typeof search !== 'undefined') {
676
+ payload['search'] = search;
677
+ }
610
678
 
611
- const uri = new URL(this.client.config.endpoint + path);
612
- return await this.client.call('get', uri, {
613
- 'content-type': 'application/json',
614
- }, payload);
679
+ const uri = new URL(this.client.config.endpoint + apiPath);
680
+ return await this.client.call('get', uri, {
681
+ 'content-type': 'application/json',
682
+ }, payload);
683
+ }
684
+
685
+ /**
686
+ * Create execution
687
+ *
688
+ * Trigger a function execution. The returned object will return you the
689
+ * current execution status. You can ping the `Get Execution` endpoint to get
690
+ * updates on the current execution status. Once this endpoint is called, your
691
+ * function execution process will start asynchronously.
692
+ *
693
+ * @param {string} functionId
694
+ * @param {string} body
695
+ * @param {boolean} async
696
+ * @param {string} xpath
697
+ * @param {string} method
698
+ * @param {object} headers
699
+ * @throws {AppwriteException}
700
+ * @returns {Promise}
701
+ */
702
+ async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: string, headers?: object): Promise<Models.Execution> {
703
+ if (typeof functionId === 'undefined') {
704
+ throw new AppwriteException('Missing required parameter: "functionId"');
615
705
  }
616
706
 
617
- /**
618
- * Get Function Usage
619
- *
620
- *
621
- * @param {string} functionId
622
- * @param {string} range
623
- * @throws {AppwriteException}
624
- * @returns {Promise}
625
- */
626
- async getFunctionUsage(functionId: string, range?: string): Promise<Models.UsageFunctions> {
627
- if (typeof functionId === 'undefined') {
628
- throw new AppwriteException('Missing required parameter: "functionId"');
629
- }
707
+ const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
708
+ const payload: Payload = {};
630
709
 
631
- let path = '/functions/{functionId}/usage'.replace('{functionId}', functionId);
632
- let payload: Payload = {};
710
+ if (typeof body !== 'undefined') {
711
+ payload['body'] = body;
712
+ }
633
713
 
634
- if (typeof range !== 'undefined') {
635
- payload['range'] = range;
636
- }
714
+ if (typeof async !== 'undefined') {
715
+ payload['async'] = async;
716
+ }
637
717
 
638
- const uri = new URL(this.client.config.endpoint + path);
639
- return await this.client.call('get', uri, {
640
- 'content-type': 'application/json',
641
- }, payload);
718
+ if (typeof xpath !== 'undefined') {
719
+ payload['path'] = xpath;
642
720
  }
643
721
 
644
- /**
645
- * List Variables
646
- *
647
- * Get a list of all variables of a specific function.
648
- *
649
- * @param {string} functionId
650
- * @throws {AppwriteException}
651
- * @returns {Promise}
652
- */
653
- async listVariables(functionId: string): Promise<Models.VariableList> {
654
- if (typeof functionId === 'undefined') {
655
- throw new AppwriteException('Missing required parameter: "functionId"');
656
- }
722
+ if (typeof method !== 'undefined') {
723
+ payload['method'] = method;
724
+ }
657
725
 
658
- let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
659
- let payload: Payload = {};
726
+ if (typeof headers !== 'undefined') {
727
+ payload['headers'] = headers;
728
+ }
660
729
 
661
- const uri = new URL(this.client.config.endpoint + path);
662
- return await this.client.call('get', uri, {
663
- 'content-type': 'application/json',
664
- }, payload);
730
+ const uri = new URL(this.client.config.endpoint + apiPath);
731
+ return await this.client.call('post', uri, {
732
+ 'content-type': 'application/json',
733
+ }, payload);
734
+ }
735
+
736
+ /**
737
+ * Get execution
738
+ *
739
+ * Get a function execution log by its unique ID.
740
+ *
741
+ * @param {string} functionId
742
+ * @param {string} executionId
743
+ * @throws {AppwriteException}
744
+ * @returns {Promise}
745
+ */
746
+ async getExecution(functionId: string, executionId: string): Promise<Models.Execution> {
747
+ if (typeof functionId === 'undefined') {
748
+ throw new AppwriteException('Missing required parameter: "functionId"');
665
749
  }
666
750
 
667
- /**
668
- * Create Variable
669
- *
670
- * Create a new function variable. These variables can be accessed within
671
- * function in the `env` object under the request variable.
672
- *
673
- * @param {string} functionId
674
- * @param {string} key
675
- * @param {string} value
676
- * @throws {AppwriteException}
677
- * @returns {Promise}
678
- */
679
- async createVariable(functionId: string, key: string, value: string): Promise<Models.Variable> {
680
- if (typeof functionId === 'undefined') {
681
- throw new AppwriteException('Missing required parameter: "functionId"');
682
- }
751
+ if (typeof executionId === 'undefined') {
752
+ throw new AppwriteException('Missing required parameter: "executionId"');
753
+ }
683
754
 
684
- if (typeof key === 'undefined') {
685
- throw new AppwriteException('Missing required parameter: "key"');
686
- }
755
+ const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
756
+ const payload: Payload = {};
757
+
758
+ const uri = new URL(this.client.config.endpoint + apiPath);
759
+ return await this.client.call('get', uri, {
760
+ 'content-type': 'application/json',
761
+ }, payload);
762
+ }
763
+
764
+ /**
765
+ * Get function usage
766
+ *
767
+ *
768
+ * @param {string} functionId
769
+ * @param {string} range
770
+ * @throws {AppwriteException}
771
+ * @returns {Promise}
772
+ */
773
+ async getFunctionUsage(functionId: string, range?: string): Promise<Models.UsageFunctions> {
774
+ if (typeof functionId === 'undefined') {
775
+ throw new AppwriteException('Missing required parameter: "functionId"');
776
+ }
687
777
 
688
- if (typeof value === 'undefined') {
689
- throw new AppwriteException('Missing required parameter: "value"');
690
- }
778
+ const apiPath = '/functions/{functionId}/usage'.replace('{functionId}', functionId);
779
+ const payload: Payload = {};
691
780
 
692
- let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
693
- let payload: Payload = {};
781
+ if (typeof range !== 'undefined') {
782
+ payload['range'] = range;
783
+ }
694
784
 
695
- if (typeof key !== 'undefined') {
696
- payload['key'] = key;
697
- }
785
+ const uri = new URL(this.client.config.endpoint + apiPath);
786
+ return await this.client.call('get', uri, {
787
+ 'content-type': 'application/json',
788
+ }, payload);
789
+ }
790
+
791
+ /**
792
+ * List variables
793
+ *
794
+ * Get a list of all variables of a specific function.
795
+ *
796
+ * @param {string} functionId
797
+ * @throws {AppwriteException}
798
+ * @returns {Promise}
799
+ */
800
+ async listVariables(functionId: string): Promise<Models.VariableList> {
801
+ if (typeof functionId === 'undefined') {
802
+ throw new AppwriteException('Missing required parameter: "functionId"');
803
+ }
698
804
 
699
- if (typeof value !== 'undefined') {
700
- payload['value'] = value;
701
- }
805
+ const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
806
+ const payload: Payload = {};
807
+
808
+ const uri = new URL(this.client.config.endpoint + apiPath);
809
+ return await this.client.call('get', uri, {
810
+ 'content-type': 'application/json',
811
+ }, payload);
812
+ }
813
+
814
+ /**
815
+ * Create variable
816
+ *
817
+ * Create a new function environment variable. These variables can be accessed
818
+ * in the function at runtime as environment variables.
819
+ *
820
+ * @param {string} functionId
821
+ * @param {string} key
822
+ * @param {string} value
823
+ * @throws {AppwriteException}
824
+ * @returns {Promise}
825
+ */
826
+ async createVariable(functionId: string, key: string, value: string): Promise<Models.Variable> {
827
+ if (typeof functionId === 'undefined') {
828
+ throw new AppwriteException('Missing required parameter: "functionId"');
829
+ }
702
830
 
703
- const uri = new URL(this.client.config.endpoint + path);
704
- return await this.client.call('post', uri, {
705
- 'content-type': 'application/json',
706
- }, payload);
831
+ if (typeof key === 'undefined') {
832
+ throw new AppwriteException('Missing required parameter: "key"');
707
833
  }
708
834
 
709
- /**
710
- * Get Variable
711
- *
712
- * Get a variable by its unique ID.
713
- *
714
- * @param {string} functionId
715
- * @param {string} variableId
716
- * @throws {AppwriteException}
717
- * @returns {Promise}
718
- */
719
- async getVariable(functionId: string, variableId: string): Promise<Models.Variable> {
720
- if (typeof functionId === 'undefined') {
721
- throw new AppwriteException('Missing required parameter: "functionId"');
722
- }
835
+ if (typeof value === 'undefined') {
836
+ throw new AppwriteException('Missing required parameter: "value"');
837
+ }
723
838
 
724
- if (typeof variableId === 'undefined') {
725
- throw new AppwriteException('Missing required parameter: "variableId"');
726
- }
839
+ const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
840
+ const payload: Payload = {};
727
841
 
728
- let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
729
- let payload: Payload = {};
842
+ if (typeof key !== 'undefined') {
843
+ payload['key'] = key;
844
+ }
730
845
 
731
- const uri = new URL(this.client.config.endpoint + path);
732
- return await this.client.call('get', uri, {
733
- 'content-type': 'application/json',
734
- }, payload);
846
+ if (typeof value !== 'undefined') {
847
+ payload['value'] = value;
735
848
  }
736
849
 
737
- /**
738
- * Update Variable
739
- *
740
- * Update variable by its unique ID.
741
- *
742
- * @param {string} functionId
743
- * @param {string} variableId
744
- * @param {string} key
745
- * @param {string} value
746
- * @throws {AppwriteException}
747
- * @returns {Promise}
748
- */
749
- async updateVariable(functionId: string, variableId: string, key: string, value?: string): Promise<Models.Variable> {
750
- if (typeof functionId === 'undefined') {
751
- throw new AppwriteException('Missing required parameter: "functionId"');
752
- }
850
+ const uri = new URL(this.client.config.endpoint + apiPath);
851
+ return await this.client.call('post', uri, {
852
+ 'content-type': 'application/json',
853
+ }, payload);
854
+ }
855
+
856
+ /**
857
+ * Get variable
858
+ *
859
+ * Get a variable by its unique ID.
860
+ *
861
+ * @param {string} functionId
862
+ * @param {string} variableId
863
+ * @throws {AppwriteException}
864
+ * @returns {Promise}
865
+ */
866
+ async getVariable(functionId: string, variableId: string): Promise<Models.Variable> {
867
+ if (typeof functionId === 'undefined') {
868
+ throw new AppwriteException('Missing required parameter: "functionId"');
869
+ }
753
870
 
754
- if (typeof variableId === 'undefined') {
755
- throw new AppwriteException('Missing required parameter: "variableId"');
756
- }
871
+ if (typeof variableId === 'undefined') {
872
+ throw new AppwriteException('Missing required parameter: "variableId"');
873
+ }
757
874
 
758
- if (typeof key === 'undefined') {
759
- throw new AppwriteException('Missing required parameter: "key"');
760
- }
875
+ const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
876
+ const payload: Payload = {};
877
+
878
+ const uri = new URL(this.client.config.endpoint + apiPath);
879
+ return await this.client.call('get', uri, {
880
+ 'content-type': 'application/json',
881
+ }, payload);
882
+ }
883
+
884
+ /**
885
+ * Update variable
886
+ *
887
+ * Update variable by its unique ID.
888
+ *
889
+ * @param {string} functionId
890
+ * @param {string} variableId
891
+ * @param {string} key
892
+ * @param {string} value
893
+ * @throws {AppwriteException}
894
+ * @returns {Promise}
895
+ */
896
+ async updateVariable(functionId: string, variableId: string, key: string, value?: string): Promise<Models.Variable> {
897
+ if (typeof functionId === 'undefined') {
898
+ throw new AppwriteException('Missing required parameter: "functionId"');
899
+ }
761
900
 
762
- let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
763
- let payload: Payload = {};
901
+ if (typeof variableId === 'undefined') {
902
+ throw new AppwriteException('Missing required parameter: "variableId"');
903
+ }
764
904
 
765
- if (typeof key !== 'undefined') {
766
- payload['key'] = key;
767
- }
905
+ if (typeof key === 'undefined') {
906
+ throw new AppwriteException('Missing required parameter: "key"');
907
+ }
768
908
 
769
- if (typeof value !== 'undefined') {
770
- payload['value'] = value;
771
- }
909
+ const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
910
+ const payload: Payload = {};
772
911
 
773
- const uri = new URL(this.client.config.endpoint + path);
774
- return await this.client.call('put', uri, {
775
- 'content-type': 'application/json',
776
- }, payload);
912
+ if (typeof key !== 'undefined') {
913
+ payload['key'] = key;
777
914
  }
778
915
 
779
- /**
780
- * Delete Variable
781
- *
782
- * Delete a variable by its unique ID.
783
- *
784
- * @param {string} functionId
785
- * @param {string} variableId
786
- * @throws {AppwriteException}
787
- * @returns {Promise}
788
- */
789
- async deleteVariable(functionId: string, variableId: string): Promise<{}> {
790
- if (typeof functionId === 'undefined') {
791
- throw new AppwriteException('Missing required parameter: "functionId"');
792
- }
793
-
794
- if (typeof variableId === 'undefined') {
795
- throw new AppwriteException('Missing required parameter: "variableId"');
796
- }
916
+ if (typeof value !== 'undefined') {
917
+ payload['value'] = value;
918
+ }
797
919
 
798
- let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
799
- let payload: Payload = {};
920
+ const uri = new URL(this.client.config.endpoint + apiPath);
921
+ return await this.client.call('put', uri, {
922
+ 'content-type': 'application/json',
923
+ }, payload);
924
+ }
925
+
926
+ /**
927
+ * Delete variable
928
+ *
929
+ * Delete a variable by its unique ID.
930
+ *
931
+ * @param {string} functionId
932
+ * @param {string} variableId
933
+ * @throws {AppwriteException}
934
+ * @returns {Promise}
935
+ */
936
+ async deleteVariable(functionId: string, variableId: string): Promise<{}> {
937
+ if (typeof functionId === 'undefined') {
938
+ throw new AppwriteException('Missing required parameter: "functionId"');
939
+ }
800
940
 
801
- const uri = new URL(this.client.config.endpoint + path);
802
- return await this.client.call('delete', uri, {
803
- 'content-type': 'application/json',
804
- }, payload);
941
+ if (typeof variableId === 'undefined') {
942
+ throw new AppwriteException('Missing required parameter: "variableId"');
805
943
  }
944
+
945
+ const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
946
+ const payload: Payload = {};
947
+
948
+ const uri = new URL(this.client.config.endpoint + apiPath);
949
+ return await this.client.call('delete', uri, {
950
+ 'content-type': 'application/json',
951
+ }, payload);
952
+ }
806
953
  };